diff options
author | david decotigny <decot@googlers.com> | 2014-03-29 09:48:35 -0700 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-03-31 16:24:52 -0400 |
commit | 2d3b479df41a10e2f41f9259fcba775bd34de6e4 (patch) | |
tree | 517291066c35188a41b005e81904e69865643e76 /net/sched | |
parent | 9c76a114bbef10b4d44bd258006721dd896695dd (diff) | |
download | op-kernel-dev-2d3b479df41a10e2f41f9259fcba775bd34de6e4.zip op-kernel-dev-2d3b479df41a10e2f41f9259fcba775bd34de6e4.tar.gz |
net-sysfs: expose number of carrier on/off changes
This allows to monitor carrier on/off transitions and detect link
flapping issues:
- new /sys/class/net/X/carrier_changes
- new rtnetlink IFLA_CARRIER_CHANGES (getlink)
Tested:
- grep . /sys/class/net/*/carrier_changes
+ ip link set dev X down/up
+ plug/unplug cable
- updated iproute2: prints IFLA_CARRIER_CHANGES
- iproute2 20121211-2 (debian): unchanged behavior
Signed-off-by: David Decotigny <decot@googlers.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sched')
-rw-r--r-- | net/sched/sch_generic.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c index e82e43b..e1543b0 100644 --- a/net/sched/sch_generic.c +++ b/net/sched/sch_generic.c @@ -310,6 +310,7 @@ void netif_carrier_on(struct net_device *dev) if (test_and_clear_bit(__LINK_STATE_NOCARRIER, &dev->state)) { if (dev->reg_state == NETREG_UNINITIALIZED) return; + atomic_inc(&dev->carrier_changes); linkwatch_fire_event(dev); if (netif_running(dev)) __netdev_watchdog_up(dev); @@ -328,6 +329,7 @@ void netif_carrier_off(struct net_device *dev) if (!test_and_set_bit(__LINK_STATE_NOCARRIER, &dev->state)) { if (dev->reg_state == NETREG_UNINITIALIZED) return; + atomic_inc(&dev->carrier_changes); linkwatch_fire_event(dev); } } |