[ovs-dev] [PATCH] netdev-tc-offloads: Fix probing multi mask per prio

Roi Dayan roid at mellanox.com
Mon Jul 2 09:07:58 UTC 2018


When adding TC rules we save the prio so can reuse same prio
for same mask since different mask will have to use different prio.
The multi mask per prio probe broke this by using a prio but
get_prio_for_tc_flower() didn't know about it.
Also multi mask per prio support changes the hash calculation.
It's best the probe will add and del the ingress qdisc to have a clean start
after it.

Signed-off-by: Roi Dayan <roid at mellanox.com>
Acked-by: Paul Blakey <paulb at mellanox.com>
---
 lib/netdev-tc-offloads.c | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/lib/netdev-tc-offloads.c b/lib/netdev-tc-offloads.c
index 86dbeeccb33b..bdf288c0622c 100644
--- a/lib/netdev-tc-offloads.c
+++ b/lib/netdev-tc-offloads.c
@@ -1235,11 +1235,17 @@ netdev_tc_flow_del(struct netdev *netdev OVS_UNUSED,
 }
 
 static void
-probe_multi_mask_per_prio(int ifindex, uint32_t block_id)
+probe_multi_mask_per_prio(int ifindex)
 {
     struct tc_flower flower;
+    int block_id = 0;
     int error;
 
+    error = tc_add_del_ingress_qdisc(ifindex, true, block_id);
+    if (error) {
+        return;
+    }
+
     memset(&flower, 0, sizeof flower);
 
     flower.key.eth_type = htons(ETH_P_IP);
@@ -1249,7 +1255,7 @@ probe_multi_mask_per_prio(int ifindex, uint32_t block_id)
 
     error = tc_replace_flower(ifindex, 1, 1, &flower, block_id);
     if (error) {
-        return;
+        goto out;
     }
 
     memset(&flower.key.src_mac, 0x11, sizeof flower.key.src_mac);
@@ -1259,13 +1265,16 @@ probe_multi_mask_per_prio(int ifindex, uint32_t block_id)
     tc_del_filter(ifindex, 1, 1, block_id);
 
     if (error) {
-        return;
+        goto out;
     }
 
     tc_del_filter(ifindex, 1, 2, block_id);
 
     multi_mask_per_prio = true;
     VLOG_INFO("probe tc: multiple masks on single tc prio is supported.");
+
+out:
+    tc_add_del_ingress_qdisc(ifindex, false, block_id);
 }
 
 static void
@@ -1306,6 +1315,11 @@ netdev_tc_init_flow_api(struct netdev *netdev)
         ovsthread_once_done(&block_once);
     }
 
+    if (ovsthread_once_start(&multi_mask_once)) {
+        probe_multi_mask_per_prio(ifindex);
+        ovsthread_once_done(&multi_mask_once);
+    }
+
     block_id = get_block_id_from_netdev(netdev);
     error = tc_add_del_ingress_qdisc(ifindex, true, block_id);
 
@@ -1317,10 +1331,5 @@ netdev_tc_init_flow_api(struct netdev *netdev)
 
     VLOG_INFO("added ingress qdisc to %s", netdev_get_name(netdev));
 
-    if (ovsthread_once_start(&multi_mask_once)) {
-        probe_multi_mask_per_prio(ifindex, block_id);
-        ovsthread_once_done(&multi_mask_once);
-    }
-
     return 0;
 }
-- 
2.7.0



More information about the dev mailing list