diff mbox series

[ovs-dev,09/62] netdev-offload-dpdk: Add consumed_mask check in parse_flow_match

Message ID 20201228092520.11807-10-taoyunxiang@cmss.chinamobile.com
State Not Applicable
Headers show
Series [ovs-dev] db-ctl-base: add uuid specified method for create cmd | expand

Commit Message

Tao YunXiang Dec. 28, 2020, 9:24 a.m. UTC
From: Liuchang <liuchang@cmss.chinamobile.com>

Code Source From: Self Code
Description:

    Add consumed_mask check in parse_flow_match

Jira:  #[Optional]
市场项目编号(名称):[Optional]
---
 lib/netdev-offload-dpdk.c | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)
diff mbox series

Patch

diff --git a/lib/netdev-offload-dpdk.c b/lib/netdev-offload-dpdk.c
index 05c7558..5cce175 100644
--- a/lib/netdev-offload-dpdk.c
+++ b/lib/netdev-offload-dpdk.c
@@ -568,6 +568,14 @@  parse_flow_match(struct flow_patterns *patterns,
 {
     uint8_t *next_proto_mask = NULL;
     uint8_t proto = 0;
+    struct flow *consumed_masks;
+
+    consumed_masks = &match->wc.masks;
+    /* Not attemp to offload in_port/recirc_id ?
+    memset(&consumed_masks->in_port, 0, sizeof consumed_masks->in_port);
+    consumed_masks->recirc_id = 0;
+    */
+    consumed_masks->packet_type = 0;
 
     /* Eth */
     if (!eth_addr_is_zero(match->wc.masks.dl_src) ||
@@ -586,6 +594,9 @@  parse_flow_match(struct flow_patterns *patterns,
         mask->type = match->wc.masks.dl_type;
 
         add_flow_pattern(patterns, RTE_FLOW_ITEM_TYPE_ETH, spec, mask);
+        memset(&consumed_masks->dl_dst, 0, sizeof consumed_masks->dl_dst);
+        memset(&consumed_masks->dl_src, 0, sizeof consumed_masks->dl_src);
+
     } else {
         /*
          * If user specifies a flow (like UDP flow) without L2 patterns,
@@ -596,6 +607,7 @@  parse_flow_match(struct flow_patterns *patterns,
          */
         add_flow_pattern(patterns, RTE_FLOW_ITEM_TYPE_ETH, NULL, NULL);
     }
+    consumed_masks->dl_type = 0;
 
     /* VLAN */
     if (match->wc.masks.vlans[0].tci && match->flow.vlans[0].tci) {
@@ -612,6 +624,7 @@  parse_flow_match(struct flow_patterns *patterns,
 
         add_flow_pattern(patterns, RTE_FLOW_ITEM_TYPE_VLAN, spec, mask);
     }
+    memset(&consumed_masks->vlans[0], 0, sizeof consumed_masks->vlans[0]);
 
     /* do not attempt to offload frags. */
     if (match->flow.nw_frag != OVS_FRAG_TYPE_NONE && match->wc.masks.nw_frag) {
@@ -619,6 +632,7 @@  parse_flow_match(struct flow_patterns *patterns,
                     match->wc.masks.nw_frag);
         return -1;
     }
+    consumed_masks->nw_frag = 0;
 
     /* IP v4 */
     if (match->flow.dl_type == htons(ETH_TYPE_IP)) {
@@ -641,6 +655,12 @@  parse_flow_match(struct flow_patterns *patterns,
 
         add_flow_pattern(patterns, RTE_FLOW_ITEM_TYPE_IPV4, spec, mask);
 
+        consumed_masks->nw_tos = 0;
+        consumed_masks->nw_ttl = 0;
+        consumed_masks->nw_proto = 0;
+        consumed_masks->nw_src = 0;
+        consumed_masks->nw_dst = 0;
+
         /* Save proto for L4 protocol setup. */
         proto = spec->hdr.next_proto_id &
                 mask->hdr.next_proto_id;
@@ -679,6 +699,10 @@  parse_flow_match(struct flow_patterns *patterns,
 
         add_flow_pattern(patterns, RTE_FLOW_ITEM_TYPE_TCP, spec, mask);
 
+        consumed_masks->tp_src = 0;
+        consumed_masks->tp_dst = 0;
+        consumed_masks->tcp_flags = 0;
+
         /* proto == TCP and ITEM_TYPE_TCP, thus no need for proto match. */
         if (next_proto_mask) {
             *next_proto_mask = 0;
@@ -697,6 +721,9 @@  parse_flow_match(struct flow_patterns *patterns,
 
         add_flow_pattern(patterns, RTE_FLOW_ITEM_TYPE_UDP, spec, mask);
 
+        consumed_masks->tp_src = 0;
+        consumed_masks->tp_dst = 0;
+
         /* proto == UDP and ITEM_TYPE_UDP, thus no need for proto match. */
         if (next_proto_mask) {
             *next_proto_mask = 0;
@@ -715,6 +742,9 @@  parse_flow_match(struct flow_patterns *patterns,
 
         add_flow_pattern(patterns, RTE_FLOW_ITEM_TYPE_SCTP, spec, mask);
 
+        consumed_masks->tp_src = 0;
+        consumed_masks->tp_dst = 0;
+
         /* proto == SCTP and ITEM_TYPE_SCTP, thus no need for proto match. */
         if (next_proto_mask) {
             *next_proto_mask = 0;
@@ -733,6 +763,9 @@  parse_flow_match(struct flow_patterns *patterns,
 
         add_flow_pattern(patterns, RTE_FLOW_ITEM_TYPE_ICMP, spec, mask);
 
+        consumed_masks->tp_src = 0;
+        consumed_masks->tp_dst = 0;
+
         /* proto == ICMP and ITEM_TYPE_ICMP, thus no need for proto match. */
         if (next_proto_mask) {
             *next_proto_mask = 0;
@@ -741,6 +774,12 @@  parse_flow_match(struct flow_patterns *patterns,
 
     add_flow_pattern(patterns, RTE_FLOW_ITEM_TYPE_END, NULL, NULL);
 
+    if (!is_all_zeros(consumed_masks, sizeof *consumed_masks)) {
+        VLOG_DBG("Cannot match all matches. dl_type=0x%04x",
+                    ntohs(match->flow.dl_type));
+        return -1;
+    }
+
     return 0;
 }