[ovs-dev,ovs,V4,15/24] netdev-tc-offloads: Implement netdev flow del using tc interface

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

Details

Message ID 1489412234-30916-16-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>

Signed-off-by: Paul Blakey <paulb@mellanox.com>
Reviewed-by: Roi Dayan <roid@mellanox.com>
---
 lib/netdev-tc-offloads.c |   33 ++++++++++++++++++++++++++++++---
 1 files changed, 30 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

diff --git a/lib/netdev-tc-offloads.c b/lib/netdev-tc-offloads.c
index cf21c3a..7b21b73 100644
--- a/lib/netdev-tc-offloads.c
+++ b/lib/netdev-tc-offloads.c
@@ -772,10 +772,37 @@  netdev_tc_flow_get(struct netdev *netdev OVS_UNUSED,
 
 int
 netdev_tc_flow_del(struct netdev *netdev OVS_UNUSED,
-                   const ovs_u128 *ufid OVS_UNUSED,
-                   struct dpif_flow_stats *stats OVS_UNUSED)
+                   const ovs_u128 *ufid,
+                   struct dpif_flow_stats *stats)
 {
-    return EOPNOTSUPP;
+    struct netdev *dev;
+    int prio = 0;
+    int ifindex;
+    int handle;
+    int error;
+
+    handle = get_ufid_tc_mapping(ufid, &prio, &dev);
+    if (!handle) {
+        return ENOENT;
+    }
+
+    ifindex = netdev_get_ifindex(dev);
+    if (ifindex < 0) {
+        VLOG_ERR_RL(&rl_err, "failed to get ifindex for %s: %s",
+                    netdev_get_name(dev), ovs_strerror(-ifindex));
+        netdev_close(dev);
+        return -ifindex;
+    }
+
+    error = tc_del_filter(ifindex, prio, handle);
+    del_ufid_tc_mapping(ufid);
+
+    netdev_close(dev);
+
+    if (stats) {
+        memset(stats, 0, sizeof(*stats));
+    }
+    return error;
 }
 
 int