Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 69312
b: refs/heads/master
c: 2ab8285
h: refs/heads/master
v: v3
  • Loading branch information
Moni Shoua authored and Jeff Garzik committed Oct 15, 2007
1 parent d999e62 commit 4a3e90b
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 29 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 872254dd6b1f80cb95ee9e2e22980888533fc293
refs/heads/master: 2ab82852a2706b47c257ac87675ab8b06bc214dd
87 changes: 59 additions & 28 deletions trunk/drivers/net/bonding/bond_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1096,6 +1096,14 @@ void bond_change_active_slave(struct bonding *bond, struct slave *new_active)
if (new_active) {
bond_set_slave_active_flags(new_active);
}

/* when bonding does not set the slave MAC address, the bond MAC
* address is the one of the active slave.
*/
if (new_active && !bond->do_set_mac_addr)
memcpy(bond->dev->dev_addr, new_active->dev->dev_addr,
new_active->dev->addr_len);

bond_send_gratuitous_arp(bond);
}
}
Expand Down Expand Up @@ -1346,13 +1354,22 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
}

if (slave_dev->set_mac_address == NULL) {
printk(KERN_ERR DRV_NAME
": %s: Error: The slave device you specified does "
"not support setting the MAC address. "
"Your kernel likely does not support slave "
"devices.\n", bond_dev->name);
res = -EOPNOTSUPP;
goto err_undo_flags;
if (bond->slave_cnt == 0) {
printk(KERN_WARNING DRV_NAME
": %s: Warning: The first slave device you "
"specified does not support setting the MAC "
"address. This bond MAC address would be that "
"of the active slave.\n", bond_dev->name);
bond->do_set_mac_addr = 0;
} else if (bond->do_set_mac_addr) {
printk(KERN_ERR DRV_NAME
": %s: Error: The slave device you specified "
"does not support setting the MAC addres,."
"but this bond uses this practice. \n"
, bond_dev->name);
res = -EOPNOTSUPP;
goto err_undo_flags;
}
}

new_slave = kzalloc(sizeof(struct slave), GFP_KERNEL);
Expand All @@ -1373,16 +1390,18 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
*/
memcpy(new_slave->perm_hwaddr, slave_dev->dev_addr, ETH_ALEN);

/*
* Set slave to master's mac address. The application already
* set the master's mac address to that of the first slave
*/
memcpy(addr.sa_data, bond_dev->dev_addr, bond_dev->addr_len);
addr.sa_family = slave_dev->type;
res = dev_set_mac_address(slave_dev, &addr);
if (res) {
dprintk("Error %d calling set_mac_address\n", res);
goto err_free;
if (bond->do_set_mac_addr) {
/*
* Set slave to master's mac address. The application already
* set the master's mac address to that of the first slave
*/
memcpy(addr.sa_data, bond_dev->dev_addr, bond_dev->addr_len);
addr.sa_family = slave_dev->type;
res = dev_set_mac_address(slave_dev, &addr);
if (res) {
dprintk("Error %d calling set_mac_address\n", res);
goto err_free;
}
}

res = netdev_set_master(slave_dev, bond_dev);
Expand Down Expand Up @@ -1607,9 +1626,11 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
dev_close(slave_dev);

err_restore_mac:
memcpy(addr.sa_data, new_slave->perm_hwaddr, ETH_ALEN);
addr.sa_family = slave_dev->type;
dev_set_mac_address(slave_dev, &addr);
if (bond->do_set_mac_addr) {
memcpy(addr.sa_data, new_slave->perm_hwaddr, ETH_ALEN);
addr.sa_family = slave_dev->type;
dev_set_mac_address(slave_dev, &addr);
}

err_free:
kfree(new_slave);
Expand Down Expand Up @@ -1782,10 +1803,12 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev)
/* close slave before restoring its mac address */
dev_close(slave_dev);

/* restore original ("permanent") mac address */
memcpy(addr.sa_data, slave->perm_hwaddr, ETH_ALEN);
addr.sa_family = slave_dev->type;
dev_set_mac_address(slave_dev, &addr);
if (bond->do_set_mac_addr) {
/* restore original ("permanent") mac address */
memcpy(addr.sa_data, slave->perm_hwaddr, ETH_ALEN);
addr.sa_family = slave_dev->type;
dev_set_mac_address(slave_dev, &addr);
}

slave_dev->priv_flags &= ~(IFF_MASTER_8023AD | IFF_MASTER_ALB |
IFF_SLAVE_INACTIVE | IFF_BONDING |
Expand Down Expand Up @@ -1872,10 +1895,12 @@ static int bond_release_all(struct net_device *bond_dev)
/* close slave before restoring its mac address */
dev_close(slave_dev);

/* restore original ("permanent") mac address*/
memcpy(addr.sa_data, slave->perm_hwaddr, ETH_ALEN);
addr.sa_family = slave_dev->type;
dev_set_mac_address(slave_dev, &addr);
if (bond->do_set_mac_addr) {
/* restore original ("permanent") mac address*/
memcpy(addr.sa_data, slave->perm_hwaddr, ETH_ALEN);
addr.sa_family = slave_dev->type;
dev_set_mac_address(slave_dev, &addr);
}

slave_dev->priv_flags &= ~(IFF_MASTER_8023AD | IFF_MASTER_ALB |
IFF_SLAVE_INACTIVE);
Expand Down Expand Up @@ -3913,6 +3938,9 @@ static int bond_set_mac_address(struct net_device *bond_dev, void *addr)

dprintk("bond=%p, name=%s\n", bond, (bond_dev ? bond_dev->name : "None"));

if (!bond->do_set_mac_addr)
return -EOPNOTSUPP;

if (!is_valid_ether_addr(sa->sa_data)) {
return -EADDRNOTAVAIL;
}
Expand Down Expand Up @@ -4299,6 +4327,9 @@ static int bond_init(struct net_device *bond_dev, struct bond_params *params)
bond_create_proc_entry(bond);
#endif

/* set do_set_mac_addr to true on startup */
bond->do_set_mac_addr = 1;

list_add_tail(&bond->bond_list, &bond_dev_list);

return 0;
Expand Down
1 change: 1 addition & 0 deletions trunk/drivers/net/bonding/bonding.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ struct bonding {
struct timer_list mii_timer;
struct timer_list arp_timer;
s8 kill_timers;
s8 do_set_mac_addr;
struct net_device_stats stats;
#ifdef CONFIG_PROC_FS
struct proc_dir_entry *proc_entry;
Expand Down

0 comments on commit 4a3e90b

Please sign in to comment.