[ovs-dev] [PATCH] tc: Fix using uninitialized id chain.

Ilya Maximets i.maximets at ovn.org
Fri Jan 3 18:48:18 UTC 2020


tc_make_tcf_id() doesn't initialize the 'chain' field leaving it with a
random value from the stack.  This makes request_from_tcf_id() create
request with random TCA_CHAIN included.  These requests are obviously
doesn't work as needed leading to broken flow dump and various other
issues.  Fix that by using designated initializer instead.

Fixes: acdd544c4c9a ("tc: Introduce tcf_id to specify a tc filter")
Signed-off-by: Ilya Maximets <i.maximets at ovn.org>
---
 lib/tc.h | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/lib/tc.h b/lib/tc.h
index 70e7f38d2..d31c0953e 100644
--- a/lib/tc.h
+++ b/lib/tc.h
@@ -271,13 +271,12 @@ static inline struct tcf_id
 tc_make_tcf_id(int ifindex, uint32_t block_id, uint16_t prio,
                enum tc_qdisc_hook hook)
 {
-    struct tcf_id id;
-
-    id.block_id = block_id;
-    id.ifindex = ifindex;
-    id.prio = prio;
-    id.hook = hook;
-    id.handle = 0;
+    struct tcf_id id = {
+        .hook = hook,
+        .block_id = block_id,
+        .ifindex = ifindex,
+        .prio = prio,
+    };
 
     return id;
 }
-- 
2.17.1



More information about the dev mailing list