Skip to content

Commit b76cdba

Browse files
mawilli1linvjw
authored andcommitted
[PATCH] bonding: add sysfs functionality to bonding (large)
This large patch adds sysfs functionality to the channel bonding module. Bonds can be added, removed, and reconfigured at runtime without having to reload the module. Multiple bonds with different configurations are easily configured, and ifenslave is no longer required to configure bonds. Signed-off-by: Mitch Williams <mitch.a.williams@intel.com> Acked-by: Jay Vosburgh <fubar@us.ibm.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
1 parent 4756b02 commit b76cdba

File tree

4 files changed

+1429
-2
lines changed

4 files changed

+1429
-2
lines changed

drivers/net/bonding/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44

55
obj-$(CONFIG_BONDING) += bonding.o
66

7-
bonding-objs := bond_main.o bond_3ad.o bond_alb.o
7+
bonding-objs := bond_main.o bond_3ad.o bond_alb.o bond_sysfs.o
88

drivers/net/bonding/bond_main.c

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,7 @@ LIST_HEAD(bond_dev_list);
600600
static struct proc_dir_entry *bond_proc_dir = NULL;
601601
#endif
602602

603+
extern struct rw_semaphore bonding_rwsem;
603604
static u32 arp_target[BOND_MAX_ARP_TARGETS] = { 0, } ;
604605
static int arp_ip_count = 0;
605606
static int bond_mode = BOND_MODE_ROUNDROBIN;
@@ -1960,6 +1961,10 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
19601961

19611962
write_unlock_bh(&bond->lock);
19621963

1964+
res = bond_create_slave_symlinks(bond_dev, slave_dev);
1965+
if (res)
1966+
goto err_unset_master;
1967+
19631968
printk(KERN_INFO DRV_NAME
19641969
": %s: enslaving %s as a%s interface with a%s link.\n",
19651970
bond_dev->name, slave_dev->name,
@@ -2133,6 +2138,9 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev)
21332138

21342139
write_unlock_bh(&bond->lock);
21352140

2141+
/* must do this from outside any spinlocks */
2142+
bond_destroy_slave_symlinks(bond_dev, slave_dev);
2143+
21362144
bond_del_vlans_from_slave(bond, slave_dev);
21372145

21382146
/* If the mode USES_PRIMARY, then we should only remove its
@@ -2224,6 +2232,7 @@ static int bond_release_all(struct net_device *bond_dev)
22242232
*/
22252233
write_unlock_bh(&bond->lock);
22262234

2235+
bond_destroy_slave_symlinks(bond_dev, slave_dev);
22272236
bond_del_vlans_from_slave(bond, slave_dev);
22282237

22292238
/* If the mode USES_PRIMARY, then we should only remove its
@@ -3518,7 +3527,10 @@ static int bond_event_changename(struct bonding *bond)
35183527
bond_remove_proc_entry(bond);
35193528
bond_create_proc_entry(bond);
35203529
#endif
3521-
3530+
down_write(&(bonding_rwsem));
3531+
bond_destroy_sysfs_entry(bond);
3532+
bond_create_sysfs_entry(bond);
3533+
up_write(&(bonding_rwsem));
35223534
return NOTIFY_DONE;
35233535
}
35243536

@@ -3995,6 +4007,7 @@ static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd
39954007
return -EPERM;
39964008
}
39974009

4010+
down_write(&(bonding_rwsem));
39984011
slave_dev = dev_get_by_name(ifr->ifr_slave);
39994012

40004013
dprintk("slave_dev=%p: \n", slave_dev);
@@ -4027,6 +4040,7 @@ static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd
40274040
dev_put(slave_dev);
40284041
}
40294042

4043+
up_write(&(bonding_rwsem));
40304044
return res;
40314045
}
40324046

@@ -4962,6 +4976,7 @@ int bond_create(char *name, struct bond_params *params, struct bonding **newbond
49624976
*newbond = bond_dev->priv;
49634977

49644978
rtnl_unlock(); /* allows sysfs registration of net device */
4979+
res = bond_create_sysfs_entry(bond_dev->priv);
49654980
goto done;
49664981
out_bond:
49674982
bond_deinit(bond_dev);
@@ -4996,13 +5011,18 @@ static int __init bonding_init(void)
49965011
goto err;
49975012
}
49985013

5014+
res = bond_create_sysfs();
5015+
if (res)
5016+
goto err;
5017+
49995018
register_netdevice_notifier(&bond_netdev_notifier);
50005019
register_inetaddr_notifier(&bond_inetaddr_notifier);
50015020

50025021
goto out;
50035022
err:
50045023
rtnl_lock();
50055024
bond_free_all();
5025+
bond_destroy_sysfs();
50065026
rtnl_unlock();
50075027
out:
50085028
return res;
@@ -5016,6 +5036,7 @@ static void __exit bonding_exit(void)
50165036

50175037
rtnl_lock();
50185038
bond_free_all();
5039+
bond_destroy_sysfs();
50195040
rtnl_unlock();
50205041
}
50215042

0 commit comments

Comments
 (0)