diff -Nuarp a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c --- a/drivers/net/bonding/bond_alb.c Sun Dec 21 16:08:50 2003 +++ b/drivers/net/bonding/bond_alb.c Sun Dec 21 16:08:51 2003 @@ -137,7 +137,7 @@ static inline void _unlock_tx_hashtbl(st } /* Caller must hold tx_hashtbl lock */ -static inline void tlb_init_table_entry(struct tlb_client_info *entry, u8 save_load) +static inline void tlb_init_table_entry(struct tlb_client_info *entry, int save_load) { if (save_load) { entry->load_history = 1 + entry->tx_bytes / @@ -156,9 +156,9 @@ static inline void tlb_init_slave(struct } /* Caller must hold bond lock for read */ -static void tlb_clear_slave(struct bonding *bond, struct slave *slave, u8 save_load) +static void tlb_clear_slave(struct bonding *bond, struct slave *slave, int save_load) { - struct tlb_client_info *tx_hash_table = NULL; + struct tlb_client_info *tx_hash_table; u32 index; _lock_tx_hashtbl(bond); @@ -180,14 +180,13 @@ static void tlb_clear_slave(struct bondi static int tlb_initialize(struct bonding *bond) { struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond)); + int size = TLB_HASH_TABLE_SIZE * sizeof(struct tlb_client_info); int i; - size_t size; spin_lock_init(&(bond_info->tx_hashtbl_lock)); _lock_tx_hashtbl(bond); - size = TLB_HASH_TABLE_SIZE * sizeof(struct tlb_client_info); bond_info->tx_hashtbl = kmalloc(size, GFP_KERNEL); if (bond_info->tx_hashtbl == NULL) { printk(KERN_ERR DRV_NAME @@ -220,9 +219,8 @@ static void tlb_deinitialize(struct bond /* Caller must hold bond lock for read */ static struct slave *tlb_get_least_loaded_slave(struct bonding *bond) { - struct slave *slave; - struct slave *least_loaded; - s64 curr_gap, max_gap; + struct slave *slave, *least_loaded; + s64 max_gap; int i, found = 0; /* Find the first enabled slave */ @@ -244,11 +242,11 @@ static struct slave *tlb_get_least_loade /* Find the slave with the largest gap */ bond_for_each_slave_from(bond, slave, i, least_loaded) { if (SLAVE_IS_OK(slave)) { - curr_gap = (s64)(slave->speed * 1000000) - + s64 gap = (s64)(slave->speed * 1000000) - (s64)(SLAVE_TLB_INFO(slave).load * 8); - if (max_gap < curr_gap) { + if (max_gap < gap) { least_loaded = slave; - max_gap = curr_gap; + max_gap = gap; } } } @@ -260,8 +258,8 @@ static struct slave *tlb_get_least_loade struct slave *tlb_choose_channel(struct bonding *bond, u32 hash_index, u32 skb_len) { struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond)); - struct tlb_client_info *hash_table = NULL; - struct slave *assigned_slave = NULL; + struct tlb_client_info *hash_table; + struct slave *assigned_slave; _lock_tx_hashtbl(bond); @@ -314,9 +312,9 @@ static inline void _unlock_rx_hashtbl(st */ static void rlb_update_entry_from_arp(struct bonding *bond, struct arp_pkt *arp) { - u32 hash_index; - struct rlb_client_info *client_info = NULL; struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond)); + struct rlb_client_info *client_info; + u32 hash_index; _lock_rx_hashtbl(bond); @@ -336,13 +334,13 @@ static void rlb_update_entry_from_arp(st _unlock_rx_hashtbl(bond); } -static int rlb_arp_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type *ptype) +static int rlb_arp_recv(struct sk_buff *skb, struct net_device *bond_dev, struct packet_type *ptype) { - struct bonding *bond = (struct bonding *)dev->priv; - int ret = NET_RX_DROP; + struct bonding *bond = (struct bonding *)bond_dev->priv; struct arp_pkt *arp = (struct arp_pkt *)skb->data; + int ret = NET_RX_DROP; - if (!(dev->flags & IFF_MASTER)) { + if (!(bond_dev->flags & IFF_MASTER)) { goto out; } @@ -373,9 +371,9 @@ out: /* Caller must hold bond lock for read */ static struct slave *rlb_next_rx_slave(struct bonding *bond) { - struct slave *rx_slave = NULL, *slave = NULL; - unsigned int i = 0; struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond)); + struct slave *rx_slave = NULL, *slave; + int i = 0; slave = bond_info->next_rx_slave; if (slave == NULL) { @@ -425,8 +423,8 @@ static void rlb_teach_disabled_mac_on_pr */ static void rlb_clear_slave(struct bonding *bond, struct slave *slave) { - struct rlb_client_info *rx_hash_table = NULL; struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond)); + struct rlb_client_info *rx_hash_table; u8 mac_bcast[ETH_ALEN] = {0xff,0xff,0xff,0xff,0xff,0xff}; u32 index, next_index; @@ -474,7 +472,7 @@ static void rlb_clear_slave(struct bondi static void rlb_update_client(struct rlb_client_info *client_info) { - int i = 0; + int i; if (client_info->slave == NULL) { return; @@ -494,9 +492,9 @@ static void rlb_update_client(struct rlb /* sends ARP REPLIES that update the clients that need updating */ static void rlb_update_rx_clients(struct bonding *bond) { - u32 hash_index; - struct rlb_client_info *client_info = NULL; struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond)); + struct rlb_client_info *client_info; + u32 hash_index; _lock_rx_hashtbl(bond); @@ -522,11 +520,11 @@ static void rlb_update_rx_clients(struct /* The slave was assigned a new mac address - update the clients */ static void rlb_req_update_slave_clients(struct bonding *bond, struct slave *slave) { - u32 hash_index; - u8 ntt = 0; struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond)); u8 mac_bcast[ETH_ALEN] = {0xff,0xff,0xff,0xff,0xff,0xff}; - struct rlb_client_info *client_info = NULL; + struct rlb_client_info *client_info; + int ntt = 0; + u32 hash_index; _lock_rx_hashtbl(bond); @@ -554,10 +552,10 @@ static void rlb_req_update_slave_clients /* mark all clients using src_ip to be updated */ static void rlb_req_update_subnet_clients(struct bonding *bond, u32 src_ip) { - u32 hash_index; struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond)); u8 mac_bcast[ETH_ALEN] = {0xff,0xff,0xff,0xff,0xff,0xff}; - struct rlb_client_info *client_info = NULL; + struct rlb_client_info *client_info; + u32 hash_index; _lock_rx_hashtbl(bond); @@ -591,9 +589,9 @@ static void rlb_req_update_subnet_client struct slave *rlb_choose_channel(struct bonding *bond, struct arp_pkt *arp) { struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond)); - struct rlb_client_info *client_info = NULL; + struct slave *assigned_slave; + struct rlb_client_info *client_info; u32 hash_index = 0; - struct slave *assigned_slave = NULL; u8 mac_bcast[ETH_ALEN] = {0xff,0xff,0xff,0xff,0xff,0xff}; _lock_rx_hashtbl(bond); @@ -714,13 +712,14 @@ static struct slave *rlb_arp_xmit(struct static void rlb_rebalance(struct bonding *bond) { struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond)); - struct slave *assigned_slave = NULL; + struct slave *assigned_slave; + struct rlb_client_info *client_info; + int ntt; u32 hash_index; - struct rlb_client_info *client_info = NULL; - u8 ntt = 0; _lock_rx_hashtbl(bond); + ntt = 0; hash_index = bond_info->rx_hashtbl_head; for (; hash_index != RLB_NULL_INDEX; hash_index = client_info->next) { client_info = &(bond_info->rx_hashtbl[hash_index]); @@ -751,14 +750,13 @@ static int rlb_initialize(struct bonding { struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond)); struct packet_type *pk_type = &(BOND_ALB_INFO(bond).rlb_pkt_type); + int size = RLB_HASH_TABLE_SIZE * sizeof(struct rlb_client_info); int i; - size_t size; spin_lock_init(&(bond_info->rx_hashtbl_lock)); _lock_rx_hashtbl(bond); - size = RLB_HASH_TABLE_SIZE * sizeof(struct rlb_client_info); bond_info->rx_hashtbl = kmalloc(size, GFP_KERNEL); if (bond_info->rx_hashtbl == NULL) { printk(KERN_ERR DRV_NAME @@ -803,11 +801,9 @@ static void rlb_deinitialize(struct bond static void alb_send_learning_packets(struct slave *slave, u8 mac_addr[]) { - struct sk_buff *skb = NULL; struct learning_pkt pkt; - char *data = NULL; + int size = sizeof(struct learning_pkt); int i; - unsigned int size = sizeof(struct learning_pkt); memset(&pkt, 0, size); memcpy(pkt.mac_dst, mac_addr, ETH_ALEN); @@ -815,7 +811,9 @@ static void alb_send_learning_packets(st pkt.type = __constant_htons(ETH_P_LOOP); for (i=0; i < MAX_LP_RETRY; i++) { - skb = NULL; + struct sk_buff *skb; + char *data; + skb = dev_alloc_skb(size); if (!skb) { return; @@ -839,11 +837,9 @@ static void alb_send_learning_packets(st */ static int alb_set_slave_mac_addr(struct slave *slave, u8 addr[], int hw) { - struct net_device *dev = NULL; + struct net_device *dev = slave->dev; struct sockaddr s_addr; - dev = slave->dev; - if (!hw) { memcpy(dev->dev_addr, addr, dev->addr_len); return 0; @@ -868,9 +864,9 @@ static int alb_set_slave_mac_addr(struct /* Caller must hold bond lock for write or ptrlock for write*/ static void alb_swap_mac_addr(struct bonding *bond, struct slave *slave1, struct slave *slave2) { - u8 tmp_mac_addr[ETH_ALEN]; struct slave *disabled_slave = NULL; - u8 slaves_state_differ; + u8 tmp_mac_addr[ETH_ALEN]; + int slaves_state_differ; slaves_state_differ = (SLAVE_IS_OK(slave1) != SLAVE_IS_OK(slave2)); @@ -1157,10 +1153,10 @@ void bond_alb_deinitialize(struct bondin } } -int bond_alb_xmit(struct sk_buff *skb, struct net_device *dev) +int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev) { - struct bonding *bond = (struct bonding *)dev->priv; - struct ethhdr *eth_data = (struct ethhdr *)skb->data; + struct bonding *bond = (struct bonding *)bond_dev->priv; + struct ethhdr *eth_data = (struct ethhdr *)skb->mac.raw = skb->data; struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond)); struct slave *tx_slave = NULL; char do_tx_balance = 1; @@ -1169,7 +1165,7 @@ int bond_alb_xmit(struct sk_buff *skb, s u8 *hash_start = NULL; u8 mac_bcast[ETH_ALEN] = {0xff,0xff,0xff,0xff,0xff,0xff}; - if (!IS_UP(dev)) { /* bond down */ + if (!IS_UP(bond_dev)) { /* bond down */ dev_kfree_skb(skb); return 0; } @@ -1278,7 +1274,7 @@ int bond_alb_xmit(struct sk_buff *skb, s void bond_alb_monitor(struct bonding *bond) { struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond)); - struct slave *slave = NULL; + struct slave *slave; int delta_in_ticks = HZ / ALB_TIMER_TICKS_PER_SEC; int i; @@ -1467,7 +1463,7 @@ void bond_alb_handle_link_change(struct */ void bond_alb_handle_active_change(struct bonding *bond, struct slave *new_slave) { - struct slave *swap_slave = bond->current_slave; + struct slave *swap_slave; int i, found = 0; if (bond->current_slave == new_slave) { @@ -1480,6 +1476,7 @@ void bond_alb_handle_active_change(struc bond->alb_info.rlb_promisc_timeout_counter = 0; } + swap_slave = bond->current_slave; bond->current_slave = new_slave; if (!new_slave || (bond->slave_cnt == 0)) { @@ -1513,11 +1510,11 @@ void bond_alb_handle_active_change(struc } } -int bond_alb_set_mac_address(struct net_device *dev, void *addr) +int bond_alb_set_mac_address(struct net_device *bond_dev, void *addr) { - struct bonding *bond = (struct bonding *)dev->priv; + struct bonding *bond = (struct bonding *)bond_dev->priv; struct sockaddr *sa = addr; - struct slave *swap_slave = NULL; + struct slave *swap_slave; int error = 0; int i, found = 0; @@ -1530,7 +1527,7 @@ int bond_alb_set_mac_address(struct net_ return error; } - memcpy(dev->dev_addr, sa->sa_data, dev->addr_len); + memcpy(bond_dev->dev_addr, sa->sa_data, bond_dev->addr_len); /* If there is no current_slave there is nothing else to do. * Otherwise we'll need to pass the new address to it and handle @@ -1541,7 +1538,7 @@ int bond_alb_set_mac_address(struct net_ } bond_for_each_slave(bond, swap_slave, i) { - if (!memcmp(swap_slave->dev->dev_addr, dev->dev_addr, ETH_ALEN)) { + if (!memcmp(swap_slave->dev->dev_addr, bond_dev->dev_addr, ETH_ALEN)) { found = 1; break; } @@ -1550,10 +1547,10 @@ int bond_alb_set_mac_address(struct net_ if (found) { alb_swap_mac_addr(bond, swap_slave, bond->current_slave); } else { - alb_set_slave_mac_addr(bond->current_slave, dev->dev_addr, + alb_set_slave_mac_addr(bond->current_slave, bond_dev->dev_addr, bond->alb_info.rlb_enabled); - alb_send_learning_packets(bond->current_slave, dev->dev_addr); + alb_send_learning_packets(bond->current_slave, bond_dev->dev_addr); if (bond->alb_info.rlb_enabled) { /* inform clients mac address has changed */ rlb_req_update_slave_clients(bond, bond->current_slave); diff -Nuarp a/drivers/net/bonding/bond_alb.h b/drivers/net/bonding/bond_alb.h --- a/drivers/net/bonding/bond_alb.h Sun Dec 21 16:08:50 2003 +++ b/drivers/net/bonding/bond_alb.h Sun Dec 21 16:08:51 2003 @@ -127,9 +127,9 @@ int bond_alb_init_slave(struct bonding * void bond_alb_deinit_slave(struct bonding *bond, struct slave *slave); void bond_alb_handle_link_change(struct bonding *bond, struct slave *slave, char link); void bond_alb_handle_active_change(struct bonding *bond, struct slave *new_slave); -int bond_alb_xmit(struct sk_buff *skb, struct net_device *dev); +int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev); void bond_alb_monitor(struct bonding *bond); -int bond_alb_set_mac_address(struct net_device *dev, void *addr); +int bond_alb_set_mac_address(struct net_device *bond_dev, void *addr); #endif /* __BOND_ALB_H__ */ diff -Nuarp a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c --- a/drivers/net/bonding/bond_main.c Sun Dec 21 16:08:50 2003 +++ b/drivers/net/bonding/bond_main.c Sun Dec 21 16:08:51 2003 @@ -572,27 +572,27 @@ MODULE_PARM_DESC(primary, "Primary netwo MODULE_PARM(lacp_rate, "s"); MODULE_PARM_DESC(lacp_rate, "LACPDU tx rate to request from 802.3ad partner (slow/fast)"); -static int bond_xmit_roundrobin(struct sk_buff *skb, struct net_device *dev); -static int bond_xmit_xor(struct sk_buff *skb, struct net_device *dev); -static int bond_xmit_activebackup(struct sk_buff *skb, struct net_device *dev); -static struct net_device_stats *bond_get_stats(struct net_device *dev); -static void bond_mii_monitor(struct net_device *dev); -static void bond_loadbalance_arp_mon(struct net_device *dev); -static void bond_activebackup_arp_mon(struct net_device *dev); +static int bond_xmit_roundrobin(struct sk_buff *skb, struct net_device *bond_dev); +static int bond_xmit_xor(struct sk_buff *skb, struct net_device *bond_dev); +static int bond_xmit_activebackup(struct sk_buff *skb, struct net_device *bond_dev); +static struct net_device_stats *bond_get_stats(struct net_device *bond_dev); +static void bond_mii_monitor(struct net_device *bond_dev); +static void bond_loadbalance_arp_mon(struct net_device *bond_dev); +static void bond_activebackup_arp_mon(struct net_device *bond_dev); static void bond_mc_list_destroy(struct bonding *bond); static void bond_mc_add(struct bonding *bond, void *addr, int alen); static void bond_mc_delete(struct bonding *bond, void *addr, int alen); -static int bond_mc_list_copy(struct dev_mc_list *src, struct bonding *dst, int gpf_flag); +static int bond_mc_list_copy(struct dev_mc_list *mc_list, struct bonding *bond, int gpf_flag); static inline int bond_is_dmi_same(struct dev_mc_list *dmi1, struct dev_mc_list *dmi2); static void bond_set_promiscuity(struct bonding *bond, int inc); static void bond_set_allmulti(struct bonding *bond, int inc); static struct dev_mc_list *bond_mc_list_find_dmi(struct dev_mc_list *dmi, struct dev_mc_list *mc_list); -static void bond_mc_swap(struct bonding *bond, struct slave *new, struct slave *old); -static int bond_enslave(struct net_device *master, struct net_device *slave); -static int bond_release(struct net_device *master, struct net_device *slave); -static int bond_release_all(struct net_device *master); -static int bond_sethwaddr(struct net_device *master, struct net_device *slave); -static void bond_change_active_slave(struct bonding *bond, struct slave *new); +static void bond_mc_swap(struct bonding *bond, struct slave *new_active, struct slave *old_active); +static int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev); +static int bond_release(struct net_device *bond_dev, struct net_device *slave_dev); +static int bond_release_all(struct net_device *bond_dev); +static int bond_sethwaddr(struct net_device *bond_dev, struct net_device *slave_dev); +static void bond_change_active_slave(struct bonding *bond, struct slave *new_active); static void bond_select_active_slave(struct bonding *bond); static struct slave *bond_find_best_slave(struct bonding *bond); @@ -719,16 +719,16 @@ static void bond_attach_slave(struct bon */ static int bond_update_speed_duplex(struct slave *slave) { - struct net_device *dev = slave->dev; + struct net_device *slave_dev = slave->dev; static int (* ioctl)(struct net_device *, struct ifreq *, int); struct ifreq ifr; struct ethtool_cmd etool; - ioctl = dev->do_ioctl; + ioctl = slave_dev->do_ioctl; if (ioctl) { etool.cmd = ETHTOOL_GSET; ifr.ifr_data = (char*)&etool; - if (IOCTL(dev, &ifr, SIOCETHTOOL) == 0) { + if (IOCTL(slave_dev, &ifr, SIOCETHTOOL) == 0) { slave->speed = etool.speed; slave->duplex = etool.duplex; } else { @@ -780,7 +780,7 @@ err_out: * It'd be nice if there was a good way to tell if a driver supports * netif_carrier, but there really isn't. */ -static int bond_check_dev_link(struct net_device *dev, int reporting) +static int bond_check_dev_link(struct net_device *slave_dev, int reporting) { static int (* ioctl)(struct net_device *, struct ifreq *, int); struct ifreq ifr; @@ -788,10 +788,10 @@ static int bond_check_dev_link(struct ne struct ethtool_value etool; if (use_carrier) { - return netif_carrier_ok(dev) ? BMSR_LSTATUS : 0; + return netif_carrier_ok(slave_dev) ? BMSR_LSTATUS : 0; } - ioctl = dev->do_ioctl; + ioctl = slave_dev->do_ioctl; if (ioctl) { /* TODO: set pointer to correct ioctl on a per team member */ /* bases to make this more efficient. that is, once */ @@ -807,9 +807,9 @@ static int bond_check_dev_link(struct ne /* Yes, the mii is overlaid on the ifreq.ifr_ifru */ mii = (struct mii_ioctl_data *)&ifr.ifr_data; - if (IOCTL(dev, &ifr, SIOCGMIIPHY) == 0) { + if (IOCTL(slave_dev, &ifr, SIOCGMIIPHY) == 0) { mii->reg_num = MII_BMSR; - if (IOCTL(dev, &ifr, SIOCGMIIREG) == 0) { + if (IOCTL(slave_dev, &ifr, SIOCGMIIREG) == 0) { return mii->val_out & BMSR_LSTATUS; } } @@ -819,7 +819,7 @@ static int bond_check_dev_link(struct ne /* from it last if the above MII ioctls fail... */ etool.cmd = ETHTOOL_GLINK; ifr.ifr_data = (char*)&etool; - if (IOCTL(dev, &ifr, SIOCETHTOOL) == 0) { + if (IOCTL(slave_dev, &ifr, SIOCETHTOOL) == 0) { if (etool.data == 1) { return BMSR_LSTATUS; } else { @@ -859,9 +859,9 @@ static void bond_unregister_lacpdu(struc dev_remove_pack(&(BOND_AD_INFO(bond).ad_pkt_type)); } -static int bond_open(struct net_device *dev) +static int bond_open(struct net_device *bond_dev) { - struct bonding *bond = (struct bonding *)dev->priv; + struct bonding *bond = (struct bonding *)bond_dev->priv; struct timer_list *timer = &bond->mii_timer; struct timer_list *arp_timer = &bond->arp_timer; @@ -889,7 +889,7 @@ static int bond_open(struct net_device * if (miimon > 0) { /* link check interval, in milliseconds. */ init_timer(timer); timer->expires = jiffies + 1; - timer->data = (unsigned long)dev; + timer->data = (unsigned long)bond_dev; timer->function = (void *)&bond_mii_monitor; add_timer(timer); } @@ -897,7 +897,7 @@ static int bond_open(struct net_device * if (arp_interval> 0) { /* arp interval, in milliseconds. */ init_timer(arp_timer); arp_timer->expires = jiffies + 1; - arp_timer->data = (unsigned long)dev; + arp_timer->data = (unsigned long)bond_dev; if (bond_mode == BOND_MODE_ACTIVEBACKUP) { arp_timer->function = (void *)&bond_activebackup_arp_mon; } else { @@ -921,9 +921,9 @@ static int bond_open(struct net_device * return 0; } -static int bond_close(struct net_device *master) +static int bond_close(struct net_device *bond_dev) { - struct bonding *bond = (struct bonding *)master->priv; + struct bonding *bond = (struct bonding *)bond_dev->priv; write_lock_bh(&bond->lock); @@ -964,7 +964,7 @@ static int bond_close(struct net_device } /* Release the bonded slaves */ - bond_release_all(master); + bond_release_all(bond_dev); if ((bond_mode == BOND_MODE_TLB) || (bond_mode == BOND_MODE_ALB)) { @@ -980,18 +980,18 @@ static int bond_close(struct net_device /* * flush all members of flush->mc_list from device dev->mc_list */ -static void bond_mc_list_flush(struct net_device *dev, struct net_device *flush) +static void bond_mc_list_flush(struct net_device *slave_dev, struct net_device *bond_dev) { struct dev_mc_list *dmi; - for (dmi = flush->mc_list; dmi != NULL; dmi = dmi->next) - dev_mc_delete(dev, dmi->dmi_addr, dmi->dmi_addrlen, 0); + for (dmi = bond_dev->mc_list; dmi != NULL; dmi = dmi->next) + dev_mc_delete(slave_dev, dmi->dmi_addr, dmi->dmi_addrlen, 0); if (bond_mode == BOND_MODE_8023AD) { /* del lacpdu mc addr from mc list */ u8 lacpdu_multicast[ETH_ALEN] = MULTICAST_LACPDU_ADDR; - dev_mc_delete(dev, lacpdu_multicast, ETH_ALEN, 0); + dev_mc_delete(slave_dev, lacpdu_multicast, ETH_ALEN, 0); } } @@ -1051,19 +1051,19 @@ static void bond_mc_delete(struct bondin /* * Copy all the Multicast addresses from src to the bonding device dst */ -static int bond_mc_list_copy(struct dev_mc_list *src, struct bonding *dst, int gpf_flag) +static int bond_mc_list_copy(struct dev_mc_list *mc_list, struct bonding *bond, int gpf_flag) { struct dev_mc_list *dmi, *new_dmi; - for (dmi = src; dmi != NULL; dmi = dmi->next) { + for (dmi = mc_list; dmi != NULL; dmi = dmi->next) { new_dmi = kmalloc(sizeof(struct dev_mc_list), gpf_flag); if (new_dmi == NULL) { return -ENOMEM; } - new_dmi->next = dst->mc_list; - dst->mc_list = new_dmi; + new_dmi->next = bond->mc_list; + bond->mc_list = new_dmi; new_dmi->dmi_addrlen = dmi->dmi_addrlen; memcpy(new_dmi->dmi_addr, dmi->dmi_addr, dmi->dmi_addrlen); @@ -1135,9 +1135,9 @@ static struct dev_mc_list *bond_mc_list_ return NULL; } -static void bond_set_multicast_list(struct net_device *master) +static void bond_set_multicast_list(struct net_device *bond_dev) { - struct bonding *bond = (struct bonding *)master->priv; + struct bonding *bond = (struct bonding *)bond_dev->priv; struct dev_mc_list *dmi; write_lock_bh(&bond->lock); @@ -1145,37 +1145,37 @@ static void bond_set_multicast_list(stru /* * Do promisc before checking multicast_mode */ - if ( (master->flags & IFF_PROMISC) && !(bond->flags & IFF_PROMISC) ) + if ( (bond_dev->flags & IFF_PROMISC) && !(bond->flags & IFF_PROMISC) ) bond_set_promiscuity(bond, 1); - if ( !(master->flags & IFF_PROMISC) && (bond->flags & IFF_PROMISC) ) + if ( !(bond_dev->flags & IFF_PROMISC) && (bond->flags & IFF_PROMISC) ) bond_set_promiscuity(bond, -1); /* set allmulti flag to slaves */ - if ( (master->flags & IFF_ALLMULTI) && !(bond->flags & IFF_ALLMULTI) ) + if ( (bond_dev->flags & IFF_ALLMULTI) && !(bond->flags & IFF_ALLMULTI) ) bond_set_allmulti(bond, 1); - if ( !(master->flags & IFF_ALLMULTI) && (bond->flags & IFF_ALLMULTI) ) + if ( !(bond_dev->flags & IFF_ALLMULTI) && (bond->flags & IFF_ALLMULTI) ) bond_set_allmulti(bond, -1); - bond->flags = master->flags; + bond->flags = bond_dev->flags; /* looking for addresses to add to slaves' mc list */ - for (dmi = master->mc_list; dmi != NULL; dmi = dmi->next) { + for (dmi = bond_dev->mc_list; dmi != NULL; dmi = dmi->next) { if (bond_mc_list_find_dmi(dmi, bond->mc_list) == NULL) bond_mc_add(bond, dmi->dmi_addr, dmi->dmi_addrlen); } /* looking for addresses to delete from slaves' list */ for (dmi = bond->mc_list; dmi != NULL; dmi = dmi->next) { - if (bond_mc_list_find_dmi(dmi, master->mc_list) == NULL) + if (bond_mc_list_find_dmi(dmi, bond_dev->mc_list) == NULL) bond_mc_delete(bond, dmi->dmi_addr, dmi->dmi_addrlen); } /* save master's multicast list */ bond_mc_list_destroy(bond); - bond_mc_list_copy(master->mc_list, bond, GFP_ATOMIC); + bond_mc_list_copy(bond_dev->mc_list, bond, GFP_ATOMIC); write_unlock_bh(&bond->lock); } @@ -1185,7 +1185,7 @@ static void bond_set_multicast_list(stru * old active slaves (if any) according to the multicast mode, and * promiscuous flags unconditionally. */ -static void bond_mc_swap(struct bonding *bond, struct slave *new, struct slave *old) +static void bond_mc_swap(struct bonding *bond, struct slave *new_active, struct slave *old_active) { struct dev_mc_list *dmi; @@ -1196,43 +1196,41 @@ static void bond_mc_swap(struct bonding return; } - if (old) { + if (old_active) { if (bond->device->flags & IFF_PROMISC) { - dev_set_promiscuity(old->dev, -1); + dev_set_promiscuity(old_active->dev, -1); } if (bond->device->flags & IFF_ALLMULTI) { - dev_set_allmulti(old->dev, -1); + dev_set_allmulti(old_active->dev, -1); } for (dmi = bond->device->mc_list; dmi != NULL; dmi = dmi->next) { - dev_mc_delete(old->dev, dmi->dmi_addr, dmi->dmi_addrlen, 0); + dev_mc_delete(old_active->dev, dmi->dmi_addr, dmi->dmi_addrlen, 0); } } - if (new) { + if (new_active) { if (bond->device->flags & IFF_PROMISC) { - dev_set_promiscuity(new->dev, 1); + dev_set_promiscuity(new_active->dev, 1); } if (bond->device->flags & IFF_ALLMULTI) { - dev_set_allmulti(new->dev, 1); + dev_set_allmulti(new_active->dev, 1); } for (dmi = bond->device->mc_list; dmi != NULL; dmi = dmi->next) { - dev_mc_add(new->dev, dmi->dmi_addr, dmi->dmi_addrlen, 0); + dev_mc_add(new_active->dev, dmi->dmi_addr, dmi->dmi_addrlen, 0); } } } /* enslave device to bond device */ -static int bond_enslave(struct net_device *master_dev, struct net_device *slave_dev) +static int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) { - struct bonding *bond = NULL; + struct bonding *bond = (struct bonding *)bond_dev->priv; struct slave *new_slave = NULL; int err = 0; struct dev_mc_list *dmi; int link_reporting; struct sockaddr addr; - bond = (struct bonding *)master_dev->priv; - if (slave_dev->do_ioctl == NULL) { printk(KERN_WARNING DRV_NAME ": Warning : no link monitoring support for %s\n", @@ -1241,7 +1239,7 @@ static int bond_enslave(struct net_devic /* bond must be initialized by bond_open() before enslaving */ - if (!(master_dev->flags & IFF_UP)) { + if (!(bond_dev->flags & IFF_UP)) { dprintk("Error, master_dev is not up\n"); return -EPERM; } @@ -1316,7 +1314,7 @@ static int bond_enslave(struct net_devic * The application already set the master's * mac address to that of the first slave */ - memcpy(addr.sa_data, master_dev->dev_addr, master_dev->addr_len); + memcpy(addr.sa_data, bond_dev->dev_addr, bond_dev->addr_len); addr.sa_family = slave_dev->type; err = slave_dev->set_mac_address(slave_dev, &addr); if (err) { @@ -1332,7 +1330,7 @@ static int bond_enslave(struct net_devic } } - err = netdev_set_master(slave_dev, master_dev); + err = netdev_set_master(slave_dev, bond_dev); if (err) { dprintk("Error %d calling netdev_set_master\n", err); if (app_abi_ver < 1) { @@ -1362,15 +1360,15 @@ static int bond_enslave(struct net_devic */ if (!USES_PRIMARY(bond_mode)) { /* set promiscuity level to new slave */ - if (master_dev->flags & IFF_PROMISC) { + if (bond_dev->flags & IFF_PROMISC) { dev_set_promiscuity(slave_dev, 1); } /* set allmulti level to new slave */ - if (master_dev->flags & IFF_ALLMULTI) + if (bond_dev->flags & IFF_ALLMULTI) dev_set_allmulti(slave_dev, 1); /* upload master's mc_list to new slave */ - for (dmi = master_dev->mc_list; dmi != NULL; dmi = dmi->next) + for (dmi = bond_dev->mc_list; dmi != NULL; dmi = dmi->next) dev_mc_add (slave_dev, dmi->dmi_addr, dmi->dmi_addrlen, 0); } @@ -1543,31 +1541,31 @@ static int bond_enslave(struct net_devic */ int ndx = 0; - for (ndx = 0; ndx < slave_dev->addr_len; ndx++) { - dprintk("Checking ndx=%d of master_dev->dev_addr\n", + for (ndx = 0; ndx < bond_dev->addr_len; ndx++) { + dprintk("Checking ndx=%d of bond_dev->dev_addr\n", ndx); - if (master_dev->dev_addr[ndx] != 0) { + if (bond_dev->dev_addr[ndx] != 0) { dprintk("Found non-zero byte at ndx=%d\n", ndx); break; } } - if (ndx == slave_dev->addr_len) { + if (ndx == bond_dev->addr_len) { /* * We got all the way through the address and it was * all 0's. */ - dprintk("%s doesn't have a MAC address yet. ", - master_dev->name); + dprintk("%s doesn't have a MAC address yet. \n", + bond_dev->name); dprintk("Going to give assign it from %s.\n", slave_dev->name); - bond_sethwaddr(master_dev, slave_dev); + bond_sethwaddr(bond_dev, slave_dev); } } printk(KERN_INFO DRV_NAME ": %s: enslaving %s as a%s interface with a%s link.\n", - master_dev->name, slave_dev->name, + bond_dev->name, slave_dev->name, new_slave->state == BOND_STATE_ACTIVE ? "n active" : " backup", new_slave->link != BOND_LINK_DOWN ? "n up" : " down"); @@ -1602,39 +1600,38 @@ err_free: * In these cases, this fuction does nothing. * In the other cases, currnt_slave pointer is changed and 0 is returned. */ -static int bond_ioctl_change_active(struct net_device *master_dev, struct net_device *slave_dev) +static int bond_ioctl_change_active(struct net_device *bond_dev, struct net_device *slave_dev) { - struct bonding *bond; - struct slave *oldactive = NULL; - struct slave *newactive = NULL; + struct bonding *bond = (struct bonding *)bond_dev->priv; + struct slave *old_active = NULL; + struct slave *new_active = NULL; int ret = 0; /* Verify that master_dev is indeed the master of slave_dev */ if (!(slave_dev->flags & IFF_SLAVE) || - (slave_dev->master != master_dev)) { + (slave_dev->master != bond_dev)) { return -EINVAL; } - bond = (struct bonding *)master_dev->priv; write_lock_bh(&bond->lock); - oldactive = bond->current_slave; - newactive = bond_get_slave_by_dev(bond, slave_dev); + old_active = bond->current_slave; + new_active = bond_get_slave_by_dev(bond, slave_dev); /* * Changing to the current active: do nothing; return success. */ - if (newactive && (newactive == oldactive)) { + if (new_active && (new_active == old_active)) { write_unlock_bh(&bond->lock); return 0; } - if ((newactive != NULL)&& - (oldactive != NULL)&& - (newactive->link == BOND_LINK_UP)&& - IS_UP(newactive->dev)) { - bond_change_active_slave(bond, newactive); + if ((new_active != NULL)&& + (old_active != NULL)&& + (new_active->link == BOND_LINK_UP)&& + IS_UP(new_active->dev)) { + bond_change_active_slave(bond, new_active); } else { ret = -EINVAL; } @@ -1650,16 +1647,16 @@ static int bond_ioctl_change_active(stru */ static struct slave *bond_find_best_slave(struct bonding *bond) { - struct slave *newslave, *oldslave; + struct slave *new_active, *old_active; struct slave *bestslave = NULL; int mintime; int i; - newslave = oldslave = bond->current_slave; + new_active = old_active = bond->current_slave; - if (newslave == NULL) { /* there were no active slaves left */ + if (new_active == NULL) { /* there were no active slaves left */ if (bond->slave_cnt > 0) { /* found one slave */ - newslave = bond->first_slave; + new_active = bond->first_slave; } else { return NULL; /* still no slave, return NULL */ } @@ -1674,22 +1671,22 @@ static struct slave *bond_find_best_slav */ if ((bond->primary_slave != NULL) && (arp_interval == 0)) { if (IS_UP(bond->primary_slave->dev)) - newslave = bond->primary_slave; + new_active = bond->primary_slave; } /* remember where to stop iterating over the slaves */ - oldslave = newslave; + old_active = new_active; - bond_for_each_slave_from(bond, newslave, i, oldslave) { - if (IS_UP(newslave->dev)) { - if (newslave->link == BOND_LINK_UP) { - return newslave; + bond_for_each_slave_from(bond, new_active, i, old_active) { + if (IS_UP(new_active->dev)) { + if (new_active->link == BOND_LINK_UP) { + return new_active; } - else if (newslave->link == BOND_LINK_BACK) { + else if (new_active->link == BOND_LINK_BACK) { /* link up, but waiting for stabilization */ - if (newslave->delay < mintime) { - mintime = newslave->delay; - bestslave = newslave; + if (new_active->delay < mintime) { + mintime = new_active->delay; + bestslave = new_active; } } } @@ -1713,65 +1710,65 @@ static struct slave *bond_find_best_slav * * Warning: Caller must hold ptrlock for writing. */ -static void bond_change_active_slave(struct bonding *bond, struct slave *new) +static void bond_change_active_slave(struct bonding *bond, struct slave *new_active) { - struct slave *old = bond->current_slave; + struct slave *old_active = bond->current_slave; - if (old == new) { + if (old_active == new_active) { return; } - if (new) { - if (new->link == BOND_LINK_BACK) { + if (new_active) { + if (new_active->link == BOND_LINK_BACK) { if (USES_PRIMARY(bond_mode)) { printk(KERN_INFO DRV_NAME ": %s: making interface %s the new " "active one %d ms earlier.\n", - bond->device->name, new->dev->name, - (updelay - new->delay) * miimon); + bond->device->name, new_active->dev->name, + (updelay - new_active->delay) * miimon); } - new->delay = 0; - new->link = BOND_LINK_UP; - new->jiffies = jiffies; + new_active->delay = 0; + new_active->link = BOND_LINK_UP; + new_active->jiffies = jiffies; if (bond_mode == BOND_MODE_8023AD) { - bond_3ad_handle_link_change(new, BOND_LINK_UP); + bond_3ad_handle_link_change(new_active, BOND_LINK_UP); } if ((bond_mode == BOND_MODE_TLB) || (bond_mode == BOND_MODE_ALB)) { - bond_alb_handle_link_change(bond, new, BOND_LINK_UP); + bond_alb_handle_link_change(bond, new_active, BOND_LINK_UP); } } else { if (USES_PRIMARY(bond_mode)) { printk(KERN_INFO DRV_NAME ": %s: making interface %s the new " "active one.\n", - bond->device->name, new->dev->name); + bond->device->name, new_active->dev->name); } } } if (bond_mode == BOND_MODE_ACTIVEBACKUP) { - if (old) { - bond_set_slave_inactive_flags(old); + if (old_active) { + bond_set_slave_inactive_flags(old_active); } - if (new) { - bond_set_slave_active_flags(new); + if (new_active) { + bond_set_slave_active_flags(new_active); } } if (USES_PRIMARY(bond_mode)) { - bond_mc_swap(bond, new, old); + bond_mc_swap(bond, new_active, old_active); } if ((bond_mode == BOND_MODE_TLB) || (bond_mode == BOND_MODE_ALB)) { - bond_alb_handle_active_change(bond, new); + bond_alb_handle_active_change(bond, new_active); } else { - bond->current_slave = new; + bond->current_slave = new_active; } } @@ -1808,37 +1805,35 @@ static void bond_select_active_slave(str * for Bonded connections: * The first up interface should be left on and all others downed. */ -static int bond_release(struct net_device *master, struct net_device *slave) +static int bond_release(struct net_device *bond_dev, struct net_device *slave_dev) { - struct bonding *bond; - struct slave *our_slave; + struct bonding *bond = (struct bonding *)bond_dev->priv; + struct slave *slave; struct sockaddr addr; int mac_addr_differ; /* slave is not a slave or master is not master of this slave */ - if (!(slave->flags & IFF_SLAVE) || - (slave->master != master)) { + if (!(slave_dev->flags & IFF_SLAVE) || + (slave_dev->master != bond_dev)) { printk(KERN_ERR DRV_NAME ": Error: %s: cannot release %s.\n", - master->name, slave->name); + bond_dev->name, slave_dev->name); return -EINVAL; } - bond = (struct bonding *)master->priv; - write_lock_bh(&bond->lock); - our_slave = bond_get_slave_by_dev(bond, slave); - if (our_slave == NULL) { + slave = bond_get_slave_by_dev(bond, slave_dev); + if (slave == NULL) { /* not a slave of this bond */ printk(KERN_INFO DRV_NAME ": %s: %s not enslaved\n", - master->name, slave->name); + bond_dev->name, slave_dev->name); return -EINVAL; } mac_addr_differ = memcmp(bond->device->dev_addr, - our_slave->perm_hwaddr, + slave->perm_hwaddr, ETH_ALEN); if (!mac_addr_differ && (bond->slave_cnt > 1)) { printk(KERN_WARNING DRV_NAME @@ -1847,15 +1842,15 @@ static int bond_release(struct net_devic "still in use by %s. Set the HWaddr of " "%s to a different address to avoid " "conflicts.\n", - slave->name, - our_slave->perm_hwaddr[0], - our_slave->perm_hwaddr[1], - our_slave->perm_hwaddr[2], - our_slave->perm_hwaddr[3], - our_slave->perm_hwaddr[4], - our_slave->perm_hwaddr[5], + slave_dev->name, + slave->perm_hwaddr[0], + slave->perm_hwaddr[1], + slave->perm_hwaddr[2], + slave->perm_hwaddr[3], + slave->perm_hwaddr[4], + slave->perm_hwaddr[5], bond->device->name, - slave->name); + slave_dev->name); } /* Inform AD package of unbinding of slave. */ @@ -1863,26 +1858,26 @@ static int bond_release(struct net_devic /* must be called before the slave is * detached from the list */ - bond_3ad_unbind_slave(our_slave); + bond_3ad_unbind_slave(slave); } printk(KERN_INFO DRV_NAME ": %s: releasing %s interface %s\n", - master->name, - (our_slave->state == BOND_STATE_ACTIVE) + bond_dev->name, + (slave->state == BOND_STATE_ACTIVE) ? "active" : "backup", - slave->name); + slave_dev->name); bond->current_arp_slave = NULL; /* release the slave from its bond */ - bond_detach_slave(bond, our_slave); + bond_detach_slave(bond, slave); - if (bond->primary_slave == our_slave) { + if (bond->primary_slave == slave) { bond->primary_slave = NULL; } - if (bond->current_slave == our_slave) { + if (bond->current_slave == slave) { bond_change_active_slave(bond, NULL); bond_select_active_slave(bond); } @@ -1891,7 +1886,7 @@ static int bond_release(struct net_devic printk(KERN_INFO DRV_NAME ": %s: now running without any active " "interface !\n", - master->name); + bond_dev->name); } if ((bond_mode == BOND_MODE_TLB) || @@ -1900,7 +1895,7 @@ static int bond_release(struct net_devic * detached from the list and the current_slave * has been replaced (if our_slave == old_current) */ - bond_alb_deinit_slave(bond, our_slave); + bond_alb_deinit_slave(bond, slave); } write_unlock_bh(&bond->lock); @@ -1911,45 +1906,45 @@ static int bond_release(struct net_devic */ if (!USES_PRIMARY(bond_mode)) { /* unset promiscuity level from slave */ - if (master->flags & IFF_PROMISC) { - dev_set_promiscuity(slave, -1); + if (bond_dev->flags & IFF_PROMISC) { + dev_set_promiscuity(slave_dev, -1); } /* unset allmulti level from slave */ - if (master->flags & IFF_ALLMULTI) - dev_set_allmulti(slave, -1); + if (bond_dev->flags & IFF_ALLMULTI) + dev_set_allmulti(slave_dev, -1); /* flush master's mc_list from slave */ - bond_mc_list_flush (slave, master); + bond_mc_list_flush (slave_dev, bond_dev); } - netdev_set_master(slave, NULL); + netdev_set_master(slave_dev, NULL); /* close slave before restoring its mac address */ - dev_close(slave); + dev_close(slave_dev); if (app_abi_ver >= 1) { /* restore original ("permanent") mac address */ - memcpy(addr.sa_data, our_slave->perm_hwaddr, ETH_ALEN); - addr.sa_family = slave->type; - slave->set_mac_address(slave, &addr); + memcpy(addr.sa_data, slave->perm_hwaddr, ETH_ALEN); + addr.sa_family = slave_dev->type; + slave_dev->set_mac_address(slave_dev, &addr); } /* restore the original state of the * IFF_NOARP flag that might have been * set by bond_set_slave_inactive_flags() */ - if ((our_slave->original_flags & IFF_NOARP) == 0) { - slave->flags &= ~IFF_NOARP; + if ((slave->original_flags & IFF_NOARP) == 0) { + slave_dev->flags &= ~IFF_NOARP; } - kfree(our_slave); + kfree(slave); /* if the last slave was removed, zero the mac address * of the master so it will be set by the application * to the mac address of the first slave */ if (bond->slave_cnt == 0) { - memset(master->dev_addr, 0, master->addr_len); + memset(bond_dev->dev_addr, 0, bond_dev->addr_len); } return 0; /* deletion OK */ @@ -1958,16 +1953,14 @@ static int bond_release(struct net_devic /* * This function releases all slaves. */ -static int bond_release_all(struct net_device *master) +static int bond_release_all(struct net_device *bond_dev) { - struct bonding *bond; - struct slave *our_slave; + struct bonding *bond = (struct bonding *)bond_dev->priv; + struct slave *slave; struct net_device *slave_dev; struct sockaddr addr; int err = 0; - bond = (struct bonding *)master->priv; - write_lock_bh(&bond->lock); if (bond->slave_cnt == 0) { @@ -1978,23 +1971,23 @@ static int bond_release_all(struct net_d bond->primary_slave = NULL; bond_change_active_slave(bond, NULL); - while ((our_slave = bond->first_slave) != NULL) { + while ((slave = bond->first_slave) != NULL) { /* Inform AD package of unbinding of slave * before slave is detached from the list. */ if (bond_mode == BOND_MODE_8023AD) { - bond_3ad_unbind_slave(our_slave); + bond_3ad_unbind_slave(slave); } - slave_dev = our_slave->dev; - bond_detach_slave(bond, our_slave); + slave_dev = slave->dev; + bond_detach_slave(bond, slave); if ((bond_mode == BOND_MODE_TLB) || (bond_mode == BOND_MODE_ALB)) { /* must be called only after the slave * has been detached from the list */ - bond_alb_deinit_slave(bond, our_slave); + bond_alb_deinit_slave(bond, slave); } /* now that the slave is detached, unlock and perform @@ -2009,15 +2002,15 @@ static int bond_release_all(struct net_d */ if (!USES_PRIMARY(bond_mode)) { /* unset promiscuity level from slave */ - if (master->flags & IFF_PROMISC) { + if (bond_dev->flags & IFF_PROMISC) { dev_set_promiscuity(slave_dev, -1); } /* unset allmulti level from slave */ - if (master->flags & IFF_ALLMULTI) - dev_set_allmulti(slave_dev, -1); + if (bond_dev->flags & IFF_ALLMULTI) + dev_set_allmulti(slave_dev, -1); /* flush master's mc_list from slave */ - bond_mc_list_flush (slave_dev, master); + bond_mc_list_flush(slave_dev, bond_dev); } netdev_set_master(slave_dev, NULL); @@ -2027,7 +2020,7 @@ static int bond_release_all(struct net_d if (app_abi_ver >= 1) { /* restore original ("permanent") mac address*/ - memcpy(addr.sa_data, our_slave->perm_hwaddr, ETH_ALEN); + memcpy(addr.sa_data, slave->perm_hwaddr, ETH_ALEN); addr.sa_family = slave_dev->type; slave_dev->set_mac_address(slave_dev, &addr); } @@ -2035,11 +2028,11 @@ static int bond_release_all(struct net_d /* restore the original state of the IFF_NOARP flag that might have * been set by bond_set_slave_inactive_flags() */ - if ((our_slave->original_flags & IFF_NOARP) == 0) { + if ((slave->original_flags & IFF_NOARP) == 0) { slave_dev->flags &= ~IFF_NOARP; } - kfree(our_slave); + kfree(slave); /* re-acquire the lock before getting the next slave */ write_lock_bh(&bond->lock); @@ -2049,11 +2042,11 @@ static int bond_release_all(struct net_d * set by the application to the mac address of the * first slave */ - memset(master->dev_addr, 0, master->addr_len); + memset(bond_dev->dev_addr, 0, bond_dev->addr_len); printk(KERN_INFO DRV_NAME ": %s: released all slaves\n", - master->name); + bond_dev->name); out: write_unlock_bh(&bond->lock); @@ -2062,9 +2055,9 @@ out: } /* this function is called regularly to monitor each slave's link. */ -static void bond_mii_monitor(struct net_device *master) +static void bond_mii_monitor(struct net_device *bond_dev) { - struct bonding *bond = (struct bonding *)master->priv; + struct bonding *bond = (struct bonding *)bond_dev->priv; struct slave *slave, *oldcurrent; int slave_died = 0; int do_failover = 0; @@ -2092,12 +2085,12 @@ static void bond_mii_monitor(struct net_ read_unlock(&bond->ptrlock); bond_for_each_slave(bond, slave, i) { - struct net_device *dev = slave->dev; + struct net_device *slave_dev = slave->dev; int link_state; u16 old_speed = slave->speed; u8 old_duplex = slave->duplex; - link_state = bond_check_dev_link(dev, 0); + link_state = bond_check_dev_link(slave_dev, 0); switch (slave->link) { case BOND_LINK_UP: /* the link was up */ @@ -2116,14 +2109,14 @@ static void bond_mii_monitor(struct net_ ": %s: link status down for %s " "interface %s, disabling it in " "%d ms.\n", - master->name, - IS_UP(dev) + bond_dev->name, + IS_UP(slave_dev) ? ((bond_mode == BOND_MODE_ACTIVEBACKUP) ? ((slave == oldcurrent) ? "active " : "backup ") : "") : "idle ", - dev->name, + slave_dev->name, downdelay * miimon); } } @@ -2148,8 +2141,8 @@ static void bond_mii_monitor(struct net_ ": %s: link status definitely " "down for interface %s, " "disabling it", - master->name, - dev->name); + bond_dev->name, + slave_dev->name); /* notify ad that the link status has changed */ if (bond_mode == BOND_MODE_8023AD) { @@ -2176,9 +2169,9 @@ static void bond_mii_monitor(struct net_ printk(KERN_INFO DRV_NAME ": %s: link status up again after %d " "ms for interface %s.\n", - master->name, + bond_dev->name, (downdelay - slave->delay) * miimon, - dev->name); + slave_dev->name); } break; case BOND_LINK_DOWN: /* the link was down */ @@ -2196,8 +2189,8 @@ static void bond_mii_monitor(struct net_ ": %s: link status up for " "interface %s, enabling it " "in %d ms.\n", - master->name, - dev->name, + bond_dev->name, + slave_dev->name, updelay * miimon); } } @@ -2211,9 +2204,9 @@ static void bond_mii_monitor(struct net_ printk(KERN_INFO DRV_NAME ": %s: link status down again after %d " "ms for interface %s.\n", - master->name, + bond_dev->name, (updelay - slave->delay) * miimon, - dev->name); + slave_dev->name); } else { /* link stays up */ if (slave->delay == 0) { @@ -2236,8 +2229,8 @@ static void bond_mii_monitor(struct net_ printk(KERN_INFO DRV_NAME ": %s: link status definitely " "up for interface %s.\n", - master->name, - dev->name); + bond_dev->name, + slave_dev->name); /* notify ad that the link status has changed */ if (bond_mode == BOND_MODE_8023AD) { @@ -2281,7 +2274,7 @@ static void bond_mii_monitor(struct net_ printk(KERN_INFO DRV_NAME ": %s: now running without any active " "interface !\n", - master->name); + bond_dev->name); } write_unlock(&bond->ptrlock); @@ -2300,12 +2293,12 @@ out: * arp is transmitted to generate traffic. see activebackup_arp_monitor for * arp monitoring in active backup mode. */ -static void bond_loadbalance_arp_mon(struct net_device *master) +static void bond_loadbalance_arp_mon(struct net_device *bond_dev) { - struct bonding *bond = (struct bonding *)master->priv; + struct bonding *bond = (struct bonding *)bond_dev->priv; struct slave *slave, *oldcurrent; int do_failover = 0; - int the_delta_in_ticks = arp_interval * HZ / 1000; + int delta_in_ticks = arp_interval * HZ / 1000; int i; read_lock(&bond->lock); @@ -2335,9 +2328,9 @@ static void bond_loadbalance_arp_mon(str if (slave->link != BOND_LINK_UP) { if (((jiffies - slave->dev->trans_start) <= - the_delta_in_ticks) && + delta_in_ticks) && ((jiffies - slave->dev->last_rx) <= - the_delta_in_ticks)) { + delta_in_ticks)) { slave->link = BOND_LINK_UP; slave->state = BOND_STATE_ACTIVE; @@ -2351,13 +2344,13 @@ static void bond_loadbalance_arp_mon(str printk(KERN_INFO DRV_NAME ": %s: link status definitely " "up for interface %s, ", - master->name, + bond_dev->name, slave->dev->name); do_failover = 1; } else { printk(KERN_INFO DRV_NAME ": %s: interface %s is now up\n", - master->name, + bond_dev->name, slave->dev->name); } } @@ -2369,9 +2362,9 @@ static void bond_loadbalance_arp_mon(str * if we don't know our ip yet */ if (((jiffies - slave->dev->trans_start) >= - (2*the_delta_in_ticks)) || + (2*delta_in_ticks)) || (((jiffies - slave->dev->last_rx) >= - (2*the_delta_in_ticks)) && my_ip !=0)) { + (2*delta_in_ticks)) && my_ip !=0)) { slave->link = BOND_LINK_DOWN; slave->state = BOND_STATE_BACKUP; if (slave->link_failure_count < UINT_MAX) { @@ -2379,7 +2372,7 @@ static void bond_loadbalance_arp_mon(str } printk(KERN_INFO DRV_NAME ": %s: interface %s is now down.\n", - master->name, + bond_dev->name, slave->dev->name); if (slave == oldcurrent) { @@ -2408,14 +2401,14 @@ static void bond_loadbalance_arp_mon(str printk(KERN_INFO DRV_NAME ": %s: now running without any active " "interface !\n", - master->name); + bond_dev->name); } write_unlock(&bond->ptrlock); } re_arm: - mod_timer(&bond->arp_timer, jiffies + the_delta_in_ticks); + mod_timer(&bond->arp_timer, jiffies + delta_in_ticks); out: read_unlock(&bond->lock); } @@ -2435,11 +2428,11 @@ out: * may have received. * see loadbalance_arp_monitor for arp monitoring in load balancing mode */ -static void bond_activebackup_arp_mon(struct net_device *master) +static void bond_activebackup_arp_mon(struct net_device *bond_dev) { - struct bonding *bond = (struct bonding *)master->priv; + struct bonding *bond = (struct bonding *)bond_dev->priv; struct slave *slave; - int the_delta_in_ticks = arp_interval * HZ / 1000; + int delta_in_ticks = arp_interval * HZ / 1000; int i; read_lock(&bond->lock); @@ -2461,13 +2454,13 @@ static void bond_activebackup_arp_mon(st if (slave->link != BOND_LINK_UP) { if ((jiffies - slave->dev->last_rx) <= - the_delta_in_ticks) { + delta_in_ticks) { slave->link = BOND_LINK_UP; write_lock(&bond->ptrlock); if ((bond->current_slave == NULL) && ((jiffies - slave->dev->trans_start) <= - the_delta_in_ticks)) { + delta_in_ticks)) { bond_change_active_slave(bond, slave); bond->current_arp_slave = NULL; } else if (bond->current_slave != slave) { @@ -2485,13 +2478,13 @@ static void bond_activebackup_arp_mon(st printk(KERN_INFO DRV_NAME ": %s: %s is up and now the " "active interface\n", - master->name, + bond_dev->name, slave->dev->name); } else { printk(KERN_INFO DRV_NAME ": %s: backup interface %s is " "now up\n", - master->name, + bond_dev->name, slave->dev->name); } @@ -2502,7 +2495,7 @@ static void bond_activebackup_arp_mon(st if ((slave != bond->current_slave) && (bond->current_arp_slave == NULL) && (((jiffies - slave->dev->last_rx) >= - 3*the_delta_in_ticks) && (my_ip != 0))) { + 3*delta_in_ticks) && (my_ip != 0))) { /* a backup slave has gone down; three times * the delta allows the current slave to be * taken out before the backup slave. @@ -2521,7 +2514,7 @@ static void bond_activebackup_arp_mon(st bond_set_slave_inactive_flags(slave); printk(KERN_INFO DRV_NAME ": %s: backup interface %s is now down\n", - master->name, + bond_dev->name, slave->dev->name); } else { read_unlock(&bond->ptrlock); @@ -2544,10 +2537,10 @@ static void bond_activebackup_arp_mon(st * if it is up and needs to take over as the current_slave */ if ((((jiffies - slave->dev->trans_start) >= - (2*the_delta_in_ticks)) || + (2*delta_in_ticks)) || (((jiffies - slave->dev->last_rx) >= - (2*the_delta_in_ticks)) && (my_ip != 0))) && - ((jiffies - slave->jiffies) >= 2*the_delta_in_ticks)) { + (2*delta_in_ticks)) && (my_ip != 0))) && + ((jiffies - slave->jiffies) >= 2*delta_in_ticks)) { slave->link = BOND_LINK_DOWN; if (slave->link_failure_count < UINT_MAX) { @@ -2556,7 +2549,7 @@ static void bond_activebackup_arp_mon(st printk(KERN_INFO DRV_NAME ": %s: link status down for active interface " "%s, disabling it", - master->name, + bond_dev->name, slave->dev->name); write_lock(&bond->ptrlock); bond_select_active_slave(bond); @@ -2574,7 +2567,7 @@ static void bond_activebackup_arp_mon(st printk(KERN_INFO DRV_NAME ": %s: changing from interface %s to primary " "interface %s\n", - master->name, + bond_dev->name, slave->dev->name, bond->primary_slave->dev->name); @@ -2638,7 +2631,7 @@ static void bond_activebackup_arp_mon(st printk(KERN_INFO DRV_NAME ": %s: backup interface %s is " "now down.\n", - master->name, + bond_dev->name, slave->dev->name); } } @@ -2646,23 +2639,23 @@ static void bond_activebackup_arp_mon(st } re_arm: - mod_timer(&bond->arp_timer, jiffies + the_delta_in_ticks); + mod_timer(&bond->arp_timer, jiffies + delta_in_ticks); out: read_unlock(&bond->lock); } -static int bond_sethwaddr(struct net_device *master, struct net_device *slave) +static int bond_sethwaddr(struct net_device *bond_dev, struct net_device *slave_dev) { - dprintk("master=%p\n", master); - dprintk("slave=%p\n", slave); - dprintk("slave->addr_len=%d\n", slave->addr_len); - memcpy(master->dev_addr, slave->dev_addr, slave->addr_len); + dprintk("bond_dev=%p\n", bond_dev); + dprintk("slave_dev=%p\n", slave_dev); + dprintk("slave_dev->addr_len=%d\n", slave_dev->addr_len); + memcpy(bond_dev->dev_addr, slave_dev->dev_addr, slave_dev->addr_len); return 0; } -static int bond_info_query(struct net_device *master, struct ifbond *info) +static int bond_info_query(struct net_device *bond_dev, struct ifbond *info) { - struct bonding *bond = (struct bonding *)master->priv; + struct bonding *bond = (struct bonding *)bond_dev->priv; info->bond_mode = bond_mode; info->miimon = miimon; @@ -2674,9 +2667,9 @@ static int bond_info_query(struct net_de return 0; } -static int bond_slave_info_query(struct net_device *master, struct ifslave *info) +static int bond_slave_info_query(struct net_device *bond_dev, struct ifslave *info) { - struct bonding *bond = (struct bonding *)master->priv; + struct bonding *bond = (struct bonding *)bond_dev->priv; struct slave *slave; int i, found = 0; @@ -2705,7 +2698,7 @@ static int bond_slave_info_query(struct return 0; } -static int bond_ethtool_ioctl(struct net_device *master_dev, struct ifreq *ifr) +static int bond_ethtool_ioctl(struct net_device *bond_dev, struct ifreq *ifr) { void *addr = ifr->ifr_data; uint32_t cmd; @@ -2758,7 +2751,7 @@ static int bond_ethtool_ioctl(struct net } } -static int bond_do_ioctl(struct net_device *master_dev, struct ifreq *ifr, int cmd) +static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd) { struct net_device *slave_dev = NULL; struct ifbond *u_binfo = NULL, k_binfo; @@ -2768,11 +2761,11 @@ static int bond_do_ioctl(struct net_devi int ret = 0; dprintk("bond_ioctl: master=%s, cmd=%d\n", - master_dev->name, cmd); + bond_dev->name, cmd); switch (cmd) { case SIOCETHTOOL: - return bond_ethtool_ioctl(master_dev, ifr); + return bond_ethtool_ioctl(bond_dev, ifr); case SIOCGMIIPHY: mii = (struct mii_ioctl_data *)&ifr->ifr_data; @@ -2791,7 +2784,7 @@ static int bond_do_ioctl(struct net_devi return -EINVAL; } if (mii->reg_num == 1) { - struct bonding *bond = (struct bonding *)master_dev->priv; + struct bonding *bond = (struct bonding *)bond_dev->priv; mii->val_out = 0; read_lock_bh(&bond->lock); read_lock(&bond->ptrlock); @@ -2808,7 +2801,7 @@ static int bond_do_ioctl(struct net_devi if (copy_from_user(&k_binfo, u_binfo, sizeof(ifbond))) { return -EFAULT; } - ret = bond_info_query(master_dev, &k_binfo); + ret = bond_info_query(bond_dev, &k_binfo); if (ret == 0) { if (copy_to_user(u_binfo, &k_binfo, sizeof(ifbond))) { return -EFAULT; @@ -2821,7 +2814,7 @@ static int bond_do_ioctl(struct net_devi if (copy_from_user(&k_sinfo, u_sinfo, sizeof(ifslave))) { return -EFAULT; } - ret = bond_slave_info_query(master_dev, &k_sinfo); + ret = bond_slave_info_query(bond_dev, &k_sinfo); if (ret == 0) { if (copy_to_user(u_sinfo, &k_sinfo, sizeof(ifslave))) { return -EFAULT; @@ -2860,20 +2853,20 @@ static int bond_do_ioctl(struct net_devi switch (cmd) { case BOND_ENSLAVE_OLD: case SIOCBONDENSLAVE: - ret = bond_enslave(master_dev, slave_dev); + ret = bond_enslave(bond_dev, slave_dev); break; case BOND_RELEASE_OLD: case SIOCBONDRELEASE: - ret = bond_release(master_dev, slave_dev); + ret = bond_release(bond_dev, slave_dev); break; case BOND_SETHWADDR_OLD: case SIOCBONDSETHWADDR: - ret = bond_sethwaddr(master_dev, slave_dev); + ret = bond_sethwaddr(bond_dev, slave_dev); break; case BOND_CHANGE_ACTIVE_OLD: case SIOCBONDCHANGEACTIVE: if (USES_PRIMARY(bond_mode)) { - ret = bond_ioctl_change_active(master_dev, slave_dev); + ret = bond_ioctl_change_active(bond_dev, slave_dev); } else { ret = -EINVAL; @@ -2897,7 +2890,7 @@ static int bond_do_ioctl(struct net_devi } #ifdef CONFIG_NET_FASTROUTE -static int bond_accept_fastpath(struct net_device *dev, struct dst_entry *dst) +static int bond_accept_fastpath(struct net_device *bond_dev, struct dst_entry *dst) { return -1; } @@ -2906,14 +2899,14 @@ static int bond_accept_fastpath(struct n /* * in broadcast mode, we send everything to all usable interfaces. */ -static int bond_xmit_broadcast(struct sk_buff *skb, struct net_device *dev) +static int bond_xmit_broadcast(struct sk_buff *skb, struct net_device *bond_dev) { + struct bonding *bond = (struct bonding *)bond_dev->priv; struct slave *slave, *start_at; - struct bonding *bond = (struct bonding *)dev->priv; - struct net_device *device_we_should_send_to = NULL; + struct net_device *tx_dev = NULL; int i; - if (!IS_UP(dev)) { /* bond down */ + if (!IS_UP(bond_dev)) { /* bond down */ dev_kfree_skb(skb); return 0; } @@ -2935,7 +2928,7 @@ static int bond_xmit_broadcast(struct sk if (IS_UP(slave->dev) && (slave->link == BOND_LINK_UP) && (slave->state == BOND_STATE_ACTIVE)) { - if (device_we_should_send_to) { + if (tx_dev) { struct sk_buff *skb2; if ((skb2 = skb_clone(skb, GFP_ATOMIC)) == NULL) { printk(KERN_ERR DRV_NAME @@ -2944,16 +2937,16 @@ static int bond_xmit_broadcast(struct sk continue; } - skb2->dev = device_we_should_send_to; + skb2->dev = tx_dev; skb2->priority = 1; dev_queue_xmit(skb2); } - device_we_should_send_to = slave->dev; + tx_dev = slave->dev; } } - if (device_we_should_send_to) { - skb->dev = device_we_should_send_to; + if (tx_dev) { + skb->dev = tx_dev; skb->priority = 1; dev_queue_xmit(skb); } else @@ -2964,13 +2957,13 @@ static int bond_xmit_broadcast(struct sk return 0; } -static int bond_xmit_roundrobin(struct sk_buff *skb, struct net_device *dev) +static int bond_xmit_roundrobin(struct sk_buff *skb, struct net_device *bond_dev) { + struct bonding *bond = (struct bonding *)bond_dev->priv; struct slave *slave, *start_at; - struct bonding *bond = (struct bonding *)dev->priv; int i; - if (!IS_UP(dev)) { /* bond down */ + if (!IS_UP(bond_dev)) { /* bond down */ dev_kfree_skb(skb); return 0; } @@ -3017,15 +3010,15 @@ static int bond_xmit_roundrobin(struct s * the source and destination hw adresses. If this device is not * enabled, find the next slave following this xor slave. */ -static int bond_xmit_xor(struct sk_buff *skb, struct net_device *dev) +static int bond_xmit_xor(struct sk_buff *skb, struct net_device *bond_dev) { - struct slave *slave, *start_at; - struct bonding *bond = (struct bonding *)dev->priv; + struct bonding *bond = (struct bonding *)bond_dev->priv; struct ethhdr *data = (struct ethhdr *)skb->data; + struct slave *slave, *start_at; int slave_no; int i; - if (!IS_UP(dev)) { /* bond down */ + if (!IS_UP(bond_dev)) { /* bond down */ dev_kfree_skb(skb); return 0; } @@ -3074,12 +3067,12 @@ static int bond_xmit_xor(struct sk_buff * in active-backup mode, we know that bond->current_slave is always valid if * the bond has a usable interface. */ -static int bond_xmit_activebackup(struct sk_buff *skb, struct net_device *dev) +static int bond_xmit_activebackup(struct sk_buff *skb, struct net_device *bond_dev) { - struct bonding *bond = (struct bonding *)dev->priv; + struct bonding *bond = (struct bonding *)bond_dev->priv; int ret; - if (!IS_UP(dev)) { /* bond down */ + if (!IS_UP(bond_dev)) { /* bond down */ dev_kfree_skb(skb); return 0; } @@ -3117,9 +3110,9 @@ static int bond_xmit_activebackup(struct return 0; } -static struct net_device_stats *bond_get_stats(struct net_device *dev) +static struct net_device_stats *bond_get_stats(struct net_device *bond_dev) { - struct bonding *bond = (struct bonding *)dev->priv; + struct bonding *bond = (struct bonding *)bond_dev->priv; struct net_device_stats *stats = &(bond->stats), *sstats; struct slave *slave; int i; @@ -3344,21 +3337,21 @@ static struct file_operations bond_info_ static int bond_create_proc_entry(struct bonding *bond) { - struct net_device *dev = bond->device; + struct net_device *bond_dev = bond->device; if (bond_proc_dir) { - bond->bond_proc_file = create_proc_entry(dev->name, + bond->bond_proc_file = create_proc_entry(bond_dev->name, S_IRUGO, bond_proc_dir); if (bond->bond_proc_file == NULL) { printk(KERN_WARNING DRV_NAME ": Warning: Cannot create /proc/net/bonding/%s\n", - dev->name); + bond_dev->name); } else { bond->bond_proc_file->data = bond; bond->bond_proc_file->proc_fops = &bond_info_fops; bond->bond_proc_file->owner = THIS_MODULE; - memcpy(bond->procdir_name, dev->name, IFNAMSIZ); + memcpy(bond->procdir_name, bond_dev->name, IFNAMSIZ); } } @@ -3438,9 +3431,9 @@ static void bond_destroy_proc_dir(void) * downing the master releases all slaves. We can make bonds full of * bonding devices to test this, however. */ -static int bond_set_mac_address(struct net_device *dev, void *addr) +static int bond_set_mac_address(struct net_device *bond_dev, void *addr) { - struct bonding *bond = (struct bonding *)dev->priv; + struct bonding *bond = (struct bonding *)bond_dev->priv; struct sockaddr *sa = addr, tmp_sa; struct slave *slave, *stop_at; int error; @@ -3489,12 +3482,12 @@ static int bond_set_mac_address(struct n } /* success */ - memcpy(dev->dev_addr, sa->sa_data, dev->addr_len); + memcpy(bond_dev->dev_addr, sa->sa_data, bond_dev->addr_len); return 0; unwind: - memcpy(tmp_sa.sa_data, dev->dev_addr, dev->addr_len); - tmp_sa.sa_family = dev->type; + memcpy(tmp_sa.sa_data, bond_dev->dev_addr, bond_dev->addr_len); + tmp_sa.sa_family = bond_dev->type; /* unwind from the first slave that failed to head */ stop_at = slave; @@ -3514,9 +3507,9 @@ unwind: /* * Change the MTU of all of a master's slaves to match the master */ -static int bond_change_mtu(struct net_device *dev, int newmtu) +static int bond_change_mtu(struct net_device *bond_dev, int new_mtu) { - struct bonding *bond = (struct bonding *)dev->priv; + struct bonding *bond = (struct bonding *)bond_dev->priv; struct slave *slave, *stop_at; int error; int i; @@ -3543,9 +3536,9 @@ static int bond_change_mtu(struct net_de dprintk("s %p s->p %p c_m %p\n", slave, slave->prev, slave->dev->change_mtu); if (slave->dev->change_mtu) { - error = slave->dev->change_mtu(slave->dev, newmtu); + error = slave->dev->change_mtu(slave->dev, new_mtu); } else { - slave->dev->mtu = newmtu; + slave->dev->mtu = new_mtu; error = 0; } @@ -3563,7 +3556,7 @@ static int bond_change_mtu(struct net_de } } - dev->mtu = newmtu; + bond_dev->mtu = new_mtu; return 0; @@ -3572,9 +3565,9 @@ unwind: stop_at = slave; bond_for_each_slave_from_to(bond, slave, i, bond->first_slave, stop_at) { if (slave->dev->change_mtu) { - slave->dev->change_mtu(slave->dev, dev->mtu); + slave->dev->change_mtu(slave->dev, bond_dev->mtu); } else { - slave->dev->mtu = dev->mtu; + slave->dev->mtu = bond_dev->mtu; } } @@ -3594,9 +3587,9 @@ static int bond_event_changename(struct return NOTIFY_DONE; } -static int bond_master_netdev_event(unsigned long event, struct net_device *event_dev) +static int bond_master_netdev_event(unsigned long event, struct net_device *bond_dev) { - struct bonding *event_bond = (struct bonding *)event_dev->priv; + struct bonding *event_bond = (struct bonding *)bond_dev->priv; switch (event) { case NETDEV_CHANGENAME: @@ -3613,14 +3606,14 @@ static int bond_master_netdev_event(unsi return NOTIFY_DONE; } -static int bond_slave_netdev_event(unsigned long event, struct net_device *event_dev) +static int bond_slave_netdev_event(unsigned long event, struct net_device *slave_dev) { - struct net_device *master = event_dev->master; + struct net_device *bond_dev = slave_dev->master; switch (event) { case NETDEV_UNREGISTER: - if (master != NULL) { - bond_release(master, event_dev); + if (bond_dev != NULL) { + bond_release(bond_dev, slave_dev); } break; case NETDEV_CHANGE: @@ -3697,9 +3690,9 @@ static struct notifier_block bond_netdev /* De-initialize device specific data. * Caller must hold rtnl_lock. */ -static inline void bond_deinit(struct net_device *dev) +static inline void bond_deinit(struct net_device *bond_dev) { - struct bonding *bond = (struct bonding *)dev->priv; + struct bonding *bond = (struct bonding *)bond_dev->priv; list_del(&bond->bond_list); @@ -3716,11 +3709,11 @@ static void bond_free_all(void) struct bonding *bond, *nxt; list_for_each_entry_safe(bond, nxt, &bond_dev_list, bond_list) { - struct net_device *dev = bond->device; + struct net_device *bond_dev = bond->device; - unregister_netdevice(dev); - bond_deinit(dev); - free_netdev(dev); + unregister_netdevice(bond_dev); + bond_deinit(bond_dev); + free_netdev(bond_dev); } #ifdef CONFIG_PROC_FS @@ -3732,14 +3725,12 @@ static void bond_free_all(void) * Does not allocate but creates a /proc entry. * Allowed to fail. */ -static int __init bond_init(struct net_device *dev) +static int __init bond_init(struct net_device *bond_dev) { - struct bonding *bond; + struct bonding *bond = (struct bonding *)bond_dev->priv; int count; - dprintk("Begin bond_init for %s\n", dev->name); - - bond = (struct bonding *)dev->priv; + dprintk("Begin bond_init for %s\n", bond_dev->name); /* initialize rwlocks */ rwlock_init(&bond->lock); @@ -3750,31 +3741,31 @@ static int __init bond_init(struct net_d bond->current_slave = NULL; bond->current_arp_slave = NULL; bond->primary_slave = NULL; - bond->device = dev; + bond->device = bond_dev; /* Initialize the device structure. */ - dev->set_mac_address = bond_set_mac_address; + bond_dev->set_mac_address = bond_set_mac_address; switch (bond_mode) { case BOND_MODE_ACTIVEBACKUP: - dev->hard_start_xmit = bond_xmit_activebackup; + bond_dev->hard_start_xmit = bond_xmit_activebackup; break; case BOND_MODE_ROUNDROBIN: - dev->hard_start_xmit = bond_xmit_roundrobin; + bond_dev->hard_start_xmit = bond_xmit_roundrobin; break; case BOND_MODE_XOR: - dev->hard_start_xmit = bond_xmit_xor; + bond_dev->hard_start_xmit = bond_xmit_xor; break; case BOND_MODE_BROADCAST: - dev->hard_start_xmit = bond_xmit_broadcast; + bond_dev->hard_start_xmit = bond_xmit_broadcast; break; case BOND_MODE_8023AD: - dev->hard_start_xmit = bond_3ad_xmit_xor; + bond_dev->hard_start_xmit = bond_3ad_xmit_xor; break; case BOND_MODE_TLB: case BOND_MODE_ALB: - dev->hard_start_xmit = bond_alb_xmit; - dev->set_mac_address = bond_alb_set_mac_address; + bond_dev->hard_start_xmit = bond_alb_xmit; + bond_dev->set_mac_address = bond_alb_set_mac_address; break; default: printk(KERN_ERR DRV_NAME @@ -3783,19 +3774,19 @@ static int __init bond_init(struct net_d return -EINVAL; } - dev->get_stats = bond_get_stats; - dev->open = bond_open; - dev->stop = bond_close; - dev->set_multicast_list = bond_set_multicast_list; - dev->do_ioctl = bond_do_ioctl; - dev->change_mtu = bond_change_mtu; - dev->tx_queue_len = 0; - dev->flags |= IFF_MASTER|IFF_MULTICAST; + bond_dev->get_stats = bond_get_stats; + bond_dev->open = bond_open; + bond_dev->stop = bond_close; + bond_dev->set_multicast_list = bond_set_multicast_list; + bond_dev->do_ioctl = bond_do_ioctl; + bond_dev->change_mtu = bond_change_mtu; + bond_dev->tx_queue_len = 0; + bond_dev->flags |= IFF_MASTER|IFF_MULTICAST; #ifdef CONFIG_NET_FASTROUTE - dev->accept_fastpath = bond_accept_fastpath; + bond_dev->accept_fastpath = bond_accept_fastpath; #endif - printk(KERN_INFO DRV_NAME ": %s registered with", dev->name); + printk(KERN_INFO DRV_NAME ": %s registered with", bond_dev->name); if (miimon > 0) { printk(" MII link monitoring set to %d ms", miimon); updelay /= miimon; @@ -3805,7 +3796,7 @@ static int __init bond_init(struct net_d } printk(", in %s mode.\n", bond_mode_name()); - printk(KERN_INFO DRV_NAME ": %s registered with", dev->name); + printk(KERN_INFO DRV_NAME ": %s registered with", bond_dev->name); if (arp_interval > 0) { printk(" ARP monitoring set to %d ms with %d target(s):", arp_interval, arp_ip_count); @@ -4063,7 +4054,7 @@ static int bond_check_params(void) static int __init bonding_init(void) { - int no; + int i; int err; printk(KERN_INFO "%s", version); @@ -4080,18 +4071,18 @@ static int __init bonding_init(void) #endif err = 0; - for (no = 0; no < max_bonds; no++) { - struct net_device *dev; + for (i = 0; i < max_bonds; i++) { + struct net_device *bond_dev; - dev = alloc_netdev(sizeof(struct bonding), "", ether_setup); - if (!dev) { + bond_dev = alloc_netdev(sizeof(struct bonding), "", ether_setup); + if (!bond_dev) { err = -ENOMEM; goto out_err; } - err = dev_alloc_name(dev, "bond%d"); + err = dev_alloc_name(bond_dev, "bond%d"); if (err < 0) { - free_netdev(dev); + free_netdev(bond_dev); goto out_err; } @@ -4099,18 +4090,18 @@ static int __init bonding_init(void) * /proc files), but before register_netdevice(), because we * need to set function pointers. */ - err = bond_init(dev); + err = bond_init(bond_dev); if (err < 0) { - free_netdev(dev); + free_netdev(bond_dev); goto out_err; } - SET_MODULE_OWNER(dev); + SET_MODULE_OWNER(bond_dev); - err = register_netdevice(dev); + err = register_netdevice(bond_dev); if (err < 0) { - bond_deinit(dev); - free_netdev(dev); + bond_deinit(bond_dev); + free_netdev(bond_dev); goto out_err; } }