]> git.proxmox.com Git - mirror_iproute2.git/blobdiff - tc/m_connmark.c
tc: actions: add helpers to parse and print control actions
[mirror_iproute2.git] / tc / m_connmark.c
index 6974c9ba6d16bf28c605326d6dc344037ed466d7..3c2274bc0d2afb81f0074b3a133c0dfd1cb332b5 100644 (file)
 static void
 explain(void)
 {
-       fprintf(stderr, "Usage: ... connmark [zone ZONE] [BRANCH] [index <INDEX>]\n");
+       fprintf(stderr, "Usage: ... connmark [zone ZONE] [CONTROL] [index <INDEX>]\n");
        fprintf(stderr, "where :\n"
                "\tZONE is the conntrack zone\n"
-               "\tBRANCH := reclassify|pipe|drop|continue|ok\n");
+               "\tCONTROL := reclassify|pipe|drop|continue|ok\n");
 }
 
 static void
@@ -80,31 +80,7 @@ parse_connmark(struct action_util *a, int *argc_p, char ***argv_p, int tca_id,
                }
        }
 
-       sel.action = TC_ACT_PIPE;
-       if (argc) {
-               if (matches(*argv, "reclassify") == 0) {
-                       sel.action = TC_ACT_RECLASSIFY;
-                       argc--;
-                       argv++;
-               } else if (matches(*argv, "pipe") == 0) {
-                       sel.action = TC_ACT_PIPE;
-                       argc--;
-                       argv++;
-               } else if (matches(*argv, "drop") == 0 ||
-                          matches(*argv, "shot") == 0) {
-                       sel.action = TC_ACT_SHOT;
-                       argc--;
-                       argv++;
-               } else if (matches(*argv, "continue") == 0) {
-                       sel.action = TC_ACT_UNSPEC;
-                       argc--;
-                       argv++;
-               } else if (matches(*argv, "pass") == 0) {
-                       sel.action = TC_ACT_OK;
-                       argc--;
-                       argv++;
-               }
-       }
+       parse_action_control_dflt(&argc, &argv, &sel.action, false, TC_ACT_PIPE);
 
        if (argc) {
                if (matches(*argv, "index") == 0) {
@@ -145,12 +121,13 @@ static int print_connmark(struct action_util *au, FILE *f, struct rtattr *arg)
        ci = RTA_DATA(tb[TCA_CONNMARK_PARMS]);
 
        fprintf(f, " connmark zone %d\n", ci->zone);
-       fprintf(f, "\t index %d ref %d bind %d", ci->index,
+       fprintf(f, "\t index %u ref %d bind %d", ci->index,
                ci->refcnt, ci->bindcnt);
 
        if (show_stats) {
                if (tb[TCA_CONNMARK_TM]) {
                        struct tcf_t *tm = RTA_DATA(tb[TCA_CONNMARK_TM]);
+
                        print_tm(f, tm);
                }
        }