Inovke netdev class '->flow_del' method on flow deletion. The dpdk netdev
implementation will then remove the rte flow associated with the ufid.

Co-authored-by: Finn Christensen <[email protected]>
Signed-off-by: Yuanhan Liu <[email protected]>
Signed-off-by: Finn Christensen <[email protected]>
---

v2: - check the returned "port" from dp_netdev_lookup_port
    - error log when flow is not found
---
 lib/dpif-netdev.c | 10 ++++++++--
 lib/netdev-dpdk.c | 19 ++++++++++++++++++-
 2 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index 3099c73..2fbaa96 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -1857,8 +1857,14 @@ dp_netdev_pmd_remove_flow(struct dp_netdev_pmd_thread 
*pmd,
     dpcls_remove(cls, &flow->cr);
     cmap_remove(&pmd->flow_table, node, dp_netdev_flow_hash(&flow->ufid));
     if (flow->has_mark) {
-        cmap_remove(&pmd->mark_to_flow, mark_node, flow->mark);
-        flow->has_mark = false;
+        struct dp_netdev_port *port;
+
+        port = dp_netdev_lookup_port(pmd->dp, in_port);
+        if (port) {
+            netdev_flow_del(port->netdev, &flow->ufid, NULL);
+            cmap_remove(&pmd->mark_to_flow, mark_node, flow->mark);
+            flow->has_mark = false;
+        }
     }
     flow->dead = true;
 
diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index 320fe80..e363c92 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -3853,6 +3853,23 @@ netdev_dpdk_flow_put(struct netdev *netdev, struct match 
*match,
                                             actions_len, ufid, info);
 }
 
+static int
+netdev_dpdk_flow_del(struct netdev *netdev, const ovs_u128 *ufid,
+                     struct dpif_flow_stats *stats OVS_UNUSED)
+{
+
+    struct rte_flow *rte_flow = get_rte_flow_by_ufid(ufid);
+
+    if (!rte_flow) {
+        VLOG_ERR("failed to find flow associated with ufid " UUID_FMT "\n",
+                 UUID_ARGS((struct uuid *)ufid));
+        return -1;
+    }
+
+    return netdev_dpdk_destroy_rte_flow(netdev_dpdk_cast(netdev),
+                                        ufid, rte_flow);
+}
+
 #define DPDK_FLOW_OFFLOAD_API                                 \
     NULL,                   /* flow_flush */                  \
     NULL,                   /* flow_dump_create */            \
@@ -3860,7 +3877,7 @@ netdev_dpdk_flow_put(struct netdev *netdev, struct match 
*match,
     NULL,                   /* flow_dump_next */              \
     netdev_dpdk_flow_put,                                     \
     NULL,                   /* flow_get */                    \
-    NULL,                   /* flow_del */                    \
+    netdev_dpdk_flow_del,                                     \
     NULL                    /* init_flow_api */
 
 
-- 
2.7.4

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to