Blob Blame History Raw
From 45a60c21fc17ba31199fa800cdce92cc1f17f06b Mon Sep 17 00:00:00 2001
From: Roi Dayan <roid@mellanox.com>
Date: Sun, 25 Mar 2018 12:11:48 +0300
Subject: [PATCH 1/2] lib/netdev-tc-offloads: Fix frag first/later translation

Fragment mask (any and later) always exists so we need to test
for FLOW_NW_FRAG_LATER only if the state is FLOW_NW_FRAG_ANY.
Before this fix we could pass frag no and first at the same time to TC
which is also not tested there for bad frag state.
This fix make sure we only pass frag first/later if is frag.

Fixes: 83e866067ea6 ("netdev-tc-offloads: Add support for IP fragmentation")
Signed-off-by: Roi Dayan <roid@mellanox.com>
Reviewed-by: Paul Blakey <paulb@mellanox.com>
Signed-off-by: Simon Horman <simon.horman@netronome.com>
---
 lib/netdev-tc-offloads.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/lib/netdev-tc-offloads.c b/lib/netdev-tc-offloads.c
index f22415ee1..6db76801f 100644
--- a/lib/netdev-tc-offloads.c
+++ b/lib/netdev-tc-offloads.c
@@ -948,14 +948,21 @@ netdev_tc_flow_put(struct netdev *netdev, struct match *match,
         flower.key.ip_ttl = key->nw_ttl;
         flower.mask.ip_ttl = mask->nw_ttl;
 
-        if (mask->nw_frag) {
-            if (key->nw_frag & FLOW_NW_FRAG_ANY)
+        if (mask->nw_frag & FLOW_NW_FRAG_ANY) {
+            flower.mask.flags |= TCA_FLOWER_KEY_FLAGS_IS_FRAGMENT;
+
+            if (key->nw_frag & FLOW_NW_FRAG_ANY) {
                 flower.key.flags |= TCA_FLOWER_KEY_FLAGS_IS_FRAGMENT;
-            if (!(key->nw_frag & FLOW_NW_FRAG_LATER))
-                flower.key.flags |= TCA_FLOWER_KEY_FLAGS_FRAG_IS_FIRST;
 
-            flower.mask.flags |= TCA_FLOWER_KEY_FLAGS_IS_FRAGMENT;
-            flower.mask.flags |= TCA_FLOWER_KEY_FLAGS_FRAG_IS_FIRST;
+                if (mask->nw_frag & FLOW_NW_FRAG_LATER) {
+                    flower.mask.flags |= TCA_FLOWER_KEY_FLAGS_FRAG_IS_FIRST;
+
+                    if (!(key->nw_frag & FLOW_NW_FRAG_LATER)) {
+                        flower.key.flags |= TCA_FLOWER_KEY_FLAGS_FRAG_IS_FIRST;
+                    }
+                }
+            }
+
             mask->nw_frag = 0;
         }
 
-- 
2.17.0