diff options
author | Nicolas Dichtel <nicolas.dichtel@6wind.com> | 2016-04-26 04:06:18 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-04-26 12:00:49 -0400 |
commit | 9854518ea04db33738602d45ebc96a200e6f5198 (patch) | |
tree | 96d3d6f4024f7a79010bea763f5922315d7bd63f /net/core | |
parent | b676338fb3aab0b63b4a2489feb8f35003db22e8 (diff) |
sched: align nlattr properly when needed
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r-- | net/core/gen_stats.c | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/net/core/gen_stats.c b/net/core/gen_stats.c index e640462ea8bf..f96ee8b9478d 100644 --- a/net/core/gen_stats.c +++ b/net/core/gen_stats.c | |||
@@ -25,9 +25,9 @@ | |||
25 | 25 | ||
26 | 26 | ||
27 | static inline int | 27 | static inline int |
28 | gnet_stats_copy(struct gnet_dump *d, int type, void *buf, int size) | 28 | gnet_stats_copy(struct gnet_dump *d, int type, void *buf, int size, int padattr) |
29 | { | 29 | { |
30 | if (nla_put(d->skb, type, size, buf)) | 30 | if (nla_put_64bit(d->skb, type, size, buf, padattr)) |
31 | goto nla_put_failure; | 31 | goto nla_put_failure; |
32 | return 0; | 32 | return 0; |
33 | 33 | ||
@@ -59,7 +59,8 @@ nla_put_failure: | |||
59 | */ | 59 | */ |
60 | int | 60 | int |
61 | gnet_stats_start_copy_compat(struct sk_buff *skb, int type, int tc_stats_type, | 61 | gnet_stats_start_copy_compat(struct sk_buff *skb, int type, int tc_stats_type, |
62 | int xstats_type, spinlock_t *lock, struct gnet_dump *d) | 62 | int xstats_type, spinlock_t *lock, |
63 | struct gnet_dump *d, int padattr) | ||
63 | __acquires(lock) | 64 | __acquires(lock) |
64 | { | 65 | { |
65 | memset(d, 0, sizeof(*d)); | 66 | memset(d, 0, sizeof(*d)); |
@@ -71,16 +72,17 @@ gnet_stats_start_copy_compat(struct sk_buff *skb, int type, int tc_stats_type, | |||
71 | d->skb = skb; | 72 | d->skb = skb; |
72 | d->compat_tc_stats = tc_stats_type; | 73 | d->compat_tc_stats = tc_stats_type; |
73 | d->compat_xstats = xstats_type; | 74 | d->compat_xstats = xstats_type; |
75 | d->padattr = padattr; | ||
74 | 76 | ||
75 | if (d->tail) | 77 | if (d->tail) |
76 | return gnet_stats_copy(d, type, NULL, 0); | 78 | return gnet_stats_copy(d, type, NULL, 0, padattr); |
77 | 79 | ||
78 | return 0; | 80 | return 0; |
79 | } | 81 | } |
80 | EXPORT_SYMBOL(gnet_stats_start_copy_compat); | 82 | EXPORT_SYMBOL(gnet_stats_start_copy_compat); |
81 | 83 | ||
82 | /** | 84 | /** |
83 | * gnet_stats_start_copy_compat - start dumping procedure in compatibility mode | 85 | * gnet_stats_start_copy - start dumping procedure in compatibility mode |
84 | * @skb: socket buffer to put statistics TLVs into | 86 | * @skb: socket buffer to put statistics TLVs into |
85 | * @type: TLV type for top level statistic TLV | 87 | * @type: TLV type for top level statistic TLV |
86 | * @lock: statistics lock | 88 | * @lock: statistics lock |
@@ -94,9 +96,9 @@ EXPORT_SYMBOL(gnet_stats_start_copy_compat); | |||
94 | */ | 96 | */ |
95 | int | 97 | int |
96 | gnet_stats_start_copy(struct sk_buff *skb, int type, spinlock_t *lock, | 98 | gnet_stats_start_copy(struct sk_buff *skb, int type, spinlock_t *lock, |
97 | struct gnet_dump *d) | 99 | struct gnet_dump *d, int padattr) |
98 | { | 100 | { |
99 | return gnet_stats_start_copy_compat(skb, type, 0, 0, lock, d); | 101 | return gnet_stats_start_copy_compat(skb, type, 0, 0, lock, d, padattr); |
100 | } | 102 | } |
101 | EXPORT_SYMBOL(gnet_stats_start_copy); | 103 | EXPORT_SYMBOL(gnet_stats_start_copy); |
102 | 104 | ||
@@ -169,7 +171,8 @@ gnet_stats_copy_basic(struct gnet_dump *d, | |||
169 | memset(&sb, 0, sizeof(sb)); | 171 | memset(&sb, 0, sizeof(sb)); |
170 | sb.bytes = bstats.bytes; | 172 | sb.bytes = bstats.bytes; |
171 | sb.packets = bstats.packets; | 173 | sb.packets = bstats.packets; |
172 | return gnet_stats_copy(d, TCA_STATS_BASIC, &sb, sizeof(sb)); | 174 | return gnet_stats_copy(d, TCA_STATS_BASIC, &sb, sizeof(sb), |
175 | TCA_STATS_PAD); | ||
173 | } | 176 | } |
174 | return 0; | 177 | return 0; |
175 | } | 178 | } |
@@ -208,11 +211,13 @@ gnet_stats_copy_rate_est(struct gnet_dump *d, | |||
208 | } | 211 | } |
209 | 212 | ||
210 | if (d->tail) { | 213 | if (d->tail) { |
211 | res = gnet_stats_copy(d, TCA_STATS_RATE_EST, &est, sizeof(est)); | 214 | res = gnet_stats_copy(d, TCA_STATS_RATE_EST, &est, sizeof(est), |
215 | TCA_STATS_PAD); | ||
212 | if (res < 0 || est.bps == r->bps) | 216 | if (res < 0 || est.bps == r->bps) |
213 | return res; | 217 | return res; |
214 | /* emit 64bit stats only if needed */ | 218 | /* emit 64bit stats only if needed */ |
215 | return gnet_stats_copy(d, TCA_STATS_RATE_EST64, r, sizeof(*r)); | 219 | return gnet_stats_copy(d, TCA_STATS_RATE_EST64, r, sizeof(*r), |
220 | TCA_STATS_PAD); | ||
216 | } | 221 | } |
217 | 222 | ||
218 | return 0; | 223 | return 0; |
@@ -286,7 +291,8 @@ gnet_stats_copy_queue(struct gnet_dump *d, | |||
286 | 291 | ||
287 | if (d->tail) | 292 | if (d->tail) |
288 | return gnet_stats_copy(d, TCA_STATS_QUEUE, | 293 | return gnet_stats_copy(d, TCA_STATS_QUEUE, |
289 | &qstats, sizeof(qstats)); | 294 | &qstats, sizeof(qstats), |
295 | TCA_STATS_PAD); | ||
290 | 296 | ||
291 | return 0; | 297 | return 0; |
292 | } | 298 | } |
@@ -316,7 +322,8 @@ gnet_stats_copy_app(struct gnet_dump *d, void *st, int len) | |||
316 | } | 322 | } |
317 | 323 | ||
318 | if (d->tail) | 324 | if (d->tail) |
319 | return gnet_stats_copy(d, TCA_STATS_APP, st, len); | 325 | return gnet_stats_copy(d, TCA_STATS_APP, st, len, |
326 | TCA_STATS_PAD); | ||
320 | 327 | ||
321 | return 0; | 328 | return 0; |
322 | 329 | ||
@@ -347,12 +354,12 @@ gnet_stats_finish_copy(struct gnet_dump *d) | |||
347 | 354 | ||
348 | if (d->compat_tc_stats) | 355 | if (d->compat_tc_stats) |
349 | if (gnet_stats_copy(d, d->compat_tc_stats, &d->tc_stats, | 356 | if (gnet_stats_copy(d, d->compat_tc_stats, &d->tc_stats, |
350 | sizeof(d->tc_stats)) < 0) | 357 | sizeof(d->tc_stats), d->padattr) < 0) |
351 | return -1; | 358 | return -1; |
352 | 359 | ||
353 | if (d->compat_xstats && d->xstats) { | 360 | if (d->compat_xstats && d->xstats) { |
354 | if (gnet_stats_copy(d, d->compat_xstats, d->xstats, | 361 | if (gnet_stats_copy(d, d->compat_xstats, d->xstats, |
355 | d->xstats_len) < 0) | 362 | d->xstats_len, d->padattr) < 0) |
356 | return -1; | 363 | return -1; |
357 | } | 364 | } |
358 | 365 | ||