Blame SOURCES/0144-tc_filter-resolve-device-name-before-parsing-filter.patch

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