]> git.proxmox.com Git - mirror_iproute2.git/blobdiff - tc/m_connmark.c
tc: skip actions that don't have options attribute when printing
[mirror_iproute2.git] / tc / m_connmark.c
index bcce413913984ad7ce7ac43db4137c3dd207ee61..640bba9da18e61d8764853d59e3013ccda892080 100644 (file)
@@ -27,8 +27,9 @@
 static void
 explain(void)
 {
-       fprintf(stderr, "Usage: ... connmark [zone ZONE] [CONTROL] [index <INDEX>]\n");
-       fprintf(stderr, "where :\n"
+       fprintf(stderr,
+               "Usage: ... connmark [zone ZONE] [CONTROL] [index <INDEX>]\n"
+               "where :\n"
                "\tZONE is the conntrack zone\n"
                "\tCONTROL := reclassify | pipe | drop | continue | ok |\n"
                "\t           goto chain <CHAIN_INDEX>\n");
@@ -73,7 +74,7 @@ parse_connmark(struct action_util *a, int *argc_p, char ***argv_p, int tca_id,
                if (matches(*argv, "zone") == 0) {
                        NEXT_ARG();
                        if (get_u16(&sel.zone, *argv, 10)) {
-                               fprintf(stderr, "simple: Illegal \"index\"\n");
+                               fprintf(stderr, "connmark: Illegal \"zone\"\n");
                                return -1;
                        }
                        argc--;
@@ -87,7 +88,7 @@ parse_connmark(struct action_util *a, int *argc_p, char ***argv_p, int tca_id,
                if (matches(*argv, "index") == 0) {
                        NEXT_ARG();
                        if (get_u32(&sel.index, *argv, 10)) {
-                               fprintf(stderr, "simple: Illegal \"index\"\n");
+                               fprintf(stderr, "connmark: Illegal \"index\"\n");
                                return -1;
                        }
                        argc--;
@@ -109,21 +110,25 @@ static int print_connmark(struct action_util *au, FILE *f, struct rtattr *arg)
        struct rtattr *tb[TCA_CONNMARK_MAX + 1];
        struct tc_connmark *ci;
 
+       print_string(PRINT_ANY, "kind", "%s ", "connmark");
        if (arg == NULL)
-               return -1;
+               return 0;
 
        parse_rtattr_nested(tb, TCA_CONNMARK_MAX, arg);
        if (tb[TCA_CONNMARK_PARMS] == NULL) {
-               fprintf(f, "[NULL connmark parameters]");
+               fprintf(stderr, "Missing connmark parameters\n");
                return -1;
        }
 
        ci = RTA_DATA(tb[TCA_CONNMARK_PARMS]);
 
-       fprintf(f, " connmark zone %d", ci->zone);
-       print_action_control(f, " ", ci->action, "\n");
-       fprintf(f, "\t index %u ref %d bind %d", ci->index,
-               ci->refcnt, ci->bindcnt);
+       print_uint(PRINT_ANY, "zone", "zone %u", ci->zone);
+       print_action_control(f, " ", ci->action, "");
+
+       print_nl();
+       print_uint(PRINT_ANY, "index", "\t index %u", ci->index);
+       print_int(PRINT_ANY, "ref", " ref %d", ci->refcnt);
+       print_int(PRINT_ANY, "bind", " bind %d", ci->bindcnt);
 
        if (show_stats) {
                if (tb[TCA_CONNMARK_TM]) {
@@ -132,7 +137,7 @@ static int print_connmark(struct action_util *au, FILE *f, struct rtattr *arg)
                        print_tm(f, tm);
                }
        }
-       fprintf(f, "\n");
+       print_nl();
 
        return 0;
 }