Currently tc offload flow packet counters will roll over every ~4
billion packets. This is because the packet counter in struct
tc_stats provided by TCA_STATS_BASIC is a 32bit integer.
Now we check for the optional TCA_STATS_PKT64 attribute which provides
the full 64bit packet counter if the 32bit one has rolled over. This
patch also changes the non-empty check to use bytes, in case the 32bit
packet counter has rolled over for this update.
Fixes: f98e418fbd ("tc: Add tc flower functions")
Reported-at: https://bugzilla.redhat.com/show_bug.cgi?id=1776816
Signed-off-by: Mike Pattrick <[email protected]>
---
lib/tc.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/lib/tc.c b/lib/tc.c
index 38a1dfc0e..88e813088 100644
--- a/lib/tc.c
+++ b/lib/tc.c
@@ -1702,6 +1702,9 @@ static const struct nl_policy stats_policy[] = {
[TCA_STATS_BASIC] = { .type = NL_A_UNSPEC,
.min_len = sizeof(struct gnet_stats_basic),
.optional = false, },
+ [TCA_STATS_PKT64] = { .type = NL_A_U64,
+ .min_len = sizeof(uint64_t),
+ .optional = true, },
};
static int
@@ -1772,8 +1775,13 @@ nl_parse_single_action(struct nlattr *action, struct
tc_flower *flower,
}
bs = nl_attr_get_unspec(stats_attrs[TCA_STATS_BASIC], sizeof *bs);
- if (bs->packets) {
- put_32aligned_u64(&stats->n_packets, bs->packets);
+ if (bs->bytes) {
+ if (stats_attrs[TCA_STATS_PKT64]) {
+ uint64_t packets = nl_attr_get_u64(stats_attrs[TCA_STATS_PKT64]);
+ put_32aligned_u64(&stats->n_packets, packets);
+ } else {
+ put_32aligned_u64(&stats->n_packets, bs->packets);
+ }
put_32aligned_u64(&stats->n_bytes, bs->bytes);
}
--
2.27.0
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev