Skip to content

Commit

Permalink
net_sched: add TCA_STATS_PKT64 attribute
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Eric Dumazet authored and davem330 committed Nov 6, 2019
1 parent d0083d9 commit b33e699
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions include/uapi/linux/gen_stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ enum {
TCA_STATS_RATE_EST64,
TCA_STATS_PAD,
TCA_STATS_BASIC_HW,
TCA_STATS_PKT64,
__TCA_STATS_MAX,
};
#define TCA_STATS_MAX (__TCA_STATS_MAX - 1)
Expand Down
9 changes: 7 additions & 2 deletions net/core/gen_stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 2 additions & 0 deletions net/sched/act_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ static size_t tcf_action_shared_attrs_size(const struct tc_action *act)
+ nla_total_size(0) /* TCA_ACT_STATS nested */
/* TCA_STATS_BASIC */
+ nla_total_size_64bit(sizeof(struct gnet_stats_basic))
/* TCA_STATS_PKT64 */
+ nla_total_size_64bit(sizeof(u64))
/* TCA_STATS_QUEUE */
+ nla_total_size_64bit(sizeof(struct gnet_stats_queue))
+ nla_total_size(0) /* TCA_OPTIONS nested */
Expand Down

0 comments on commit b33e699

Please sign in to comment.