From: Ido Schimmel <idosch@idosch.org>
To: netdev@vger.kernel.org
Cc: stephen@networkplumber.org, dsahern@gmail.com, jiri@mellanox.com,
mlxsw@mellanox.com, Ido Schimmel <idosch@mellanox.com>
Subject: [PATCH iproute2] tc: Fix block-handle support for filter operations
Date: Mon, 12 Aug 2019 13:17:06 +0300 [thread overview]
Message-ID: <20190812101706.15778-1-idosch@idosch.org> (raw)
From: Ido Schimmel <idosch@mellanox.com>
Commit e991c04d64c0 ("Revert "tc: Add batchsize feature for filter and
actions"") reverted more than it should and broke shared block
functionality. Fix this by restoring the original functionality.
To reproduce:
# tc qdisc add dev swp1 ingress_block 10 ingress
# tc filter add block 10 proto ip pref 1 flower \
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>
---
tc/tc_filter.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/tc/tc_filter.c b/tc/tc_filter.c
index 53759a7a8876..23e21d89d7d1 100644
--- a/tc/tc_filter.c
+++ b/tc/tc_filter.c
@@ -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) {
--
2.21.0
next reply other threads:[~2019-08-12 10:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-12 10:17 Ido Schimmel [this message]
2019-08-12 10:26 ` [PATCH iproute2] tc: Fix block-handle support for filter operations Jiri Pirko
2019-08-13 1:16 ` Stephen Hemminger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190812101706.15778-1-idosch@idosch.org \
--to=idosch@idosch.org \
--cc=dsahern@gmail.com \
--cc=idosch@mellanox.com \
--cc=jiri@mellanox.com \
--cc=mlxsw@mellanox.com \
--cc=netdev@vger.kernel.org \
--cc=stephen@networkplumber.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).