aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/bonding
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/bonding')
-rw-r--r--drivers/net/bonding/bond_3ad.c5
-rw-r--r--drivers/net/bonding/bond_3ad.h4
-rw-r--r--drivers/net/bonding/bond_main.c826
-rw-r--r--drivers/net/bonding/bond_sysfs.c463
-rw-r--r--drivers/net/bonding/bonding.h10
5 files changed, 615 insertions, 693 deletions
diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c
index faf094abef7f..d4b570886c6e 100644
--- a/drivers/net/bonding/bond_3ad.c
+++ b/drivers/net/bonding/bond_3ad.c
@@ -1850,9 +1850,10 @@ static u16 aggregator_identifier;
1850 * Can be called only after the mac address of the bond is set. 1850 * Can be called only after the mac address of the bond is set.
1851 */ 1851 */
1852void bond_3ad_initialize(struct bonding *bond, u16 tick_resolution, int lacp_fast) 1852void bond_3ad_initialize(struct bonding *bond, u16 tick_resolution, int lacp_fast)
1853{ 1853{
1854 // check that the bond is not initialized yet 1854 // check that the bond is not initialized yet
1855 if (MAC_ADDRESS_COMPARE(&(BOND_AD_INFO(bond).system.sys_mac_addr), &(bond->dev->dev_addr))) { 1855 if (MAC_ADDRESS_COMPARE(&(BOND_AD_INFO(bond).system.sys_mac_addr),
1856 bond->dev->dev_addr)) {
1856 1857
1857 aggregator_identifier = 0; 1858 aggregator_identifier = 0;
1858 1859
diff --git a/drivers/net/bonding/bond_3ad.h b/drivers/net/bonding/bond_3ad.h
index a306230381c8..2c46a154f2c6 100644
--- a/drivers/net/bonding/bond_3ad.h
+++ b/drivers/net/bonding/bond_3ad.h
@@ -26,10 +26,10 @@
26#include <asm/byteorder.h> 26#include <asm/byteorder.h>
27#include <linux/skbuff.h> 27#include <linux/skbuff.h>
28#include <linux/netdevice.h> 28#include <linux/netdevice.h>
29#include <linux/if_ether.h>
29 30
30// General definitions 31// General definitions
31#define BOND_ETH_P_LACPDU 0x8809 32#define PKT_TYPE_LACPDU cpu_to_be16(ETH_P_SLOW)
32#define PKT_TYPE_LACPDU cpu_to_be16(BOND_ETH_P_LACPDU)
33#define AD_TIMER_INTERVAL 100 /*msec*/ 33#define AD_TIMER_INTERVAL 100 /*msec*/
34 34
35#define MULTICAST_LACPDU_ADDR {0x01, 0x80, 0xC2, 0x00, 0x00, 0x02} 35#define MULTICAST_LACPDU_ADDR {0x01, 0x80, 0xC2, 0x00, 0x00, 0x02}
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 74824028f85c..d927f71af8a3 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -51,10 +51,10 @@
51#include <linux/ctype.h> 51#include <linux/ctype.h>
52#include <linux/inet.h> 52#include <linux/inet.h>
53#include <linux/bitops.h> 53#include <linux/bitops.h>
54#include <linux/io.h>
54#include <asm/system.h> 55#include <asm/system.h>
55#include <asm/io.h>
56#include <asm/dma.h> 56#include <asm/dma.h>
57#include <asm/uaccess.h> 57#include <linux/uaccess.h>
58#include <linux/errno.h> 58#include <linux/errno.h>
59#include <linux/netdevice.h> 59#include <linux/netdevice.h>
60#include <linux/inetdevice.h> 60#include <linux/inetdevice.h>
@@ -89,19 +89,19 @@ static int max_bonds = BOND_DEFAULT_MAX_BONDS;
89static int num_grat_arp = 1; 89static int num_grat_arp = 1;
90static int num_unsol_na = 1; 90static int num_unsol_na = 1;
91static int miimon = BOND_LINK_MON_INTERV; 91static int miimon = BOND_LINK_MON_INTERV;
92static int updelay = 0; 92static int updelay;
93static int downdelay = 0; 93static int downdelay;
94static int use_carrier = 1; 94static int use_carrier = 1;
95static char *mode = NULL; 95static char *mode;
96static char *primary = NULL; 96static char *primary;
97static char *lacp_rate = NULL; 97static char *lacp_rate;
98static char *ad_select = NULL; 98static char *ad_select;
99static char *xmit_hash_policy = NULL; 99static char *xmit_hash_policy;
100static int arp_interval = BOND_LINK_ARP_INTERV; 100static int arp_interval = BOND_LINK_ARP_INTERV;
101static char *arp_ip_target[BOND_MAX_ARP_TARGETS] = { NULL, }; 101static char *arp_ip_target[BOND_MAX_ARP_TARGETS];
102static char *arp_validate = NULL; 102static char *arp_validate;
103static char *fail_over_mac = NULL; 103static char *fail_over_mac;
104struct bond_params bonding_defaults; 104static struct bond_params bonding_defaults;
105 105
106module_param(max_bonds, int, 0); 106module_param(max_bonds, int, 0);
107MODULE_PARM_DESC(max_bonds, "Max number of bonded devices"); 107MODULE_PARM_DESC(max_bonds, "Max number of bonded devices");
@@ -151,14 +151,14 @@ static const char * const version =
151LIST_HEAD(bond_dev_list); 151LIST_HEAD(bond_dev_list);
152 152
153#ifdef CONFIG_PROC_FS 153#ifdef CONFIG_PROC_FS
154static struct proc_dir_entry *bond_proc_dir = NULL; 154static struct proc_dir_entry *bond_proc_dir;
155#endif 155#endif
156 156
157static __be32 arp_target[BOND_MAX_ARP_TARGETS] = { 0, } ; 157static __be32 arp_target[BOND_MAX_ARP_TARGETS];
158static int arp_ip_count = 0; 158static int arp_ip_count;
159static int bond_mode = BOND_MODE_ROUNDROBIN; 159static int bond_mode = BOND_MODE_ROUNDROBIN;
160static int xmit_hashtype= BOND_XMIT_POLICY_LAYER2; 160static int xmit_hashtype = BOND_XMIT_POLICY_LAYER2;
161static int lacp_fast = 0; 161static int lacp_fast;
162 162
163 163
164const struct bond_parm_tbl bond_lacp_tbl[] = { 164const struct bond_parm_tbl bond_lacp_tbl[] = {
@@ -210,6 +210,7 @@ struct bond_parm_tbl ad_select_tbl[] = {
210/*-------------------------- Forward declarations ---------------------------*/ 210/*-------------------------- Forward declarations ---------------------------*/
211 211
212static void bond_send_gratuitous_arp(struct bonding *bond); 212static void bond_send_gratuitous_arp(struct bonding *bond);
213static int bond_init(struct net_device *bond_dev);
213static void bond_deinit(struct net_device *bond_dev); 214static void bond_deinit(struct net_device *bond_dev);
214 215
215/*---------------------------- General routines -----------------------------*/ 216/*---------------------------- General routines -----------------------------*/
@@ -221,7 +222,7 @@ static const char *bond_mode_name(int mode)
221 [BOND_MODE_ACTIVEBACKUP] = "fault-tolerance (active-backup)", 222 [BOND_MODE_ACTIVEBACKUP] = "fault-tolerance (active-backup)",
222 [BOND_MODE_XOR] = "load balancing (xor)", 223 [BOND_MODE_XOR] = "load balancing (xor)",
223 [BOND_MODE_BROADCAST] = "fault-tolerance (broadcast)", 224 [BOND_MODE_BROADCAST] = "fault-tolerance (broadcast)",
224 [BOND_MODE_8023AD]= "IEEE 802.3ad Dynamic link aggregation", 225 [BOND_MODE_8023AD] = "IEEE 802.3ad Dynamic link aggregation",
225 [BOND_MODE_TLB] = "transmit load balancing", 226 [BOND_MODE_TLB] = "transmit load balancing",
226 [BOND_MODE_ALB] = "adaptive load balancing", 227 [BOND_MODE_ALB] = "adaptive load balancing",
227 }; 228 };
@@ -246,12 +247,11 @@ static int bond_add_vlan(struct bonding *bond, unsigned short vlan_id)
246 struct vlan_entry *vlan; 247 struct vlan_entry *vlan;
247 248
248 pr_debug("bond: %s, vlan id %d\n", 249 pr_debug("bond: %s, vlan id %d\n",
249 (bond ? bond->dev->name: "None"), vlan_id); 250 (bond ? bond->dev->name : "None"), vlan_id);
250 251
251 vlan = kzalloc(sizeof(struct vlan_entry), GFP_KERNEL); 252 vlan = kzalloc(sizeof(struct vlan_entry), GFP_KERNEL);
252 if (!vlan) { 253 if (!vlan)
253 return -ENOMEM; 254 return -ENOMEM;
254 }
255 255
256 INIT_LIST_HEAD(&vlan->vlan_list); 256 INIT_LIST_HEAD(&vlan->vlan_list);
257 vlan->vlan_id = vlan_id; 257 vlan->vlan_id = vlan_id;
@@ -351,16 +351,15 @@ static int bond_has_challenged_slaves(struct bonding *bond)
351 * 351 *
352 * Returns %NULL if list is empty, bond->next_vlan if @curr is %NULL, 352 * Returns %NULL if list is empty, bond->next_vlan if @curr is %NULL,
353 * or @curr->next otherwise (even if it is @curr itself again). 353 * or @curr->next otherwise (even if it is @curr itself again).
354 * 354 *
355 * Caller must hold bond->lock 355 * Caller must hold bond->lock
356 */ 356 */
357struct vlan_entry *bond_next_vlan(struct bonding *bond, struct vlan_entry *curr) 357struct vlan_entry *bond_next_vlan(struct bonding *bond, struct vlan_entry *curr)
358{ 358{
359 struct vlan_entry *next, *last; 359 struct vlan_entry *next, *last;
360 360
361 if (list_empty(&bond->vlan_list)) { 361 if (list_empty(&bond->vlan_list))
362 return NULL; 362 return NULL;
363 }
364 363
365 if (!curr) { 364 if (!curr) {
366 next = list_entry(bond->vlan_list.next, 365 next = list_entry(bond->vlan_list.next,
@@ -382,11 +381,11 @@ struct vlan_entry *bond_next_vlan(struct bonding *bond, struct vlan_entry *curr)
382 381
383/** 382/**
384 * bond_dev_queue_xmit - Prepare skb for xmit. 383 * bond_dev_queue_xmit - Prepare skb for xmit.
385 * 384 *
386 * @bond: bond device that got this skb for tx. 385 * @bond: bond device that got this skb for tx.
387 * @skb: hw accel VLAN tagged skb to transmit 386 * @skb: hw accel VLAN tagged skb to transmit
388 * @slave_dev: slave that is supposed to xmit this skbuff 387 * @slave_dev: slave that is supposed to xmit this skbuff
389 * 388 *
390 * When the bond gets an skb to transmit that is 389 * When the bond gets an skb to transmit that is
391 * already hardware accelerated VLAN tagged, and it 390 * already hardware accelerated VLAN tagged, and it
392 * needs to relay this skb to a slave that is not 391 * needs to relay this skb to a slave that is not
@@ -394,7 +393,8 @@ struct vlan_entry *bond_next_vlan(struct bonding *bond, struct vlan_entry *curr)
394 * i.e. strip the hwaccel tag and re-insert it as part 393 * i.e. strip the hwaccel tag and re-insert it as part
395 * of the payload. 394 * of the payload.
396 */ 395 */
397int bond_dev_queue_xmit(struct bonding *bond, struct sk_buff *skb, struct net_device *slave_dev) 396int bond_dev_queue_xmit(struct bonding *bond, struct sk_buff *skb,
397 struct net_device *slave_dev)
398{ 398{
399 unsigned short uninitialized_var(vlan_id); 399 unsigned short uninitialized_var(vlan_id);
400 400
@@ -428,7 +428,7 @@ int bond_dev_queue_xmit(struct bonding *bond, struct sk_buff *skb, struct net_de
428 * b. The operation is protected by the RTNL semaphore in the 8021q code, 428 * b. The operation is protected by the RTNL semaphore in the 8021q code,
429 * c. Holding a lock with BH disabled while directly calling a base driver 429 * c. Holding a lock with BH disabled while directly calling a base driver
430 * entry point is generally a BAD idea. 430 * entry point is generally a BAD idea.
431 * 431 *
432 * The design of synchronization/protection for this operation in the 8021q 432 * The design of synchronization/protection for this operation in the 8021q
433 * module is good for one or more VLAN devices over a single physical device 433 * module is good for one or more VLAN devices over a single physical device
434 * and cannot be extended for a teaming solution like bonding, so there is a 434 * and cannot be extended for a teaming solution like bonding, so there is a
@@ -443,7 +443,8 @@ int bond_dev_queue_xmit(struct bonding *bond, struct sk_buff *skb, struct net_de
443 * @bond_dev: bonding net device that got called 443 * @bond_dev: bonding net device that got called
444 * @grp: vlan group being registered 444 * @grp: vlan group being registered
445 */ 445 */
446static void bond_vlan_rx_register(struct net_device *bond_dev, struct vlan_group *grp) 446static void bond_vlan_rx_register(struct net_device *bond_dev,
447 struct vlan_group *grp)
447{ 448{
448 struct bonding *bond = netdev_priv(bond_dev); 449 struct bonding *bond = netdev_priv(bond_dev);
449 struct slave *slave; 450 struct slave *slave;
@@ -485,7 +486,7 @@ static void bond_vlan_rx_add_vid(struct net_device *bond_dev, uint16_t vid)
485 486
486 res = bond_add_vlan(bond, vid); 487 res = bond_add_vlan(bond, vid);
487 if (res) { 488 if (res) {
488 printk(KERN_ERR DRV_NAME 489 pr_err(DRV_NAME
489 ": %s: Error: Failed to add vlan id %d\n", 490 ": %s: Error: Failed to add vlan id %d\n",
490 bond_dev->name, vid); 491 bond_dev->name, vid);
491 } 492 }
@@ -520,7 +521,7 @@ static void bond_vlan_rx_kill_vid(struct net_device *bond_dev, uint16_t vid)
520 521
521 res = bond_del_vlan(bond, vid); 522 res = bond_del_vlan(bond, vid);
522 if (res) { 523 if (res) {
523 printk(KERN_ERR DRV_NAME 524 pr_err(DRV_NAME
524 ": %s: Error: Failed to remove vlan id %d\n", 525 ": %s: Error: Failed to remove vlan id %d\n",
525 bond_dev->name, vid); 526 bond_dev->name, vid);
526 } 527 }
@@ -551,7 +552,8 @@ out:
551 write_unlock_bh(&bond->lock); 552 write_unlock_bh(&bond->lock);
552} 553}
553 554
554static void bond_del_vlans_from_slave(struct bonding *bond, struct net_device *slave_dev) 555static void bond_del_vlans_from_slave(struct bonding *bond,
556 struct net_device *slave_dev)
555{ 557{
556 const struct net_device_ops *slave_ops = slave_dev->netdev_ops; 558 const struct net_device_ops *slave_ops = slave_dev->netdev_ops;
557 struct vlan_entry *vlan; 559 struct vlan_entry *vlan;
@@ -673,7 +675,7 @@ static int bond_update_speed_duplex(struct slave *slave)
673 * if <dev> supports MII link status reporting, check its link status. 675 * if <dev> supports MII link status reporting, check its link status.
674 * 676 *
675 * We either do MII/ETHTOOL ioctls, or check netif_carrier_ok(), 677 * We either do MII/ETHTOOL ioctls, or check netif_carrier_ok(),
676 * depening upon the setting of the use_carrier parameter. 678 * depending upon the setting of the use_carrier parameter.
677 * 679 *
678 * Return either BMSR_LSTATUS, meaning that the link is up (or we 680 * Return either BMSR_LSTATUS, meaning that the link is up (or we
679 * can't tell and just pretend it is), or 0, meaning that the link is 681 * can't tell and just pretend it is), or 0, meaning that the link is
@@ -685,16 +687,29 @@ static int bond_update_speed_duplex(struct slave *slave)
685 * It'd be nice if there was a good way to tell if a driver supports 687 * It'd be nice if there was a good way to tell if a driver supports
686 * netif_carrier, but there really isn't. 688 * netif_carrier, but there really isn't.
687 */ 689 */
688static int bond_check_dev_link(struct bonding *bond, struct net_device *slave_dev, int reporting) 690static int bond_check_dev_link(struct bonding *bond,
691 struct net_device *slave_dev, int reporting)
689{ 692{
690 const struct net_device_ops *slave_ops = slave_dev->netdev_ops; 693 const struct net_device_ops *slave_ops = slave_dev->netdev_ops;
691 static int (* ioctl)(struct net_device *, struct ifreq *, int); 694 static int (*ioctl)(struct net_device *, struct ifreq *, int);
692 struct ifreq ifr; 695 struct ifreq ifr;
693 struct mii_ioctl_data *mii; 696 struct mii_ioctl_data *mii;
694 697
695 if (bond->params.use_carrier) 698 if (bond->params.use_carrier)
696 return netif_carrier_ok(slave_dev) ? BMSR_LSTATUS : 0; 699 return netif_carrier_ok(slave_dev) ? BMSR_LSTATUS : 0;
697 700
701 /* Try to get link status using Ethtool first. */
702 if (slave_dev->ethtool_ops) {
703 if (slave_dev->ethtool_ops->get_link) {
704 u32 link;
705
706 link = slave_dev->ethtool_ops->get_link(slave_dev);
707
708 return link ? BMSR_LSTATUS : 0;
709 }
710 }
711
712 /* Ethtool can't be used, fallback to MII ioctls. */
698 ioctl = slave_ops->ndo_do_ioctl; 713 ioctl = slave_ops->ndo_do_ioctl;
699 if (ioctl) { 714 if (ioctl) {
700 /* TODO: set pointer to correct ioctl on a per team member */ 715 /* TODO: set pointer to correct ioctl on a per team member */
@@ -714,23 +729,8 @@ static int bond_check_dev_link(struct bonding *bond, struct net_device *slave_de
714 mii = if_mii(&ifr); 729 mii = if_mii(&ifr);
715 if (IOCTL(slave_dev, &ifr, SIOCGMIIPHY) == 0) { 730 if (IOCTL(slave_dev, &ifr, SIOCGMIIPHY) == 0) {
716 mii->reg_num = MII_BMSR; 731 mii->reg_num = MII_BMSR;
717 if (IOCTL(slave_dev, &ifr, SIOCGMIIREG) == 0) { 732 if (IOCTL(slave_dev, &ifr, SIOCGMIIREG) == 0)
718 return (mii->val_out & BMSR_LSTATUS); 733 return mii->val_out & BMSR_LSTATUS;
719 }
720 }
721 }
722
723 /*
724 * Some drivers cache ETHTOOL_GLINK for a period of time so we only
725 * attempt to get link status from it if the above MII ioctls fail.
726 */
727 if (slave_dev->ethtool_ops) {
728 if (slave_dev->ethtool_ops->get_link) {
729 u32 link;
730
731 link = slave_dev->ethtool_ops->get_link(slave_dev);
732
733 return link ? BMSR_LSTATUS : 0;
734 } 734 }
735 } 735 }
736 736
@@ -740,7 +740,7 @@ static int bond_check_dev_link(struct bonding *bond, struct net_device *slave_de
740 * cannot report link status). If not reporting, pretend 740 * cannot report link status). If not reporting, pretend
741 * we're ok. 741 * we're ok.
742 */ 742 */
743 return (reporting ? -1 : BMSR_LSTATUS); 743 return reporting ? -1 : BMSR_LSTATUS;
744} 744}
745 745
746/*----------------------------- Multicast list ------------------------------*/ 746/*----------------------------- Multicast list ------------------------------*/
@@ -748,7 +748,8 @@ static int bond_check_dev_link(struct bonding *bond, struct net_device *slave_de
748/* 748/*
749 * Returns 0 if dmi1 and dmi2 are the same, non-0 otherwise 749 * Returns 0 if dmi1 and dmi2 are the same, non-0 otherwise
750 */ 750 */
751static inline int bond_is_dmi_same(struct dev_mc_list *dmi1, struct dev_mc_list *dmi2) 751static inline int bond_is_dmi_same(const struct dev_mc_list *dmi1,
752 const struct dev_mc_list *dmi2)
752{ 753{
753 return memcmp(dmi1->dmi_addr, dmi2->dmi_addr, dmi1->dmi_addrlen) == 0 && 754 return memcmp(dmi1->dmi_addr, dmi2->dmi_addr, dmi1->dmi_addrlen) == 0 &&
754 dmi1->dmi_addrlen == dmi2->dmi_addrlen; 755 dmi1->dmi_addrlen == dmi2->dmi_addrlen;
@@ -757,14 +758,14 @@ static inline int bond_is_dmi_same(struct dev_mc_list *dmi1, struct dev_mc_list
757/* 758/*
758 * returns dmi entry if found, NULL otherwise 759 * returns dmi entry if found, NULL otherwise
759 */ 760 */
760static struct dev_mc_list *bond_mc_list_find_dmi(struct dev_mc_list *dmi, struct dev_mc_list *mc_list) 761static struct dev_mc_list *bond_mc_list_find_dmi(struct dev_mc_list *dmi,
762 struct dev_mc_list *mc_list)
761{ 763{
762 struct dev_mc_list *idmi; 764 struct dev_mc_list *idmi;
763 765
764 for (idmi = mc_list; idmi; idmi = idmi->next) { 766 for (idmi = mc_list; idmi; idmi = idmi->next) {
765 if (bond_is_dmi_same(dmi, idmi)) { 767 if (bond_is_dmi_same(dmi, idmi))
766 return idmi; 768 return idmi;
767 }
768 } 769 }
769 770
770 return NULL; 771 return NULL;
@@ -826,15 +827,14 @@ static void bond_mc_add(struct bonding *bond, void *addr, int alen)
826{ 827{
827 if (USES_PRIMARY(bond->params.mode)) { 828 if (USES_PRIMARY(bond->params.mode)) {
828 /* write lock already acquired */ 829 /* write lock already acquired */
829 if (bond->curr_active_slave) { 830 if (bond->curr_active_slave)
830 dev_mc_add(bond->curr_active_slave->dev, addr, alen, 0); 831 dev_mc_add(bond->curr_active_slave->dev, addr, alen, 0);
831 }
832 } else { 832 } else {
833 struct slave *slave; 833 struct slave *slave;
834 int i; 834 int i;
835 bond_for_each_slave(bond, slave, i) { 835
836 bond_for_each_slave(bond, slave, i)
836 dev_mc_add(slave->dev, addr, alen, 0); 837 dev_mc_add(slave->dev, addr, alen, 0);
837 }
838 } 838 }
839} 839}
840 840
@@ -846,9 +846,9 @@ static void bond_mc_delete(struct bonding *bond, void *addr, int alen)
846{ 846{
847 if (USES_PRIMARY(bond->params.mode)) { 847 if (USES_PRIMARY(bond->params.mode)) {
848 /* write lock already acquired */ 848 /* write lock already acquired */
849 if (bond->curr_active_slave) { 849 if (bond->curr_active_slave)
850 dev_mc_delete(bond->curr_active_slave->dev, addr, alen, 0); 850 dev_mc_delete(bond->curr_active_slave->dev, addr,
851 } 851 alen, 0);
852 } else { 852 } else {
853 struct slave *slave; 853 struct slave *slave;
854 int i; 854 int i;
@@ -872,9 +872,8 @@ static void bond_resend_igmp_join_requests(struct bonding *bond)
872 rcu_read_lock(); 872 rcu_read_lock();
873 in_dev = __in_dev_get_rcu(bond->dev); 873 in_dev = __in_dev_get_rcu(bond->dev);
874 if (in_dev) { 874 if (in_dev) {
875 for (im = in_dev->mc_list; im; im = im->next) { 875 for (im = in_dev->mc_list; im; im = im->next)
876 ip_mc_rejoin_group(im); 876 ip_mc_rejoin_group(im);
877 }
878 } 877 }
879 878
880 rcu_read_unlock(); 879 rcu_read_unlock();
@@ -893,7 +892,8 @@ static void bond_mc_list_destroy(struct bonding *bond)
893 kfree(dmi); 892 kfree(dmi);
894 dmi = bond->mc_list; 893 dmi = bond->mc_list;
895 } 894 }
896 bond->mc_list = NULL; 895
896 bond->mc_list = NULL;
897} 897}
898 898
899/* 899/*
@@ -926,14 +926,14 @@ static int bond_mc_list_copy(struct dev_mc_list *mc_list, struct bonding *bond,
926/* 926/*
927 * flush all members of flush->mc_list from device dev->mc_list 927 * flush all members of flush->mc_list from device dev->mc_list
928 */ 928 */
929static void bond_mc_list_flush(struct net_device *bond_dev, struct net_device *slave_dev) 929static void bond_mc_list_flush(struct net_device *bond_dev,
930 struct net_device *slave_dev)
930{ 931{
931 struct bonding *bond = netdev_priv(bond_dev); 932 struct bonding *bond = netdev_priv(bond_dev);
932 struct dev_mc_list *dmi; 933 struct dev_mc_list *dmi;
933 934
934 for (dmi = bond_dev->mc_list; dmi; dmi = dmi->next) { 935 for (dmi = bond_dev->mc_list; dmi; dmi = dmi->next)
935 dev_mc_delete(slave_dev, dmi->dmi_addr, dmi->dmi_addrlen, 0); 936 dev_mc_delete(slave_dev, dmi->dmi_addr, dmi->dmi_addrlen, 0);
936 }
937 937
938 if (bond->params.mode == BOND_MODE_8023AD) { 938 if (bond->params.mode == BOND_MODE_8023AD) {
939 /* del lacpdu mc addr from mc list */ 939 /* del lacpdu mc addr from mc list */
@@ -950,44 +950,40 @@ static void bond_mc_list_flush(struct net_device *bond_dev, struct net_device *s
950 * old active slaves (if any) according to the multicast mode, and 950 * old active slaves (if any) according to the multicast mode, and
951 * promiscuous flags unconditionally. 951 * promiscuous flags unconditionally.
952 */ 952 */
953static void bond_mc_swap(struct bonding *bond, struct slave *new_active, struct slave *old_active) 953static void bond_mc_swap(struct bonding *bond, struct slave *new_active,
954 struct slave *old_active)
954{ 955{
955 struct dev_mc_list *dmi; 956 struct dev_mc_list *dmi;
956 957
957 if (!USES_PRIMARY(bond->params.mode)) { 958 if (!USES_PRIMARY(bond->params.mode))
958 /* nothing to do - mc list is already up-to-date on 959 /* nothing to do - mc list is already up-to-date on
959 * all slaves 960 * all slaves
960 */ 961 */
961 return; 962 return;
962 }
963 963
964 if (old_active) { 964 if (old_active) {
965 if (bond->dev->flags & IFF_PROMISC) { 965 if (bond->dev->flags & IFF_PROMISC)
966 dev_set_promiscuity(old_active->dev, -1); 966 dev_set_promiscuity(old_active->dev, -1);
967 }
968 967
969 if (bond->dev->flags & IFF_ALLMULTI) { 968 if (bond->dev->flags & IFF_ALLMULTI)
970 dev_set_allmulti(old_active->dev, -1); 969 dev_set_allmulti(old_active->dev, -1);
971 }
972 970
973 for (dmi = bond->dev->mc_list; dmi; dmi = dmi->next) { 971 for (dmi = bond->dev->mc_list; dmi; dmi = dmi->next)
974 dev_mc_delete(old_active->dev, dmi->dmi_addr, dmi->dmi_addrlen, 0); 972 dev_mc_delete(old_active->dev, dmi->dmi_addr,
975 } 973 dmi->dmi_addrlen, 0);
976 } 974 }
977 975
978 if (new_active) { 976 if (new_active) {
979 /* FIXME: Signal errors upstream. */ 977 /* FIXME: Signal errors upstream. */
980 if (bond->dev->flags & IFF_PROMISC) { 978 if (bond->dev->flags & IFF_PROMISC)
981 dev_set_promiscuity(new_active->dev, 1); 979 dev_set_promiscuity(new_active->dev, 1);
982 }
983 980
984 if (bond->dev->flags & IFF_ALLMULTI) { 981 if (bond->dev->flags & IFF_ALLMULTI)
985 dev_set_allmulti(new_active->dev, 1); 982 dev_set_allmulti(new_active->dev, 1);
986 }
987 983
988 for (dmi = bond->dev->mc_list; dmi; dmi = dmi->next) { 984 for (dmi = bond->dev->mc_list; dmi; dmi = dmi->next)
989 dev_mc_add(new_active->dev, dmi->dmi_addr, dmi->dmi_addrlen, 0); 985 dev_mc_add(new_active->dev, dmi->dmi_addr,
990 } 986 dmi->dmi_addrlen, 0);
991 bond_resend_igmp_join_requests(bond); 987 bond_resend_igmp_join_requests(bond);
992 } 988 }
993} 989}
@@ -1041,7 +1037,7 @@ static void bond_do_fail_over_mac(struct bonding *bond,
1041 1037
1042 rv = dev_set_mac_address(new_active->dev, &saddr); 1038 rv = dev_set_mac_address(new_active->dev, &saddr);
1043 if (rv) { 1039 if (rv) {
1044 printk(KERN_ERR DRV_NAME 1040 pr_err(DRV_NAME
1045 ": %s: Error %d setting MAC of slave %s\n", 1041 ": %s: Error %d setting MAC of slave %s\n",
1046 bond->dev->name, -rv, new_active->dev->name); 1042 bond->dev->name, -rv, new_active->dev->name);
1047 goto out; 1043 goto out;
@@ -1055,7 +1051,7 @@ static void bond_do_fail_over_mac(struct bonding *bond,
1055 1051
1056 rv = dev_set_mac_address(old_active->dev, &saddr); 1052 rv = dev_set_mac_address(old_active->dev, &saddr);
1057 if (rv) 1053 if (rv)
1058 printk(KERN_ERR DRV_NAME 1054 pr_err(DRV_NAME
1059 ": %s: Error %d setting MAC of slave %s\n", 1055 ": %s: Error %d setting MAC of slave %s\n",
1060 bond->dev->name, -rv, new_active->dev->name); 1056 bond->dev->name, -rv, new_active->dev->name);
1061out: 1057out:
@@ -1063,7 +1059,7 @@ out:
1063 write_lock_bh(&bond->curr_slave_lock); 1059 write_lock_bh(&bond->curr_slave_lock);
1064 break; 1060 break;
1065 default: 1061 default:
1066 printk(KERN_ERR DRV_NAME 1062 pr_err(DRV_NAME
1067 ": %s: bond_do_fail_over_mac impossible: bad policy %d\n", 1063 ": %s: bond_do_fail_over_mac impossible: bad policy %d\n",
1068 bond->dev->name, bond->params.fail_over_mac); 1064 bond->dev->name, bond->params.fail_over_mac);
1069 break; 1065 break;
@@ -1088,17 +1084,17 @@ static struct slave *bond_find_best_slave(struct bonding *bond)
1088 new_active = old_active = bond->curr_active_slave; 1084 new_active = old_active = bond->curr_active_slave;
1089 1085
1090 if (!new_active) { /* there were no active slaves left */ 1086 if (!new_active) { /* there were no active slaves left */
1091 if (bond->slave_cnt > 0) { /* found one slave */ 1087 if (bond->slave_cnt > 0) /* found one slave */
1092 new_active = bond->first_slave; 1088 new_active = bond->first_slave;
1093 } else { 1089 else
1094 return NULL; /* still no slave, return NULL */ 1090 return NULL; /* still no slave, return NULL */
1095 }
1096 } 1091 }
1097 1092
1098 /* first try the primary link; if arping, a link must tx/rx traffic 1093 /*
1099 * before it can be considered the curr_active_slave - also, we would skip 1094 * first try the primary link; if arping, a link must tx/rx
1100 * slaves between the curr_active_slave and primary_slave that may be up 1095 * traffic before it can be considered the curr_active_slave.
1101 * and able to arp 1096 * also, we would skip slaves between the curr_active_slave
1097 * and primary_slave that may be up and able to arp
1102 */ 1098 */
1103 if ((bond->primary_slave) && 1099 if ((bond->primary_slave) &&
1104 (!bond->params.arp_interval) && 1100 (!bond->params.arp_interval) &&
@@ -1146,16 +1142,15 @@ void bond_change_active_slave(struct bonding *bond, struct slave *new_active)
1146{ 1142{
1147 struct slave *old_active = bond->curr_active_slave; 1143 struct slave *old_active = bond->curr_active_slave;
1148 1144
1149 if (old_active == new_active) { 1145 if (old_active == new_active)
1150 return; 1146 return;
1151 }
1152 1147
1153 if (new_active) { 1148 if (new_active) {
1154 new_active->jiffies = jiffies; 1149 new_active->jiffies = jiffies;
1155 1150
1156 if (new_active->link == BOND_LINK_BACK) { 1151 if (new_active->link == BOND_LINK_BACK) {
1157 if (USES_PRIMARY(bond->params.mode)) { 1152 if (USES_PRIMARY(bond->params.mode)) {
1158 printk(KERN_INFO DRV_NAME 1153 pr_info(DRV_NAME
1159 ": %s: making interface %s the new " 1154 ": %s: making interface %s the new "
1160 "active one %d ms earlier.\n", 1155 "active one %d ms earlier.\n",
1161 bond->dev->name, new_active->dev->name, 1156 bond->dev->name, new_active->dev->name,
@@ -1165,15 +1160,14 @@ void bond_change_active_slave(struct bonding *bond, struct slave *new_active)
1165 new_active->delay = 0; 1160 new_active->delay = 0;
1166 new_active->link = BOND_LINK_UP; 1161 new_active->link = BOND_LINK_UP;
1167 1162
1168 if (bond->params.mode == BOND_MODE_8023AD) { 1163 if (bond->params.mode == BOND_MODE_8023AD)
1169 bond_3ad_handle_link_change(new_active, BOND_LINK_UP); 1164 bond_3ad_handle_link_change(new_active, BOND_LINK_UP);
1170 }
1171 1165
1172 if (bond_is_lb(bond)) 1166 if (bond_is_lb(bond))
1173 bond_alb_handle_link_change(bond, new_active, BOND_LINK_UP); 1167 bond_alb_handle_link_change(bond, new_active, BOND_LINK_UP);
1174 } else { 1168 } else {
1175 if (USES_PRIMARY(bond->params.mode)) { 1169 if (USES_PRIMARY(bond->params.mode)) {
1176 printk(KERN_INFO DRV_NAME 1170 pr_info(DRV_NAME
1177 ": %s: making interface %s the new " 1171 ": %s: making interface %s the new "
1178 "active one.\n", 1172 "active one.\n",
1179 bond->dev->name, new_active->dev->name); 1173 bond->dev->name, new_active->dev->name);
@@ -1181,9 +1175,8 @@ void bond_change_active_slave(struct bonding *bond, struct slave *new_active)
1181 } 1175 }
1182 } 1176 }
1183 1177
1184 if (USES_PRIMARY(bond->params.mode)) { 1178 if (USES_PRIMARY(bond->params.mode))
1185 bond_mc_swap(bond, new_active, old_active); 1179 bond_mc_swap(bond, new_active, old_active);
1186 }
1187 1180
1188 if (bond_is_lb(bond)) { 1181 if (bond_is_lb(bond)) {
1189 bond_alb_handle_active_change(bond, new_active); 1182 bond_alb_handle_active_change(bond, new_active);
@@ -1196,9 +1189,8 @@ void bond_change_active_slave(struct bonding *bond, struct slave *new_active)
1196 } 1189 }
1197 1190
1198 if (bond->params.mode == BOND_MODE_ACTIVEBACKUP) { 1191 if (bond->params.mode == BOND_MODE_ACTIVEBACKUP) {
1199 if (old_active) { 1192 if (old_active)
1200 bond_set_slave_inactive_flags(old_active); 1193 bond_set_slave_inactive_flags(old_active);
1201 }
1202 1194
1203 if (new_active) { 1195 if (new_active) {
1204 bond_set_slave_active_flags(new_active); 1196 bond_set_slave_active_flags(new_active);
@@ -1228,7 +1220,7 @@ void bond_change_active_slave(struct bonding *bond, struct slave *new_active)
1228 * bond_select_active_slave - select a new active slave, if needed 1220 * bond_select_active_slave - select a new active slave, if needed
1229 * @bond: our bonding struct 1221 * @bond: our bonding struct
1230 * 1222 *
1231 * This functions shoud be called when one of the following occurs: 1223 * This functions should be called when one of the following occurs:
1232 * - The old curr_active_slave has been released or lost its link. 1224 * - The old curr_active_slave has been released or lost its link.
1233 * - The primary_slave has got its link back. 1225 * - The primary_slave has got its link back.
1234 * - A slave has got its link back and there's no old curr_active_slave. 1226 * - A slave has got its link back and there's no old curr_active_slave.
@@ -1248,11 +1240,11 @@ void bond_select_active_slave(struct bonding *bond)
1248 return; 1240 return;
1249 1241
1250 if (netif_carrier_ok(bond->dev)) { 1242 if (netif_carrier_ok(bond->dev)) {
1251 printk(KERN_INFO DRV_NAME 1243 pr_info(DRV_NAME
1252 ": %s: first active interface up!\n", 1244 ": %s: first active interface up!\n",
1253 bond->dev->name); 1245 bond->dev->name);
1254 } else { 1246 } else {
1255 printk(KERN_INFO DRV_NAME ": %s: " 1247 pr_info(DRV_NAME ": %s: "
1256 "now running without any active interface !\n", 1248 "now running without any active interface !\n",
1257 bond->dev->name); 1249 bond->dev->name);
1258 } 1250 }
@@ -1294,13 +1286,11 @@ static void bond_attach_slave(struct bonding *bond, struct slave *new_slave)
1294 */ 1286 */
1295static void bond_detach_slave(struct bonding *bond, struct slave *slave) 1287static void bond_detach_slave(struct bonding *bond, struct slave *slave)
1296{ 1288{
1297 if (slave->next) { 1289 if (slave->next)
1298 slave->next->prev = slave->prev; 1290 slave->next->prev = slave->prev;
1299 }
1300 1291
1301 if (slave->prev) { 1292 if (slave->prev)
1302 slave->prev->next = slave->next; 1293 slave->prev->next = slave->next;
1303 }
1304 1294
1305 if (bond->first_slave == slave) { /* slave is the first slave */ 1295 if (bond->first_slave == slave) { /* slave is the first slave */
1306 if (bond->slave_cnt > 1) { /* there are more slave */ 1296 if (bond->slave_cnt > 1) { /* there are more slave */
@@ -1331,7 +1321,7 @@ static int bond_sethwaddr(struct net_device *bond_dev,
1331 (NETIF_F_VLAN_CHALLENGED | NETIF_F_HW_VLAN_RX | NETIF_F_HW_VLAN_TX | \ 1321 (NETIF_F_VLAN_CHALLENGED | NETIF_F_HW_VLAN_RX | NETIF_F_HW_VLAN_TX | \
1332 NETIF_F_HW_VLAN_FILTER) 1322 NETIF_F_HW_VLAN_FILTER)
1333 1323
1334/* 1324/*
1335 * Compute the common dev->feature set available to all slaves. Some 1325 * Compute the common dev->feature set available to all slaves. Some
1336 * feature bits are managed elsewhere, so preserve those feature bits 1326 * feature bits are managed elsewhere, so preserve those feature bits
1337 * on the master device. 1327 * on the master device.
@@ -1399,14 +1389,14 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1399 1389
1400 if (!bond->params.use_carrier && slave_dev->ethtool_ops == NULL && 1390 if (!bond->params.use_carrier && slave_dev->ethtool_ops == NULL &&
1401 slave_ops->ndo_do_ioctl == NULL) { 1391 slave_ops->ndo_do_ioctl == NULL) {
1402 printk(KERN_WARNING DRV_NAME 1392 pr_warning(DRV_NAME
1403 ": %s: Warning: no link monitoring support for %s\n", 1393 ": %s: Warning: no link monitoring support for %s\n",
1404 bond_dev->name, slave_dev->name); 1394 bond_dev->name, slave_dev->name);
1405 } 1395 }
1406 1396
1407 /* bond must be initialized by bond_open() before enslaving */ 1397 /* bond must be initialized by bond_open() before enslaving */
1408 if (!(bond_dev->flags & IFF_UP)) { 1398 if (!(bond_dev->flags & IFF_UP)) {
1409 printk(KERN_WARNING DRV_NAME 1399 pr_warning(DRV_NAME
1410 " %s: master_dev is not up in bond_enslave\n", 1400 " %s: master_dev is not up in bond_enslave\n",
1411 bond_dev->name); 1401 bond_dev->name);
1412 } 1402 }
@@ -1422,14 +1412,14 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1422 if (slave_dev->features & NETIF_F_VLAN_CHALLENGED) { 1412 if (slave_dev->features & NETIF_F_VLAN_CHALLENGED) {
1423 pr_debug("%s: NETIF_F_VLAN_CHALLENGED\n", slave_dev->name); 1413 pr_debug("%s: NETIF_F_VLAN_CHALLENGED\n", slave_dev->name);
1424 if (!list_empty(&bond->vlan_list)) { 1414 if (!list_empty(&bond->vlan_list)) {
1425 printk(KERN_ERR DRV_NAME 1415 pr_err(DRV_NAME
1426 ": %s: Error: cannot enslave VLAN " 1416 ": %s: Error: cannot enslave VLAN "
1427 "challenged slave %s on VLAN enabled " 1417 "challenged slave %s on VLAN enabled "
1428 "bond %s\n", bond_dev->name, slave_dev->name, 1418 "bond %s\n", bond_dev->name, slave_dev->name,
1429 bond_dev->name); 1419 bond_dev->name);
1430 return -EPERM; 1420 return -EPERM;
1431 } else { 1421 } else {
1432 printk(KERN_WARNING DRV_NAME 1422 pr_warning(DRV_NAME
1433 ": %s: Warning: enslaved VLAN challenged " 1423 ": %s: Warning: enslaved VLAN challenged "
1434 "slave %s. Adding VLANs will be blocked as " 1424 "slave %s. Adding VLANs will be blocked as "
1435 "long as %s is part of bond %s\n", 1425 "long as %s is part of bond %s\n",
@@ -1449,12 +1439,12 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1449 1439
1450 /* 1440 /*
1451 * Old ifenslave binaries are no longer supported. These can 1441 * Old ifenslave binaries are no longer supported. These can
1452 * be identified with moderate accurary by the state of the slave: 1442 * be identified with moderate accuracy by the state of the slave:
1453 * the current ifenslave will set the interface down prior to 1443 * the current ifenslave will set the interface down prior to
1454 * enslaving it; the old ifenslave will not. 1444 * enslaving it; the old ifenslave will not.
1455 */ 1445 */
1456 if ((slave_dev->flags & IFF_UP)) { 1446 if ((slave_dev->flags & IFF_UP)) {
1457 printk(KERN_ERR DRV_NAME ": %s is up. " 1447 pr_err(DRV_NAME ": %s is up. "
1458 "This may be due to an out of date ifenslave.\n", 1448 "This may be due to an out of date ifenslave.\n",
1459 slave_dev->name); 1449 slave_dev->name);
1460 res = -EPERM; 1450 res = -EPERM;
@@ -1472,7 +1462,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1472 if (slave_dev->type != ARPHRD_ETHER) 1462 if (slave_dev->type != ARPHRD_ETHER)
1473 bond_setup_by_slave(bond_dev, slave_dev); 1463 bond_setup_by_slave(bond_dev, slave_dev);
1474 } else if (bond_dev->type != slave_dev->type) { 1464 } else if (bond_dev->type != slave_dev->type) {
1475 printk(KERN_ERR DRV_NAME ": %s ether type (%d) is different " 1465 pr_err(DRV_NAME ": %s ether type (%d) is different "
1476 "from other slaves (%d), can not enslave it.\n", 1466 "from other slaves (%d), can not enslave it.\n",
1477 slave_dev->name, 1467 slave_dev->name,
1478 slave_dev->type, bond_dev->type); 1468 slave_dev->type, bond_dev->type);
@@ -1482,14 +1472,14 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1482 1472
1483 if (slave_ops->ndo_set_mac_address == NULL) { 1473 if (slave_ops->ndo_set_mac_address == NULL) {
1484 if (bond->slave_cnt == 0) { 1474 if (bond->slave_cnt == 0) {
1485 printk(KERN_WARNING DRV_NAME 1475 pr_warning(DRV_NAME
1486 ": %s: Warning: The first slave device " 1476 ": %s: Warning: The first slave device "
1487 "specified does not support setting the MAC " 1477 "specified does not support setting the MAC "
1488 "address. Setting fail_over_mac to active.", 1478 "address. Setting fail_over_mac to active.",
1489 bond_dev->name); 1479 bond_dev->name);
1490 bond->params.fail_over_mac = BOND_FOM_ACTIVE; 1480 bond->params.fail_over_mac = BOND_FOM_ACTIVE;
1491 } else if (bond->params.fail_over_mac != BOND_FOM_ACTIVE) { 1481 } else if (bond->params.fail_over_mac != BOND_FOM_ACTIVE) {
1492 printk(KERN_ERR DRV_NAME 1482 pr_err(DRV_NAME
1493 ": %s: Error: The slave device specified " 1483 ": %s: Error: The slave device specified "
1494 "does not support setting the MAC address, " 1484 "does not support setting the MAC address, "
1495 "but fail_over_mac is not set to active.\n" 1485 "but fail_over_mac is not set to active.\n"
@@ -1539,7 +1529,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1539 /* open the slave since the application closed it */ 1529 /* open the slave since the application closed it */
1540 res = dev_open(slave_dev); 1530 res = dev_open(slave_dev);
1541 if (res) { 1531 if (res) {
1542 pr_debug("Openning slave %s failed\n", slave_dev->name); 1532 pr_debug("Opening slave %s failed\n", slave_dev->name);
1543 goto err_unset_master; 1533 goto err_unset_master;
1544 } 1534 }
1545 1535
@@ -1551,9 +1541,8 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1551 * it might fail and we do not want to have to undo everything 1541 * it might fail and we do not want to have to undo everything
1552 */ 1542 */
1553 res = bond_alb_init_slave(bond, new_slave); 1543 res = bond_alb_init_slave(bond, new_slave);
1554 if (res) { 1544 if (res)
1555 goto err_close; 1545 goto err_close;
1556 }
1557 } 1546 }
1558 1547
1559 /* If the mode USES_PRIMARY, then the new slave gets the 1548 /* If the mode USES_PRIMARY, then the new slave gets the
@@ -1578,9 +1567,9 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1578 1567
1579 netif_addr_lock_bh(bond_dev); 1568 netif_addr_lock_bh(bond_dev);
1580 /* upload master's mc_list to new slave */ 1569 /* upload master's mc_list to new slave */
1581 for (dmi = bond_dev->mc_list; dmi; dmi = dmi->next) { 1570 for (dmi = bond_dev->mc_list; dmi; dmi = dmi->next)
1582 dev_mc_add (slave_dev, dmi->dmi_addr, dmi->dmi_addrlen, 0); 1571 dev_mc_add(slave_dev, dmi->dmi_addr,
1583 } 1572 dmi->dmi_addrlen, 0);
1584 netif_addr_unlock_bh(bond_dev); 1573 netif_addr_unlock_bh(bond_dev);
1585 } 1574 }
1586 1575
@@ -1621,7 +1610,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1621 * supported); thus, we don't need to change 1610 * supported); thus, we don't need to change
1622 * the messages for netif_carrier. 1611 * the messages for netif_carrier.
1623 */ 1612 */
1624 printk(KERN_WARNING DRV_NAME 1613 pr_warning(DRV_NAME
1625 ": %s: Warning: MII and ETHTOOL support not " 1614 ": %s: Warning: MII and ETHTOOL support not "
1626 "available for interface %s, and " 1615 "available for interface %s, and "
1627 "arp_interval/arp_ip_target module parameters " 1616 "arp_interval/arp_ip_target module parameters "
@@ -1630,7 +1619,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1630 bond_dev->name, slave_dev->name); 1619 bond_dev->name, slave_dev->name);
1631 } else if (link_reporting == -1) { 1620 } else if (link_reporting == -1) {
1632 /* unable get link status using mii/ethtool */ 1621 /* unable get link status using mii/ethtool */
1633 printk(KERN_WARNING DRV_NAME 1622 pr_warning(DRV_NAME
1634 ": %s: Warning: can't get link status from " 1623 ": %s: Warning: can't get link status from "
1635 "interface %s; the network driver associated " 1624 "interface %s; the network driver associated "
1636 "with this interface does not support MII or " 1625 "with this interface does not support MII or "
@@ -1662,13 +1651,13 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1662 1651
1663 if (bond_update_speed_duplex(new_slave) && 1652 if (bond_update_speed_duplex(new_slave) &&
1664 (new_slave->link != BOND_LINK_DOWN)) { 1653 (new_slave->link != BOND_LINK_DOWN)) {
1665 printk(KERN_WARNING DRV_NAME 1654 pr_warning(DRV_NAME
1666 ": %s: Warning: failed to get speed and duplex from %s, " 1655 ": %s: Warning: failed to get speed and duplex from %s, "
1667 "assumed to be 100Mb/sec and Full.\n", 1656 "assumed to be 100Mb/sec and Full.\n",
1668 bond_dev->name, new_slave->dev->name); 1657 bond_dev->name, new_slave->dev->name);
1669 1658
1670 if (bond->params.mode == BOND_MODE_8023AD) { 1659 if (bond->params.mode == BOND_MODE_8023AD) {
1671 printk(KERN_WARNING DRV_NAME 1660 pr_warning(DRV_NAME
1672 ": %s: Warning: Operation of 802.3ad mode requires ETHTOOL " 1661 ": %s: Warning: Operation of 802.3ad mode requires ETHTOOL "
1673 "support in base driver for proper aggregator " 1662 "support in base driver for proper aggregator "
1674 "selection.\n", bond_dev->name); 1663 "selection.\n", bond_dev->name);
@@ -1677,9 +1666,8 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1677 1666
1678 if (USES_PRIMARY(bond->params.mode) && bond->params.primary[0]) { 1667 if (USES_PRIMARY(bond->params.mode) && bond->params.primary[0]) {
1679 /* if there is a primary slave, remember it */ 1668 /* if there is a primary slave, remember it */
1680 if (strcmp(bond->params.primary, new_slave->dev->name) == 0) { 1669 if (strcmp(bond->params.primary, new_slave->dev->name) == 0)
1681 bond->primary_slave = new_slave; 1670 bond->primary_slave = new_slave;
1682 }
1683 } 1671 }
1684 1672
1685 write_lock_bh(&bond->curr_slave_lock); 1673 write_lock_bh(&bond->curr_slave_lock);
@@ -1726,9 +1714,9 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1726 * anyway (it holds no special properties of the bond device), 1714 * anyway (it holds no special properties of the bond device),
1727 * so we can change it without calling change_active_interface() 1715 * so we can change it without calling change_active_interface()
1728 */ 1716 */
1729 if (!bond->curr_active_slave) { 1717 if (!bond->curr_active_slave)
1730 bond->curr_active_slave = new_slave; 1718 bond->curr_active_slave = new_slave;
1731 } 1719
1732 break; 1720 break;
1733 } /* switch(bond_mode) */ 1721 } /* switch(bond_mode) */
1734 1722
@@ -1742,7 +1730,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1742 if (res) 1730 if (res)
1743 goto err_close; 1731 goto err_close;
1744 1732
1745 printk(KERN_INFO DRV_NAME 1733 pr_info(DRV_NAME
1746 ": %s: enslaving %s as a%s interface with a%s link.\n", 1734 ": %s: enslaving %s as a%s interface with a%s link.\n",
1747 bond_dev->name, slave_dev->name, 1735 bond_dev->name, slave_dev->name,
1748 new_slave->state == BOND_STATE_ACTIVE ? "n active" : " backup", 1736 new_slave->state == BOND_STATE_ACTIVE ? "n active" : " backup",
@@ -1774,7 +1762,7 @@ err_free:
1774 1762
1775err_undo_flags: 1763err_undo_flags:
1776 bond_dev->features = old_features; 1764 bond_dev->features = old_features;
1777 1765
1778 return res; 1766 return res;
1779} 1767}
1780 1768
@@ -1799,7 +1787,7 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev)
1799 /* slave is not a slave or master is not master of this slave */ 1787 /* slave is not a slave or master is not master of this slave */
1800 if (!(slave_dev->flags & IFF_SLAVE) || 1788 if (!(slave_dev->flags & IFF_SLAVE) ||
1801 (slave_dev->master != bond_dev)) { 1789 (slave_dev->master != bond_dev)) {
1802 printk(KERN_ERR DRV_NAME 1790 pr_err(DRV_NAME
1803 ": %s: Error: cannot release %s.\n", 1791 ": %s: Error: cannot release %s.\n",
1804 bond_dev->name, slave_dev->name); 1792 bond_dev->name, slave_dev->name);
1805 return -EINVAL; 1793 return -EINVAL;
@@ -1810,7 +1798,7 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev)
1810 slave = bond_get_slave_by_dev(bond, slave_dev); 1798 slave = bond_get_slave_by_dev(bond, slave_dev);
1811 if (!slave) { 1799 if (!slave) {
1812 /* not a slave of this bond */ 1800 /* not a slave of this bond */
1813 printk(KERN_INFO DRV_NAME 1801 pr_info(DRV_NAME
1814 ": %s: %s not enslaved\n", 1802 ": %s: %s not enslaved\n",
1815 bond_dev->name, slave_dev->name); 1803 bond_dev->name, slave_dev->name);
1816 write_unlock_bh(&bond->lock); 1804 write_unlock_bh(&bond->lock);
@@ -1821,7 +1809,7 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev)
1821 mac_addr_differ = memcmp(bond_dev->dev_addr, slave->perm_hwaddr, 1809 mac_addr_differ = memcmp(bond_dev->dev_addr, slave->perm_hwaddr,
1822 ETH_ALEN); 1810 ETH_ALEN);
1823 if (!mac_addr_differ && (bond->slave_cnt > 1)) 1811 if (!mac_addr_differ && (bond->slave_cnt > 1))
1824 printk(KERN_WARNING DRV_NAME 1812 pr_warning(DRV_NAME
1825 ": %s: Warning: the permanent HWaddr of %s - " 1813 ": %s: Warning: the permanent HWaddr of %s - "
1826 "%pM - is still in use by %s. " 1814 "%pM - is still in use by %s. "
1827 "Set the HWaddr of %s to a different address " 1815 "Set the HWaddr of %s to a different address "
@@ -1839,7 +1827,7 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev)
1839 bond_3ad_unbind_slave(slave); 1827 bond_3ad_unbind_slave(slave);
1840 } 1828 }
1841 1829
1842 printk(KERN_INFO DRV_NAME 1830 pr_info(DRV_NAME
1843 ": %s: releasing %s interface %s\n", 1831 ": %s: releasing %s interface %s\n",
1844 bond_dev->name, 1832 bond_dev->name,
1845 (slave->state == BOND_STATE_ACTIVE) 1833 (slave->state == BOND_STATE_ACTIVE)
@@ -1855,13 +1843,11 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev)
1855 1843
1856 bond_compute_features(bond); 1844 bond_compute_features(bond);
1857 1845
1858 if (bond->primary_slave == slave) { 1846 if (bond->primary_slave == slave)
1859 bond->primary_slave = NULL; 1847 bond->primary_slave = NULL;
1860 }
1861 1848
1862 if (oldcurrent == slave) { 1849 if (oldcurrent == slave)
1863 bond_change_active_slave(bond, NULL); 1850 bond_change_active_slave(bond, NULL);
1864 }
1865 1851
1866 if (bond_is_lb(bond)) { 1852 if (bond_is_lb(bond)) {
1867 /* Must be called only after the slave has been 1853 /* Must be called only after the slave has been
@@ -1903,18 +1889,18 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev)
1903 if (list_empty(&bond->vlan_list)) { 1889 if (list_empty(&bond->vlan_list)) {
1904 bond_dev->features |= NETIF_F_VLAN_CHALLENGED; 1890 bond_dev->features |= NETIF_F_VLAN_CHALLENGED;
1905 } else { 1891 } else {
1906 printk(KERN_WARNING DRV_NAME 1892 pr_warning(DRV_NAME
1907 ": %s: Warning: clearing HW address of %s while it " 1893 ": %s: Warning: clearing HW address of %s while it "
1908 "still has VLANs.\n", 1894 "still has VLANs.\n",
1909 bond_dev->name, bond_dev->name); 1895 bond_dev->name, bond_dev->name);
1910 printk(KERN_WARNING DRV_NAME 1896 pr_warning(DRV_NAME
1911 ": %s: When re-adding slaves, make sure the bond's " 1897 ": %s: When re-adding slaves, make sure the bond's "
1912 "HW address matches its VLANs'.\n", 1898 "HW address matches its VLANs'.\n",
1913 bond_dev->name); 1899 bond_dev->name);
1914 } 1900 }
1915 } else if ((bond_dev->features & NETIF_F_VLAN_CHALLENGED) && 1901 } else if ((bond_dev->features & NETIF_F_VLAN_CHALLENGED) &&
1916 !bond_has_challenged_slaves(bond)) { 1902 !bond_has_challenged_slaves(bond)) {
1917 printk(KERN_INFO DRV_NAME 1903 pr_info(DRV_NAME
1918 ": %s: last VLAN challenged slave %s " 1904 ": %s: last VLAN challenged slave %s "
1919 "left bond %s. VLAN blocking is removed\n", 1905 "left bond %s. VLAN blocking is removed\n",
1920 bond_dev->name, slave_dev->name, bond_dev->name); 1906 bond_dev->name, slave_dev->name, bond_dev->name);
@@ -1934,14 +1920,12 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev)
1934 */ 1920 */
1935 if (!USES_PRIMARY(bond->params.mode)) { 1921 if (!USES_PRIMARY(bond->params.mode)) {
1936 /* unset promiscuity level from slave */ 1922 /* unset promiscuity level from slave */
1937 if (bond_dev->flags & IFF_PROMISC) { 1923 if (bond_dev->flags & IFF_PROMISC)
1938 dev_set_promiscuity(slave_dev, -1); 1924 dev_set_promiscuity(slave_dev, -1);
1939 }
1940 1925
1941 /* unset allmulti level from slave */ 1926 /* unset allmulti level from slave */
1942 if (bond_dev->flags & IFF_ALLMULTI) { 1927 if (bond_dev->flags & IFF_ALLMULTI)
1943 dev_set_allmulti(slave_dev, -1); 1928 dev_set_allmulti(slave_dev, -1);
1944 }
1945 1929
1946 /* flush master's mc_list from slave */ 1930 /* flush master's mc_list from slave */
1947 netif_addr_lock_bh(bond_dev); 1931 netif_addr_lock_bh(bond_dev);
@@ -1974,41 +1958,36 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev)
1974* Destroy a bonding device. 1958* Destroy a bonding device.
1975* Must be under rtnl_lock when this function is called. 1959* Must be under rtnl_lock when this function is called.
1976*/ 1960*/
1977void bond_destroy(struct bonding *bond) 1961static void bond_uninit(struct net_device *bond_dev)
1978{
1979 bond_deinit(bond->dev);
1980 bond_destroy_sysfs_entry(bond);
1981 unregister_netdevice(bond->dev);
1982}
1983
1984static void bond_destructor(struct net_device *bond_dev)
1985{ 1962{
1986 struct bonding *bond = netdev_priv(bond_dev); 1963 struct bonding *bond = netdev_priv(bond_dev);
1987 1964
1965 bond_deinit(bond_dev);
1966 bond_destroy_sysfs_entry(bond);
1967
1988 if (bond->wq) 1968 if (bond->wq)
1989 destroy_workqueue(bond->wq); 1969 destroy_workqueue(bond->wq);
1990 1970
1991 netif_addr_lock_bh(bond_dev); 1971 netif_addr_lock_bh(bond_dev);
1992 bond_mc_list_destroy(bond); 1972 bond_mc_list_destroy(bond);
1993 netif_addr_unlock_bh(bond_dev); 1973 netif_addr_unlock_bh(bond_dev);
1994
1995 free_netdev(bond_dev);
1996} 1974}
1997 1975
1998/* 1976/*
1999* First release a slave and than destroy the bond if no more slaves iare left. 1977* First release a slave and than destroy the bond if no more slaves are left.
2000* Must be under rtnl_lock when this function is called. 1978* Must be under rtnl_lock when this function is called.
2001*/ 1979*/
2002int bond_release_and_destroy(struct net_device *bond_dev, struct net_device *slave_dev) 1980int bond_release_and_destroy(struct net_device *bond_dev,
1981 struct net_device *slave_dev)
2003{ 1982{
2004 struct bonding *bond = netdev_priv(bond_dev); 1983 struct bonding *bond = netdev_priv(bond_dev);
2005 int ret; 1984 int ret;
2006 1985
2007 ret = bond_release(bond_dev, slave_dev); 1986 ret = bond_release(bond_dev, slave_dev);
2008 if ((ret == 0) && (bond->slave_cnt == 0)) { 1987 if ((ret == 0) && (bond->slave_cnt == 0)) {
2009 printk(KERN_INFO DRV_NAME ": %s: destroying bond %s.\n", 1988 pr_info(DRV_NAME ": %s: destroying bond %s.\n",
2010 bond_dev->name, bond_dev->name); 1989 bond_dev->name, bond_dev->name);
2011 bond_destroy(bond); 1990 unregister_netdevice(bond_dev);
2012 } 1991 }
2013 return ret; 1992 return ret;
2014} 1993}
@@ -2027,9 +2006,8 @@ static int bond_release_all(struct net_device *bond_dev)
2027 2006
2028 netif_carrier_off(bond_dev); 2007 netif_carrier_off(bond_dev);
2029 2008
2030 if (bond->slave_cnt == 0) { 2009 if (bond->slave_cnt == 0)
2031 goto out; 2010 goto out;
2032 }
2033 2011
2034 bond->current_arp_slave = NULL; 2012 bond->current_arp_slave = NULL;
2035 bond->primary_slave = NULL; 2013 bond->primary_slave = NULL;
@@ -2039,9 +2017,8 @@ static int bond_release_all(struct net_device *bond_dev)
2039 /* Inform AD package of unbinding of slave 2017 /* Inform AD package of unbinding of slave
2040 * before slave is detached from the list. 2018 * before slave is detached from the list.
2041 */ 2019 */
2042 if (bond->params.mode == BOND_MODE_8023AD) { 2020 if (bond->params.mode == BOND_MODE_8023AD)
2043 bond_3ad_unbind_slave(slave); 2021 bond_3ad_unbind_slave(slave);
2044 }
2045 2022
2046 slave_dev = slave->dev; 2023 slave_dev = slave->dev;
2047 bond_detach_slave(bond, slave); 2024 bond_detach_slave(bond, slave);
@@ -2070,14 +2047,12 @@ static int bond_release_all(struct net_device *bond_dev)
2070 */ 2047 */
2071 if (!USES_PRIMARY(bond->params.mode)) { 2048 if (!USES_PRIMARY(bond->params.mode)) {
2072 /* unset promiscuity level from slave */ 2049 /* unset promiscuity level from slave */
2073 if (bond_dev->flags & IFF_PROMISC) { 2050 if (bond_dev->flags & IFF_PROMISC)
2074 dev_set_promiscuity(slave_dev, -1); 2051 dev_set_promiscuity(slave_dev, -1);
2075 }
2076 2052
2077 /* unset allmulti level from slave */ 2053 /* unset allmulti level from slave */
2078 if (bond_dev->flags & IFF_ALLMULTI) { 2054 if (bond_dev->flags & IFF_ALLMULTI)
2079 dev_set_allmulti(slave_dev, -1); 2055 dev_set_allmulti(slave_dev, -1);
2080 }
2081 2056
2082 /* flush master's mc_list from slave */ 2057 /* flush master's mc_list from slave */
2083 netif_addr_lock_bh(bond_dev); 2058 netif_addr_lock_bh(bond_dev);
@@ -2112,20 +2087,20 @@ static int bond_release_all(struct net_device *bond_dev)
2112 */ 2087 */
2113 memset(bond_dev->dev_addr, 0, bond_dev->addr_len); 2088 memset(bond_dev->dev_addr, 0, bond_dev->addr_len);
2114 2089
2115 if (list_empty(&bond->vlan_list)) { 2090 if (list_empty(&bond->vlan_list))
2116 bond_dev->features |= NETIF_F_VLAN_CHALLENGED; 2091 bond_dev->features |= NETIF_F_VLAN_CHALLENGED;
2117 } else { 2092 else {
2118 printk(KERN_WARNING DRV_NAME 2093 pr_warning(DRV_NAME
2119 ": %s: Warning: clearing HW address of %s while it " 2094 ": %s: Warning: clearing HW address of %s while it "
2120 "still has VLANs.\n", 2095 "still has VLANs.\n",
2121 bond_dev->name, bond_dev->name); 2096 bond_dev->name, bond_dev->name);
2122 printk(KERN_WARNING DRV_NAME 2097 pr_warning(DRV_NAME
2123 ": %s: When re-adding slaves, make sure the bond's " 2098 ": %s: When re-adding slaves, make sure the bond's "
2124 "HW address matches its VLANs'.\n", 2099 "HW address matches its VLANs'.\n",
2125 bond_dev->name); 2100 bond_dev->name);
2126 } 2101 }
2127 2102
2128 printk(KERN_INFO DRV_NAME 2103 pr_info(DRV_NAME
2129 ": %s: released all slaves\n", 2104 ": %s: released all slaves\n",
2130 bond_dev->name); 2105 bond_dev->name);
2131 2106
@@ -2143,8 +2118,8 @@ out:
2143 * - <slave_dev> is already active. 2118 * - <slave_dev> is already active.
2144 * - The link state of <slave_dev> is not BOND_LINK_UP. 2119 * - The link state of <slave_dev> is not BOND_LINK_UP.
2145 * - <slave_dev> is not running. 2120 * - <slave_dev> is not running.
2146 * In these cases, this fuction does nothing. 2121 * In these cases, this function does nothing.
2147 * In the other cases, currnt_slave pointer is changed and 0 is returned. 2122 * In the other cases, current_slave pointer is changed and 0 is returned.
2148 */ 2123 */
2149static int bond_ioctl_change_active(struct net_device *bond_dev, struct net_device *slave_dev) 2124static int bond_ioctl_change_active(struct net_device *bond_dev, struct net_device *slave_dev)
2150{ 2125{
@@ -2153,15 +2128,12 @@ static int bond_ioctl_change_active(struct net_device *bond_dev, struct net_devi
2153 struct slave *new_active = NULL; 2128 struct slave *new_active = NULL;
2154 int res = 0; 2129 int res = 0;
2155 2130
2156 if (!USES_PRIMARY(bond->params.mode)) { 2131 if (!USES_PRIMARY(bond->params.mode))
2157 return -EINVAL; 2132 return -EINVAL;
2158 }
2159 2133
2160 /* Verify that master_dev is indeed the master of slave_dev */ 2134 /* Verify that master_dev is indeed the master of slave_dev */
2161 if (!(slave_dev->flags & IFF_SLAVE) || 2135 if (!(slave_dev->flags & IFF_SLAVE) || (slave_dev->master != bond_dev))
2162 (slave_dev->master != bond_dev)) {
2163 return -EINVAL; 2136 return -EINVAL;
2164 }
2165 2137
2166 read_lock(&bond->lock); 2138 read_lock(&bond->lock);
2167 2139
@@ -2186,9 +2158,8 @@ static int bond_ioctl_change_active(struct net_device *bond_dev, struct net_devi
2186 write_lock_bh(&bond->curr_slave_lock); 2158 write_lock_bh(&bond->curr_slave_lock);
2187 bond_change_active_slave(bond, new_active); 2159 bond_change_active_slave(bond, new_active);
2188 write_unlock_bh(&bond->curr_slave_lock); 2160 write_unlock_bh(&bond->curr_slave_lock);
2189 } else { 2161 } else
2190 res = -EINVAL; 2162 res = -EINVAL;
2191 }
2192 2163
2193 read_unlock(&bond->lock); 2164 read_unlock(&bond->lock);
2194 2165
@@ -2240,6 +2211,9 @@ static int bond_miimon_inspect(struct bonding *bond)
2240{ 2211{
2241 struct slave *slave; 2212 struct slave *slave;
2242 int i, link_state, commit = 0; 2213 int i, link_state, commit = 0;
2214 bool ignore_updelay;
2215
2216 ignore_updelay = !bond->curr_active_slave ? true : false;
2243 2217
2244 bond_for_each_slave(bond, slave, i) { 2218 bond_for_each_slave(bond, slave, i) {
2245 slave->new_link = BOND_LINK_NOCHANGE; 2219 slave->new_link = BOND_LINK_NOCHANGE;
@@ -2254,7 +2228,7 @@ static int bond_miimon_inspect(struct bonding *bond)
2254 slave->link = BOND_LINK_FAIL; 2228 slave->link = BOND_LINK_FAIL;
2255 slave->delay = bond->params.downdelay; 2229 slave->delay = bond->params.downdelay;
2256 if (slave->delay) { 2230 if (slave->delay) {
2257 printk(KERN_INFO DRV_NAME 2231 pr_info(DRV_NAME
2258 ": %s: link status down for %s" 2232 ": %s: link status down for %s"
2259 "interface %s, disabling it in %d ms.\n", 2233 "interface %s, disabling it in %d ms.\n",
2260 bond->dev->name, 2234 bond->dev->name,
@@ -2273,7 +2247,7 @@ static int bond_miimon_inspect(struct bonding *bond)
2273 */ 2247 */
2274 slave->link = BOND_LINK_UP; 2248 slave->link = BOND_LINK_UP;
2275 slave->jiffies = jiffies; 2249 slave->jiffies = jiffies;
2276 printk(KERN_INFO DRV_NAME 2250 pr_info(DRV_NAME
2277 ": %s: link status up again after %d " 2251 ": %s: link status up again after %d "
2278 "ms for interface %s.\n", 2252 "ms for interface %s.\n",
2279 bond->dev->name, 2253 bond->dev->name,
@@ -2300,10 +2274,11 @@ static int bond_miimon_inspect(struct bonding *bond)
2300 slave->delay = bond->params.updelay; 2274 slave->delay = bond->params.updelay;
2301 2275
2302 if (slave->delay) { 2276 if (slave->delay) {
2303 printk(KERN_INFO DRV_NAME 2277 pr_info(DRV_NAME
2304 ": %s: link status up for " 2278 ": %s: link status up for "
2305 "interface %s, enabling it in %d ms.\n", 2279 "interface %s, enabling it in %d ms.\n",
2306 bond->dev->name, slave->dev->name, 2280 bond->dev->name, slave->dev->name,
2281 ignore_updelay ? 0 :
2307 bond->params.updelay * 2282 bond->params.updelay *
2308 bond->params.miimon); 2283 bond->params.miimon);
2309 } 2284 }
@@ -2311,7 +2286,7 @@ static int bond_miimon_inspect(struct bonding *bond)
2311 case BOND_LINK_BACK: 2286 case BOND_LINK_BACK:
2312 if (!link_state) { 2287 if (!link_state) {
2313 slave->link = BOND_LINK_DOWN; 2288 slave->link = BOND_LINK_DOWN;
2314 printk(KERN_INFO DRV_NAME 2289 pr_info(DRV_NAME
2315 ": %s: link status down again after %d " 2290 ": %s: link status down again after %d "
2316 "ms for interface %s.\n", 2291 "ms for interface %s.\n",
2317 bond->dev->name, 2292 bond->dev->name,
@@ -2322,9 +2297,13 @@ static int bond_miimon_inspect(struct bonding *bond)
2322 continue; 2297 continue;
2323 } 2298 }
2324 2299
2300 if (ignore_updelay)
2301 slave->delay = 0;
2302
2325 if (slave->delay <= 0) { 2303 if (slave->delay <= 0) {
2326 slave->new_link = BOND_LINK_UP; 2304 slave->new_link = BOND_LINK_UP;
2327 commit++; 2305 commit++;
2306 ignore_updelay = false;
2328 continue; 2307 continue;
2329 } 2308 }
2330 2309
@@ -2361,7 +2340,7 @@ static void bond_miimon_commit(struct bonding *bond)
2361 slave->state = BOND_STATE_BACKUP; 2340 slave->state = BOND_STATE_BACKUP;
2362 } 2341 }
2363 2342
2364 printk(KERN_INFO DRV_NAME 2343 pr_info(DRV_NAME
2365 ": %s: link status definitely " 2344 ": %s: link status definitely "
2366 "up for interface %s.\n", 2345 "up for interface %s.\n",
2367 bond->dev->name, slave->dev->name); 2346 bond->dev->name, slave->dev->name);
@@ -2390,7 +2369,7 @@ static void bond_miimon_commit(struct bonding *bond)
2390 bond->params.mode == BOND_MODE_8023AD) 2369 bond->params.mode == BOND_MODE_8023AD)
2391 bond_set_slave_inactive_flags(slave); 2370 bond_set_slave_inactive_flags(slave);
2392 2371
2393 printk(KERN_INFO DRV_NAME 2372 pr_info(DRV_NAME
2394 ": %s: link status definitely down for " 2373 ": %s: link status definitely down for "
2395 "interface %s, disabling it\n", 2374 "interface %s, disabling it\n",
2396 bond->dev->name, slave->dev->name); 2375 bond->dev->name, slave->dev->name);
@@ -2399,8 +2378,7 @@ static void bond_miimon_commit(struct bonding *bond)
2399 bond_3ad_handle_link_change(slave, 2378 bond_3ad_handle_link_change(slave,
2400 BOND_LINK_DOWN); 2379 BOND_LINK_DOWN);
2401 2380
2402 if (bond->params.mode == BOND_MODE_TLB || 2381 if (bond_is_lb(bond))
2403 bond->params.mode == BOND_MODE_ALB)
2404 bond_alb_handle_link_change(bond, slave, 2382 bond_alb_handle_link_change(bond, slave,
2405 BOND_LINK_DOWN); 2383 BOND_LINK_DOWN);
2406 2384
@@ -2410,7 +2388,7 @@ static void bond_miimon_commit(struct bonding *bond)
2410 continue; 2388 continue;
2411 2389
2412 default: 2390 default:
2413 printk(KERN_ERR DRV_NAME 2391 pr_err(DRV_NAME
2414 ": %s: invalid new link %d on slave %s\n", 2392 ": %s: invalid new link %d on slave %s\n",
2415 bond->dev->name, slave->new_link, 2393 bond->dev->name, slave->new_link,
2416 slave->dev->name); 2394 slave->dev->name);
@@ -2531,18 +2509,18 @@ static void bond_arp_send(struct net_device *slave_dev, int arp_op, __be32 dest_
2531 2509
2532 pr_debug("arp %d on slave %s: dst %x src %x vid %d\n", arp_op, 2510 pr_debug("arp %d on slave %s: dst %x src %x vid %d\n", arp_op,
2533 slave_dev->name, dest_ip, src_ip, vlan_id); 2511 slave_dev->name, dest_ip, src_ip, vlan_id);
2534 2512
2535 skb = arp_create(arp_op, ETH_P_ARP, dest_ip, slave_dev, src_ip, 2513 skb = arp_create(arp_op, ETH_P_ARP, dest_ip, slave_dev, src_ip,
2536 NULL, slave_dev->dev_addr, NULL); 2514 NULL, slave_dev->dev_addr, NULL);
2537 2515
2538 if (!skb) { 2516 if (!skb) {
2539 printk(KERN_ERR DRV_NAME ": ARP packet allocation failed\n"); 2517 pr_err(DRV_NAME ": ARP packet allocation failed\n");
2540 return; 2518 return;
2541 } 2519 }
2542 if (vlan_id) { 2520 if (vlan_id) {
2543 skb = vlan_put_tag(skb, vlan_id); 2521 skb = vlan_put_tag(skb, vlan_id);
2544 if (!skb) { 2522 if (!skb) {
2545 printk(KERN_ERR DRV_NAME ": failed to insert VLAN tag\n"); 2523 pr_err(DRV_NAME ": failed to insert VLAN tag\n");
2546 return; 2524 return;
2547 } 2525 }
2548 } 2526 }
@@ -2582,7 +2560,7 @@ static void bond_arp_send_all(struct bonding *bond, struct slave *slave)
2582 rv = ip_route_output_key(&init_net, &rt, &fl); 2560 rv = ip_route_output_key(&init_net, &rt, &fl);
2583 if (rv) { 2561 if (rv) {
2584 if (net_ratelimit()) { 2562 if (net_ratelimit()) {
2585 printk(KERN_WARNING DRV_NAME 2563 pr_warning(DRV_NAME
2586 ": %s: no route to arp_ip_target %pI4\n", 2564 ": %s: no route to arp_ip_target %pI4\n",
2587 bond->dev->name, &fl.fl4_dst); 2565 bond->dev->name, &fl.fl4_dst);
2588 } 2566 }
@@ -2619,7 +2597,7 @@ static void bond_arp_send_all(struct bonding *bond, struct slave *slave)
2619 } 2597 }
2620 2598
2621 if (net_ratelimit()) { 2599 if (net_ratelimit()) {
2622 printk(KERN_WARNING DRV_NAME 2600 pr_warning(DRV_NAME
2623 ": %s: no path to arp_ip_target %pI4 via rt.dev %s\n", 2601 ": %s: no path to arp_ip_target %pI4 via rt.dev %s\n",
2624 bond->dev->name, &fl.fl4_dst, 2602 bond->dev->name, &fl.fl4_dst,
2625 rt->u.dst.dev ? rt->u.dst.dev->name : "NULL"); 2603 rt->u.dst.dev ? rt->u.dst.dev->name : "NULL");
@@ -2767,13 +2745,11 @@ void bond_loadbalance_arp_mon(struct work_struct *work)
2767 2745
2768 delta_in_ticks = msecs_to_jiffies(bond->params.arp_interval); 2746 delta_in_ticks = msecs_to_jiffies(bond->params.arp_interval);
2769 2747
2770 if (bond->kill_timers) { 2748 if (bond->kill_timers)
2771 goto out; 2749 goto out;
2772 }
2773 2750
2774 if (bond->slave_cnt == 0) { 2751 if (bond->slave_cnt == 0)
2775 goto re_arm; 2752 goto re_arm;
2776 }
2777 2753
2778 read_lock(&bond->curr_slave_lock); 2754 read_lock(&bond->curr_slave_lock);
2779 oldcurrent = bond->curr_active_slave; 2755 oldcurrent = bond->curr_active_slave;
@@ -2789,7 +2765,7 @@ void bond_loadbalance_arp_mon(struct work_struct *work)
2789 */ 2765 */
2790 bond_for_each_slave(bond, slave, i) { 2766 bond_for_each_slave(bond, slave, i) {
2791 if (slave->link != BOND_LINK_UP) { 2767 if (slave->link != BOND_LINK_UP) {
2792 if (time_before_eq(jiffies, slave->dev->trans_start + delta_in_ticks) && 2768 if (time_before_eq(jiffies, dev_trans_start(slave->dev) + delta_in_ticks) &&
2793 time_before_eq(jiffies, slave->dev->last_rx + delta_in_ticks)) { 2769 time_before_eq(jiffies, slave->dev->last_rx + delta_in_ticks)) {
2794 2770
2795 slave->link = BOND_LINK_UP; 2771 slave->link = BOND_LINK_UP;
@@ -2801,14 +2777,14 @@ void bond_loadbalance_arp_mon(struct work_struct *work)
2801 * is closed. 2777 * is closed.
2802 */ 2778 */
2803 if (!oldcurrent) { 2779 if (!oldcurrent) {
2804 printk(KERN_INFO DRV_NAME 2780 pr_info(DRV_NAME
2805 ": %s: link status definitely " 2781 ": %s: link status definitely "
2806 "up for interface %s, ", 2782 "up for interface %s, ",
2807 bond->dev->name, 2783 bond->dev->name,
2808 slave->dev->name); 2784 slave->dev->name);
2809 do_failover = 1; 2785 do_failover = 1;
2810 } else { 2786 } else {
2811 printk(KERN_INFO DRV_NAME 2787 pr_info(DRV_NAME
2812 ": %s: interface %s is now up\n", 2788 ": %s: interface %s is now up\n",
2813 bond->dev->name, 2789 bond->dev->name,
2814 slave->dev->name); 2790 slave->dev->name);
@@ -2821,24 +2797,22 @@ void bond_loadbalance_arp_mon(struct work_struct *work)
2821 * when the source ip is 0, so don't take the link down 2797 * when the source ip is 0, so don't take the link down
2822 * if we don't know our ip yet 2798 * if we don't know our ip yet
2823 */ 2799 */
2824 if (time_after_eq(jiffies, slave->dev->trans_start + 2*delta_in_ticks) || 2800 if (time_after_eq(jiffies, dev_trans_start(slave->dev) + 2*delta_in_ticks) ||
2825 (time_after_eq(jiffies, slave->dev->last_rx + 2*delta_in_ticks))) { 2801 (time_after_eq(jiffies, slave->dev->last_rx + 2*delta_in_ticks))) {
2826 2802
2827 slave->link = BOND_LINK_DOWN; 2803 slave->link = BOND_LINK_DOWN;
2828 slave->state = BOND_STATE_BACKUP; 2804 slave->state = BOND_STATE_BACKUP;
2829 2805
2830 if (slave->link_failure_count < UINT_MAX) { 2806 if (slave->link_failure_count < UINT_MAX)
2831 slave->link_failure_count++; 2807 slave->link_failure_count++;
2832 }
2833 2808
2834 printk(KERN_INFO DRV_NAME 2809 pr_info(DRV_NAME
2835 ": %s: interface %s is now down.\n", 2810 ": %s: interface %s is now down.\n",
2836 bond->dev->name, 2811 bond->dev->name,
2837 slave->dev->name); 2812 slave->dev->name);
2838 2813
2839 if (slave == oldcurrent) { 2814 if (slave == oldcurrent)
2840 do_failover = 1; 2815 do_failover = 1;
2841 }
2842 } 2816 }
2843 } 2817 }
2844 2818
@@ -2849,9 +2823,8 @@ void bond_loadbalance_arp_mon(struct work_struct *work)
2849 * do - all replies will be rx'ed on same link causing slaves 2823 * do - all replies will be rx'ed on same link causing slaves
2850 * to be unstable during low/no traffic periods 2824 * to be unstable during low/no traffic periods
2851 */ 2825 */
2852 if (IS_UP(slave->dev)) { 2826 if (IS_UP(slave->dev))
2853 bond_arp_send_all(bond, slave); 2827 bond_arp_send_all(bond, slave);
2854 }
2855 } 2828 }
2856 2829
2857 if (do_failover) { 2830 if (do_failover) {
@@ -2932,7 +2905,7 @@ static int bond_ab_arp_inspect(struct bonding *bond, int delta_in_ticks)
2932 * the bond has an IP address) 2905 * the bond has an IP address)
2933 */ 2906 */
2934 if ((slave->state == BOND_STATE_ACTIVE) && 2907 if ((slave->state == BOND_STATE_ACTIVE) &&
2935 (time_after_eq(jiffies, slave->dev->trans_start + 2908 (time_after_eq(jiffies, dev_trans_start(slave->dev) +
2936 2 * delta_in_ticks) || 2909 2 * delta_in_ticks) ||
2937 (time_after_eq(jiffies, slave_last_rx(bond, slave) 2910 (time_after_eq(jiffies, slave_last_rx(bond, slave)
2938 + 2 * delta_in_ticks)))) { 2911 + 2 * delta_in_ticks)))) {
@@ -2976,13 +2949,13 @@ static void bond_ab_arp_commit(struct bonding *bond, int delta_in_ticks)
2976 write_lock_bh(&bond->curr_slave_lock); 2949 write_lock_bh(&bond->curr_slave_lock);
2977 2950
2978 if (!bond->curr_active_slave && 2951 if (!bond->curr_active_slave &&
2979 time_before_eq(jiffies, slave->dev->trans_start + 2952 time_before_eq(jiffies, dev_trans_start(slave->dev) +
2980 delta_in_ticks)) { 2953 delta_in_ticks)) {
2981 slave->link = BOND_LINK_UP; 2954 slave->link = BOND_LINK_UP;
2982 bond_change_active_slave(bond, slave); 2955 bond_change_active_slave(bond, slave);
2983 bond->current_arp_slave = NULL; 2956 bond->current_arp_slave = NULL;
2984 2957
2985 printk(KERN_INFO DRV_NAME 2958 pr_info(DRV_NAME
2986 ": %s: %s is up and now the " 2959 ": %s: %s is up and now the "
2987 "active interface\n", 2960 "active interface\n",
2988 bond->dev->name, slave->dev->name); 2961 bond->dev->name, slave->dev->name);
@@ -2998,7 +2971,7 @@ static void bond_ab_arp_commit(struct bonding *bond, int delta_in_ticks)
2998 bond_set_slave_inactive_flags(slave); 2971 bond_set_slave_inactive_flags(slave);
2999 bond->current_arp_slave = NULL; 2972 bond->current_arp_slave = NULL;
3000 2973
3001 printk(KERN_INFO DRV_NAME 2974 pr_info(DRV_NAME
3002 ": %s: backup interface %s is now up\n", 2975 ": %s: backup interface %s is now up\n",
3003 bond->dev->name, slave->dev->name); 2976 bond->dev->name, slave->dev->name);
3004 } 2977 }
@@ -3014,7 +2987,7 @@ static void bond_ab_arp_commit(struct bonding *bond, int delta_in_ticks)
3014 slave->link = BOND_LINK_DOWN; 2987 slave->link = BOND_LINK_DOWN;
3015 2988
3016 if (slave == bond->curr_active_slave) { 2989 if (slave == bond->curr_active_slave) {
3017 printk(KERN_INFO DRV_NAME 2990 pr_info(DRV_NAME
3018 ": %s: link status down for active " 2991 ": %s: link status down for active "
3019 "interface %s, disabling it\n", 2992 "interface %s, disabling it\n",
3020 bond->dev->name, slave->dev->name); 2993 bond->dev->name, slave->dev->name);
@@ -3033,7 +3006,7 @@ static void bond_ab_arp_commit(struct bonding *bond, int delta_in_ticks)
3033 bond->current_arp_slave = NULL; 3006 bond->current_arp_slave = NULL;
3034 3007
3035 } else if (slave->state == BOND_STATE_BACKUP) { 3008 } else if (slave->state == BOND_STATE_BACKUP) {
3036 printk(KERN_INFO DRV_NAME 3009 pr_info(DRV_NAME
3037 ": %s: backup interface %s is now down\n", 3010 ": %s: backup interface %s is now down\n",
3038 bond->dev->name, slave->dev->name); 3011 bond->dev->name, slave->dev->name);
3039 3012
@@ -3042,7 +3015,7 @@ static void bond_ab_arp_commit(struct bonding *bond, int delta_in_ticks)
3042 break; 3015 break;
3043 3016
3044 default: 3017 default:
3045 printk(KERN_ERR DRV_NAME 3018 pr_err(DRV_NAME
3046 ": %s: impossible: new_link %d on slave %s\n", 3019 ": %s: impossible: new_link %d on slave %s\n",
3047 bond->dev->name, slave->new_link, 3020 bond->dev->name, slave->new_link,
3048 slave->dev->name); 3021 slave->dev->name);
@@ -3076,7 +3049,7 @@ static void bond_ab_arp_probe(struct bonding *bond)
3076 read_lock(&bond->curr_slave_lock); 3049 read_lock(&bond->curr_slave_lock);
3077 3050
3078 if (bond->current_arp_slave && bond->curr_active_slave) 3051 if (bond->current_arp_slave && bond->curr_active_slave)
3079 printk("PROBE: c_arp %s && cas %s BAD\n", 3052 pr_info(DRV_NAME "PROBE: c_arp %s && cas %s BAD\n",
3080 bond->current_arp_slave->dev->name, 3053 bond->current_arp_slave->dev->name,
3081 bond->curr_active_slave->dev->name); 3054 bond->curr_active_slave->dev->name);
3082 3055
@@ -3126,7 +3099,7 @@ static void bond_ab_arp_probe(struct bonding *bond)
3126 3099
3127 bond_set_slave_inactive_flags(slave); 3100 bond_set_slave_inactive_flags(slave);
3128 3101
3129 printk(KERN_INFO DRV_NAME 3102 pr_info(DRV_NAME
3130 ": %s: backup interface %s is now down.\n", 3103 ": %s: backup interface %s is now down.\n",
3131 bond->dev->name, slave->dev->name); 3104 bond->dev->name, slave->dev->name);
3132 } 3105 }
@@ -3176,9 +3149,8 @@ void bond_activebackup_arp_mon(struct work_struct *work)
3176 bond_ab_arp_probe(bond); 3149 bond_ab_arp_probe(bond);
3177 3150
3178re_arm: 3151re_arm:
3179 if (bond->params.arp_interval) { 3152 if (bond->params.arp_interval)
3180 queue_delayed_work(bond->wq, &bond->arp_work, delta_in_ticks); 3153 queue_delayed_work(bond->wq, &bond->arp_work, delta_in_ticks);
3181 }
3182out: 3154out:
3183 read_unlock(&bond->lock); 3155 read_unlock(&bond->lock);
3184} 3156}
@@ -3200,14 +3172,12 @@ static void *bond_info_seq_start(struct seq_file *seq, loff_t *pos)
3200 read_lock(&dev_base_lock); 3172 read_lock(&dev_base_lock);
3201 read_lock(&bond->lock); 3173 read_lock(&bond->lock);
3202 3174
3203 if (*pos == 0) { 3175 if (*pos == 0)
3204 return SEQ_START_TOKEN; 3176 return SEQ_START_TOKEN;
3205 }
3206 3177
3207 bond_for_each_slave(bond, slave, i) { 3178 bond_for_each_slave(bond, slave, i) {
3208 if (++off == *pos) { 3179 if (++off == *pos)
3209 return slave; 3180 return slave;
3210 }
3211 } 3181 }
3212 3182
3213 return NULL; 3183 return NULL;
@@ -3219,9 +3189,8 @@ static void *bond_info_seq_next(struct seq_file *seq, void *v, loff_t *pos)
3219 struct slave *slave = v; 3189 struct slave *slave = v;
3220 3190
3221 ++*pos; 3191 ++*pos;
3222 if (v == SEQ_START_TOKEN) { 3192 if (v == SEQ_START_TOKEN)
3223 return bond->first_slave; 3193 return bond->first_slave;
3224 }
3225 3194
3226 slave = slave->next; 3195 slave = slave->next;
3227 3196
@@ -3284,14 +3253,14 @@ static void bond_info_show_master(struct seq_file *seq)
3284 3253
3285 3254
3286 /* ARP information */ 3255 /* ARP information */
3287 if(bond->params.arp_interval > 0) { 3256 if (bond->params.arp_interval > 0) {
3288 int printed=0; 3257 int printed = 0;
3289 seq_printf(seq, "ARP Polling Interval (ms): %d\n", 3258 seq_printf(seq, "ARP Polling Interval (ms): %d\n",
3290 bond->params.arp_interval); 3259 bond->params.arp_interval);
3291 3260
3292 seq_printf(seq, "ARP IP target/s (n.n.n.n form):"); 3261 seq_printf(seq, "ARP IP target/s (n.n.n.n form):");
3293 3262
3294 for(i = 0; (i < BOND_MAX_ARP_TARGETS) ;i++) { 3263 for (i = 0; (i < BOND_MAX_ARP_TARGETS); i++) {
3295 if (!bond->params.arp_targets[i]) 3264 if (!bond->params.arp_targets[i])
3296 break; 3265 break;
3297 if (printed) 3266 if (printed)
@@ -3331,7 +3300,8 @@ static void bond_info_show_master(struct seq_file *seq)
3331 } 3300 }
3332} 3301}
3333 3302
3334static void bond_info_show_slave(struct seq_file *seq, const struct slave *slave) 3303static void bond_info_show_slave(struct seq_file *seq,
3304 const struct slave *slave)
3335{ 3305{
3336 struct bonding *bond = seq->private; 3306 struct bonding *bond = seq->private;
3337 3307
@@ -3347,12 +3317,11 @@ static void bond_info_show_slave(struct seq_file *seq, const struct slave *slave
3347 const struct aggregator *agg 3317 const struct aggregator *agg
3348 = SLAVE_AD_INFO(slave).port.aggregator; 3318 = SLAVE_AD_INFO(slave).port.aggregator;
3349 3319
3350 if (agg) { 3320 if (agg)
3351 seq_printf(seq, "Aggregator ID: %d\n", 3321 seq_printf(seq, "Aggregator ID: %d\n",
3352 agg->aggregator_identifier); 3322 agg->aggregator_identifier);
3353 } else { 3323 else
3354 seq_puts(seq, "Aggregator ID: N/A\n"); 3324 seq_puts(seq, "Aggregator ID: N/A\n");
3355 }
3356 } 3325 }
3357} 3326}
3358 3327
@@ -3361,9 +3330,8 @@ static int bond_info_seq_show(struct seq_file *seq, void *v)
3361 if (v == SEQ_START_TOKEN) { 3330 if (v == SEQ_START_TOKEN) {
3362 seq_printf(seq, "%s\n", version); 3331 seq_printf(seq, "%s\n", version);
3363 bond_info_show_master(seq); 3332 bond_info_show_master(seq);
3364 } else { 3333 } else
3365 bond_info_show_slave(seq, v); 3334 bond_info_show_slave(seq, v);
3366 }
3367 3335
3368 return 0; 3336 return 0;
3369} 3337}
@@ -3408,13 +3376,12 @@ static int bond_create_proc_entry(struct bonding *bond)
3408 bond->proc_entry = proc_create_data(bond_dev->name, 3376 bond->proc_entry = proc_create_data(bond_dev->name,
3409 S_IRUGO, bond_proc_dir, 3377 S_IRUGO, bond_proc_dir,
3410 &bond_info_fops, bond); 3378 &bond_info_fops, bond);
3411 if (bond->proc_entry == NULL) { 3379 if (bond->proc_entry == NULL)
3412 printk(KERN_WARNING DRV_NAME 3380 pr_warning(DRV_NAME
3413 ": Warning: Cannot create /proc/net/%s/%s\n", 3381 ": Warning: Cannot create /proc/net/%s/%s\n",
3414 DRV_NAME, bond_dev->name); 3382 DRV_NAME, bond_dev->name);
3415 } else { 3383 else
3416 memcpy(bond->proc_file_name, bond_dev->name, IFNAMSIZ); 3384 memcpy(bond->proc_file_name, bond_dev->name, IFNAMSIZ);
3417 }
3418 } 3385 }
3419 3386
3420 return 0; 3387 return 0;
@@ -3437,7 +3404,7 @@ static void bond_create_proc_dir(void)
3437 if (!bond_proc_dir) { 3404 if (!bond_proc_dir) {
3438 bond_proc_dir = proc_mkdir(DRV_NAME, init_net.proc_net); 3405 bond_proc_dir = proc_mkdir(DRV_NAME, init_net.proc_net);
3439 if (!bond_proc_dir) 3406 if (!bond_proc_dir)
3440 printk(KERN_WARNING DRV_NAME 3407 pr_warning(DRV_NAME
3441 ": Warning: cannot create /proc/net/%s\n", 3408 ": Warning: cannot create /proc/net/%s\n",
3442 DRV_NAME); 3409 DRV_NAME);
3443 } 3410 }
@@ -3453,8 +3420,28 @@ static void bond_destroy_proc_dir(void)
3453 bond_proc_dir = NULL; 3420 bond_proc_dir = NULL;
3454 } 3421 }
3455} 3422}
3423
3424#else /* !CONFIG_PROC_FS */
3425
3426static int bond_create_proc_entry(struct bonding *bond)
3427{
3428}
3429
3430static void bond_remove_proc_entry(struct bonding *bond)
3431{
3432}
3433
3434static void bond_create_proc_dir(void)
3435{
3436}
3437
3438static void bond_destroy_proc_dir(void)
3439{
3440}
3441
3456#endif /* CONFIG_PROC_FS */ 3442#endif /* CONFIG_PROC_FS */
3457 3443
3444
3458/*-------------------------- netdev event handling --------------------------*/ 3445/*-------------------------- netdev event handling --------------------------*/
3459 3446
3460/* 3447/*
@@ -3462,18 +3449,17 @@ static void bond_destroy_proc_dir(void)
3462 */ 3449 */
3463static int bond_event_changename(struct bonding *bond) 3450static int bond_event_changename(struct bonding *bond)
3464{ 3451{
3465#ifdef CONFIG_PROC_FS
3466 bond_remove_proc_entry(bond); 3452 bond_remove_proc_entry(bond);
3467 bond_create_proc_entry(bond); 3453 bond_create_proc_entry(bond);
3468#endif 3454
3469 down_write(&(bonding_rwsem)); 3455 bond_destroy_sysfs_entry(bond);
3470 bond_destroy_sysfs_entry(bond); 3456 bond_create_sysfs_entry(bond);
3471 bond_create_sysfs_entry(bond); 3457
3472 up_write(&(bonding_rwsem));
3473 return NOTIFY_DONE; 3458 return NOTIFY_DONE;
3474} 3459}
3475 3460
3476static int bond_master_netdev_event(unsigned long event, struct net_device *bond_dev) 3461static int bond_master_netdev_event(unsigned long event,
3462 struct net_device *bond_dev)
3477{ 3463{
3478 struct bonding *event_bond = netdev_priv(bond_dev); 3464 struct bonding *event_bond = netdev_priv(bond_dev);
3479 3465
@@ -3490,7 +3476,8 @@ static int bond_master_netdev_event(unsigned long event, struct net_device *bond
3490 return NOTIFY_DONE; 3476 return NOTIFY_DONE;
3491} 3477}
3492 3478
3493static int bond_slave_netdev_event(unsigned long event, struct net_device *slave_dev) 3479static int bond_slave_netdev_event(unsigned long event,
3480 struct net_device *slave_dev)
3494{ 3481{
3495 struct net_device *bond_dev = slave_dev->master; 3482 struct net_device *bond_dev = slave_dev->master;
3496 struct bonding *bond = netdev_priv(bond_dev); 3483 struct bonding *bond = netdev_priv(bond_dev);
@@ -3568,7 +3555,8 @@ static int bond_slave_netdev_event(unsigned long event, struct net_device *slave
3568 * locks for us to safely manipulate the slave devices (RTNL lock, 3555 * locks for us to safely manipulate the slave devices (RTNL lock,
3569 * dev_probe_lock). 3556 * dev_probe_lock).
3570 */ 3557 */
3571static int bond_netdev_event(struct notifier_block *this, unsigned long event, void *ptr) 3558static int bond_netdev_event(struct notifier_block *this,
3559 unsigned long event, void *ptr)
3572{ 3560{
3573 struct net_device *event_dev = (struct net_device *)ptr; 3561 struct net_device *event_dev = (struct net_device *)ptr;
3574 3562
@@ -3923,9 +3911,9 @@ static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd
3923 switch (cmd) { 3911 switch (cmd) {
3924 case SIOCGMIIPHY: 3912 case SIOCGMIIPHY:
3925 mii = if_mii(ifr); 3913 mii = if_mii(ifr);
3926 if (!mii) { 3914 if (!mii)
3927 return -EINVAL; 3915 return -EINVAL;
3928 } 3916
3929 mii->phy_id = 0; 3917 mii->phy_id = 0;
3930 /* Fall Through */ 3918 /* Fall Through */
3931 case SIOCGMIIREG: 3919 case SIOCGMIIREG:
@@ -3934,18 +3922,18 @@ static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd
3934 * instead of SIOCGMIIPHY. 3922 * instead of SIOCGMIIPHY.
3935 */ 3923 */
3936 mii = if_mii(ifr); 3924 mii = if_mii(ifr);
3937 if (!mii) { 3925 if (!mii)
3938 return -EINVAL; 3926 return -EINVAL;
3939 } 3927
3940 3928
3941 if (mii->reg_num == 1) { 3929 if (mii->reg_num == 1) {
3942 struct bonding *bond = netdev_priv(bond_dev); 3930 struct bonding *bond = netdev_priv(bond_dev);
3943 mii->val_out = 0; 3931 mii->val_out = 0;
3944 read_lock(&bond->lock); 3932 read_lock(&bond->lock);
3945 read_lock(&bond->curr_slave_lock); 3933 read_lock(&bond->curr_slave_lock);
3946 if (netif_carrier_ok(bond->dev)) { 3934 if (netif_carrier_ok(bond->dev))
3947 mii->val_out = BMSR_LSTATUS; 3935 mii->val_out = BMSR_LSTATUS;
3948 } 3936
3949 read_unlock(&bond->curr_slave_lock); 3937 read_unlock(&bond->curr_slave_lock);
3950 read_unlock(&bond->lock); 3938 read_unlock(&bond->lock);
3951 } 3939 }
@@ -3955,32 +3943,26 @@ static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd
3955 case SIOCBONDINFOQUERY: 3943 case SIOCBONDINFOQUERY:
3956 u_binfo = (struct ifbond __user *)ifr->ifr_data; 3944 u_binfo = (struct ifbond __user *)ifr->ifr_data;
3957 3945
3958 if (copy_from_user(&k_binfo, u_binfo, sizeof(ifbond))) { 3946 if (copy_from_user(&k_binfo, u_binfo, sizeof(ifbond)))
3959 return -EFAULT; 3947 return -EFAULT;
3960 }
3961 3948
3962 res = bond_info_query(bond_dev, &k_binfo); 3949 res = bond_info_query(bond_dev, &k_binfo);
3963 if (res == 0) { 3950 if (res == 0 &&
3964 if (copy_to_user(u_binfo, &k_binfo, sizeof(ifbond))) { 3951 copy_to_user(u_binfo, &k_binfo, sizeof(ifbond)))
3965 return -EFAULT; 3952 return -EFAULT;
3966 }
3967 }
3968 3953
3969 return res; 3954 return res;
3970 case BOND_SLAVE_INFO_QUERY_OLD: 3955 case BOND_SLAVE_INFO_QUERY_OLD:
3971 case SIOCBONDSLAVEINFOQUERY: 3956 case SIOCBONDSLAVEINFOQUERY:
3972 u_sinfo = (struct ifslave __user *)ifr->ifr_data; 3957 u_sinfo = (struct ifslave __user *)ifr->ifr_data;
3973 3958
3974 if (copy_from_user(&k_sinfo, u_sinfo, sizeof(ifslave))) { 3959 if (copy_from_user(&k_sinfo, u_sinfo, sizeof(ifslave)))
3975 return -EFAULT; 3960 return -EFAULT;
3976 }
3977 3961
3978 res = bond_slave_info_query(bond_dev, &k_sinfo); 3962 res = bond_slave_info_query(bond_dev, &k_sinfo);
3979 if (res == 0) { 3963 if (res == 0 &&
3980 if (copy_to_user(u_sinfo, &k_sinfo, sizeof(ifslave))) { 3964 copy_to_user(u_sinfo, &k_sinfo, sizeof(ifslave)))
3981 return -EFAULT; 3965 return -EFAULT;
3982 }
3983 }
3984 3966
3985 return res; 3967 return res;
3986 default: 3968 default:
@@ -3988,18 +3970,16 @@ static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd
3988 break; 3970 break;
3989 } 3971 }
3990 3972
3991 if (!capable(CAP_NET_ADMIN)) { 3973 if (!capable(CAP_NET_ADMIN))
3992 return -EPERM; 3974 return -EPERM;
3993 }
3994 3975
3995 down_write(&(bonding_rwsem));
3996 slave_dev = dev_get_by_name(&init_net, ifr->ifr_slave); 3976 slave_dev = dev_get_by_name(&init_net, ifr->ifr_slave);
3997 3977
3998 pr_debug("slave_dev=%p: \n", slave_dev); 3978 pr_debug("slave_dev=%p: \n", slave_dev);
3999 3979
4000 if (!slave_dev) { 3980 if (!slave_dev)
4001 res = -ENODEV; 3981 res = -ENODEV;
4002 } else { 3982 else {
4003 pr_debug("slave_dev->name=%s: \n", slave_dev->name); 3983 pr_debug("slave_dev->name=%s: \n", slave_dev->name);
4004 switch (cmd) { 3984 switch (cmd) {
4005 case BOND_ENSLAVE_OLD: 3985 case BOND_ENSLAVE_OLD:
@@ -4025,7 +4005,6 @@ static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd
4025 dev_put(slave_dev); 4005 dev_put(slave_dev);
4026 } 4006 }
4027 4007
4028 up_write(&(bonding_rwsem));
4029 return res; 4008 return res;
4030} 4009}
4031 4010
@@ -4037,30 +4016,30 @@ static void bond_set_multicast_list(struct net_device *bond_dev)
4037 /* 4016 /*
4038 * Do promisc before checking multicast_mode 4017 * Do promisc before checking multicast_mode
4039 */ 4018 */
4040 if ((bond_dev->flags & IFF_PROMISC) && !(bond->flags & IFF_PROMISC)) { 4019 if ((bond_dev->flags & IFF_PROMISC) && !(bond->flags & IFF_PROMISC))
4041 /* 4020 /*
4042 * FIXME: Need to handle the error when one of the multi-slaves 4021 * FIXME: Need to handle the error when one of the multi-slaves
4043 * encounters error. 4022 * encounters error.
4044 */ 4023 */
4045 bond_set_promiscuity(bond, 1); 4024 bond_set_promiscuity(bond, 1);
4046 }
4047 4025
4048 if (!(bond_dev->flags & IFF_PROMISC) && (bond->flags & IFF_PROMISC)) { 4026
4027 if (!(bond_dev->flags & IFF_PROMISC) && (bond->flags & IFF_PROMISC))
4049 bond_set_promiscuity(bond, -1); 4028 bond_set_promiscuity(bond, -1);
4050 } 4029
4051 4030
4052 /* set allmulti flag to slaves */ 4031 /* set allmulti flag to slaves */
4053 if ((bond_dev->flags & IFF_ALLMULTI) && !(bond->flags & IFF_ALLMULTI)) { 4032 if ((bond_dev->flags & IFF_ALLMULTI) && !(bond->flags & IFF_ALLMULTI))
4054 /* 4033 /*
4055 * FIXME: Need to handle the error when one of the multi-slaves 4034 * FIXME: Need to handle the error when one of the multi-slaves
4056 * encounters error. 4035 * encounters error.
4057 */ 4036 */
4058 bond_set_allmulti(bond, 1); 4037 bond_set_allmulti(bond, 1);
4059 }
4060 4038
4061 if (!(bond_dev->flags & IFF_ALLMULTI) && (bond->flags & IFF_ALLMULTI)) { 4039
4040 if (!(bond_dev->flags & IFF_ALLMULTI) && (bond->flags & IFF_ALLMULTI))
4062 bond_set_allmulti(bond, -1); 4041 bond_set_allmulti(bond, -1);
4063 } 4042
4064 4043
4065 read_lock(&bond->lock); 4044 read_lock(&bond->lock);
4066 4045
@@ -4068,16 +4047,14 @@ static void bond_set_multicast_list(struct net_device *bond_dev)
4068 4047
4069 /* looking for addresses to add to slaves' mc list */ 4048 /* looking for addresses to add to slaves' mc list */
4070 for (dmi = bond_dev->mc_list; dmi; dmi = dmi->next) { 4049 for (dmi = bond_dev->mc_list; dmi; dmi = dmi->next) {
4071 if (!bond_mc_list_find_dmi(dmi, bond->mc_list)) { 4050 if (!bond_mc_list_find_dmi(dmi, bond->mc_list))
4072 bond_mc_add(bond, dmi->dmi_addr, dmi->dmi_addrlen); 4051 bond_mc_add(bond, dmi->dmi_addr, dmi->dmi_addrlen);
4073 }
4074 } 4052 }
4075 4053
4076 /* looking for addresses to delete from slaves' list */ 4054 /* looking for addresses to delete from slaves' list */
4077 for (dmi = bond->mc_list; dmi; dmi = dmi->next) { 4055 for (dmi = bond->mc_list; dmi; dmi = dmi->next) {
4078 if (!bond_mc_list_find_dmi(dmi, bond_dev->mc_list)) { 4056 if (!bond_mc_list_find_dmi(dmi, bond_dev->mc_list))
4079 bond_mc_delete(bond, dmi->dmi_addr, dmi->dmi_addrlen); 4057 bond_mc_delete(bond, dmi->dmi_addr, dmi->dmi_addrlen);
4080 }
4081 } 4058 }
4082 4059
4083 /* save master's multicast list */ 4060 /* save master's multicast list */
@@ -4197,9 +4174,8 @@ static int bond_set_mac_address(struct net_device *bond_dev, void *addr)
4197 if (bond->params.fail_over_mac == BOND_FOM_ACTIVE) 4174 if (bond->params.fail_over_mac == BOND_FOM_ACTIVE)
4198 return 0; 4175 return 0;
4199 4176
4200 if (!is_valid_ether_addr(sa->sa_data)) { 4177 if (!is_valid_ether_addr(sa->sa_data))
4201 return -EADDRNOTAVAIL; 4178 return -EADDRNOTAVAIL;
4202 }
4203 4179
4204 /* Can't hold bond->lock with bh disabled here since 4180 /* Can't hold bond->lock with bh disabled here since
4205 * some base drivers panic. On the other hand we can't 4181 * some base drivers panic. On the other hand we can't
@@ -4270,9 +4246,8 @@ static int bond_xmit_roundrobin(struct sk_buff *skb, struct net_device *bond_dev
4270 4246
4271 read_lock(&bond->lock); 4247 read_lock(&bond->lock);
4272 4248
4273 if (!BOND_IS_OK(bond)) { 4249 if (!BOND_IS_OK(bond))
4274 goto out; 4250 goto out;
4275 }
4276 4251
4277 /* 4252 /*
4278 * Concurrent TX may collide on rr_tx_counter; we accept that 4253 * Concurrent TX may collide on rr_tx_counter; we accept that
@@ -4282,9 +4257,8 @@ static int bond_xmit_roundrobin(struct sk_buff *skb, struct net_device *bond_dev
4282 4257
4283 bond_for_each_slave(bond, slave, i) { 4258 bond_for_each_slave(bond, slave, i) {
4284 slave_no--; 4259 slave_no--;
4285 if (slave_no < 0) { 4260 if (slave_no < 0)
4286 break; 4261 break;
4287 }
4288 } 4262 }
4289 4263
4290 start_at = slave; 4264 start_at = slave;
@@ -4319,9 +4293,8 @@ static int bond_xmit_activebackup(struct sk_buff *skb, struct net_device *bond_d
4319 read_lock(&bond->lock); 4293 read_lock(&bond->lock);
4320 read_lock(&bond->curr_slave_lock); 4294 read_lock(&bond->curr_slave_lock);
4321 4295
4322 if (!BOND_IS_OK(bond)) { 4296 if (!BOND_IS_OK(bond))
4323 goto out; 4297 goto out;
4324 }
4325 4298
4326 if (!bond->curr_active_slave) 4299 if (!bond->curr_active_slave)
4327 goto out; 4300 goto out;
@@ -4329,10 +4302,10 @@ static int bond_xmit_activebackup(struct sk_buff *skb, struct net_device *bond_d
4329 res = bond_dev_queue_xmit(bond, skb, bond->curr_active_slave->dev); 4302 res = bond_dev_queue_xmit(bond, skb, bond->curr_active_slave->dev);
4330 4303
4331out: 4304out:
4332 if (res) { 4305 if (res)
4333 /* no suitable interface, frame not sent */ 4306 /* no suitable interface, frame not sent */
4334 dev_kfree_skb(skb); 4307 dev_kfree_skb(skb);
4335 } 4308
4336 read_unlock(&bond->curr_slave_lock); 4309 read_unlock(&bond->curr_slave_lock);
4337 read_unlock(&bond->lock); 4310 read_unlock(&bond->lock);
4338 return 0; 4311 return 0;
@@ -4353,17 +4326,15 @@ static int bond_xmit_xor(struct sk_buff *skb, struct net_device *bond_dev)
4353 4326
4354 read_lock(&bond->lock); 4327 read_lock(&bond->lock);
4355 4328
4356 if (!BOND_IS_OK(bond)) { 4329 if (!BOND_IS_OK(bond))
4357 goto out; 4330 goto out;
4358 }
4359 4331
4360 slave_no = bond->xmit_hash_policy(skb, bond_dev, bond->slave_cnt); 4332 slave_no = bond->xmit_hash_policy(skb, bond_dev, bond->slave_cnt);
4361 4333
4362 bond_for_each_slave(bond, slave, i) { 4334 bond_for_each_slave(bond, slave, i) {
4363 slave_no--; 4335 slave_no--;
4364 if (slave_no < 0) { 4336 if (slave_no < 0)
4365 break; 4337 break;
4366 }
4367 } 4338 }
4368 4339
4369 start_at = slave; 4340 start_at = slave;
@@ -4399,17 +4370,15 @@ static int bond_xmit_broadcast(struct sk_buff *skb, struct net_device *bond_dev)
4399 4370
4400 read_lock(&bond->lock); 4371 read_lock(&bond->lock);
4401 4372
4402 if (!BOND_IS_OK(bond)) { 4373 if (!BOND_IS_OK(bond))
4403 goto out; 4374 goto out;
4404 }
4405 4375
4406 read_lock(&bond->curr_slave_lock); 4376 read_lock(&bond->curr_slave_lock);
4407 start_at = bond->curr_active_slave; 4377 start_at = bond->curr_active_slave;
4408 read_unlock(&bond->curr_slave_lock); 4378 read_unlock(&bond->curr_slave_lock);
4409 4379
4410 if (!start_at) { 4380 if (!start_at)
4411 goto out; 4381 goto out;
4412 }
4413 4382
4414 bond_for_each_slave_from(bond, slave, i, start_at) { 4383 bond_for_each_slave_from(bond, slave, i, start_at) {
4415 if (IS_UP(slave->dev) && 4384 if (IS_UP(slave->dev) &&
@@ -4418,7 +4387,7 @@ static int bond_xmit_broadcast(struct sk_buff *skb, struct net_device *bond_dev)
4418 if (tx_dev) { 4387 if (tx_dev) {
4419 struct sk_buff *skb2 = skb_clone(skb, GFP_ATOMIC); 4388 struct sk_buff *skb2 = skb_clone(skb, GFP_ATOMIC);
4420 if (!skb2) { 4389 if (!skb2) {
4421 printk(KERN_ERR DRV_NAME 4390 pr_err(DRV_NAME
4422 ": %s: Error: bond_xmit_broadcast(): " 4391 ": %s: Error: bond_xmit_broadcast(): "
4423 "skb_clone() failed\n", 4392 "skb_clone() failed\n",
4424 bond_dev->name); 4393 bond_dev->name);
@@ -4435,15 +4404,14 @@ static int bond_xmit_broadcast(struct sk_buff *skb, struct net_device *bond_dev)
4435 } 4404 }
4436 } 4405 }
4437 4406
4438 if (tx_dev) { 4407 if (tx_dev)
4439 res = bond_dev_queue_xmit(bond, skb, tx_dev); 4408 res = bond_dev_queue_xmit(bond, skb, tx_dev);
4440 }
4441 4409
4442out: 4410out:
4443 if (res) { 4411 if (res)
4444 /* no suitable interface, frame not sent */ 4412 /* no suitable interface, frame not sent */
4445 dev_kfree_skb(skb); 4413 dev_kfree_skb(skb);
4446 } 4414
4447 /* frame sent to all suitable interfaces */ 4415 /* frame sent to all suitable interfaces */
4448 read_unlock(&bond->lock); 4416 read_unlock(&bond->lock);
4449 return 0; 4417 return 0;
@@ -4487,7 +4455,7 @@ static int bond_start_xmit(struct sk_buff *skb, struct net_device *dev)
4487 return bond_alb_xmit(skb, dev); 4455 return bond_alb_xmit(skb, dev);
4488 default: 4456 default:
4489 /* Should never happen, mode already checked */ 4457 /* Should never happen, mode already checked */
4490 printk(KERN_ERR DRV_NAME ": %s: Error: Unknown bonding mode %d\n", 4458 pr_err(DRV_NAME ": %s: Error: Unknown bonding mode %d\n",
4491 dev->name, bond->params.mode); 4459 dev->name, bond->params.mode);
4492 WARN_ON_ONCE(1); 4460 WARN_ON_ONCE(1);
4493 dev_kfree_skb(skb); 4461 dev_kfree_skb(skb);
@@ -4524,7 +4492,7 @@ void bond_set_mode_ops(struct bonding *bond, int mode)
4524 break; 4492 break;
4525 default: 4493 default:
4526 /* Should never happen, mode already checked */ 4494 /* Should never happen, mode already checked */
4527 printk(KERN_ERR DRV_NAME 4495 pr_err(DRV_NAME
4528 ": %s: Error: Unknown bonding mode %d\n", 4496 ": %s: Error: Unknown bonding mode %d\n",
4529 bond_dev->name, 4497 bond_dev->name,
4530 mode); 4498 mode);
@@ -4551,6 +4519,8 @@ static const struct ethtool_ops bond_ethtool_ops = {
4551}; 4519};
4552 4520
4553static const struct net_device_ops bond_netdev_ops = { 4521static const struct net_device_ops bond_netdev_ops = {
4522 .ndo_init = bond_init,
4523 .ndo_uninit = bond_uninit,
4554 .ndo_open = bond_open, 4524 .ndo_open = bond_open,
4555 .ndo_stop = bond_close, 4525 .ndo_stop = bond_close,
4556 .ndo_start_xmit = bond_start_xmit, 4526 .ndo_start_xmit = bond_start_xmit,
@@ -4565,48 +4535,34 @@ static const struct net_device_ops bond_netdev_ops = {
4565 .ndo_vlan_rx_kill_vid = bond_vlan_rx_kill_vid, 4535 .ndo_vlan_rx_kill_vid = bond_vlan_rx_kill_vid,
4566}; 4536};
4567 4537
4568/* 4538static void bond_setup(struct net_device *bond_dev)
4569 * Does not allocate but creates a /proc entry.
4570 * Allowed to fail.
4571 */
4572static int bond_init(struct net_device *bond_dev, struct bond_params *params)
4573{ 4539{
4574 struct bonding *bond = netdev_priv(bond_dev); 4540 struct bonding *bond = netdev_priv(bond_dev);
4575 4541
4576 pr_debug("Begin bond_init for %s\n", bond_dev->name);
4577
4578 /* initialize rwlocks */ 4542 /* initialize rwlocks */
4579 rwlock_init(&bond->lock); 4543 rwlock_init(&bond->lock);
4580 rwlock_init(&bond->curr_slave_lock); 4544 rwlock_init(&bond->curr_slave_lock);
4581 4545
4582 bond->params = *params; /* copy params struct */ 4546 bond->params = bonding_defaults;
4583
4584 bond->wq = create_singlethread_workqueue(bond_dev->name);
4585 if (!bond->wq)
4586 return -ENOMEM;
4587 4547
4588 /* Initialize pointers */ 4548 /* Initialize pointers */
4589 bond->first_slave = NULL;
4590 bond->curr_active_slave = NULL;
4591 bond->current_arp_slave = NULL;
4592 bond->primary_slave = NULL;
4593 bond->dev = bond_dev; 4549 bond->dev = bond_dev;
4594 bond->send_grat_arp = 0;
4595 bond->send_unsol_na = 0;
4596 bond->setup_by_slave = 0;
4597 INIT_LIST_HEAD(&bond->vlan_list); 4550 INIT_LIST_HEAD(&bond->vlan_list);
4598 4551
4599 /* Initialize the device entry points */ 4552 /* Initialize the device entry points */
4553 ether_setup(bond_dev);
4600 bond_dev->netdev_ops = &bond_netdev_ops; 4554 bond_dev->netdev_ops = &bond_netdev_ops;
4601 bond_dev->ethtool_ops = &bond_ethtool_ops; 4555 bond_dev->ethtool_ops = &bond_ethtool_ops;
4602 bond_set_mode_ops(bond, bond->params.mode); 4556 bond_set_mode_ops(bond, bond->params.mode);
4603 4557
4604 bond_dev->destructor = bond_destructor; 4558 bond_dev->destructor = free_netdev;
4605 4559
4606 /* Initialize the device options */ 4560 /* Initialize the device options */
4607 bond_dev->tx_queue_len = 0; 4561 bond_dev->tx_queue_len = 0;
4608 bond_dev->flags |= IFF_MASTER|IFF_MULTICAST; 4562 bond_dev->flags |= IFF_MASTER|IFF_MULTICAST;
4609 bond_dev->priv_flags |= IFF_BONDING; 4563 bond_dev->priv_flags |= IFF_BONDING;
4564 bond_dev->priv_flags &= ~IFF_XMIT_DST_RELEASE;
4565
4610 if (bond->params.arp_interval) 4566 if (bond->params.arp_interval)
4611 bond_dev->priv_flags |= IFF_MASTER_ARPMON; 4567 bond_dev->priv_flags |= IFF_MASTER_ARPMON;
4612 4568
@@ -4631,12 +4587,6 @@ static int bond_init(struct net_device *bond_dev, struct bond_params *params)
4631 NETIF_F_HW_VLAN_RX | 4587 NETIF_F_HW_VLAN_RX |
4632 NETIF_F_HW_VLAN_FILTER); 4588 NETIF_F_HW_VLAN_FILTER);
4633 4589
4634#ifdef CONFIG_PROC_FS
4635 bond_create_proc_entry(bond);
4636#endif
4637 list_add_tail(&bond->bond_list, &bond_dev_list);
4638
4639 return 0;
4640} 4590}
4641 4591
4642static void bond_work_cancel_all(struct bonding *bond) 4592static void bond_work_cancel_all(struct bonding *bond)
@@ -4671,9 +4621,7 @@ static void bond_deinit(struct net_device *bond_dev)
4671 4621
4672 bond_work_cancel_all(bond); 4622 bond_work_cancel_all(bond);
4673 4623
4674#ifdef CONFIG_PROC_FS
4675 bond_remove_proc_entry(bond); 4624 bond_remove_proc_entry(bond);
4676#endif
4677} 4625}
4678 4626
4679/* Unregister and free all bond devices. 4627/* Unregister and free all bond devices.
@@ -4689,12 +4637,10 @@ static void bond_free_all(void)
4689 bond_work_cancel_all(bond); 4637 bond_work_cancel_all(bond);
4690 /* Release the bonded slaves */ 4638 /* Release the bonded slaves */
4691 bond_release_all(bond_dev); 4639 bond_release_all(bond_dev);
4692 bond_destroy(bond); 4640 unregister_netdevice(bond_dev);
4693 } 4641 }
4694 4642
4695#ifdef CONFIG_PROC_FS
4696 bond_destroy_proc_dir(); 4643 bond_destroy_proc_dir();
4697#endif
4698} 4644}
4699 4645
4700/*------------------------- Module initialization ---------------------------*/ 4646/*------------------------- Module initialization ---------------------------*/
@@ -4742,7 +4688,7 @@ static int bond_check_params(struct bond_params *params)
4742 if (mode) { 4688 if (mode) {
4743 bond_mode = bond_parse_parm(mode, bond_mode_tbl); 4689 bond_mode = bond_parse_parm(mode, bond_mode_tbl);
4744 if (bond_mode == -1) { 4690 if (bond_mode == -1) {
4745 printk(KERN_ERR DRV_NAME 4691 pr_err(DRV_NAME
4746 ": Error: Invalid bonding mode \"%s\"\n", 4692 ": Error: Invalid bonding mode \"%s\"\n",
4747 mode == NULL ? "NULL" : mode); 4693 mode == NULL ? "NULL" : mode);
4748 return -EINVAL; 4694 return -EINVAL;
@@ -4752,16 +4698,16 @@ static int bond_check_params(struct bond_params *params)
4752 if (xmit_hash_policy) { 4698 if (xmit_hash_policy) {
4753 if ((bond_mode != BOND_MODE_XOR) && 4699 if ((bond_mode != BOND_MODE_XOR) &&
4754 (bond_mode != BOND_MODE_8023AD)) { 4700 (bond_mode != BOND_MODE_8023AD)) {
4755 printk(KERN_INFO DRV_NAME 4701 pr_info(DRV_NAME
4756 ": xor_mode param is irrelevant in mode %s\n", 4702 ": xor_mode param is irrelevant in mode %s\n",
4757 bond_mode_name(bond_mode)); 4703 bond_mode_name(bond_mode));
4758 } else { 4704 } else {
4759 xmit_hashtype = bond_parse_parm(xmit_hash_policy, 4705 xmit_hashtype = bond_parse_parm(xmit_hash_policy,
4760 xmit_hashtype_tbl); 4706 xmit_hashtype_tbl);
4761 if (xmit_hashtype == -1) { 4707 if (xmit_hashtype == -1) {
4762 printk(KERN_ERR DRV_NAME 4708 pr_err(DRV_NAME
4763 ": Error: Invalid xmit_hash_policy \"%s\"\n", 4709 ": Error: Invalid xmit_hash_policy \"%s\"\n",
4764 xmit_hash_policy == NULL ? "NULL" : 4710 xmit_hash_policy == NULL ? "NULL" :
4765 xmit_hash_policy); 4711 xmit_hash_policy);
4766 return -EINVAL; 4712 return -EINVAL;
4767 } 4713 }
@@ -4770,13 +4716,13 @@ static int bond_check_params(struct bond_params *params)
4770 4716
4771 if (lacp_rate) { 4717 if (lacp_rate) {
4772 if (bond_mode != BOND_MODE_8023AD) { 4718 if (bond_mode != BOND_MODE_8023AD) {
4773 printk(KERN_INFO DRV_NAME 4719 pr_info(DRV_NAME
4774 ": lacp_rate param is irrelevant in mode %s\n", 4720 ": lacp_rate param is irrelevant in mode %s\n",
4775 bond_mode_name(bond_mode)); 4721 bond_mode_name(bond_mode));
4776 } else { 4722 } else {
4777 lacp_fast = bond_parse_parm(lacp_rate, bond_lacp_tbl); 4723 lacp_fast = bond_parse_parm(lacp_rate, bond_lacp_tbl);
4778 if (lacp_fast == -1) { 4724 if (lacp_fast == -1) {
4779 printk(KERN_ERR DRV_NAME 4725 pr_err(DRV_NAME
4780 ": Error: Invalid lacp rate \"%s\"\n", 4726 ": Error: Invalid lacp rate \"%s\"\n",
4781 lacp_rate == NULL ? "NULL" : lacp_rate); 4727 lacp_rate == NULL ? "NULL" : lacp_rate);
4782 return -EINVAL; 4728 return -EINVAL;
@@ -4787,14 +4733,14 @@ static int bond_check_params(struct bond_params *params)
4787 if (ad_select) { 4733 if (ad_select) {
4788 params->ad_select = bond_parse_parm(ad_select, ad_select_tbl); 4734 params->ad_select = bond_parse_parm(ad_select, ad_select_tbl);
4789 if (params->ad_select == -1) { 4735 if (params->ad_select == -1) {
4790 printk(KERN_ERR DRV_NAME 4736 pr_err(DRV_NAME
4791 ": Error: Invalid ad_select \"%s\"\n", 4737 ": Error: Invalid ad_select \"%s\"\n",
4792 ad_select == NULL ? "NULL" : ad_select); 4738 ad_select == NULL ? "NULL" : ad_select);
4793 return -EINVAL; 4739 return -EINVAL;
4794 } 4740 }
4795 4741
4796 if (bond_mode != BOND_MODE_8023AD) { 4742 if (bond_mode != BOND_MODE_8023AD) {
4797 printk(KERN_WARNING DRV_NAME 4743 pr_warning(DRV_NAME
4798 ": ad_select param only affects 802.3ad mode\n"); 4744 ": ad_select param only affects 802.3ad mode\n");
4799 } 4745 }
4800 } else { 4746 } else {
@@ -4802,7 +4748,7 @@ static int bond_check_params(struct bond_params *params)
4802 } 4748 }
4803 4749
4804 if (max_bonds < 0 || max_bonds > INT_MAX) { 4750 if (max_bonds < 0 || max_bonds > INT_MAX) {
4805 printk(KERN_WARNING DRV_NAME 4751 pr_warning(DRV_NAME
4806 ": Warning: max_bonds (%d) not in range %d-%d, so it " 4752 ": Warning: max_bonds (%d) not in range %d-%d, so it "
4807 "was reset to BOND_DEFAULT_MAX_BONDS (%d)\n", 4753 "was reset to BOND_DEFAULT_MAX_BONDS (%d)\n",
4808 max_bonds, 0, INT_MAX, BOND_DEFAULT_MAX_BONDS); 4754 max_bonds, 0, INT_MAX, BOND_DEFAULT_MAX_BONDS);
@@ -4810,7 +4756,7 @@ static int bond_check_params(struct bond_params *params)
4810 } 4756 }
4811 4757
4812 if (miimon < 0) { 4758 if (miimon < 0) {
4813 printk(KERN_WARNING DRV_NAME 4759 pr_warning(DRV_NAME
4814 ": Warning: miimon module parameter (%d), " 4760 ": Warning: miimon module parameter (%d), "
4815 "not in range 0-%d, so it was reset to %d\n", 4761 "not in range 0-%d, so it was reset to %d\n",
4816 miimon, INT_MAX, BOND_LINK_MON_INTERV); 4762 miimon, INT_MAX, BOND_LINK_MON_INTERV);
@@ -4818,7 +4764,7 @@ static int bond_check_params(struct bond_params *params)
4818 } 4764 }
4819 4765
4820 if (updelay < 0) { 4766 if (updelay < 0) {
4821 printk(KERN_WARNING DRV_NAME 4767 pr_warning(DRV_NAME
4822 ": Warning: updelay module parameter (%d), " 4768 ": Warning: updelay module parameter (%d), "
4823 "not in range 0-%d, so it was reset to 0\n", 4769 "not in range 0-%d, so it was reset to 0\n",
4824 updelay, INT_MAX); 4770 updelay, INT_MAX);
@@ -4826,7 +4772,7 @@ static int bond_check_params(struct bond_params *params)
4826 } 4772 }
4827 4773
4828 if (downdelay < 0) { 4774 if (downdelay < 0) {
4829 printk(KERN_WARNING DRV_NAME 4775 pr_warning(DRV_NAME
4830 ": Warning: downdelay module parameter (%d), " 4776 ": Warning: downdelay module parameter (%d), "
4831 "not in range 0-%d, so it was reset to 0\n", 4777 "not in range 0-%d, so it was reset to 0\n",
4832 downdelay, INT_MAX); 4778 downdelay, INT_MAX);
@@ -4834,7 +4780,7 @@ static int bond_check_params(struct bond_params *params)
4834 } 4780 }
4835 4781
4836 if ((use_carrier != 0) && (use_carrier != 1)) { 4782 if ((use_carrier != 0) && (use_carrier != 1)) {
4837 printk(KERN_WARNING DRV_NAME 4783 pr_warning(DRV_NAME
4838 ": Warning: use_carrier module parameter (%d), " 4784 ": Warning: use_carrier module parameter (%d), "
4839 "not of valid value (0/1), so it was set to 1\n", 4785 "not of valid value (0/1), so it was set to 1\n",
4840 use_carrier); 4786 use_carrier);
@@ -4842,14 +4788,14 @@ static int bond_check_params(struct bond_params *params)
4842 } 4788 }
4843 4789
4844 if (num_grat_arp < 0 || num_grat_arp > 255) { 4790 if (num_grat_arp < 0 || num_grat_arp > 255) {
4845 printk(KERN_WARNING DRV_NAME 4791 pr_warning(DRV_NAME
4846 ": Warning: num_grat_arp (%d) not in range 0-255 so it " 4792 ": Warning: num_grat_arp (%d) not in range 0-255 so it "
4847 "was reset to 1 \n", num_grat_arp); 4793 "was reset to 1 \n", num_grat_arp);
4848 num_grat_arp = 1; 4794 num_grat_arp = 1;
4849 } 4795 }
4850 4796
4851 if (num_unsol_na < 0 || num_unsol_na > 255) { 4797 if (num_unsol_na < 0 || num_unsol_na > 255) {
4852 printk(KERN_WARNING DRV_NAME 4798 pr_warning(DRV_NAME
4853 ": Warning: num_unsol_na (%d) not in range 0-255 so it " 4799 ": Warning: num_unsol_na (%d) not in range 0-255 so it "
4854 "was reset to 1 \n", num_unsol_na); 4800 "was reset to 1 \n", num_unsol_na);
4855 num_unsol_na = 1; 4801 num_unsol_na = 1;
@@ -4858,12 +4804,12 @@ static int bond_check_params(struct bond_params *params)
4858 /* reset values for 802.3ad */ 4804 /* reset values for 802.3ad */
4859 if (bond_mode == BOND_MODE_8023AD) { 4805 if (bond_mode == BOND_MODE_8023AD) {
4860 if (!miimon) { 4806 if (!miimon) {
4861 printk(KERN_WARNING DRV_NAME 4807 pr_warning(DRV_NAME
4862 ": Warning: miimon must be specified, " 4808 ": Warning: miimon must be specified, "
4863 "otherwise bonding will not detect link " 4809 "otherwise bonding will not detect link "
4864 "failure, speed and duplex which are " 4810 "failure, speed and duplex which are "
4865 "essential for 802.3ad operation\n"); 4811 "essential for 802.3ad operation\n");
4866 printk(KERN_WARNING "Forcing miimon to 100msec\n"); 4812 pr_warning("Forcing miimon to 100msec\n");
4867 miimon = 100; 4813 miimon = 100;
4868 } 4814 }
4869 } 4815 }
@@ -4872,12 +4818,12 @@ static int bond_check_params(struct bond_params *params)
4872 if ((bond_mode == BOND_MODE_TLB) || 4818 if ((bond_mode == BOND_MODE_TLB) ||
4873 (bond_mode == BOND_MODE_ALB)) { 4819 (bond_mode == BOND_MODE_ALB)) {
4874 if (!miimon) { 4820 if (!miimon) {
4875 printk(KERN_WARNING DRV_NAME 4821 pr_warning(DRV_NAME
4876 ": Warning: miimon must be specified, " 4822 ": Warning: miimon must be specified, "
4877 "otherwise bonding will not detect link " 4823 "otherwise bonding will not detect link "
4878 "failure and link speed which are essential " 4824 "failure and link speed which are essential "
4879 "for TLB/ALB load balancing\n"); 4825 "for TLB/ALB load balancing\n");
4880 printk(KERN_WARNING "Forcing miimon to 100msec\n"); 4826 pr_warning("Forcing miimon to 100msec\n");
4881 miimon = 100; 4827 miimon = 100;
4882 } 4828 }
4883 } 4829 }
@@ -4897,7 +4843,7 @@ static int bond_check_params(struct bond_params *params)
4897 /* just warn the user the up/down delay will have 4843 /* just warn the user the up/down delay will have
4898 * no effect since miimon is zero... 4844 * no effect since miimon is zero...
4899 */ 4845 */
4900 printk(KERN_WARNING DRV_NAME 4846 pr_warning(DRV_NAME
4901 ": Warning: miimon module parameter not set " 4847 ": Warning: miimon module parameter not set "
4902 "and updelay (%d) or downdelay (%d) module " 4848 "and updelay (%d) or downdelay (%d) module "
4903 "parameter is set; updelay and downdelay have " 4849 "parameter is set; updelay and downdelay have "
@@ -4907,7 +4853,7 @@ static int bond_check_params(struct bond_params *params)
4907 } else { 4853 } else {
4908 /* don't allow arp monitoring */ 4854 /* don't allow arp monitoring */
4909 if (arp_interval) { 4855 if (arp_interval) {
4910 printk(KERN_WARNING DRV_NAME 4856 pr_warning(DRV_NAME
4911 ": Warning: miimon (%d) and arp_interval (%d) " 4857 ": Warning: miimon (%d) and arp_interval (%d) "
4912 "can't be used simultaneously, disabling ARP " 4858 "can't be used simultaneously, disabling ARP "
4913 "monitoring\n", 4859 "monitoring\n",
@@ -4916,7 +4862,7 @@ static int bond_check_params(struct bond_params *params)
4916 } 4862 }
4917 4863
4918 if ((updelay % miimon) != 0) { 4864 if ((updelay % miimon) != 0) {
4919 printk(KERN_WARNING DRV_NAME 4865 pr_warning(DRV_NAME
4920 ": Warning: updelay (%d) is not a multiple " 4866 ": Warning: updelay (%d) is not a multiple "
4921 "of miimon (%d), updelay rounded to %d ms\n", 4867 "of miimon (%d), updelay rounded to %d ms\n",
4922 updelay, miimon, (updelay / miimon) * miimon); 4868 updelay, miimon, (updelay / miimon) * miimon);
@@ -4925,7 +4871,7 @@ static int bond_check_params(struct bond_params *params)
4925 updelay /= miimon; 4871 updelay /= miimon;
4926 4872
4927 if ((downdelay % miimon) != 0) { 4873 if ((downdelay % miimon) != 0) {
4928 printk(KERN_WARNING DRV_NAME 4874 pr_warning(DRV_NAME
4929 ": Warning: downdelay (%d) is not a multiple " 4875 ": Warning: downdelay (%d) is not a multiple "
4930 "of miimon (%d), downdelay rounded to %d ms\n", 4876 "of miimon (%d), downdelay rounded to %d ms\n",
4931 downdelay, miimon, 4877 downdelay, miimon,
@@ -4936,7 +4882,7 @@ static int bond_check_params(struct bond_params *params)
4936 } 4882 }
4937 4883
4938 if (arp_interval < 0) { 4884 if (arp_interval < 0) {
4939 printk(KERN_WARNING DRV_NAME 4885 pr_warning(DRV_NAME
4940 ": Warning: arp_interval module parameter (%d) " 4886 ": Warning: arp_interval module parameter (%d) "
4941 ", not in range 0-%d, so it was reset to %d\n", 4887 ", not in range 0-%d, so it was reset to %d\n",
4942 arp_interval, INT_MAX, BOND_LINK_ARP_INTERV); 4888 arp_interval, INT_MAX, BOND_LINK_ARP_INTERV);
@@ -4949,7 +4895,7 @@ static int bond_check_params(struct bond_params *params)
4949 /* not complete check, but should be good enough to 4895 /* not complete check, but should be good enough to
4950 catch mistakes */ 4896 catch mistakes */
4951 if (!isdigit(arp_ip_target[arp_ip_count][0])) { 4897 if (!isdigit(arp_ip_target[arp_ip_count][0])) {
4952 printk(KERN_WARNING DRV_NAME 4898 pr_warning(DRV_NAME
4953 ": Warning: bad arp_ip_target module parameter " 4899 ": Warning: bad arp_ip_target module parameter "
4954 "(%s), ARP monitoring will not be performed\n", 4900 "(%s), ARP monitoring will not be performed\n",
4955 arp_ip_target[arp_ip_count]); 4901 arp_ip_target[arp_ip_count]);
@@ -4962,7 +4908,7 @@ static int bond_check_params(struct bond_params *params)
4962 4908
4963 if (arp_interval && !arp_ip_count) { 4909 if (arp_interval && !arp_ip_count) {
4964 /* don't allow arping if no arp_ip_target given... */ 4910 /* don't allow arping if no arp_ip_target given... */
4965 printk(KERN_WARNING DRV_NAME 4911 pr_warning(DRV_NAME
4966 ": Warning: arp_interval module parameter (%d) " 4912 ": Warning: arp_interval module parameter (%d) "
4967 "specified without providing an arp_ip_target " 4913 "specified without providing an arp_ip_target "
4968 "parameter, arp_interval was reset to 0\n", 4914 "parameter, arp_interval was reset to 0\n",
@@ -4972,12 +4918,12 @@ static int bond_check_params(struct bond_params *params)
4972 4918
4973 if (arp_validate) { 4919 if (arp_validate) {
4974 if (bond_mode != BOND_MODE_ACTIVEBACKUP) { 4920 if (bond_mode != BOND_MODE_ACTIVEBACKUP) {
4975 printk(KERN_ERR DRV_NAME 4921 pr_err(DRV_NAME
4976 ": arp_validate only supported in active-backup mode\n"); 4922 ": arp_validate only supported in active-backup mode\n");
4977 return -EINVAL; 4923 return -EINVAL;
4978 } 4924 }
4979 if (!arp_interval) { 4925 if (!arp_interval) {
4980 printk(KERN_ERR DRV_NAME 4926 pr_err(DRV_NAME
4981 ": arp_validate requires arp_interval\n"); 4927 ": arp_validate requires arp_interval\n");
4982 return -EINVAL; 4928 return -EINVAL;
4983 } 4929 }
@@ -4985,7 +4931,7 @@ static int bond_check_params(struct bond_params *params)
4985 arp_validate_value = bond_parse_parm(arp_validate, 4931 arp_validate_value = bond_parse_parm(arp_validate,
4986 arp_validate_tbl); 4932 arp_validate_tbl);
4987 if (arp_validate_value == -1) { 4933 if (arp_validate_value == -1) {
4988 printk(KERN_ERR DRV_NAME 4934 pr_err(DRV_NAME
4989 ": Error: invalid arp_validate \"%s\"\n", 4935 ": Error: invalid arp_validate \"%s\"\n",
4990 arp_validate == NULL ? "NULL" : arp_validate); 4936 arp_validate == NULL ? "NULL" : arp_validate);
4991 return -EINVAL; 4937 return -EINVAL;
@@ -4994,20 +4940,20 @@ static int bond_check_params(struct bond_params *params)
4994 arp_validate_value = 0; 4940 arp_validate_value = 0;
4995 4941
4996 if (miimon) { 4942 if (miimon) {
4997 printk(KERN_INFO DRV_NAME 4943 pr_info(DRV_NAME
4998 ": MII link monitoring set to %d ms\n", 4944 ": MII link monitoring set to %d ms\n",
4999 miimon); 4945 miimon);
5000 } else if (arp_interval) { 4946 } else if (arp_interval) {
5001 int i; 4947 int i;
5002 4948
5003 printk(KERN_INFO DRV_NAME 4949 pr_info(DRV_NAME ": ARP monitoring set to %d ms,"
5004 ": ARP monitoring set to %d ms, validate %s, with %d target(s):", 4950 " validate %s, with %d target(s):",
5005 arp_interval, 4951 arp_interval,
5006 arp_validate_tbl[arp_validate_value].modename, 4952 arp_validate_tbl[arp_validate_value].modename,
5007 arp_ip_count); 4953 arp_ip_count);
5008 4954
5009 for (i = 0; i < arp_ip_count; i++) 4955 for (i = 0; i < arp_ip_count; i++)
5010 printk (" %s", arp_ip_target[i]); 4956 printk(" %s", arp_ip_target[i]);
5011 4957
5012 printk("\n"); 4958 printk("\n");
5013 4959
@@ -5015,7 +4961,7 @@ static int bond_check_params(struct bond_params *params)
5015 /* miimon and arp_interval not set, we need one so things 4961 /* miimon and arp_interval not set, we need one so things
5016 * work as expected, see bonding.txt for details 4962 * work as expected, see bonding.txt for details
5017 */ 4963 */
5018 printk(KERN_WARNING DRV_NAME 4964 pr_warning(DRV_NAME
5019 ": Warning: either miimon or arp_interval and " 4965 ": Warning: either miimon or arp_interval and "
5020 "arp_ip_target module parameters must be specified, " 4966 "arp_ip_target module parameters must be specified, "
5021 "otherwise bonding will not detect link failures! see " 4967 "otherwise bonding will not detect link failures! see "
@@ -5026,7 +4972,7 @@ static int bond_check_params(struct bond_params *params)
5026 /* currently, using a primary only makes sense 4972 /* currently, using a primary only makes sense
5027 * in active backup, TLB or ALB modes 4973 * in active backup, TLB or ALB modes
5028 */ 4974 */
5029 printk(KERN_WARNING DRV_NAME 4975 pr_warning(DRV_NAME
5030 ": Warning: %s primary device specified but has no " 4976 ": Warning: %s primary device specified but has no "
5031 "effect in %s mode\n", 4977 "effect in %s mode\n",
5032 primary, bond_mode_name(bond_mode)); 4978 primary, bond_mode_name(bond_mode));
@@ -5037,14 +4983,14 @@ static int bond_check_params(struct bond_params *params)
5037 fail_over_mac_value = bond_parse_parm(fail_over_mac, 4983 fail_over_mac_value = bond_parse_parm(fail_over_mac,
5038 fail_over_mac_tbl); 4984 fail_over_mac_tbl);
5039 if (fail_over_mac_value == -1) { 4985 if (fail_over_mac_value == -1) {
5040 printk(KERN_ERR DRV_NAME 4986 pr_err(DRV_NAME
5041 ": Error: invalid fail_over_mac \"%s\"\n", 4987 ": Error: invalid fail_over_mac \"%s\"\n",
5042 arp_validate == NULL ? "NULL" : arp_validate); 4988 arp_validate == NULL ? "NULL" : arp_validate);
5043 return -EINVAL; 4989 return -EINVAL;
5044 } 4990 }
5045 4991
5046 if (bond_mode != BOND_MODE_ACTIVEBACKUP) 4992 if (bond_mode != BOND_MODE_ACTIVEBACKUP)
5047 printk(KERN_WARNING DRV_NAME 4993 pr_warning(DRV_NAME
5048 ": Warning: fail_over_mac only affects " 4994 ": Warning: fail_over_mac only affects "
5049 "active-backup mode.\n"); 4995 "active-backup mode.\n");
5050 } else { 4996 } else {
@@ -5094,37 +5040,53 @@ static void bond_set_lockdep_class(struct net_device *dev)
5094 netdev_for_each_tx_queue(dev, bond_set_lockdep_class_one, NULL); 5040 netdev_for_each_tx_queue(dev, bond_set_lockdep_class_one, NULL);
5095} 5041}
5096 5042
5043/*
5044 * Called from registration process
5045 */
5046static int bond_init(struct net_device *bond_dev)
5047{
5048 struct bonding *bond = netdev_priv(bond_dev);
5049
5050 pr_debug("Begin bond_init for %s\n", bond_dev->name);
5051
5052 bond->wq = create_singlethread_workqueue(bond_dev->name);
5053 if (!bond->wq)
5054 return -ENOMEM;
5055
5056 bond_set_lockdep_class(bond_dev);
5057
5058 netif_carrier_off(bond_dev);
5059
5060 bond_create_proc_entry(bond);
5061 list_add_tail(&bond->bond_list, &bond_dev_list);
5062
5063 return 0;
5064}
5065
5097/* Create a new bond based on the specified name and bonding parameters. 5066/* Create a new bond based on the specified name and bonding parameters.
5098 * If name is NULL, obtain a suitable "bond%d" name for us. 5067 * If name is NULL, obtain a suitable "bond%d" name for us.
5099 * Caller must NOT hold rtnl_lock; we need to release it here before we 5068 * Caller must NOT hold rtnl_lock; we need to release it here before we
5100 * set up our sysfs entries. 5069 * set up our sysfs entries.
5101 */ 5070 */
5102int bond_create(char *name, struct bond_params *params) 5071int bond_create(const char *name)
5103{ 5072{
5104 struct net_device *bond_dev; 5073 struct net_device *bond_dev;
5105 struct bonding *bond;
5106 int res; 5074 int res;
5107 5075
5108 rtnl_lock(); 5076 rtnl_lock();
5109 down_write(&bonding_rwsem);
5110
5111 /* Check to see if the bond already exists. */ 5077 /* Check to see if the bond already exists. */
5112 if (name) { 5078 /* FIXME: pass netns from caller */
5113 list_for_each_entry(bond, &bond_dev_list, bond_list) 5079 if (name && __dev_get_by_name(&init_net, name)) {
5114 if (strnicmp(bond->dev->name, name, IFNAMSIZ) == 0) { 5080 pr_err(DRV_NAME ": cannot add bond %s; already exists\n",
5115 printk(KERN_ERR DRV_NAME 5081 name);
5116 ": cannot add bond %s; it already exists\n", 5082 res = -EEXIST;
5117 name); 5083 goto out_rtnl;
5118 res = -EPERM;
5119 goto out_rtnl;
5120 }
5121 } 5084 }
5122 5085
5123 bond_dev = alloc_netdev(sizeof(struct bonding), name ? name : "", 5086 bond_dev = alloc_netdev(sizeof(struct bonding), name ? name : "",
5124 ether_setup); 5087 bond_setup);
5125 if (!bond_dev) { 5088 if (!bond_dev) {
5126 printk(KERN_ERR DRV_NAME 5089 pr_err(DRV_NAME ": %s: eek! can't alloc netdev!\n",
5127 ": %s: eek! can't alloc netdev!\n",
5128 name); 5090 name);
5129 res = -ENOMEM; 5091 res = -ENOMEM;
5130 goto out_rtnl; 5092 goto out_rtnl;
@@ -5136,43 +5098,24 @@ int bond_create(char *name, struct bond_params *params)
5136 goto out_netdev; 5098 goto out_netdev;
5137 } 5099 }
5138 5100
5139 /* bond_init() must be called after dev_alloc_name() (for the
5140 * /proc files), but before register_netdevice(), because we
5141 * need to set function pointers.
5142 */
5143
5144 res = bond_init(bond_dev, params);
5145 if (res < 0) {
5146 goto out_netdev;
5147 }
5148
5149 res = register_netdevice(bond_dev); 5101 res = register_netdevice(bond_dev);
5150 if (res < 0) { 5102 if (res < 0)
5151 goto out_bond; 5103 goto out_bond;
5152 }
5153
5154 bond_set_lockdep_class(bond_dev);
5155
5156 netif_carrier_off(bond_dev);
5157 5104
5158 up_write(&bonding_rwsem);
5159 rtnl_unlock(); /* allows sysfs registration of net device */
5160 res = bond_create_sysfs_entry(netdev_priv(bond_dev)); 5105 res = bond_create_sysfs_entry(netdev_priv(bond_dev));
5161 if (res < 0) 5106 if (res < 0)
5162 goto out_unreg; 5107 goto out_unreg;
5163 5108
5109 rtnl_unlock();
5164 return 0; 5110 return 0;
5165 5111
5166out_unreg: 5112out_unreg:
5167 rtnl_lock();
5168 down_write(&bonding_rwsem);
5169 unregister_netdevice(bond_dev); 5113 unregister_netdevice(bond_dev);
5170out_bond: 5114out_bond:
5171 bond_deinit(bond_dev); 5115 bond_deinit(bond_dev);
5172out_netdev: 5116out_netdev:
5173 free_netdev(bond_dev); 5117 free_netdev(bond_dev);
5174out_rtnl: 5118out_rtnl:
5175 up_write(&bonding_rwsem);
5176 rtnl_unlock(); 5119 rtnl_unlock();
5177 return res; 5120 return res;
5178} 5121}
@@ -5182,21 +5125,16 @@ static int __init bonding_init(void)
5182 int i; 5125 int i;
5183 int res; 5126 int res;
5184 5127
5185 printk(KERN_INFO "%s", version); 5128 pr_info("%s", version);
5186 5129
5187 res = bond_check_params(&bonding_defaults); 5130 res = bond_check_params(&bonding_defaults);
5188 if (res) { 5131 if (res)
5189 goto out; 5132 goto out;
5190 }
5191 5133
5192#ifdef CONFIG_PROC_FS
5193 bond_create_proc_dir(); 5134 bond_create_proc_dir();
5194#endif
5195
5196 init_rwsem(&bonding_rwsem);
5197 5135
5198 for (i = 0; i < max_bonds; i++) { 5136 for (i = 0; i < max_bonds; i++) {
5199 res = bond_create(NULL, &bonding_defaults); 5137 res = bond_create(NULL);
5200 if (res) 5138 if (res)
5201 goto err; 5139 goto err;
5202 } 5140 }
@@ -5238,13 +5176,3 @@ MODULE_LICENSE("GPL");
5238MODULE_VERSION(DRV_VERSION); 5176MODULE_VERSION(DRV_VERSION);
5239MODULE_DESCRIPTION(DRV_DESCRIPTION ", v" DRV_VERSION); 5177MODULE_DESCRIPTION(DRV_DESCRIPTION ", v" DRV_VERSION);
5240MODULE_AUTHOR("Thomas Davis, tadavis@lbl.gov and many others"); 5178MODULE_AUTHOR("Thomas Davis, tadavis@lbl.gov and many others");
5241MODULE_SUPPORTED_DEVICE("most ethernet devices");
5242
5243/*
5244 * Local variables:
5245 * c-indent-level: 8
5246 * c-basic-offset: 8
5247 * tab-width: 8
5248 * End:
5249 */
5250
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index d28731535226..55bf34f59bbf 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -1,4 +1,3 @@
1
2/* 1/*
3 * Copyright(c) 2004-2005 Intel Corporation. All rights reserved. 2 * Copyright(c) 2004-2005 Intel Corporation. All rights reserved.
4 * 3 *
@@ -34,33 +33,14 @@
34#include <linux/ctype.h> 33#include <linux/ctype.h>
35#include <linux/inet.h> 34#include <linux/inet.h>
36#include <linux/rtnetlink.h> 35#include <linux/rtnetlink.h>
36#include <linux/etherdevice.h>
37#include <net/net_namespace.h> 37#include <net/net_namespace.h>
38 38
39#include "bonding.h" 39#include "bonding.h"
40 40
41#define to_dev(obj) container_of(obj,struct device,kobj) 41#define to_dev(obj) container_of(obj, struct device, kobj)
42#define to_bond(cd) ((struct bonding *)(netdev_priv(to_net_dev(cd)))) 42#define to_bond(cd) ((struct bonding *)(netdev_priv(to_net_dev(cd))))
43 43
44/*---------------------------- Declarations -------------------------------*/
45
46static int expected_refcount = -1;
47/*--------------------------- Data Structures -----------------------------*/
48
49/* Bonding sysfs lock. Why can't we just use the subsystem lock?
50 * Because kobject_register tries to acquire the subsystem lock. If
51 * we already hold the lock (which we would if the user was creating
52 * a new bond through the sysfs interface), we deadlock.
53 * This lock is only needed when deleting a bond - we need to make sure
54 * that we don't collide with an ongoing ioctl.
55 */
56
57struct rw_semaphore bonding_rwsem;
58
59
60
61
62/*------------------------------ Functions --------------------------------*/
63
64/* 44/*
65 * "show" function for the bond_masters attribute. 45 * "show" function for the bond_masters attribute.
66 * The class parameter is ignored. 46 * The class parameter is ignored.
@@ -70,7 +50,7 @@ static ssize_t bonding_show_bonds(struct class *cls, char *buf)
70 int res = 0; 50 int res = 0;
71 struct bonding *bond; 51 struct bonding *bond;
72 52
73 down_read(&(bonding_rwsem)); 53 rtnl_lock();
74 54
75 list_for_each_entry(bond, &bond_dev_list, bond_list) { 55 list_for_each_entry(bond, &bond_dev_list, bond_list) {
76 if (res > (PAGE_SIZE - IFNAMSIZ)) { 56 if (res > (PAGE_SIZE - IFNAMSIZ)) {
@@ -84,10 +64,22 @@ static ssize_t bonding_show_bonds(struct class *cls, char *buf)
84 } 64 }
85 if (res) 65 if (res)
86 buf[res-1] = '\n'; /* eat the leftover space */ 66 buf[res-1] = '\n'; /* eat the leftover space */
87 up_read(&(bonding_rwsem)); 67
68 rtnl_unlock();
88 return res; 69 return res;
89} 70}
90 71
72static struct net_device *bond_get_by_name(const char *ifname)
73{
74 struct bonding *bond;
75
76 list_for_each_entry(bond, &bond_dev_list, bond_list) {
77 if (strncmp(bond->dev->name, ifname, IFNAMSIZ) == 0)
78 return bond->dev;
79 }
80 return NULL;
81}
82
91/* 83/*
92 * "store" function for the bond_masters attribute. This is what 84 * "store" function for the bond_masters attribute. This is what
93 * creates and deletes entire bonds. 85 * creates and deletes entire bonds.
@@ -96,12 +88,12 @@ static ssize_t bonding_show_bonds(struct class *cls, char *buf)
96 * 88 *
97 */ 89 */
98 90
99static ssize_t bonding_store_bonds(struct class *cls, const char *buffer, size_t count) 91static ssize_t bonding_store_bonds(struct class *cls,
92 const char *buffer, size_t count)
100{ 93{
101 char command[IFNAMSIZ + 1] = {0, }; 94 char command[IFNAMSIZ + 1] = {0, };
102 char *ifname; 95 char *ifname;
103 int rv, res = count; 96 int rv, res = count;
104 struct bonding *bond;
105 97
106 sscanf(buffer, "%16s", command); /* IFNAMSIZ*/ 98 sscanf(buffer, "%16s", command); /* IFNAMSIZ*/
107 ifname = command + 1; 99 ifname = command + 1;
@@ -110,67 +102,48 @@ static ssize_t bonding_store_bonds(struct class *cls, const char *buffer, size_t
110 goto err_no_cmd; 102 goto err_no_cmd;
111 103
112 if (command[0] == '+') { 104 if (command[0] == '+') {
113 printk(KERN_INFO DRV_NAME 105 pr_info(DRV_NAME
114 ": %s is being created...\n", ifname); 106 ": %s is being created...\n", ifname);
115 rv = bond_create(ifname, &bonding_defaults); 107 rv = bond_create(ifname);
116 if (rv) { 108 if (rv) {
117 printk(KERN_INFO DRV_NAME ": Bond creation failed.\n"); 109 pr_info(DRV_NAME ": Bond creation failed.\n");
118 res = rv; 110 res = rv;
119 } 111 }
120 goto out; 112 } else if (command[0] == '-') {
121 } 113 struct net_device *bond_dev;
122 114
123 if (command[0] == '-') {
124 rtnl_lock(); 115 rtnl_lock();
125 down_write(&bonding_rwsem); 116 bond_dev = bond_get_by_name(ifname);
126 117 if (bond_dev) {
127 list_for_each_entry(bond, &bond_dev_list, bond_list) 118 pr_info(DRV_NAME ": %s is being deleted...\n",
128 if (strnicmp(bond->dev->name, ifname, IFNAMSIZ) == 0) { 119 ifname);
129 /* check the ref count on the bond's kobject. 120 unregister_netdevice(bond_dev);
130 * If it's > expected, then there's a file open, 121 } else {
131 * and we have to fail. 122 pr_err(DRV_NAME ": unable to delete non-existent %s\n",
132 */ 123 ifname);
133 if (atomic_read(&bond->dev->dev.kobj.kref.refcount) 124 res = -ENODEV;
134 > expected_refcount){ 125 }
135 printk(KERN_INFO DRV_NAME 126 rtnl_unlock();
136 ": Unable remove bond %s due to open references.\n", 127 } else
137 ifname); 128 goto err_no_cmd;
138 res = -EPERM;
139 goto out_unlock;
140 }
141 printk(KERN_INFO DRV_NAME
142 ": %s is being deleted...\n",
143 bond->dev->name);
144 bond_destroy(bond);
145 goto out_unlock;
146 }
147
148 printk(KERN_ERR DRV_NAME
149 ": unable to delete non-existent bond %s\n", ifname);
150 res = -ENODEV;
151 goto out_unlock;
152 }
153
154err_no_cmd:
155 printk(KERN_ERR DRV_NAME
156 ": no command found in bonding_masters. Use +ifname or -ifname.\n");
157 return -EPERM;
158
159out_unlock:
160 up_write(&bonding_rwsem);
161 rtnl_unlock();
162 129
163 /* Always return either count or an error. If you return 0, you'll 130 /* Always return either count or an error. If you return 0, you'll
164 * get called forever, which is bad. 131 * get called forever, which is bad.
165 */ 132 */
166out:
167 return res; 133 return res;
134
135err_no_cmd:
136 pr_err(DRV_NAME ": no command found in bonding_masters."
137 " Use +ifname or -ifname.\n");
138 return -EPERM;
168} 139}
140
169/* class attribute for bond_masters file. This ends up in /sys/class/net */ 141/* class attribute for bond_masters file. This ends up in /sys/class/net */
170static CLASS_ATTR(bonding_masters, S_IWUSR | S_IRUGO, 142static CLASS_ATTR(bonding_masters, S_IWUSR | S_IRUGO,
171 bonding_show_bonds, bonding_store_bonds); 143 bonding_show_bonds, bonding_store_bonds);
172 144
173int bond_create_slave_symlinks(struct net_device *master, struct net_device *slave) 145int bond_create_slave_symlinks(struct net_device *master,
146 struct net_device *slave)
174{ 147{
175 char linkname[IFNAMSIZ+7]; 148 char linkname[IFNAMSIZ+7];
176 int ret = 0; 149 int ret = 0;
@@ -181,19 +154,20 @@ int bond_create_slave_symlinks(struct net_device *master, struct net_device *sla
181 if (ret) 154 if (ret)
182 return ret; 155 return ret;
183 /* next, create a link from the master to the slave */ 156 /* next, create a link from the master to the slave */
184 sprintf(linkname,"slave_%s",slave->name); 157 sprintf(linkname, "slave_%s", slave->name);
185 ret = sysfs_create_link(&(master->dev.kobj), &(slave->dev.kobj), 158 ret = sysfs_create_link(&(master->dev.kobj), &(slave->dev.kobj),
186 linkname); 159 linkname);
187 return ret; 160 return ret;
188 161
189} 162}
190 163
191void bond_destroy_slave_symlinks(struct net_device *master, struct net_device *slave) 164void bond_destroy_slave_symlinks(struct net_device *master,
165 struct net_device *slave)
192{ 166{
193 char linkname[IFNAMSIZ+7]; 167 char linkname[IFNAMSIZ+7];
194 168
195 sysfs_remove_link(&(slave->dev.kobj), "master"); 169 sysfs_remove_link(&(slave->dev.kobj), "master");
196 sprintf(linkname,"slave_%s",slave->name); 170 sprintf(linkname, "slave_%s", slave->name);
197 sysfs_remove_link(&(master->dev.kobj), linkname); 171 sysfs_remove_link(&(master->dev.kobj), linkname);
198} 172}
199 173
@@ -251,8 +225,8 @@ static ssize_t bonding_store_slaves(struct device *d,
251 225
252 /* Note: We can't hold bond->lock here, as bond_create grabs it. */ 226 /* Note: We can't hold bond->lock here, as bond_create grabs it. */
253 227
254 rtnl_lock(); 228 if (!rtnl_trylock())
255 down_write(&(bonding_rwsem)); 229 return restart_syscall();
256 230
257 sscanf(buffer, "%16s", command); /* IFNAMSIZ*/ 231 sscanf(buffer, "%16s", command); /* IFNAMSIZ*/
258 ifname = command + 1; 232 ifname = command + 1;
@@ -264,46 +238,47 @@ static ssize_t bonding_store_slaves(struct device *d,
264 238
265 /* Got a slave name in ifname. Is it already in the list? */ 239 /* Got a slave name in ifname. Is it already in the list? */
266 found = 0; 240 found = 0;
267 read_lock(&bond->lock);
268 bond_for_each_slave(bond, slave, i)
269 if (strnicmp(slave->dev->name, ifname, IFNAMSIZ) == 0) {
270 printk(KERN_ERR DRV_NAME
271 ": %s: Interface %s is already enslaved!\n",
272 bond->dev->name, ifname);
273 ret = -EPERM;
274 read_unlock(&bond->lock);
275 goto out;
276 }
277 241
278 read_unlock(&bond->lock); 242 /* FIXME: get netns from sysfs object */
279 printk(KERN_INFO DRV_NAME ": %s: Adding slave %s.\n", 243 dev = __dev_get_by_name(&init_net, ifname);
280 bond->dev->name, ifname);
281 dev = dev_get_by_name(&init_net, ifname);
282 if (!dev) { 244 if (!dev) {
283 printk(KERN_INFO DRV_NAME 245 pr_info(DRV_NAME
284 ": %s: Interface %s does not exist!\n", 246 ": %s: Interface %s does not exist!\n",
285 bond->dev->name, ifname); 247 bond->dev->name, ifname);
286 ret = -EPERM; 248 ret = -ENODEV;
287 goto out; 249 goto out;
288 } 250 }
289 else
290 dev_put(dev);
291 251
292 if (dev->flags & IFF_UP) { 252 if (dev->flags & IFF_UP) {
293 printk(KERN_ERR DRV_NAME 253 pr_err(DRV_NAME
294 ": %s: Error: Unable to enslave %s " 254 ": %s: Error: Unable to enslave %s "
295 "because it is already up.\n", 255 "because it is already up.\n",
296 bond->dev->name, dev->name); 256 bond->dev->name, dev->name);
297 ret = -EPERM; 257 ret = -EPERM;
298 goto out; 258 goto out;
299 } 259 }
260
261 read_lock(&bond->lock);
262 bond_for_each_slave(bond, slave, i)
263 if (slave->dev == dev) {
264 pr_err(DRV_NAME
265 ": %s: Interface %s is already enslaved!\n",
266 bond->dev->name, ifname);
267 ret = -EPERM;
268 read_unlock(&bond->lock);
269 goto out;
270 }
271 read_unlock(&bond->lock);
272
273 pr_info(DRV_NAME ": %s: Adding slave %s.\n",
274 bond->dev->name, ifname);
275
300 /* If this is the first slave, then we need to set 276 /* If this is the first slave, then we need to set
301 the master's hardware address to be the same as the 277 the master's hardware address to be the same as the
302 slave's. */ 278 slave's. */
303 if (!(*((u32 *) & (bond->dev->dev_addr[0])))) { 279 if (is_zero_ether_addr(bond->dev->dev_addr))
304 memcpy(bond->dev->dev_addr, dev->dev_addr, 280 memcpy(bond->dev->dev_addr, dev->dev_addr,
305 dev->addr_len); 281 dev->addr_len);
306 }
307 282
308 /* Set the slave's MTU to match the bond */ 283 /* Set the slave's MTU to match the bond */
309 original_mtu = dev->mtu; 284 original_mtu = dev->mtu;
@@ -317,9 +292,9 @@ static ssize_t bonding_store_slaves(struct device *d,
317 bond_for_each_slave(bond, slave, i) 292 bond_for_each_slave(bond, slave, i)
318 if (strnicmp(slave->dev->name, ifname, IFNAMSIZ) == 0) 293 if (strnicmp(slave->dev->name, ifname, IFNAMSIZ) == 0)
319 slave->original_mtu = original_mtu; 294 slave->original_mtu = original_mtu;
320 if (res) { 295 if (res)
321 ret = res; 296 ret = res;
322 } 297
323 goto out; 298 goto out;
324 } 299 }
325 300
@@ -333,7 +308,7 @@ static ssize_t bonding_store_slaves(struct device *d,
333 break; 308 break;
334 } 309 }
335 if (dev) { 310 if (dev) {
336 printk(KERN_INFO DRV_NAME ": %s: Removing slave %s\n", 311 pr_info(DRV_NAME ": %s: Removing slave %s\n",
337 bond->dev->name, dev->name); 312 bond->dev->name, dev->name);
338 res = bond_release(bond->dev, dev); 313 res = bond_release(bond->dev, dev);
339 if (res) { 314 if (res) {
@@ -342,9 +317,9 @@ static ssize_t bonding_store_slaves(struct device *d,
342 } 317 }
343 /* set the slave MTU to the default */ 318 /* set the slave MTU to the default */
344 dev_set_mtu(dev, original_mtu); 319 dev_set_mtu(dev, original_mtu);
345 } 320 } else {
346 else { 321 pr_err(DRV_NAME ": unable to remove non-existent"
347 printk(KERN_ERR DRV_NAME ": unable to remove non-existent slave %s for bond %s.\n", 322 " slave %s for bond %s.\n",
348 ifname, bond->dev->name); 323 ifname, bond->dev->name);
349 ret = -ENODEV; 324 ret = -ENODEV;
350 } 325 }
@@ -352,16 +327,16 @@ static ssize_t bonding_store_slaves(struct device *d,
352 } 327 }
353 328
354err_no_cmd: 329err_no_cmd:
355 printk(KERN_ERR DRV_NAME ": no command found in slaves file for bond %s. Use +ifname or -ifname.\n", bond->dev->name); 330 pr_err(DRV_NAME ": no command found in slaves file for bond %s. Use +ifname or -ifname.\n", bond->dev->name);
356 ret = -EPERM; 331 ret = -EPERM;
357 332
358out: 333out:
359 up_write(&(bonding_rwsem));
360 rtnl_unlock(); 334 rtnl_unlock();
361 return ret; 335 return ret;
362} 336}
363 337
364static DEVICE_ATTR(slaves, S_IRUGO | S_IWUSR, bonding_show_slaves, bonding_store_slaves); 338static DEVICE_ATTR(slaves, S_IRUGO | S_IWUSR, bonding_show_slaves,
339 bonding_store_slaves);
365 340
366/* 341/*
367 * Show and set the bonding mode. The bond interface must be down to 342 * Show and set the bonding mode. The bond interface must be down to
@@ -385,16 +360,15 @@ static ssize_t bonding_store_mode(struct device *d,
385 struct bonding *bond = to_bond(d); 360 struct bonding *bond = to_bond(d);
386 361
387 if (bond->dev->flags & IFF_UP) { 362 if (bond->dev->flags & IFF_UP) {
388 printk(KERN_ERR DRV_NAME 363 pr_err(DRV_NAME ": unable to update mode of %s"
389 ": unable to update mode of %s because interface is up.\n", 364 " because interface is up.\n", bond->dev->name);
390 bond->dev->name);
391 ret = -EPERM; 365 ret = -EPERM;
392 goto out; 366 goto out;
393 } 367 }
394 368
395 new_value = bond_parse_parm(buf, bond_mode_tbl); 369 new_value = bond_parse_parm(buf, bond_mode_tbl);
396 if (new_value < 0) { 370 if (new_value < 0) {
397 printk(KERN_ERR DRV_NAME 371 pr_err(DRV_NAME
398 ": %s: Ignoring invalid mode value %.*s.\n", 372 ": %s: Ignoring invalid mode value %.*s.\n",
399 bond->dev->name, 373 bond->dev->name,
400 (int)strlen(buf) - 1, buf); 374 (int)strlen(buf) - 1, buf);
@@ -409,17 +383,19 @@ static ssize_t bonding_store_mode(struct device *d,
409 383
410 bond->params.mode = new_value; 384 bond->params.mode = new_value;
411 bond_set_mode_ops(bond, bond->params.mode); 385 bond_set_mode_ops(bond, bond->params.mode);
412 printk(KERN_INFO DRV_NAME ": %s: setting mode to %s (%d).\n", 386 pr_info(DRV_NAME ": %s: setting mode to %s (%d).\n",
413 bond->dev->name, bond_mode_tbl[new_value].modename, new_value); 387 bond->dev->name, bond_mode_tbl[new_value].modename,
388 new_value);
414 } 389 }
415out: 390out:
416 return ret; 391 return ret;
417} 392}
418static DEVICE_ATTR(mode, S_IRUGO | S_IWUSR, bonding_show_mode, bonding_store_mode); 393static DEVICE_ATTR(mode, S_IRUGO | S_IWUSR,
394 bonding_show_mode, bonding_store_mode);
419 395
420/* 396/*
421 * Show and set the bonding transmit hash method. The bond interface must be down to 397 * Show and set the bonding transmit hash method.
422 * change the xmit hash policy. 398 * The bond interface must be down to change the xmit hash policy.
423 */ 399 */
424static ssize_t bonding_show_xmit_hash(struct device *d, 400static ssize_t bonding_show_xmit_hash(struct device *d,
425 struct device_attribute *attr, 401 struct device_attribute *attr,
@@ -440,7 +416,7 @@ static ssize_t bonding_store_xmit_hash(struct device *d,
440 struct bonding *bond = to_bond(d); 416 struct bonding *bond = to_bond(d);
441 417
442 if (bond->dev->flags & IFF_UP) { 418 if (bond->dev->flags & IFF_UP) {
443 printk(KERN_ERR DRV_NAME 419 pr_err(DRV_NAME
444 "%s: Interface is up. Unable to update xmit policy.\n", 420 "%s: Interface is up. Unable to update xmit policy.\n",
445 bond->dev->name); 421 bond->dev->name);
446 ret = -EPERM; 422 ret = -EPERM;
@@ -449,7 +425,7 @@ static ssize_t bonding_store_xmit_hash(struct device *d,
449 425
450 new_value = bond_parse_parm(buf, xmit_hashtype_tbl); 426 new_value = bond_parse_parm(buf, xmit_hashtype_tbl);
451 if (new_value < 0) { 427 if (new_value < 0) {
452 printk(KERN_ERR DRV_NAME 428 pr_err(DRV_NAME
453 ": %s: Ignoring invalid xmit hash policy value %.*s.\n", 429 ": %s: Ignoring invalid xmit hash policy value %.*s.\n",
454 bond->dev->name, 430 bond->dev->name,
455 (int)strlen(buf) - 1, buf); 431 (int)strlen(buf) - 1, buf);
@@ -458,13 +434,15 @@ static ssize_t bonding_store_xmit_hash(struct device *d,
458 } else { 434 } else {
459 bond->params.xmit_policy = new_value; 435 bond->params.xmit_policy = new_value;
460 bond_set_mode_ops(bond, bond->params.mode); 436 bond_set_mode_ops(bond, bond->params.mode);
461 printk(KERN_INFO DRV_NAME ": %s: setting xmit hash policy to %s (%d).\n", 437 pr_info(DRV_NAME ": %s: setting xmit hash policy to %s (%d).\n",
462 bond->dev->name, xmit_hashtype_tbl[new_value].modename, new_value); 438 bond->dev->name,
439 xmit_hashtype_tbl[new_value].modename, new_value);
463 } 440 }
464out: 441out:
465 return ret; 442 return ret;
466} 443}
467static DEVICE_ATTR(xmit_hash_policy, S_IRUGO | S_IWUSR, bonding_show_xmit_hash, bonding_store_xmit_hash); 444static DEVICE_ATTR(xmit_hash_policy, S_IRUGO | S_IWUSR,
445 bonding_show_xmit_hash, bonding_store_xmit_hash);
468 446
469/* 447/*
470 * Show and set arp_validate. 448 * Show and set arp_validate.
@@ -489,39 +467,41 @@ static ssize_t bonding_store_arp_validate(struct device *d,
489 467
490 new_value = bond_parse_parm(buf, arp_validate_tbl); 468 new_value = bond_parse_parm(buf, arp_validate_tbl);
491 if (new_value < 0) { 469 if (new_value < 0) {
492 printk(KERN_ERR DRV_NAME 470 pr_err(DRV_NAME
493 ": %s: Ignoring invalid arp_validate value %s\n", 471 ": %s: Ignoring invalid arp_validate value %s\n",
494 bond->dev->name, buf); 472 bond->dev->name, buf);
495 return -EINVAL; 473 return -EINVAL;
496 } 474 }
497 if (new_value && (bond->params.mode != BOND_MODE_ACTIVEBACKUP)) { 475 if (new_value && (bond->params.mode != BOND_MODE_ACTIVEBACKUP)) {
498 printk(KERN_ERR DRV_NAME 476 pr_err(DRV_NAME
499 ": %s: arp_validate only supported in active-backup mode.\n", 477 ": %s: arp_validate only supported in active-backup mode.\n",
500 bond->dev->name); 478 bond->dev->name);
501 return -EINVAL; 479 return -EINVAL;
502 } 480 }
503 printk(KERN_INFO DRV_NAME ": %s: setting arp_validate to %s (%d).\n", 481 pr_info(DRV_NAME ": %s: setting arp_validate to %s (%d).\n",
504 bond->dev->name, arp_validate_tbl[new_value].modename, 482 bond->dev->name, arp_validate_tbl[new_value].modename,
505 new_value); 483 new_value);
506 484
507 if (!bond->params.arp_validate && new_value) { 485 if (!bond->params.arp_validate && new_value)
508 bond_register_arp(bond); 486 bond_register_arp(bond);
509 } else if (bond->params.arp_validate && !new_value) { 487 else if (bond->params.arp_validate && !new_value)
510 bond_unregister_arp(bond); 488 bond_unregister_arp(bond);
511 }
512 489
513 bond->params.arp_validate = new_value; 490 bond->params.arp_validate = new_value;
514 491
515 return count; 492 return count;
516} 493}
517 494
518static DEVICE_ATTR(arp_validate, S_IRUGO | S_IWUSR, bonding_show_arp_validate, bonding_store_arp_validate); 495static DEVICE_ATTR(arp_validate, S_IRUGO | S_IWUSR, bonding_show_arp_validate,
496 bonding_store_arp_validate);
519 497
520/* 498/*
521 * Show and store fail_over_mac. User only allowed to change the 499 * Show and store fail_over_mac. User only allowed to change the
522 * value when there are no slaves. 500 * value when there are no slaves.
523 */ 501 */
524static ssize_t bonding_show_fail_over_mac(struct device *d, struct device_attribute *attr, char *buf) 502static ssize_t bonding_show_fail_over_mac(struct device *d,
503 struct device_attribute *attr,
504 char *buf)
525{ 505{
526 struct bonding *bond = to_bond(d); 506 struct bonding *bond = to_bond(d);
527 507
@@ -530,13 +510,15 @@ static ssize_t bonding_show_fail_over_mac(struct device *d, struct device_attrib
530 bond->params.fail_over_mac); 510 bond->params.fail_over_mac);
531} 511}
532 512
533static ssize_t bonding_store_fail_over_mac(struct device *d, struct device_attribute *attr, const char *buf, size_t count) 513static ssize_t bonding_store_fail_over_mac(struct device *d,
514 struct device_attribute *attr,
515 const char *buf, size_t count)
534{ 516{
535 int new_value; 517 int new_value;
536 struct bonding *bond = to_bond(d); 518 struct bonding *bond = to_bond(d);
537 519
538 if (bond->slave_cnt != 0) { 520 if (bond->slave_cnt != 0) {
539 printk(KERN_ERR DRV_NAME 521 pr_err(DRV_NAME
540 ": %s: Can't alter fail_over_mac with slaves in bond.\n", 522 ": %s: Can't alter fail_over_mac with slaves in bond.\n",
541 bond->dev->name); 523 bond->dev->name);
542 return -EPERM; 524 return -EPERM;
@@ -544,21 +526,22 @@ static ssize_t bonding_store_fail_over_mac(struct device *d, struct device_attri
544 526
545 new_value = bond_parse_parm(buf, fail_over_mac_tbl); 527 new_value = bond_parse_parm(buf, fail_over_mac_tbl);
546 if (new_value < 0) { 528 if (new_value < 0) {
547 printk(KERN_ERR DRV_NAME 529 pr_err(DRV_NAME
548 ": %s: Ignoring invalid fail_over_mac value %s.\n", 530 ": %s: Ignoring invalid fail_over_mac value %s.\n",
549 bond->dev->name, buf); 531 bond->dev->name, buf);
550 return -EINVAL; 532 return -EINVAL;
551 } 533 }
552 534
553 bond->params.fail_over_mac = new_value; 535 bond->params.fail_over_mac = new_value;
554 printk(KERN_INFO DRV_NAME ": %s: Setting fail_over_mac to %s (%d).\n", 536 pr_info(DRV_NAME ": %s: Setting fail_over_mac to %s (%d).\n",
555 bond->dev->name, fail_over_mac_tbl[new_value].modename, 537 bond->dev->name, fail_over_mac_tbl[new_value].modename,
556 new_value); 538 new_value);
557 539
558 return count; 540 return count;
559} 541}
560 542
561static DEVICE_ATTR(fail_over_mac, S_IRUGO | S_IWUSR, bonding_show_fail_over_mac, bonding_store_fail_over_mac); 543static DEVICE_ATTR(fail_over_mac, S_IRUGO | S_IWUSR,
544 bonding_show_fail_over_mac, bonding_store_fail_over_mac);
562 545
563/* 546/*
564 * Show and set the arp timer interval. There are two tricky bits 547 * Show and set the arp timer interval. There are two tricky bits
@@ -583,28 +566,28 @@ static ssize_t bonding_store_arp_interval(struct device *d,
583 struct bonding *bond = to_bond(d); 566 struct bonding *bond = to_bond(d);
584 567
585 if (sscanf(buf, "%d", &new_value) != 1) { 568 if (sscanf(buf, "%d", &new_value) != 1) {
586 printk(KERN_ERR DRV_NAME 569 pr_err(DRV_NAME
587 ": %s: no arp_interval value specified.\n", 570 ": %s: no arp_interval value specified.\n",
588 bond->dev->name); 571 bond->dev->name);
589 ret = -EINVAL; 572 ret = -EINVAL;
590 goto out; 573 goto out;
591 } 574 }
592 if (new_value < 0) { 575 if (new_value < 0) {
593 printk(KERN_ERR DRV_NAME 576 pr_err(DRV_NAME
594 ": %s: Invalid arp_interval value %d not in range 1-%d; rejected.\n", 577 ": %s: Invalid arp_interval value %d not in range 1-%d; rejected.\n",
595 bond->dev->name, new_value, INT_MAX); 578 bond->dev->name, new_value, INT_MAX);
596 ret = -EINVAL; 579 ret = -EINVAL;
597 goto out; 580 goto out;
598 } 581 }
599 582
600 printk(KERN_INFO DRV_NAME 583 pr_info(DRV_NAME
601 ": %s: Setting ARP monitoring interval to %d.\n", 584 ": %s: Setting ARP monitoring interval to %d.\n",
602 bond->dev->name, new_value); 585 bond->dev->name, new_value);
603 bond->params.arp_interval = new_value; 586 bond->params.arp_interval = new_value;
604 if (bond->params.arp_interval) 587 if (bond->params.arp_interval)
605 bond->dev->priv_flags |= IFF_MASTER_ARPMON; 588 bond->dev->priv_flags |= IFF_MASTER_ARPMON;
606 if (bond->params.miimon) { 589 if (bond->params.miimon) {
607 printk(KERN_INFO DRV_NAME 590 pr_info(DRV_NAME
608 ": %s: ARP monitoring cannot be used with MII monitoring. " 591 ": %s: ARP monitoring cannot be used with MII monitoring. "
609 "%s Disabling MII monitoring.\n", 592 "%s Disabling MII monitoring.\n",
610 bond->dev->name, bond->dev->name); 593 bond->dev->name, bond->dev->name);
@@ -615,7 +598,7 @@ static ssize_t bonding_store_arp_interval(struct device *d,
615 } 598 }
616 } 599 }
617 if (!bond->params.arp_targets[0]) { 600 if (!bond->params.arp_targets[0]) {
618 printk(KERN_INFO DRV_NAME 601 pr_info(DRV_NAME
619 ": %s: ARP monitoring has been set up, " 602 ": %s: ARP monitoring has been set up, "
620 "but no ARP targets have been specified.\n", 603 "but no ARP targets have been specified.\n",
621 bond->dev->name); 604 bond->dev->name);
@@ -641,7 +624,8 @@ static ssize_t bonding_store_arp_interval(struct device *d,
641out: 624out:
642 return ret; 625 return ret;
643} 626}
644static DEVICE_ATTR(arp_interval, S_IRUGO | S_IWUSR , bonding_show_arp_interval, bonding_store_arp_interval); 627static DEVICE_ATTR(arp_interval, S_IRUGO | S_IWUSR,
628 bonding_show_arp_interval, bonding_store_arp_interval);
645 629
646/* 630/*
647 * Show and set the arp targets. 631 * Show and set the arp targets.
@@ -677,7 +661,7 @@ static ssize_t bonding_store_arp_targets(struct device *d,
677 /* look for adds */ 661 /* look for adds */
678 if (buf[0] == '+') { 662 if (buf[0] == '+') {
679 if ((newtarget == 0) || (newtarget == htonl(INADDR_BROADCAST))) { 663 if ((newtarget == 0) || (newtarget == htonl(INADDR_BROADCAST))) {
680 printk(KERN_ERR DRV_NAME 664 pr_err(DRV_NAME
681 ": %s: invalid ARP target %pI4 specified for addition\n", 665 ": %s: invalid ARP target %pI4 specified for addition\n",
682 bond->dev->name, &newtarget); 666 bond->dev->name, &newtarget);
683 ret = -EINVAL; 667 ret = -EINVAL;
@@ -686,14 +670,14 @@ static ssize_t bonding_store_arp_targets(struct device *d,
686 /* look for an empty slot to put the target in, and check for dupes */ 670 /* look for an empty slot to put the target in, and check for dupes */
687 for (i = 0; (i < BOND_MAX_ARP_TARGETS) && !done; i++) { 671 for (i = 0; (i < BOND_MAX_ARP_TARGETS) && !done; i++) {
688 if (targets[i] == newtarget) { /* duplicate */ 672 if (targets[i] == newtarget) { /* duplicate */
689 printk(KERN_ERR DRV_NAME 673 pr_err(DRV_NAME
690 ": %s: ARP target %pI4 is already present\n", 674 ": %s: ARP target %pI4 is already present\n",
691 bond->dev->name, &newtarget); 675 bond->dev->name, &newtarget);
692 ret = -EINVAL; 676 ret = -EINVAL;
693 goto out; 677 goto out;
694 } 678 }
695 if (targets[i] == 0) { 679 if (targets[i] == 0) {
696 printk(KERN_INFO DRV_NAME 680 pr_info(DRV_NAME
697 ": %s: adding ARP target %pI4.\n", 681 ": %s: adding ARP target %pI4.\n",
698 bond->dev->name, &newtarget); 682 bond->dev->name, &newtarget);
699 done = 1; 683 done = 1;
@@ -701,17 +685,16 @@ static ssize_t bonding_store_arp_targets(struct device *d,
701 } 685 }
702 } 686 }
703 if (!done) { 687 if (!done) {
704 printk(KERN_ERR DRV_NAME 688 pr_err(DRV_NAME
705 ": %s: ARP target table is full!\n", 689 ": %s: ARP target table is full!\n",
706 bond->dev->name); 690 bond->dev->name);
707 ret = -EINVAL; 691 ret = -EINVAL;
708 goto out; 692 goto out;
709 } 693 }
710 694
711 } 695 } else if (buf[0] == '-') {
712 else if (buf[0] == '-') {
713 if ((newtarget == 0) || (newtarget == htonl(INADDR_BROADCAST))) { 696 if ((newtarget == 0) || (newtarget == htonl(INADDR_BROADCAST))) {
714 printk(KERN_ERR DRV_NAME 697 pr_err(DRV_NAME
715 ": %s: invalid ARP target %pI4 specified for removal\n", 698 ": %s: invalid ARP target %pI4 specified for removal\n",
716 bond->dev->name, &newtarget); 699 bond->dev->name, &newtarget);
717 ret = -EINVAL; 700 ret = -EINVAL;
@@ -721,7 +704,7 @@ static ssize_t bonding_store_arp_targets(struct device *d,
721 for (i = 0; (i < BOND_MAX_ARP_TARGETS) && !done; i++) { 704 for (i = 0; (i < BOND_MAX_ARP_TARGETS) && !done; i++) {
722 if (targets[i] == newtarget) { 705 if (targets[i] == newtarget) {
723 int j; 706 int j;
724 printk(KERN_INFO DRV_NAME 707 pr_info(DRV_NAME
725 ": %s: removing ARP target %pI4.\n", 708 ": %s: removing ARP target %pI4.\n",
726 bond->dev->name, &newtarget); 709 bond->dev->name, &newtarget);
727 for (j = i; (j < (BOND_MAX_ARP_TARGETS-1)) && targets[j+1]; j++) 710 for (j = i; (j < (BOND_MAX_ARP_TARGETS-1)) && targets[j+1]; j++)
@@ -732,15 +715,15 @@ static ssize_t bonding_store_arp_targets(struct device *d,
732 } 715 }
733 } 716 }
734 if (!done) { 717 if (!done) {
735 printk(KERN_INFO DRV_NAME 718 pr_info(DRV_NAME
736 ": %s: unable to remove nonexistent ARP target %pI4.\n", 719 ": %s: unable to remove nonexistent ARP target %pI4.\n",
737 bond->dev->name, &newtarget); 720 bond->dev->name, &newtarget);
738 ret = -EINVAL; 721 ret = -EINVAL;
739 goto out; 722 goto out;
740 } 723 }
741 } 724 } else {
742 else { 725 pr_err(DRV_NAME ": no command found in arp_ip_targets file"
743 printk(KERN_ERR DRV_NAME ": no command found in arp_ip_targets file for bond %s. Use +<addr> or -<addr>.\n", 726 " for bond %s. Use +<addr> or -<addr>.\n",
744 bond->dev->name); 727 bond->dev->name);
745 ret = -EPERM; 728 ret = -EPERM;
746 goto out; 729 goto out;
@@ -773,7 +756,7 @@ static ssize_t bonding_store_downdelay(struct device *d,
773 struct bonding *bond = to_bond(d); 756 struct bonding *bond = to_bond(d);
774 757
775 if (!(bond->params.miimon)) { 758 if (!(bond->params.miimon)) {
776 printk(KERN_ERR DRV_NAME 759 pr_err(DRV_NAME
777 ": %s: Unable to set down delay as MII monitoring is disabled\n", 760 ": %s: Unable to set down delay as MII monitoring is disabled\n",
778 bond->dev->name); 761 bond->dev->name);
779 ret = -EPERM; 762 ret = -EPERM;
@@ -781,14 +764,14 @@ static ssize_t bonding_store_downdelay(struct device *d,
781 } 764 }
782 765
783 if (sscanf(buf, "%d", &new_value) != 1) { 766 if (sscanf(buf, "%d", &new_value) != 1) {
784 printk(KERN_ERR DRV_NAME 767 pr_err(DRV_NAME
785 ": %s: no down delay value specified.\n", 768 ": %s: no down delay value specified.\n",
786 bond->dev->name); 769 bond->dev->name);
787 ret = -EINVAL; 770 ret = -EINVAL;
788 goto out; 771 goto out;
789 } 772 }
790 if (new_value < 0) { 773 if (new_value < 0) {
791 printk(KERN_ERR DRV_NAME 774 pr_err(DRV_NAME
792 ": %s: Invalid down delay value %d not in range %d-%d; rejected.\n", 775 ": %s: Invalid down delay value %d not in range %d-%d; rejected.\n",
793 bond->dev->name, new_value, 1, INT_MAX); 776 bond->dev->name, new_value, 1, INT_MAX);
794 ret = -EINVAL; 777 ret = -EINVAL;
@@ -803,15 +786,17 @@ static ssize_t bonding_store_downdelay(struct device *d,
803 bond->params.miimon); 786 bond->params.miimon);
804 } 787 }
805 bond->params.downdelay = new_value / bond->params.miimon; 788 bond->params.downdelay = new_value / bond->params.miimon;
806 printk(KERN_INFO DRV_NAME ": %s: Setting down delay to %d.\n", 789 pr_info(DRV_NAME ": %s: Setting down delay to %d.\n",
807 bond->dev->name, bond->params.downdelay * bond->params.miimon); 790 bond->dev->name,
791 bond->params.downdelay * bond->params.miimon);
808 792
809 } 793 }
810 794
811out: 795out:
812 return ret; 796 return ret;
813} 797}
814static DEVICE_ATTR(downdelay, S_IRUGO | S_IWUSR , bonding_show_downdelay, bonding_store_downdelay); 798static DEVICE_ATTR(downdelay, S_IRUGO | S_IWUSR,
799 bonding_show_downdelay, bonding_store_downdelay);
815 800
816static ssize_t bonding_show_updelay(struct device *d, 801static ssize_t bonding_show_updelay(struct device *d,
817 struct device_attribute *attr, 802 struct device_attribute *attr,
@@ -831,7 +816,7 @@ static ssize_t bonding_store_updelay(struct device *d,
831 struct bonding *bond = to_bond(d); 816 struct bonding *bond = to_bond(d);
832 817
833 if (!(bond->params.miimon)) { 818 if (!(bond->params.miimon)) {
834 printk(KERN_ERR DRV_NAME 819 pr_err(DRV_NAME
835 ": %s: Unable to set up delay as MII monitoring is disabled\n", 820 ": %s: Unable to set up delay as MII monitoring is disabled\n",
836 bond->dev->name); 821 bond->dev->name);
837 ret = -EPERM; 822 ret = -EPERM;
@@ -839,14 +824,14 @@ static ssize_t bonding_store_updelay(struct device *d,
839 } 824 }
840 825
841 if (sscanf(buf, "%d", &new_value) != 1) { 826 if (sscanf(buf, "%d", &new_value) != 1) {
842 printk(KERN_ERR DRV_NAME 827 pr_err(DRV_NAME
843 ": %s: no up delay value specified.\n", 828 ": %s: no up delay value specified.\n",
844 bond->dev->name); 829 bond->dev->name);
845 ret = -EINVAL; 830 ret = -EINVAL;
846 goto out; 831 goto out;
847 } 832 }
848 if (new_value < 0) { 833 if (new_value < 0) {
849 printk(KERN_ERR DRV_NAME 834 pr_err(DRV_NAME
850 ": %s: Invalid down delay value %d not in range %d-%d; rejected.\n", 835 ": %s: Invalid down delay value %d not in range %d-%d; rejected.\n",
851 bond->dev->name, new_value, 1, INT_MAX); 836 bond->dev->name, new_value, 1, INT_MAX);
852 ret = -EINVAL; 837 ret = -EINVAL;
@@ -861,7 +846,7 @@ static ssize_t bonding_store_updelay(struct device *d,
861 bond->params.miimon); 846 bond->params.miimon);
862 } 847 }
863 bond->params.updelay = new_value / bond->params.miimon; 848 bond->params.updelay = new_value / bond->params.miimon;
864 printk(KERN_INFO DRV_NAME ": %s: Setting up delay to %d.\n", 849 pr_info(DRV_NAME ": %s: Setting up delay to %d.\n",
865 bond->dev->name, bond->params.updelay * bond->params.miimon); 850 bond->dev->name, bond->params.updelay * bond->params.miimon);
866 851
867 } 852 }
@@ -869,7 +854,8 @@ static ssize_t bonding_store_updelay(struct device *d,
869out: 854out:
870 return ret; 855 return ret;
871} 856}
872static DEVICE_ATTR(updelay, S_IRUGO | S_IWUSR , bonding_show_updelay, bonding_store_updelay); 857static DEVICE_ATTR(updelay, S_IRUGO | S_IWUSR,
858 bonding_show_updelay, bonding_store_updelay);
873 859
874/* 860/*
875 * Show and set the LACP interval. Interface must be down, and the mode 861 * Show and set the LACP interval. Interface must be down, and the mode
@@ -894,7 +880,7 @@ static ssize_t bonding_store_lacp(struct device *d,
894 struct bonding *bond = to_bond(d); 880 struct bonding *bond = to_bond(d);
895 881
896 if (bond->dev->flags & IFF_UP) { 882 if (bond->dev->flags & IFF_UP) {
897 printk(KERN_ERR DRV_NAME 883 pr_err(DRV_NAME
898 ": %s: Unable to update LACP rate because interface is up.\n", 884 ": %s: Unable to update LACP rate because interface is up.\n",
899 bond->dev->name); 885 bond->dev->name);
900 ret = -EPERM; 886 ret = -EPERM;
@@ -902,7 +888,7 @@ static ssize_t bonding_store_lacp(struct device *d,
902 } 888 }
903 889
904 if (bond->params.mode != BOND_MODE_8023AD) { 890 if (bond->params.mode != BOND_MODE_8023AD) {
905 printk(KERN_ERR DRV_NAME 891 pr_err(DRV_NAME
906 ": %s: Unable to update LACP rate because bond is not in 802.3ad mode.\n", 892 ": %s: Unable to update LACP rate because bond is not in 802.3ad mode.\n",
907 bond->dev->name); 893 bond->dev->name);
908 ret = -EPERM; 894 ret = -EPERM;
@@ -913,19 +899,20 @@ static ssize_t bonding_store_lacp(struct device *d,
913 899
914 if ((new_value == 1) || (new_value == 0)) { 900 if ((new_value == 1) || (new_value == 0)) {
915 bond->params.lacp_fast = new_value; 901 bond->params.lacp_fast = new_value;
916 printk(KERN_INFO DRV_NAME 902 pr_info(DRV_NAME ": %s: Setting LACP rate to %s (%d).\n",
917 ": %s: Setting LACP rate to %s (%d).\n", 903 bond->dev->name, bond_lacp_tbl[new_value].modename,
918 bond->dev->name, bond_lacp_tbl[new_value].modename, new_value); 904 new_value);
919 } else { 905 } else {
920 printk(KERN_ERR DRV_NAME 906 pr_err(DRV_NAME
921 ": %s: Ignoring invalid LACP rate value %.*s.\n", 907 ": %s: Ignoring invalid LACP rate value %.*s.\n",
922 bond->dev->name, (int)strlen(buf) - 1, buf); 908 bond->dev->name, (int)strlen(buf) - 1, buf);
923 ret = -EINVAL; 909 ret = -EINVAL;
924 } 910 }
925out: 911out:
926 return ret; 912 return ret;
927} 913}
928static DEVICE_ATTR(lacp_rate, S_IRUGO | S_IWUSR, bonding_show_lacp, bonding_store_lacp); 914static DEVICE_ATTR(lacp_rate, S_IRUGO | S_IWUSR,
915 bonding_show_lacp, bonding_store_lacp);
929 916
930static ssize_t bonding_show_ad_select(struct device *d, 917static ssize_t bonding_show_ad_select(struct device *d,
931 struct device_attribute *attr, 918 struct device_attribute *attr,
@@ -947,7 +934,7 @@ static ssize_t bonding_store_ad_select(struct device *d,
947 struct bonding *bond = to_bond(d); 934 struct bonding *bond = to_bond(d);
948 935
949 if (bond->dev->flags & IFF_UP) { 936 if (bond->dev->flags & IFF_UP) {
950 printk(KERN_ERR DRV_NAME 937 pr_err(DRV_NAME
951 ": %s: Unable to update ad_select because interface " 938 ": %s: Unable to update ad_select because interface "
952 "is up.\n", bond->dev->name); 939 "is up.\n", bond->dev->name);
953 ret = -EPERM; 940 ret = -EPERM;
@@ -958,12 +945,12 @@ static ssize_t bonding_store_ad_select(struct device *d,
958 945
959 if (new_value != -1) { 946 if (new_value != -1) {
960 bond->params.ad_select = new_value; 947 bond->params.ad_select = new_value;
961 printk(KERN_INFO DRV_NAME 948 pr_info(DRV_NAME
962 ": %s: Setting ad_select to %s (%d).\n", 949 ": %s: Setting ad_select to %s (%d).\n",
963 bond->dev->name, ad_select_tbl[new_value].modename, 950 bond->dev->name, ad_select_tbl[new_value].modename,
964 new_value); 951 new_value);
965 } else { 952 } else {
966 printk(KERN_ERR DRV_NAME 953 pr_err(DRV_NAME
967 ": %s: Ignoring invalid ad_select value %.*s.\n", 954 ": %s: Ignoring invalid ad_select value %.*s.\n",
968 bond->dev->name, (int)strlen(buf) - 1, buf); 955 bond->dev->name, (int)strlen(buf) - 1, buf);
969 ret = -EINVAL; 956 ret = -EINVAL;
@@ -971,8 +958,8 @@ static ssize_t bonding_store_ad_select(struct device *d,
971out: 958out:
972 return ret; 959 return ret;
973} 960}
974 961static DEVICE_ATTR(ad_select, S_IRUGO | S_IWUSR,
975static DEVICE_ATTR(ad_select, S_IRUGO | S_IWUSR, bonding_show_ad_select, bonding_store_ad_select); 962 bonding_show_ad_select, bonding_store_ad_select);
976 963
977/* 964/*
978 * Show and set the number of grat ARP to send after a failover event. 965 * Show and set the number of grat ARP to send after a failover event.
@@ -994,14 +981,14 @@ static ssize_t bonding_store_n_grat_arp(struct device *d,
994 struct bonding *bond = to_bond(d); 981 struct bonding *bond = to_bond(d);
995 982
996 if (sscanf(buf, "%d", &new_value) != 1) { 983 if (sscanf(buf, "%d", &new_value) != 1) {
997 printk(KERN_ERR DRV_NAME 984 pr_err(DRV_NAME
998 ": %s: no num_grat_arp value specified.\n", 985 ": %s: no num_grat_arp value specified.\n",
999 bond->dev->name); 986 bond->dev->name);
1000 ret = -EINVAL; 987 ret = -EINVAL;
1001 goto out; 988 goto out;
1002 } 989 }
1003 if (new_value < 0 || new_value > 255) { 990 if (new_value < 0 || new_value > 255) {
1004 printk(KERN_ERR DRV_NAME 991 pr_err(DRV_NAME
1005 ": %s: Invalid num_grat_arp value %d not in range 0-255; rejected.\n", 992 ": %s: Invalid num_grat_arp value %d not in range 0-255; rejected.\n",
1006 bond->dev->name, new_value); 993 bond->dev->name, new_value);
1007 ret = -EINVAL; 994 ret = -EINVAL;
@@ -1012,10 +999,11 @@ static ssize_t bonding_store_n_grat_arp(struct device *d,
1012out: 999out:
1013 return ret; 1000 return ret;
1014} 1001}
1015static DEVICE_ATTR(num_grat_arp, S_IRUGO | S_IWUSR, bonding_show_n_grat_arp, bonding_store_n_grat_arp); 1002static DEVICE_ATTR(num_grat_arp, S_IRUGO | S_IWUSR,
1003 bonding_show_n_grat_arp, bonding_store_n_grat_arp);
1016 1004
1017/* 1005/*
1018 * Show and set the number of unsolicted NA's to send after a failover event. 1006 * Show and set the number of unsolicited NA's to send after a failover event.
1019 */ 1007 */
1020static ssize_t bonding_show_n_unsol_na(struct device *d, 1008static ssize_t bonding_show_n_unsol_na(struct device *d,
1021 struct device_attribute *attr, 1009 struct device_attribute *attr,
@@ -1034,25 +1022,26 @@ static ssize_t bonding_store_n_unsol_na(struct device *d,
1034 struct bonding *bond = to_bond(d); 1022 struct bonding *bond = to_bond(d);
1035 1023
1036 if (sscanf(buf, "%d", &new_value) != 1) { 1024 if (sscanf(buf, "%d", &new_value) != 1) {
1037 printk(KERN_ERR DRV_NAME 1025 pr_err(DRV_NAME
1038 ": %s: no num_unsol_na value specified.\n", 1026 ": %s: no num_unsol_na value specified.\n",
1039 bond->dev->name); 1027 bond->dev->name);
1040 ret = -EINVAL; 1028 ret = -EINVAL;
1041 goto out; 1029 goto out;
1042 } 1030 }
1031
1043 if (new_value < 0 || new_value > 255) { 1032 if (new_value < 0 || new_value > 255) {
1044 printk(KERN_ERR DRV_NAME 1033 pr_err(DRV_NAME
1045 ": %s: Invalid num_unsol_na value %d not in range 0-255; rejected.\n", 1034 ": %s: Invalid num_unsol_na value %d not in range 0-255; rejected.\n",
1046 bond->dev->name, new_value); 1035 bond->dev->name, new_value);
1047 ret = -EINVAL; 1036 ret = -EINVAL;
1048 goto out; 1037 goto out;
1049 } else { 1038 } else
1050 bond->params.num_unsol_na = new_value; 1039 bond->params.num_unsol_na = new_value;
1051 }
1052out: 1040out:
1053 return ret; 1041 return ret;
1054} 1042}
1055static DEVICE_ATTR(num_unsol_na, S_IRUGO | S_IWUSR, bonding_show_n_unsol_na, bonding_store_n_unsol_na); 1043static DEVICE_ATTR(num_unsol_na, S_IRUGO | S_IWUSR,
1044 bonding_show_n_unsol_na, bonding_store_n_unsol_na);
1056 1045
1057/* 1046/*
1058 * Show and set the MII monitor interval. There are two tricky bits 1047 * Show and set the MII monitor interval. There are two tricky bits
@@ -1077,37 +1066,37 @@ static ssize_t bonding_store_miimon(struct device *d,
1077 struct bonding *bond = to_bond(d); 1066 struct bonding *bond = to_bond(d);
1078 1067
1079 if (sscanf(buf, "%d", &new_value) != 1) { 1068 if (sscanf(buf, "%d", &new_value) != 1) {
1080 printk(KERN_ERR DRV_NAME 1069 pr_err(DRV_NAME
1081 ": %s: no miimon value specified.\n", 1070 ": %s: no miimon value specified.\n",
1082 bond->dev->name); 1071 bond->dev->name);
1083 ret = -EINVAL; 1072 ret = -EINVAL;
1084 goto out; 1073 goto out;
1085 } 1074 }
1086 if (new_value < 0) { 1075 if (new_value < 0) {
1087 printk(KERN_ERR DRV_NAME 1076 pr_err(DRV_NAME
1088 ": %s: Invalid miimon value %d not in range %d-%d; rejected.\n", 1077 ": %s: Invalid miimon value %d not in range %d-%d; rejected.\n",
1089 bond->dev->name, new_value, 1, INT_MAX); 1078 bond->dev->name, new_value, 1, INT_MAX);
1090 ret = -EINVAL; 1079 ret = -EINVAL;
1091 goto out; 1080 goto out;
1092 } else { 1081 } else {
1093 printk(KERN_INFO DRV_NAME 1082 pr_info(DRV_NAME
1094 ": %s: Setting MII monitoring interval to %d.\n", 1083 ": %s: Setting MII monitoring interval to %d.\n",
1095 bond->dev->name, new_value); 1084 bond->dev->name, new_value);
1096 bond->params.miimon = new_value; 1085 bond->params.miimon = new_value;
1097 if(bond->params.updelay) 1086 if (bond->params.updelay)
1098 printk(KERN_INFO DRV_NAME 1087 pr_info(DRV_NAME
1099 ": %s: Note: Updating updelay (to %d) " 1088 ": %s: Note: Updating updelay (to %d) "
1100 "since it is a multiple of the miimon value.\n", 1089 "since it is a multiple of the miimon value.\n",
1101 bond->dev->name, 1090 bond->dev->name,
1102 bond->params.updelay * bond->params.miimon); 1091 bond->params.updelay * bond->params.miimon);
1103 if(bond->params.downdelay) 1092 if (bond->params.downdelay)
1104 printk(KERN_INFO DRV_NAME 1093 pr_info(DRV_NAME
1105 ": %s: Note: Updating downdelay (to %d) " 1094 ": %s: Note: Updating downdelay (to %d) "
1106 "since it is a multiple of the miimon value.\n", 1095 "since it is a multiple of the miimon value.\n",
1107 bond->dev->name, 1096 bond->dev->name,
1108 bond->params.downdelay * bond->params.miimon); 1097 bond->params.downdelay * bond->params.miimon);
1109 if (bond->params.arp_interval) { 1098 if (bond->params.arp_interval) {
1110 printk(KERN_INFO DRV_NAME 1099 pr_info(DRV_NAME
1111 ": %s: MII monitoring cannot be used with " 1100 ": %s: MII monitoring cannot be used with "
1112 "ARP monitoring. Disabling ARP monitoring...\n", 1101 "ARP monitoring. Disabling ARP monitoring...\n",
1113 bond->dev->name); 1102 bond->dev->name);
@@ -1141,7 +1130,8 @@ static ssize_t bonding_store_miimon(struct device *d,
1141out: 1130out:
1142 return ret; 1131 return ret;
1143} 1132}
1144static DEVICE_ATTR(miimon, S_IRUGO | S_IWUSR, bonding_show_miimon, bonding_store_miimon); 1133static DEVICE_ATTR(miimon, S_IRUGO | S_IWUSR,
1134 bonding_show_miimon, bonding_store_miimon);
1145 1135
1146/* 1136/*
1147 * Show and set the primary slave. The store function is much 1137 * Show and set the primary slave. The store function is much
@@ -1171,12 +1161,13 @@ static ssize_t bonding_store_primary(struct device *d,
1171 struct slave *slave; 1161 struct slave *slave;
1172 struct bonding *bond = to_bond(d); 1162 struct bonding *bond = to_bond(d);
1173 1163
1174 rtnl_lock(); 1164 if (!rtnl_trylock())
1165 return restart_syscall();
1175 read_lock(&bond->lock); 1166 read_lock(&bond->lock);
1176 write_lock_bh(&bond->curr_slave_lock); 1167 write_lock_bh(&bond->curr_slave_lock);
1177 1168
1178 if (!USES_PRIMARY(bond->params.mode)) { 1169 if (!USES_PRIMARY(bond->params.mode)) {
1179 printk(KERN_INFO DRV_NAME 1170 pr_info(DRV_NAME
1180 ": %s: Unable to set primary slave; %s is in mode %d\n", 1171 ": %s: Unable to set primary slave; %s is in mode %d\n",
1181 bond->dev->name, bond->dev->name, bond->params.mode); 1172 bond->dev->name, bond->dev->name, bond->params.mode);
1182 } else { 1173 } else {
@@ -1184,7 +1175,7 @@ static ssize_t bonding_store_primary(struct device *d,
1184 if (strnicmp 1175 if (strnicmp
1185 (slave->dev->name, buf, 1176 (slave->dev->name, buf,
1186 strlen(slave->dev->name)) == 0) { 1177 strlen(slave->dev->name)) == 0) {
1187 printk(KERN_INFO DRV_NAME 1178 pr_info(DRV_NAME
1188 ": %s: Setting %s as primary slave.\n", 1179 ": %s: Setting %s as primary slave.\n",
1189 bond->dev->name, slave->dev->name); 1180 bond->dev->name, slave->dev->name);
1190 bond->primary_slave = slave; 1181 bond->primary_slave = slave;
@@ -1196,13 +1187,13 @@ static ssize_t bonding_store_primary(struct device *d,
1196 /* if we got here, then we didn't match the name of any slave */ 1187 /* if we got here, then we didn't match the name of any slave */
1197 1188
1198 if (strlen(buf) == 0 || buf[0] == '\n') { 1189 if (strlen(buf) == 0 || buf[0] == '\n') {
1199 printk(KERN_INFO DRV_NAME 1190 pr_info(DRV_NAME
1200 ": %s: Setting primary slave to None.\n", 1191 ": %s: Setting primary slave to None.\n",
1201 bond->dev->name); 1192 bond->dev->name);
1202 bond->primary_slave = NULL; 1193 bond->primary_slave = NULL;
1203 bond_select_active_slave(bond); 1194 bond_select_active_slave(bond);
1204 } else { 1195 } else {
1205 printk(KERN_INFO DRV_NAME 1196 pr_info(DRV_NAME
1206 ": %s: Unable to set %.*s as primary slave as it is not a slave.\n", 1197 ": %s: Unable to set %.*s as primary slave as it is not a slave.\n",
1207 bond->dev->name, (int)strlen(buf) - 1, buf); 1198 bond->dev->name, (int)strlen(buf) - 1, buf);
1208 } 1199 }
@@ -1214,7 +1205,8 @@ out:
1214 1205
1215 return count; 1206 return count;
1216} 1207}
1217static DEVICE_ATTR(primary, S_IRUGO | S_IWUSR, bonding_show_primary, bonding_store_primary); 1208static DEVICE_ATTR(primary, S_IRUGO | S_IWUSR,
1209 bonding_show_primary, bonding_store_primary);
1218 1210
1219/* 1211/*
1220 * Show and set the use_carrier flag. 1212 * Show and set the use_carrier flag.
@@ -1237,7 +1229,7 @@ static ssize_t bonding_store_carrier(struct device *d,
1237 1229
1238 1230
1239 if (sscanf(buf, "%d", &new_value) != 1) { 1231 if (sscanf(buf, "%d", &new_value) != 1) {
1240 printk(KERN_ERR DRV_NAME 1232 pr_err(DRV_NAME
1241 ": %s: no use_carrier value specified.\n", 1233 ": %s: no use_carrier value specified.\n",
1242 bond->dev->name); 1234 bond->dev->name);
1243 ret = -EINVAL; 1235 ret = -EINVAL;
@@ -1245,17 +1237,18 @@ static ssize_t bonding_store_carrier(struct device *d,
1245 } 1237 }
1246 if ((new_value == 0) || (new_value == 1)) { 1238 if ((new_value == 0) || (new_value == 1)) {
1247 bond->params.use_carrier = new_value; 1239 bond->params.use_carrier = new_value;
1248 printk(KERN_INFO DRV_NAME ": %s: Setting use_carrier to %d.\n", 1240 pr_info(DRV_NAME ": %s: Setting use_carrier to %d.\n",
1249 bond->dev->name, new_value); 1241 bond->dev->name, new_value);
1250 } else { 1242 } else {
1251 printk(KERN_INFO DRV_NAME 1243 pr_info(DRV_NAME
1252 ": %s: Ignoring invalid use_carrier value %d.\n", 1244 ": %s: Ignoring invalid use_carrier value %d.\n",
1253 bond->dev->name, new_value); 1245 bond->dev->name, new_value);
1254 } 1246 }
1255out: 1247out:
1256 return count; 1248 return count;
1257} 1249}
1258static DEVICE_ATTR(use_carrier, S_IRUGO | S_IWUSR, bonding_show_carrier, bonding_store_carrier); 1250static DEVICE_ATTR(use_carrier, S_IRUGO | S_IWUSR,
1251 bonding_show_carrier, bonding_store_carrier);
1259 1252
1260 1253
1261/* 1254/*
@@ -1284,19 +1277,20 @@ static ssize_t bonding_store_active_slave(struct device *d,
1284{ 1277{
1285 int i; 1278 int i;
1286 struct slave *slave; 1279 struct slave *slave;
1287 struct slave *old_active = NULL; 1280 struct slave *old_active = NULL;
1288 struct slave *new_active = NULL; 1281 struct slave *new_active = NULL;
1289 struct bonding *bond = to_bond(d); 1282 struct bonding *bond = to_bond(d);
1290 1283
1291 rtnl_lock(); 1284 if (!rtnl_trylock())
1285 return restart_syscall();
1292 read_lock(&bond->lock); 1286 read_lock(&bond->lock);
1293 write_lock_bh(&bond->curr_slave_lock); 1287 write_lock_bh(&bond->curr_slave_lock);
1294 1288
1295 if (!USES_PRIMARY(bond->params.mode)) { 1289 if (!USES_PRIMARY(bond->params.mode))
1296 printk(KERN_INFO DRV_NAME 1290 pr_info(DRV_NAME ": %s: Unable to change active slave;"
1297 ": %s: Unable to change active slave; %s is in mode %d\n", 1291 " %s is in mode %d\n",
1298 bond->dev->name, bond->dev->name, bond->params.mode); 1292 bond->dev->name, bond->dev->name, bond->params.mode);
1299 } else { 1293 else {
1300 bond_for_each_slave(bond, slave, i) { 1294 bond_for_each_slave(bond, slave, i) {
1301 if (strnicmp 1295 if (strnicmp
1302 (slave->dev->name, buf, 1296 (slave->dev->name, buf,
@@ -1335,18 +1329,18 @@ static ssize_t bonding_store_active_slave(struct device *d,
1335 /* if we got here, then we didn't match the name of any slave */ 1329 /* if we got here, then we didn't match the name of any slave */
1336 1330
1337 if (strlen(buf) == 0 || buf[0] == '\n') { 1331 if (strlen(buf) == 0 || buf[0] == '\n') {
1338 printk(KERN_INFO DRV_NAME 1332 pr_info(DRV_NAME
1339 ": %s: Setting active slave to None.\n", 1333 ": %s: Setting active slave to None.\n",
1340 bond->dev->name); 1334 bond->dev->name);
1341 bond->primary_slave = NULL; 1335 bond->primary_slave = NULL;
1342 bond_select_active_slave(bond); 1336 bond_select_active_slave(bond);
1343 } else { 1337 } else {
1344 printk(KERN_INFO DRV_NAME 1338 pr_info(DRV_NAME ": %s: Unable to set %.*s"
1345 ": %s: Unable to set %.*s as active slave as it is not a slave.\n", 1339 " as active slave as it is not a slave.\n",
1346 bond->dev->name, (int)strlen(buf) - 1, buf); 1340 bond->dev->name, (int)strlen(buf) - 1, buf);
1347 } 1341 }
1348 } 1342 }
1349out: 1343 out:
1350 write_unlock_bh(&bond->curr_slave_lock); 1344 write_unlock_bh(&bond->curr_slave_lock);
1351 read_unlock(&bond->lock); 1345 read_unlock(&bond->lock);
1352 rtnl_unlock(); 1346 rtnl_unlock();
@@ -1354,7 +1348,8 @@ out:
1354 return count; 1348 return count;
1355 1349
1356} 1350}
1357static DEVICE_ATTR(active_slave, S_IRUGO | S_IWUSR, bonding_show_active_slave, bonding_store_active_slave); 1351static DEVICE_ATTR(active_slave, S_IRUGO | S_IWUSR,
1352 bonding_show_active_slave, bonding_store_active_slave);
1358 1353
1359 1354
1360/* 1355/*
@@ -1371,7 +1366,7 @@ static ssize_t bonding_show_mii_status(struct device *d,
1371 curr = bond->curr_active_slave; 1366 curr = bond->curr_active_slave;
1372 read_unlock(&bond->curr_slave_lock); 1367 read_unlock(&bond->curr_slave_lock);
1373 1368
1374 return sprintf(buf, "%s\n", (curr) ? "up" : "down"); 1369 return sprintf(buf, "%s\n", curr ? "up" : "down");
1375} 1370}
1376static DEVICE_ATTR(mii_status, S_IRUGO, bonding_show_mii_status, NULL); 1371static DEVICE_ATTR(mii_status, S_IRUGO, bonding_show_mii_status, NULL);
1377 1372
@@ -1388,7 +1383,9 @@ static ssize_t bonding_show_ad_aggregator(struct device *d,
1388 1383
1389 if (bond->params.mode == BOND_MODE_8023AD) { 1384 if (bond->params.mode == BOND_MODE_8023AD) {
1390 struct ad_info ad_info; 1385 struct ad_info ad_info;
1391 count = sprintf(buf, "%d\n", (bond_3ad_get_active_agg_info(bond, &ad_info)) ? 0 : ad_info.aggregator_id); 1386 count = sprintf(buf, "%d\n",
1387 (bond_3ad_get_active_agg_info(bond, &ad_info))
1388 ? 0 : ad_info.aggregator_id);
1392 } 1389 }
1393 1390
1394 return count; 1391 return count;
@@ -1408,7 +1405,9 @@ static ssize_t bonding_show_ad_num_ports(struct device *d,
1408 1405
1409 if (bond->params.mode == BOND_MODE_8023AD) { 1406 if (bond->params.mode == BOND_MODE_8023AD) {
1410 struct ad_info ad_info; 1407 struct ad_info ad_info;
1411 count = sprintf(buf, "%d\n", (bond_3ad_get_active_agg_info(bond, &ad_info)) ? 0: ad_info.ports); 1408 count = sprintf(buf, "%d\n",
1409 (bond_3ad_get_active_agg_info(bond, &ad_info))
1410 ? 0 : ad_info.ports);
1412 } 1411 }
1413 1412
1414 return count; 1413 return count;
@@ -1428,7 +1427,9 @@ static ssize_t bonding_show_ad_actor_key(struct device *d,
1428 1427
1429 if (bond->params.mode == BOND_MODE_8023AD) { 1428 if (bond->params.mode == BOND_MODE_8023AD) {
1430 struct ad_info ad_info; 1429 struct ad_info ad_info;
1431 count = sprintf(buf, "%d\n", (bond_3ad_get_active_agg_info(bond, &ad_info)) ? 0 : ad_info.actor_key); 1430 count = sprintf(buf, "%d\n",
1431 (bond_3ad_get_active_agg_info(bond, &ad_info))
1432 ? 0 : ad_info.actor_key);
1432 } 1433 }
1433 1434
1434 return count; 1435 return count;
@@ -1448,7 +1449,9 @@ static ssize_t bonding_show_ad_partner_key(struct device *d,
1448 1449
1449 if (bond->params.mode == BOND_MODE_8023AD) { 1450 if (bond->params.mode == BOND_MODE_8023AD) {
1450 struct ad_info ad_info; 1451 struct ad_info ad_info;
1451 count = sprintf(buf, "%d\n", (bond_3ad_get_active_agg_info(bond, &ad_info)) ? 0 : ad_info.partner_key); 1452 count = sprintf(buf, "%d\n",
1453 (bond_3ad_get_active_agg_info(bond, &ad_info))
1454 ? 0 : ad_info.partner_key);
1452 } 1455 }
1453 1456
1454 return count; 1457 return count;
@@ -1468,9 +1471,8 @@ static ssize_t bonding_show_ad_partner_mac(struct device *d,
1468 1471
1469 if (bond->params.mode == BOND_MODE_8023AD) { 1472 if (bond->params.mode == BOND_MODE_8023AD) {
1470 struct ad_info ad_info; 1473 struct ad_info ad_info;
1471 if (!bond_3ad_get_active_agg_info(bond, &ad_info)) { 1474 if (!bond_3ad_get_active_agg_info(bond, &ad_info))
1472 count = sprintf(buf, "%pM\n", ad_info.partner_system); 1475 count = sprintf(buf, "%pM\n", ad_info.partner_system);
1473 }
1474 } 1476 }
1475 1477
1476 return count; 1478 return count;
@@ -1538,6 +1540,7 @@ int bond_create_sysfs(void)
1538 printk(KERN_ERR 1540 printk(KERN_ERR
1539 "network device named %s already exists in sysfs", 1541 "network device named %s already exists in sysfs",
1540 class_attr_bonding_masters.attr.name); 1542 class_attr_bonding_masters.attr.name);
1543 ret = 0;
1541 } 1544 }
1542 1545
1543 return ret; 1546 return ret;
@@ -1562,12 +1565,8 @@ int bond_create_sysfs_entry(struct bonding *bond)
1562 int err; 1565 int err;
1563 1566
1564 err = sysfs_create_group(&(dev->dev.kobj), &bonding_group); 1567 err = sysfs_create_group(&(dev->dev.kobj), &bonding_group);
1565 if (err) { 1568 if (err)
1566 printk(KERN_EMERG "eek! didn't create group!\n"); 1569 printk(KERN_EMERG "eek! didn't create group!\n");
1567 }
1568
1569 if (expected_refcount < 1)
1570 expected_refcount = atomic_read(&bond->dev->dev.kobj.kref.refcount);
1571 1570
1572 return err; 1571 return err;
1573} 1572}
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index ca849d2adf98..6290a502742e 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -286,8 +286,7 @@ static inline unsigned long slave_last_rx(struct bonding *bond,
286static inline void bond_set_slave_inactive_flags(struct slave *slave) 286static inline void bond_set_slave_inactive_flags(struct slave *slave)
287{ 287{
288 struct bonding *bond = netdev_priv(slave->dev->master); 288 struct bonding *bond = netdev_priv(slave->dev->master);
289 if (bond->params.mode != BOND_MODE_TLB && 289 if (!bond_is_lb(bond))
290 bond->params.mode != BOND_MODE_ALB)
291 slave->state = BOND_STATE_BACKUP; 290 slave->state = BOND_STATE_BACKUP;
292 slave->dev->priv_flags |= IFF_SLAVE_INACTIVE; 291 slave->dev->priv_flags |= IFF_SLAVE_INACTIVE;
293 if (slave_do_arp_validate(bond, slave)) 292 if (slave_do_arp_validate(bond, slave))
@@ -322,8 +321,7 @@ static inline void bond_unset_master_alb_flags(struct bonding *bond)
322 321
323struct vlan_entry *bond_next_vlan(struct bonding *bond, struct vlan_entry *curr); 322struct vlan_entry *bond_next_vlan(struct bonding *bond, struct vlan_entry *curr);
324int bond_dev_queue_xmit(struct bonding *bond, struct sk_buff *skb, struct net_device *slave_dev); 323int bond_dev_queue_xmit(struct bonding *bond, struct sk_buff *skb, struct net_device *slave_dev);
325int bond_create(char *name, struct bond_params *params); 324int bond_create(const char *name);
326void bond_destroy(struct bonding *bond);
327int bond_release_and_destroy(struct net_device *bond_dev, struct net_device *slave_dev); 325int bond_release_and_destroy(struct net_device *bond_dev, struct net_device *slave_dev);
328int bond_create_sysfs(void); 326int bond_create_sysfs(void);
329void bond_destroy_sysfs(void); 327void bond_destroy_sysfs(void);
@@ -350,12 +348,8 @@ extern const struct bond_parm_tbl bond_mode_tbl[];
350extern const struct bond_parm_tbl xmit_hashtype_tbl[]; 348extern const struct bond_parm_tbl xmit_hashtype_tbl[];
351extern const struct bond_parm_tbl arp_validate_tbl[]; 349extern const struct bond_parm_tbl arp_validate_tbl[];
352extern const struct bond_parm_tbl fail_over_mac_tbl[]; 350extern const struct bond_parm_tbl fail_over_mac_tbl[];
353extern struct bond_params bonding_defaults;
354extern struct bond_parm_tbl ad_select_tbl[]; 351extern struct bond_parm_tbl ad_select_tbl[];
355 352
356/* exported from bond_sysfs.c */
357extern struct rw_semaphore bonding_rwsem;
358
359#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) 353#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
360void bond_send_unsolicited_na(struct bonding *bond); 354void bond_send_unsolicited_na(struct bonding *bond);
361void bond_register_ipv6_notifier(void); 355void bond_register_ipv6_notifier(void);