[ovs-dev] [PATCH 62/62] Fix some vxlan&&vlan offload problems.

Tao YunXiang taoyunxiang at cmss.chinamobile.com
Mon Dec 28 09:25:20 UTC 2020


From: Rong Yin <rongyin at cmss.chinamobile.com>

	fix vlan push issue with RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN
	fix vlan pop issue with ethertype error and ip_0_protocol error
	fix vxlan decap offload with vxlan flags
	fix ipv4 pattern ttl dump with 0x

Signed-off-by: LIU CHANG <liuchang at cmss.chinamobile.com>
---
 lib/netdev-dpdk.c         |  6 ++++--
 lib/netdev-offload-dpdk.c | 46 ++++++++++++++++++++++++++++++++++++++--------
 2 files changed, 42 insertions(+), 10 deletions(-)

diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index 5c5edb9..3d95d1b 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -2014,9 +2014,11 @@ netdev_dpdk_set_config(struct netdev *netdev, const struct smap *args,
         err = EINVAL;
     }
     /* update is_uplink_port && is_vf_rep_port flag */
-    if (strstr(dev->devargs,"representor=[10")) {
+    if (strstr(new_devargs,"representor=[10")) {
         dev->is_uplink_port = true;
-    } else if (strstr(dev->devargs,"representor")) {
+    } else if (strstr(new_devargs,"representor=[64")) {
+        dev->is_uplink_port = true;
+    } else if (strstr(new_devargs,"representor")) {
         dev->is_vf_rep_port = true;
     }
 
diff --git a/lib/netdev-offload-dpdk.c b/lib/netdev-offload-dpdk.c
index 58e6bc9..d407431 100644
--- a/lib/netdev-offload-dpdk.c
+++ b/lib/netdev-offload-dpdk.c
@@ -275,7 +275,7 @@ dump_flow_pattern(struct ds *s, const struct rte_flow_item *item)
         ds_put_cstr(s, "rte flow ipv4 pattern:\n");
         if (ipv4_spec) {
             ds_put_format(s,
-                          "  Spec: tos=0x%"PRIx8", ttl=%"PRIx8
+                          "  Spec: tos=0x%"PRIx8", ttl=0x%"PRIx8
                           ", proto=0x%"PRIx8
                           ", src="IP_FMT", dst="IP_FMT"\n",
                           ipv4_spec->hdr.type_of_service,
@@ -288,7 +288,7 @@ dump_flow_pattern(struct ds *s, const struct rte_flow_item *item)
         }
         if (ipv4_mask) {
             ds_put_format(s,
-                          "  Mask: tos=0x%"PRIx8", ttl=%"PRIx8
+                          "  Mask: tos=0x%"PRIx8", ttl=0x%"PRIx8
                           ", proto=0x%"PRIx8
                           ", src="IP_FMT", dst="IP_FMT"\n",
                           ipv4_mask->hdr.type_of_service,
@@ -857,6 +857,14 @@ parse_vxlan_match(struct flow_patterns *patterns,
     put_unaligned_be32((ovs_be32 *)vx_mask->vni,
                        htonl(ntohll(match->wc.masks.tunnel.tun_id) << 8));
 
+    /*
+    memcpy(&vx_spec->flags, 0x08, sizeof vx_spec->flags);
+    memcpy(&vx_mask->flags, 0x0, sizeof vx_mask->flags);
+    */
+
+    vx_spec->flags=0x08;
+    vx_mask->flags=0x0;    
+
     add_flow_pattern(patterns, RTE_FLOW_ITEM_TYPE_VXLAN, vx_spec, vx_mask);
     return 0;
 }
@@ -942,6 +950,7 @@ parse_flow_match(struct flow_patterns *patterns,
     }
 
     info->group_id = match->flow.recirc_id;
+
     /* Eth */
     if (match->flow.packet_type == htonl(PT_ETH)) {
         struct rte_flow_item_eth *spec, *mask;
@@ -951,7 +960,12 @@ parse_flow_match(struct flow_patterns *patterns,
 
         memcpy(&spec->dst, &match->flow.dl_dst, sizeof spec->dst);
         memcpy(&spec->src, &match->flow.dl_src, sizeof spec->src);
-        spec->type = match->flow.dl_type;
+
+        if (match->wc.masks.vlans[0].tci && match->flow.vlans[0].tci) {
+            spec->type = htons(ETH_TYPE_VLAN_8021Q);
+        } else {
+            spec->type = match->flow.dl_type;
+        }
 
         memcpy(&mask->dst, &match->wc.masks.dl_dst, sizeof mask->dst);
         memcpy(&mask->src, &match->wc.masks.dl_src, sizeof mask->src);
@@ -980,7 +994,15 @@ parse_flow_match(struct flow_patterns *patterns,
         spec->tci = match->flow.vlans[0].tci & ~htons(VLAN_CFI);
         mask->tci = match->wc.masks.vlans[0].tci & ~htons(VLAN_CFI);
 
-        /* Match any protocols. */
+        if (match->flow.dl_type == htons(ETH_TYPE_IP)) {
+            spec->inner_type = htons(ETH_TYPE_IP);
+        } else if (match->flow.dl_type == htons(ETH_TYPE_IPV6)) {
+            spec->inner_type = htons(ETH_TYPE_IPV6);
+        } else {
+            spec->inner_type = 0;
+        }
+            
+        /* Match ipv4 or ipv6 protocols. */
         mask->inner_type = 0;
 
         add_flow_pattern(patterns, RTE_FLOW_ITEM_TYPE_VLAN, spec, mask);
@@ -1830,12 +1852,16 @@ parse_clone_actions(struct netdev *netdev,
             }
             vlan_tci = xzalloc(sizeof *vlan_tci);
             vlan_tci->ethertype = vlan->vlan_tpid;
+
+            /*
             add_flow_action(actions, RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN,
                             vlan_tci);
-
             vid = xzalloc(sizeof *vid);
             vid->vlan_vid = vlan->vlan_tci & ~htons(VLAN_CFI);
-            add_flow_action(actions, RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID, vid);
+            */
+
+            vlan_tci->vlan_vid = vlan->vlan_tci & ~htons(VLAN_CFI);
+            add_flow_action(actions, RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN, vlan_tci);
 
         } else if (clone_type == OVS_ACTION_ATTR_POP_VLAN) {
             add_flow_action(actions, RTE_FLOW_ACTION_TYPE_OF_POP_VLAN, NULL);
@@ -2116,12 +2142,16 @@ parse_flow_actions(struct dpif *dpif,
 
             vlan_tci = xzalloc(sizeof *vlan_tci);
             vlan_tci->ethertype = vlan->vlan_tpid;
+
+            /*
             add_flow_action(actions, RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN,
                             vlan_tci);
-
             vid = xzalloc(sizeof *vid);
             vid->vlan_vid = vlan->vlan_tci & ~htons(VLAN_CFI);
-            add_flow_action(actions, RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID, vid);
+            */
+
+            vlan_tci->vlan_vid = vlan->vlan_tci & ~htons(VLAN_CFI);
+            add_flow_action(actions, RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN, vlan_tci);
 
         } else if (nl_attr_type(nla) == OVS_ACTION_ATTR_POP_VLAN) {
             add_flow_action(actions, RTE_FLOW_ACTION_TYPE_OF_POP_VLAN, NULL);
-- 
1.8.3.1





More information about the dev mailing list