diff options
author | david decotigny <decot@googlers.com> | 2014-03-29 12:48:35 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-03-31 16:24:52 -0400 |
commit | 2d3b479df41a10e2f41f9259fcba775bd34de6e4 (patch) | |
tree | 517291066c35188a41b005e81904e69865643e76 /net/core/net-sysfs.c | |
parent | 9c76a114bbef10b4d44bd258006721dd896695dd (diff) |
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/core/net-sysfs.c')
-rw-r--r-- | net/core/net-sysfs.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c index daed9a64c6f6..462396278484 100644 --- a/net/core/net-sysfs.c +++ b/net/core/net-sysfs.c | |||
@@ -253,6 +253,16 @@ static ssize_t operstate_show(struct device *dev, | |||
253 | } | 253 | } |
254 | static DEVICE_ATTR_RO(operstate); | 254 | static DEVICE_ATTR_RO(operstate); |
255 | 255 | ||
256 | static ssize_t carrier_changes_show(struct device *dev, | ||
257 | struct device_attribute *attr, | ||
258 | char *buf) | ||
259 | { | ||
260 | struct net_device *netdev = to_net_dev(dev); | ||
261 | return sprintf(buf, fmt_dec, | ||
262 | atomic_read(&netdev->carrier_changes)); | ||
263 | } | ||
264 | static DEVICE_ATTR_RO(carrier_changes); | ||
265 | |||
256 | /* read-write attributes */ | 266 | /* read-write attributes */ |
257 | 267 | ||
258 | static int change_mtu(struct net_device *net, unsigned long new_mtu) | 268 | static int change_mtu(struct net_device *net, unsigned long new_mtu) |
@@ -386,6 +396,7 @@ static struct attribute *net_class_attrs[] = { | |||
386 | &dev_attr_duplex.attr, | 396 | &dev_attr_duplex.attr, |
387 | &dev_attr_dormant.attr, | 397 | &dev_attr_dormant.attr, |
388 | &dev_attr_operstate.attr, | 398 | &dev_attr_operstate.attr, |
399 | &dev_attr_carrier_changes.attr, | ||
389 | &dev_attr_ifalias.attr, | 400 | &dev_attr_ifalias.attr, |
390 | &dev_attr_carrier.attr, | 401 | &dev_attr_carrier.attr, |
391 | &dev_attr_mtu.attr, | 402 | &dev_attr_mtu.attr, |