diff mbox series

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

Message ID d68a8d639c0276278c5d1d968e1905b45f6c3bb4.1510069964.git.pabeni@redhat.com
State Superseded
Headers show
Series [ovs-dev] netdev-tc-offloads: update stats properly on flow deletion | expand

Commit Message

Paolo Abeni Nov. 7, 2017, 3:53 p.m. UTC
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@mellanox.com>
Reported-by: Kumar Sanghvi <kumaras@chelsio.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
---
 lib/netdev-tc-offloads.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
diff mbox series

Patch

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;
 }