diff options
author | sfeldma@cumulusnetworks.com <sfeldma@cumulusnetworks.com> | 2014-01-16 22:57:49 -0800 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-01-17 18:51:58 -0800 |
commit | 07699f9a7c8d1002e07011d5aa382cd63241eea8 (patch) | |
tree | 3fb131944eee1d84e4bb41fa9a6b9c2cf098e5a4 /drivers/net/bonding/bond_main.c | |
parent | fd27e0d44a893b45832df3cb8e021bd1d773a73f (diff) |
bonding: add sysfs /slave dir for bond slave devices.
Add sub-directory under /sys/class/net/<interface>/slave with
read-only attributes for slave. Directory only appears when
<interface> is a slave.
$ tree /sys/class/net/eth2/slave/
/sys/class/net/eth2/slave/
├── ad_aggregator_id
├── link_failure_count
├── mii_status
├── perm_hwaddr
├── queue_id
└── state
$ cat /sys/class/net/eth2/slave/*
2
0
up
40:02:10:ef:06:01
0
active
Signed-off-by: Scott Feldman <sfeldma@cumulusnetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/bonding/bond_main.c')
-rw-r--r-- | drivers/net/bonding/bond_main.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index f00dd45b0308..df85cec3e5d9 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -466,6 +466,22 @@ static void bond_update_speed_duplex(struct slave *slave) return; } +const char *bond_slave_link_status(s8 link) +{ + switch (link) { + case BOND_LINK_UP: + return "up"; + case BOND_LINK_FAIL: + return "going down"; + case BOND_LINK_DOWN: + return "down"; + case BOND_LINK_BACK: + return "going back"; + default: + return "unknown"; + } +} + /* * if <dev> supports MII link status reporting, check its link status. * @@ -1576,6 +1592,12 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) goto err_unregister; } + res = bond_sysfs_slave_add(new_slave); + if (res) { + pr_debug("Error %d calling bond_sysfs_slave_add\n", res); + goto err_upper_unlink; + } + bond->slave_cnt++; bond_compute_features(bond); bond_set_carrier(bond); @@ -1595,6 +1617,9 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) return 0; /* Undo stages on error */ +err_upper_unlink: + bond_upper_dev_unlink(bond_dev, slave_dev); + err_unregister: netdev_rx_handler_unregister(slave_dev); @@ -1687,6 +1712,8 @@ static int __bond_release_one(struct net_device *bond_dev, /* release the slave from its bond */ bond->slave_cnt--; + bond_sysfs_slave_del(slave); + bond_upper_dev_unlink(bond_dev, slave_dev); /* unregister rx_handler early so bond_handle_frame wouldn't be called * for this slave anymore. |