[ovs-dev] [PATCH] netdev-tc-offloads: update stats properly on flow deletion

Paolo Abeni pabeni at redhat.com
Tue Nov 7 15:53:25 UTC 2017


Currently, when an offloaded DP flow is deleted, the related stats
are unconditionally cleared. As a result the counters for the
originating open flow are corrupted.

This change addresses the issue updating the DP stats with the current
values provided by the flower APIs before deleting the tc filter, as
currently done by others DP providers.

Fixes: 30b6b047260b ("netdev-tc-offloads: Implement netdev flow del using tc interface")
CC: Paul Blakey <paulb at mellanox.com>
Reported-by: Kumar Sanghvi <kumaras at chelsio.com>
Signed-off-by: Paolo Abeni <pabeni at redhat.com>
---
 lib/netdev-tc-offloads.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/lib/netdev-tc-offloads.c b/lib/netdev-tc-offloads.c
index 524c7dc5a..70bd04998 100644
--- a/lib/netdev-tc-offloads.c
+++ b/lib/netdev-tc-offloads.c
@@ -912,6 +912,7 @@ netdev_tc_flow_del(struct netdev *netdev OVS_UNUSED,
                    const ovs_u128 *ufid,
                    struct dpif_flow_stats *stats)
 {
+    struct tc_flower flower;
     struct netdev *dev;
     int prio = 0;
     int ifindex;
@@ -931,14 +932,18 @@ netdev_tc_flow_del(struct netdev *netdev OVS_UNUSED,
         return -ifindex;
     }
 
+    if (stats && !tc_get_flower(ifindex, prio, handle, &flower)) {
+        memset(stats, 0, sizeof *stats);
+        stats->n_packets = get_32aligned_u64(&flower.stats.n_packets);
+        stats->n_bytes = get_32aligned_u64(&flower.stats.n_bytes);
+        stats->used = flower.lastused;
+    }
+
     error = tc_del_filter(ifindex, prio, handle);
     del_ufid_tc_mapping(ufid);
 
     netdev_close(dev);
 
-    if (stats) {
-        memset(stats, 0, sizeof *stats);
-    }
     return error;
 }
 
-- 
2.13.6



More information about the dev mailing list