Skip to content

Commit 142c659

Browse files
Eric Dumazetdavem330
authored andcommitted
bonding: refine bond_fold_stats() wrap detection
Some device drivers reset their stats at down/up events, possibly fooling bonding stats, since they operate with relative deltas. It is nearly not possible to fix drivers, since some of them compute the tx/rx counters based on per rx/tx queue stats, and the queues can be reconfigured (ethtool -L) between the down/up sequence. Lets avoid accumulating 'negative' values that render bonding stats useless. It is better to lose small deltas, assuming the bonding stats are fetched at a reasonable frequency. Fixes: 5f0c5f7 ("bonding: make global bonding stats more reliable") Signed-off-by: Eric Dumazet <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent ed8bfd5 commit 142c659

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

drivers/net/bonding/bond_main.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3332,12 +3332,17 @@ static void bond_fold_stats(struct rtnl_link_stats64 *_res,
33323332
for (i = 0; i < sizeof(*_res) / sizeof(u64); i++) {
33333333
u64 nv = new[i];
33343334
u64 ov = old[i];
3335+
s64 delta = nv - ov;
33353336

33363337
/* detects if this particular field is 32bit only */
33373338
if (((nv | ov) >> 32) == 0)
3338-
res[i] += (u32)nv - (u32)ov;
3339-
else
3340-
res[i] += nv - ov;
3339+
delta = (s64)(s32)((u32)nv - (u32)ov);
3340+
3341+
/* filter anomalies, some drivers reset their stats
3342+
* at down/up events.
3343+
*/
3344+
if (delta > 0)
3345+
res[i] += delta;
33413346
}
33423347
}
33433348

0 commit comments

Comments
 (0)