]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
tc: m_nat: parse index argument correctly
authorPedro Tammela <pctammela@mojatatu.com>
Mon, 27 Feb 2023 18:45:10 +0000 (15:45 -0300)
committerStephen Hemminger <stephen@networkplumber.org>
Sun, 5 Mar 2023 16:49:32 +0000 (08:49 -0800)
'action nat index 1' is a valid cli according to TC's
architecture. Fix the grammar parsing to accept it.

tdc tests:
1..28
ok 1 7565 - Add nat action on ingress with default control action
ok 2 fd79 - Add nat action on ingress with pipe control action
ok 3 eab9 - Add nat action on ingress with continue control action
ok 4 c53a - Add nat action on ingress with reclassify control action
ok 5 76c9 - Add nat action on ingress with jump control action
ok 6 24c6 - Add nat action on ingress with drop control action
ok 7 2120 - Add nat action on ingress with maximum index value
ok 8 3e9d - Add nat action on ingress with invalid index value
ok 9 f6c9 - Add nat action on ingress with invalid IP address
ok 10 be25 - Add nat action on ingress with invalid argument
ok 11 a7bd - Add nat action on ingress with DEFAULT IP address
ok 12 ee1e - Add nat action on ingress with ANY IP address
ok 13 1de8 - Add nat action on ingress with ALL IP address
ok 14 8dba - Add nat action on egress with default control action
ok 15 19a7 - Add nat action on egress with pipe control action
ok 16 f1d9 - Add nat action on egress with continue control action
ok 17 6d4a - Add nat action on egress with reclassify control action
ok 18 b313 - Add nat action on egress with jump control action
ok 19 d9fc - Add nat action on egress with drop control action
ok 20 a895 - Add nat action on egress with DEFAULT IP address
ok 21 2572 - Add nat action on egress with ANY IP address
ok 22 37f3 - Add nat action on egress with ALL IP address
ok 23 6054 - Add nat action on egress with cookie
ok 24 79d6 - Add nat action on ingress with cookie
ok 25 4b12 - Replace nat action with invalid goto chain control
ok 26 b811 - Delete nat action with valid index
ok 27 a521 - Delete nat action with invalid index
ok 28 2c81 - Reference nat action object in filter

Fixes: fc2d02069b52 ("Add NAT action")
Reviewed-by: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: Pedro Tammela <pctammela@mojatatu.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
tc/m_nat.c

index 583151254f737a59d592fa59f6c6b3b95a00b33d..95b35584a23e098b35ac2b653c402c02863c1b58 100644 (file)
@@ -88,7 +88,9 @@ parse_nat(struct action_util *a, int *argc_p, char ***argv_p, int tca_id, struct
        while (argc > 0) {
                if (matches(*argv, "nat") == 0) {
                        NEXT_ARG();
-                       if (parse_nat_args(&argc, &argv, &sel)) {
+                       if (strcmp(*argv, "index") == 0) {
+                               goto skip_args;
+                       } else if (parse_nat_args(&argc, &argv, &sel)) {
                                fprintf(stderr, "Illegal nat construct (%s)\n",
                                        *argv);
                                explain();
@@ -113,6 +115,7 @@ parse_nat(struct action_util *a, int *argc_p, char ***argv_p, int tca_id, struct
 
        if (argc) {
                if (matches(*argv, "index") == 0) {
+skip_args:
                        NEXT_ARG();
                        if (get_u32(&sel.index, *argv, 10)) {
                                fprintf(stderr, "Nat: Illegal \"index\"\n");