diff options
-rw-r--r-- | include/net/gen_stats.h | 3 | ||||
-rw-r--r-- | net/core/gen_stats.c | 48 | ||||
-rw-r--r-- | net/sched/act_api.c | 2 |
3 files changed, 35 insertions, 18 deletions
diff --git a/include/net/gen_stats.h b/include/net/gen_stats.h index 9a9bea508d1be..0b95cf031d6e0 100644 --- a/include/net/gen_stats.h +++ b/include/net/gen_stats.h @@ -15,7 +15,8 @@ struct gnet_dump /* Backward compatability */ int compat_tc_stats; int compat_xstats; - struct rtattr * xstats; + void * xstats; + int xstats_len; struct tc_stats tc_stats; }; diff --git a/net/core/gen_stats.c b/net/core/gen_stats.c index ebb86fbd23ab6..8f21490355fa5 100644 --- a/net/core/gen_stats.c +++ b/net/core/gen_stats.c @@ -26,9 +26,7 @@ static inline int gnet_stats_copy(struct gnet_dump *d, int type, void *buf, int size) { - if (type) - RTA_PUT(d->skb, type, size, buf); - + RTA_PUT(d->skb, type, size, buf); return 0; rtattr_failure: @@ -58,6 +56,8 @@ int gnet_stats_start_copy_compat(struct sk_buff *skb, int type, int tc_stats_type, int xstats_type, spinlock_t *lock, struct gnet_dump *d) { + memset(d, 0, sizeof(*d)); + spin_lock_bh(lock); d->lock = lock; if (type) @@ -65,12 +65,11 @@ gnet_stats_start_copy_compat(struct sk_buff *skb, int type, int tc_stats_type, d->skb = skb; d->compat_tc_stats = tc_stats_type; d->compat_xstats = xstats_type; - d->xstats = NULL; - if (d->compat_tc_stats) - memset(&d->tc_stats, 0, sizeof(d->tc_stats)); + if (d->tail) + return gnet_stats_copy(d, type, NULL, 0); - return gnet_stats_copy(d, type, NULL, 0); + return 0; } /** @@ -111,8 +110,11 @@ gnet_stats_copy_basic(struct gnet_dump *d, struct gnet_stats_basic *b) d->tc_stats.bytes = b->bytes; d->tc_stats.packets = b->packets; } - - return gnet_stats_copy(d, TCA_STATS_BASIC, b, sizeof(*b)); + + if (d->tail) + return gnet_stats_copy(d, TCA_STATS_BASIC, b, sizeof(*b)); + + return 0; } /** @@ -134,7 +136,10 @@ gnet_stats_copy_rate_est(struct gnet_dump *d, struct gnet_stats_rate_est *r) d->tc_stats.pps = r->pps; } - return gnet_stats_copy(d, TCA_STATS_RATE_EST, r, sizeof(*r)); + if (d->tail) + return gnet_stats_copy(d, TCA_STATS_RATE_EST, r, sizeof(*r)); + + return 0; } /** @@ -157,8 +162,11 @@ gnet_stats_copy_queue(struct gnet_dump *d, struct gnet_stats_queue *q) d->tc_stats.backlog = q->backlog; d->tc_stats.overlimits = q->overlimits; } - - return gnet_stats_copy(d, TCA_STATS_QUEUE, q, sizeof(*q)); + + if (d->tail) + return gnet_stats_copy(d, TCA_STATS_QUEUE, q, sizeof(*q)); + + return 0; } /** @@ -177,9 +185,15 @@ gnet_stats_copy_queue(struct gnet_dump *d, struct gnet_stats_queue *q) int gnet_stats_copy_app(struct gnet_dump *d, void *st, int len) { - if (d->compat_xstats) - d->xstats = (struct rtattr *) d->skb->tail; - return gnet_stats_copy(d, TCA_STATS_APP, st, len); + if (d->compat_xstats) { + d->xstats = st; + d->xstats_len = len; + } + + if (d->tail) + return gnet_stats_copy(d, TCA_STATS_APP, st, len); + + return 0; } /** @@ -206,8 +220,8 @@ gnet_stats_finish_copy(struct gnet_dump *d) return -1; if (d->compat_xstats && d->xstats) { - if (gnet_stats_copy(d, d->compat_xstats, RTA_DATA(d->xstats), - RTA_PAYLOAD(d->xstats)) < 0) + if (gnet_stats_copy(d, d->compat_xstats, d->xstats, + d->xstats_len) < 0) return -1; } diff --git a/net/sched/act_api.c b/net/sched/act_api.c index 88962fa33199f..5e6cc371b39ea 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c @@ -397,6 +397,8 @@ int tcf_action_copy_stats(struct sk_buff *skb, struct tc_action *a, if (a->type == TCA_OLD_COMPAT) err = gnet_stats_start_copy_compat(skb, 0, TCA_STATS, TCA_XSTATS, h->stats_lock, &d); + else + return 0; } else err = gnet_stats_start_copy(skb, TCA_ACT_STATS, h->stats_lock, &d); |