aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVictor Nogueira <victor@mojatatu.com>2024-01-24 12:34:56 -0300
committerDavid Ahern <dsahern@kernel.org>2024-01-30 15:49:13 +0000
commitcf0eae9a9fc4a40e98bac883919dc872244ee570 (patch)
tree73c3e7e8f8043e4c7bb1ac7d04ac23129d64b785
parent071144c0bbb9a95f5c529fd536488cebcc652374 (diff)
downloadiproute2-cf0eae9a9fc4a40e98bac883919dc872244ee570.tar.gz
tc: Add NLM_F_ECHO support for filters
If the user specifies this flag for a filter command the kernel will return the command's result back to user space. For example: tc -echo filter add dev lo parent ffff: protocol ip matchall action ok added filter dev lo parent ffff: protocol ip pref 49152 matchall chain 0 As illustrated above, the kernel will give us a pref of 491252 The same can be done for other filter commands (replace, delete, and change). For example: tc -echo filter del dev lo parent ffff: pref 49152 protocol ip matchall deleted filter dev lo parent ffff: protocol ip pref 49152 matchall chain 0 Signed-off-by: Victor Nogueira <victor@mojatatu.com> Reviewed-by: Hangbin Liu <liuhangbin@gmail.com> Signed-off-by: David Ahern <dsahern@kernel.org>
-rw-r--r--tc/tc_filter.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/tc/tc_filter.c b/tc/tc_filter.c
index eb45c5887..54790ddc6 100644
--- a/tc/tc_filter.c
+++ b/tc/tc_filter.c
@@ -76,6 +76,7 @@ static int tc_filter_modify(int cmd, unsigned int flags, int argc, char **argv)
char d[IFNAMSIZ] = {};
char k[FILTER_NAMESZ] = {};
struct tc_estimator est = {};
+ int ret;
if (cmd == RTM_NEWTFILTER && flags & NLM_F_CREATE)
protocol = htons(ETH_P_ALL);
@@ -221,7 +222,12 @@ static int tc_filter_modify(int cmd, unsigned int flags, int argc, char **argv)
if (est.ewma_log)
addattr_l(&req.n, sizeof(req), TCA_RATE, &est, sizeof(est));
- if (rtnl_talk(&rth, &req.n, NULL) < 0) {
+ if (echo_request)
+ ret = rtnl_echo_talk(&rth, &req.n, json, print_filter);
+ else
+ ret = rtnl_talk(&rth, &req.n, NULL);
+
+ if (ret < 0) {
fprintf(stderr, "We have an error talking to the kernel\n");
return 2;
}