]> git.proxmox.com Git - mirror_iproute2.git/blobdiff - tc/m_bpf.c
bpf: rename bpf_parse_common() to bpf_parse_and_load_common()
[mirror_iproute2.git] / tc / m_bpf.c
index f043ae48df7a87827ca4b28f30a7faee80ec2ebb..e275afd01fb32ad1eda6b1dfcfcbe38d4f3c0e3b 100644 (file)
@@ -75,7 +75,7 @@ static int bpf_parse_opt(struct action_util *a, int *ptr_argc, char ***ptr_argv,
                         int tca_id, struct nlmsghdr *n)
 {
        const char *bpf_obj = NULL, *bpf_uds_name = NULL;
-       struct tc_act_bpf parm = { .action = TC_ACT_PIPE };
+       struct tc_act_bpf parm = {};
        struct bpf_cfg_in cfg = {};
        bool seen_run = false;
        struct rtattr *tail;
@@ -98,10 +98,11 @@ static int bpf_parse_opt(struct action_util *a, int *ptr_argc, char ***ptr_argv,
                        NEXT_ARG();
 opt_bpf:
                        seen_run = true;
+                       cfg.type = bpf_type;
                        cfg.argc = argc;
                        cfg.argv = argv;
 
-                       if (bpf_parse_common(bpf_type, &cfg, &bpf_cb_ops, n))
+                       if (bpf_parse_and_load_common(&cfg, &bpf_cb_ops, n))
                                return -1;
 
                        argc = cfg.argc;
@@ -123,8 +124,8 @@ opt_bpf:
                NEXT_ARG_FWD();
        }
 
-       if (argc && !action_a2n(*argv, &parm.action, false))
-               NEXT_ARG_FWD();
+       parse_action_control_dflt(&argc, &argv, &parm.action,
+                                 false, TC_ACT_PIPE);
 
        if (argc) {
                if (matches(*argv, "index") == 0) {
@@ -154,6 +155,7 @@ static int bpf_print_opt(struct action_util *au, FILE *f, struct rtattr *arg)
 {
        struct rtattr *tb[TCA_ACT_BPF_MAX + 1];
        struct tc_act_bpf *parm;
+       int dump_ok = 0;
 
        if (arg == NULL)
                return -1;
@@ -177,7 +179,18 @@ static int bpf_print_opt(struct action_util *au, FILE *f, struct rtattr *arg)
                fprintf(f, " ");
        }
 
-       fprintf(f, "default-action %s\n", action_n2a(parm->action));
+       if (tb[TCA_ACT_BPF_ID])
+               dump_ok = bpf_dump_prog_info(f, rta_getattr_u32(tb[TCA_ACT_BPF_ID]));
+       if (!dump_ok && tb[TCA_ACT_BPF_TAG]) {
+               SPRINT_BUF(b);
+
+               fprintf(f, "tag %s ",
+                       hexstring_n2a(RTA_DATA(tb[TCA_ACT_BPF_TAG]),
+                                     RTA_PAYLOAD(tb[TCA_ACT_BPF_TAG]),
+                                     b, sizeof(b)));
+       }
+
+       print_action_control(f, "default-action ", parm->action, "\n");
        fprintf(f, "\tindex %u ref %d bind %d", parm->index, parm->refcnt,
                parm->bindcnt);