[ovs-dev,ovs,V4,14/24] dpif-netlink: Use netdev flow del api to delete a flow

Submitted by Roi Dayan on March 13, 2017, 1:37 p.m.

Details

Message ID 1489412234-30916-15-git-send-email-roid@mellanox.com
State Superseded
Headers show

Commit Message

Roi Dayan March 13, 2017, 1:37 p.m.
From: Paul Blakey <paulb@mellanox.com>

If a flow was offloaded to a netdev we delete it using netdev
flow api.

Signed-off-by: Paul Blakey <paulb@mellanox.com>
Reviewed-by: Roi Dayan <roid@mellanox.com>
---
 lib/dpif-netlink.c |   12 +++++++++++-
 lib/netdev.c       |   15 +++++++++++++++
 lib/netdev.h       |    2 ++
 3 files changed, 28 insertions(+), 1 deletions(-)

Patch hide | download patch | download mbox

diff --git a/lib/dpif-netlink.c b/lib/dpif-netlink.c
index 59b87ff..1964c42 100644
--- a/lib/dpif-netlink.c
+++ b/lib/dpif-netlink.c
@@ -2076,7 +2076,17 @@  try_send_to_netdev(struct dpif_netlink *dpif, struct dpif_op *op)
                        (put->flags & DPIF_FP_MODIFY ? "PUT(MODIFY)" : "PUT"));
         return parse_flow_put(dpif, put);
     }
-    case DPIF_OP_FLOW_DEL:
+    case DPIF_OP_FLOW_DEL: {
+        struct dpif_flow_del *del = &op->u.flow_del;
+
+        if (!del->ufid) {
+            break;
+        }
+        dbg_print_flow(del->key, del->key_len, NULL, 0, NULL, 0,
+                       del->ufid, "DEL");
+        return netdev_ports_flow_del(DPIF_HMAP_KEY(&dpif->dpif), del->ufid,
+                                     del->stats);
+    }
     case DPIF_OP_FLOW_GET:
     case DPIF_OP_EXECUTE:
     default:
diff --git a/lib/netdev.c b/lib/netdev.c
index f26c962..5eb4dd0 100644
--- a/lib/netdev.c
+++ b/lib/netdev.c
@@ -2269,6 +2269,21 @@  netdev_ports_flow_dumps_create(const void *obj, int *ports)
     return dumps;
 }
 
+int
+netdev_ports_flow_del(const void *obj, const ovs_u128 *ufid,
+                      struct dpif_flow_stats *stats)
+{
+    struct port_to_netdev_data *data;
+
+    HMAP_FOR_EACH(data, node, &port_to_netdev) {
+        if (data->obj == obj && !netdev_flow_del(data->netdev, ufid, stats)) {
+            return 0;
+        }
+    }
+
+    return ENOENT;
+}
+
 bool netdev_flow_api_enabled = false;
 
 #ifdef __linux__
diff --git a/lib/netdev.h b/lib/netdev.h
index 869d9c4..ee8c401 100644
--- a/lib/netdev.h
+++ b/lib/netdev.h
@@ -188,6 +188,8 @@  int netdev_hmap_port_del(odp_port_t port, const void *obj);
 struct netdev_flow_dump **netdev_ports_flow_dumps_create(const void *obj,
                                                          int *ports);
 void netdev_ports_flow_flush(const void *obj);
+int netdev_ports_flow_del(const void *obj, const ovs_u128 *ufid,
+                          struct dpif_flow_stats *stats);
 odp_port_t netdev_hmap_port_get_byifidx(int ifindex);
 
 /* native tunnel APIs */