|
|
36cfb7 |
From 83b78ff645260a51ff5d643169009faeb3032d3c Mon Sep 17 00:00:00 2001
|
|
|
36cfb7 |
From: Andrea Claudi <aclaudi@redhat.com>
|
|
|
36cfb7 |
Date: Tue, 18 Jun 2019 20:02:54 +0200
|
|
|
36cfb7 |
Subject: [PATCH] tc_filter: resolve device name before parsing filter
|
|
|
36cfb7 |
|
|
|
36cfb7 |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1721291
|
|
|
36cfb7 |
Upstream Status: iproute2.git commit 01ea76b1cf545
|
|
|
36cfb7 |
|
|
|
36cfb7 |
commit 01ea76b1cf54516c71a9a54fba672410ada2cccb
|
|
|
36cfb7 |
Author: Jakub Kicinski <jakub.kicinski@netronome.com>
|
|
|
36cfb7 |
Date: Thu Nov 23 18:12:06 2017 -0800
|
|
|
36cfb7 |
|
|
|
36cfb7 |
tc_filter: resolve device name before parsing filter
|
|
|
36cfb7 |
|
|
|
36cfb7 |
Move resolving device name into an ifindex before calling filter
|
|
|
36cfb7 |
specific callbacks. This way if filters need the ifindex, they
|
|
|
36cfb7 |
can read it from the request.
|
|
|
36cfb7 |
|
|
|
36cfb7 |
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
|
|
|
36cfb7 |
Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com>
|
|
|
36cfb7 |
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
|
|
|
36cfb7 |
---
|
|
|
36cfb7 |
tc/tc_filter.c | 50 ++++++++++++++++++++++++--------------------------
|
|
|
36cfb7 |
1 file changed, 24 insertions(+), 26 deletions(-)
|
|
|
36cfb7 |
|
|
|
36cfb7 |
diff --git a/tc/tc_filter.c b/tc/tc_filter.c
|
|
|
36cfb7 |
index 8dbebf1ffa32a..e479039159df6 100644
|
|
|
36cfb7 |
--- a/tc/tc_filter.c
|
|
|
36cfb7 |
+++ b/tc/tc_filter.c
|
|
|
36cfb7 |
@@ -161,6 +161,16 @@ static int tc_filter_modify(int cmd, unsigned int flags, int argc, char **argv)
|
|
|
36cfb7 |
if (k[0])
|
|
|
36cfb7 |
addattr_l(&req.n, sizeof(req), TCA_KIND, k, strlen(k)+1);
|
|
|
36cfb7 |
|
|
|
36cfb7 |
+ if (d[0]) {
|
|
|
36cfb7 |
+ ll_init_map(&rth);
|
|
|
36cfb7 |
+
|
|
|
36cfb7 |
+ req.t.tcm_ifindex = ll_name_to_index(d);
|
|
|
36cfb7 |
+ if (req.t.tcm_ifindex == 0) {
|
|
|
36cfb7 |
+ fprintf(stderr, "Cannot find device \"%s\"\n", d);
|
|
|
36cfb7 |
+ return 1;
|
|
|
36cfb7 |
+ }
|
|
|
36cfb7 |
+ }
|
|
|
36cfb7 |
+
|
|
|
36cfb7 |
if (q) {
|
|
|
36cfb7 |
if (q->parse_fopt(q, fhandle, argc, argv, &req.n))
|
|
|
36cfb7 |
return 1;
|
|
|
36cfb7 |
@@ -183,17 +193,6 @@ static int tc_filter_modify(int cmd, unsigned int flags, int argc, char **argv)
|
|
|
36cfb7 |
if (est.ewma_log)
|
|
|
36cfb7 |
addattr_l(&req.n, sizeof(req), TCA_RATE, &est, sizeof(est));
|
|
|
36cfb7 |
|
|
|
36cfb7 |
-
|
|
|
36cfb7 |
- if (d[0]) {
|
|
|
36cfb7 |
- ll_init_map(&rth);
|
|
|
36cfb7 |
-
|
|
|
36cfb7 |
- req.t.tcm_ifindex = ll_name_to_index(d);
|
|
|
36cfb7 |
- if (req.t.tcm_ifindex == 0) {
|
|
|
36cfb7 |
- fprintf(stderr, "Cannot find device \"%s\"\n", d);
|
|
|
36cfb7 |
- return 1;
|
|
|
36cfb7 |
- }
|
|
|
36cfb7 |
- }
|
|
|
36cfb7 |
-
|
|
|
36cfb7 |
if (rtnl_talk(&rth, &req.n, NULL) < 0) {
|
|
|
36cfb7 |
fprintf(stderr, "We have an error talking to the kernel\n");
|
|
|
36cfb7 |
return 2;
|
|
|
36cfb7 |
@@ -453,10 +452,23 @@ static int tc_filter_get(int cmd, unsigned int flags, int argc, char **argv)
|
|
|
36cfb7 |
return -1;
|
|
|
36cfb7 |
}
|
|
|
36cfb7 |
|
|
|
36cfb7 |
+ if (d[0]) {
|
|
|
36cfb7 |
+ ll_init_map(&rth);
|
|
|
36cfb7 |
+
|
|
|
36cfb7 |
+ req.t.tcm_ifindex = ll_name_to_index(d);
|
|
|
36cfb7 |
+ if (req.t.tcm_ifindex == 0) {
|
|
|
36cfb7 |
+ fprintf(stderr, "Cannot find device \"%s\"\n", d);
|
|
|
36cfb7 |
+ return 1;
|
|
|
36cfb7 |
+ }
|
|
|
36cfb7 |
+ filter_ifindex = req.t.tcm_ifindex;
|
|
|
36cfb7 |
+ } else {
|
|
|
36cfb7 |
+ fprintf(stderr, "Must specify netdevice \"dev\"\n");
|
|
|
36cfb7 |
+ return -1;
|
|
|
36cfb7 |
+ }
|
|
|
36cfb7 |
+
|
|
|
36cfb7 |
if (q->parse_fopt(q, fhandle, argc, argv, &req.n))
|
|
|
36cfb7 |
return 1;
|
|
|
36cfb7 |
|
|
|
36cfb7 |
-
|
|
|
36cfb7 |
if (!fhandle) {
|
|
|
36cfb7 |
fprintf(stderr, "Must specify filter \"handle\"\n");
|
|
|
36cfb7 |
return -1;
|
|
|
36cfb7 |
@@ -471,20 +483,6 @@ static int tc_filter_get(int cmd, unsigned int flags, int argc, char **argv)
|
|
|
36cfb7 |
return -1;
|
|
|
36cfb7 |
}
|
|
|
36cfb7 |
|
|
|
36cfb7 |
- if (d[0]) {
|
|
|
36cfb7 |
- ll_init_map(&rth);
|
|
|
36cfb7 |
-
|
|
|
36cfb7 |
- req.t.tcm_ifindex = ll_name_to_index(d);
|
|
|
36cfb7 |
- if (req.t.tcm_ifindex == 0) {
|
|
|
36cfb7 |
- fprintf(stderr, "Cannot find device \"%s\"\n", d);
|
|
|
36cfb7 |
- return 1;
|
|
|
36cfb7 |
- }
|
|
|
36cfb7 |
- filter_ifindex = req.t.tcm_ifindex;
|
|
|
36cfb7 |
- } else {
|
|
|
36cfb7 |
- fprintf(stderr, "Must specify netdevice \"dev\"\n");
|
|
|
36cfb7 |
- return -1;
|
|
|
36cfb7 |
- }
|
|
|
36cfb7 |
-
|
|
|
36cfb7 |
if (rtnl_talk(&rth, &req.n, &answer) < 0) {
|
|
|
36cfb7 |
fprintf(stderr, "We have an error talking to the kernel\n");
|
|
|
36cfb7 |
return 2;
|
|
|
36cfb7 |
--
|
|
|
e138d9 |
2.21.0
|
|
|
36cfb7 |
|