summaryrefslogtreecommitdiffstats
path: root/net/core/gen_stats.c
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2019-11-04 19:13:15 -0800
committerDavid S. Miller <davem@davemloft.net>2019-11-05 18:20:55 -0800
commitb33e699fe43aa63f29113311f69357e119ef5276 (patch)
tree763247d6b42ff2e72ee2100d5ec5235daa9967ed /net/core/gen_stats.c
parentd0083d98f685b9f4fe810570f93cef0b0bb6b354 (diff)
downloadlinux-b33e699fe43aa63f29113311f69357e119ef5276.tar.gz
linux-b33e699fe43aa63f29113311f69357e119ef5276.tar.bz2
linux-b33e699fe43aa63f29113311f69357e119ef5276.zip
net_sched: add TCA_STATS_PKT64 attribute
Now the kernel uses 64bit packet counters in scheduler layer, we want to export these counters to user space. Instead risking breaking user space by adding fields to struct gnet_stats_basic, add a new TCA_STATS_PKT64. Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/gen_stats.c')
-rw-r--r--net/core/gen_stats.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/net/core/gen_stats.c b/net/core/gen_stats.c
index fe33e2a9841e..1d653fbfcf52 100644
--- a/net/core/gen_stats.c
+++ b/net/core/gen_stats.c
@@ -175,12 +175,17 @@ ___gnet_stats_copy_basic(const seqcount_t *running,
if (d->tail) {
struct gnet_stats_basic sb;
+ int res;
memset(&sb, 0, sizeof(sb));
sb.bytes = bstats.bytes;
sb.packets = bstats.packets;
- return gnet_stats_copy(d, type, &sb, sizeof(sb),
- TCA_STATS_PAD);
+ res = gnet_stats_copy(d, type, &sb, sizeof(sb), TCA_STATS_PAD);
+ if (res < 0 || sb.packets == bstats.packets)
+ return res;
+ /* emit 64bit stats only if needed */
+ return gnet_stats_copy(d, TCA_STATS_PKT64, &bstats.packets,
+ sizeof(bstats.packets), TCA_STATS_PAD);
}
return 0;
}