]> git.proxmox.com Git - mirror_iproute2.git/blobdiff - tc/m_police.c
lib: introduce print_nl
[mirror_iproute2.git] / tc / m_police.c
index ff1dcb7d0323c7fa7b5952fab411e8b08be92a0f..f3b07f7b0439c172413144b9d8e3a73cbca624a8 100644 (file)
@@ -150,15 +150,18 @@ int act_parse_police(struct action_util *a, int *argc_p, char ***argv_p,
                           matches(*argv, "shot") == 0 ||
                           matches(*argv, "continue") == 0 ||
                           matches(*argv, "pass") == 0 ||
+                          matches(*argv, "ok") == 0 ||
                           matches(*argv, "pipe") == 0 ||
                           matches(*argv, "goto") == 0) {
-                       if (parse_action_control(&argc, &argv, &p.action, false))
-                               return -1;
+                       if (!parse_action_control(&argc, &argv, &p.action, false))
+                               goto action_ctrl_ok;
+                       return -1;
                } else if (strcmp(*argv, "conform-exceed") == 0) {
                        NEXT_ARG();
-                       if (parse_action_control_slash(&argc, &argv, &p.action,
-                                                      &presult, true))
-                               return -1;
+                       if (!parse_action_control_slash(&argc, &argv, &p.action,
+                                                       &presult, true))
+                               goto action_ctrl_ok;
+                       return -1;
                } else if (matches(*argv, "overhead") == 0) {
                        NEXT_ARG();
                        if (get_u16(&overhead, *argv, 10)) {
@@ -174,8 +177,9 @@ int act_parse_police(struct action_util *a, int *argc_p, char ***argv_p,
                } else {
                        break;
                }
+               NEXT_ARG_FWD();
+action_ctrl_ok:
                ok++;
-               argc--; argv++;
        }
 
        if (!ok)
@@ -228,8 +232,7 @@ int act_parse_police(struct action_util *a, int *argc_p, char ***argv_p,
                }
        }
 
-       tail = NLMSG_TAIL(n);
-       addattr_l(n, MAX_MSG, tca_id, NULL, 0);
+       tail = addattr_nest(n, MAX_MSG, tca_id);
        addattr_l(n, MAX_MSG, TCA_POLICE_TBF, &p, sizeof(p));
        if (p.rate.rate)
                addattr_l(n, MAX_MSG, TCA_POLICE_RATE, rtab, 1024);
@@ -240,7 +243,7 @@ int act_parse_police(struct action_util *a, int *argc_p, char ***argv_p,
        if (presult)
                addattr32(n, MAX_MSG, TCA_POLICE_RESULT, presult);
 
-       tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;
+       addattr_nest_end(n, tail);
        res = 0;
 
        *argc_p = argc;