]> git.proxmox.com Git - mirror_iproute2.git/commitdiff
tc: Fix block-handle support for filter operations
authorIdo Schimmel <idosch@mellanox.com>
Mon, 12 Aug 2019 10:17:06 +0000 (13:17 +0300)
committerStephen Hemminger <stephen@networkplumber.org>
Mon, 12 Aug 2019 17:31:24 +0000 (10:31 -0700)
The revert of batchsize accidently reverted more than it should
and broke shared block functionality.  Fix this by restoring the
original functionality.

To reproduce:

dst_ip 192.0.2.0/24 action drop
Unknown filter "block", hence option "10" is unparsable

Fixes: e991c04d64c0 ("Revert "tc: Add batchsize feature for filter and actions"")
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
tc/tc_filter.c

index 53759a7a887682548e5f85161519d2078e28e1db..23e21d89d7d14b10a8d2f681dab9566a4852f62d 100644 (file)
@@ -74,6 +74,7 @@ static int tc_filter_modify(int cmd, unsigned int flags, int argc, char **argv)
        __u32 prio = 0;
        __u32 protocol = 0;
        int protocol_set = 0;
+       __u32 block_index = 0;
        __u32 chain_index;
        int chain_index_set = 0;
        char *fhandle = NULL;
@@ -89,7 +90,21 @@ static int tc_filter_modify(int cmd, unsigned int flags, int argc, char **argv)
                        NEXT_ARG();
                        if (d[0])
                                duparg("dev", *argv);
+                       if (block_index) {
+                               fprintf(stderr, "Error: \"dev\" and \"block\" are mutually exclusive\n");
+                               return -1;
+                       }
                        strncpy(d, *argv, sizeof(d)-1);
+               } else if (matches(*argv, "block") == 0) {
+                       NEXT_ARG();
+                       if (block_index)
+                               duparg("block", *argv);
+                       if (d[0]) {
+                               fprintf(stderr, "Error: \"dev\" and \"block\" are mutually exclusive\n");
+                               return -1;
+                       }
+                       if (get_u32(&block_index, *argv, 0) || !block_index)
+                               invarg("invalid block index value", *argv);
                } else if (strcmp(*argv, "root") == 0) {
                        if (req.t.tcm_parent) {
                                fprintf(stderr,
@@ -184,6 +199,9 @@ static int tc_filter_modify(int cmd, unsigned int flags, int argc, char **argv)
                        fprintf(stderr, "Cannot find device \"%s\"\n", d);
                        return 1;
                }
+       } else if (block_index) {
+               req.t.tcm_ifindex = TCM_IFINDEX_MAGIC_BLOCK;
+               req.t.tcm_block_index = block_index;
        }
 
        if (q) {