diff options
Diffstat (limited to 'drivers/net/bonding/bond_main.c')
-rw-r--r-- | drivers/net/bonding/bond_main.c | 73 |
1 files changed, 42 insertions, 31 deletions
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 535388b15cde..aba7352906a5 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c | |||
@@ -645,8 +645,8 @@ static void bond_do_fail_over_mac(struct bonding *bond, | |||
645 | struct slave *new_active, | 645 | struct slave *new_active, |
646 | struct slave *old_active) | 646 | struct slave *old_active) |
647 | { | 647 | { |
648 | u8 tmp_mac[ETH_ALEN]; | 648 | u8 tmp_mac[MAX_ADDR_LEN]; |
649 | struct sockaddr saddr; | 649 | struct sockaddr_storage ss; |
650 | int rv; | 650 | int rv; |
651 | 651 | ||
652 | switch (bond->params.fail_over_mac) { | 652 | switch (bond->params.fail_over_mac) { |
@@ -666,16 +666,20 @@ static void bond_do_fail_over_mac(struct bonding *bond, | |||
666 | old_active = bond_get_old_active(bond, new_active); | 666 | old_active = bond_get_old_active(bond, new_active); |
667 | 667 | ||
668 | if (old_active) { | 668 | if (old_active) { |
669 | ether_addr_copy(tmp_mac, new_active->dev->dev_addr); | 669 | bond_hw_addr_copy(tmp_mac, new_active->dev->dev_addr, |
670 | ether_addr_copy(saddr.sa_data, | 670 | new_active->dev->addr_len); |
671 | old_active->dev->dev_addr); | 671 | bond_hw_addr_copy(ss.__data, |
672 | saddr.sa_family = new_active->dev->type; | 672 | old_active->dev->dev_addr, |
673 | old_active->dev->addr_len); | ||
674 | ss.ss_family = new_active->dev->type; | ||
673 | } else { | 675 | } else { |
674 | ether_addr_copy(saddr.sa_data, bond->dev->dev_addr); | 676 | bond_hw_addr_copy(ss.__data, bond->dev->dev_addr, |
675 | saddr.sa_family = bond->dev->type; | 677 | bond->dev->addr_len); |
678 | ss.ss_family = bond->dev->type; | ||
676 | } | 679 | } |
677 | 680 | ||
678 | rv = dev_set_mac_address(new_active->dev, &saddr); | 681 | rv = dev_set_mac_address(new_active->dev, |
682 | (struct sockaddr *)&ss); | ||
679 | if (rv) { | 683 | if (rv) { |
680 | netdev_err(bond->dev, "Error %d setting MAC of slave %s\n", | 684 | netdev_err(bond->dev, "Error %d setting MAC of slave %s\n", |
681 | -rv, new_active->dev->name); | 685 | -rv, new_active->dev->name); |
@@ -685,10 +689,12 @@ static void bond_do_fail_over_mac(struct bonding *bond, | |||
685 | if (!old_active) | 689 | if (!old_active) |
686 | goto out; | 690 | goto out; |
687 | 691 | ||
688 | ether_addr_copy(saddr.sa_data, tmp_mac); | 692 | bond_hw_addr_copy(ss.__data, tmp_mac, |
689 | saddr.sa_family = old_active->dev->type; | 693 | new_active->dev->addr_len); |
694 | ss.ss_family = old_active->dev->type; | ||
690 | 695 | ||
691 | rv = dev_set_mac_address(old_active->dev, &saddr); | 696 | rv = dev_set_mac_address(old_active->dev, |
697 | (struct sockaddr *)&ss); | ||
692 | if (rv) | 698 | if (rv) |
693 | netdev_err(bond->dev, "Error %d setting MAC of slave %s\n", | 699 | netdev_err(bond->dev, "Error %d setting MAC of slave %s\n", |
694 | -rv, new_active->dev->name); | 700 | -rv, new_active->dev->name); |
@@ -1184,7 +1190,8 @@ static rx_handler_result_t bond_handle_frame(struct sk_buff **pskb) | |||
1184 | kfree_skb(skb); | 1190 | kfree_skb(skb); |
1185 | return RX_HANDLER_CONSUMED; | 1191 | return RX_HANDLER_CONSUMED; |
1186 | } | 1192 | } |
1187 | ether_addr_copy(eth_hdr(skb)->h_dest, bond->dev->dev_addr); | 1193 | bond_hw_addr_copy(eth_hdr(skb)->h_dest, bond->dev->dev_addr, |
1194 | bond->dev->addr_len); | ||
1188 | } | 1195 | } |
1189 | 1196 | ||
1190 | return ret; | 1197 | return ret; |
@@ -1323,7 +1330,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) | |||
1323 | struct bonding *bond = netdev_priv(bond_dev); | 1330 | struct bonding *bond = netdev_priv(bond_dev); |
1324 | const struct net_device_ops *slave_ops = slave_dev->netdev_ops; | 1331 | const struct net_device_ops *slave_ops = slave_dev->netdev_ops; |
1325 | struct slave *new_slave = NULL, *prev_slave; | 1332 | struct slave *new_slave = NULL, *prev_slave; |
1326 | struct sockaddr addr; | 1333 | struct sockaddr_storage ss; |
1327 | int link_reporting; | 1334 | int link_reporting; |
1328 | int res = 0, i; | 1335 | int res = 0, i; |
1329 | 1336 | ||
@@ -1474,16 +1481,17 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) | |||
1474 | * that need it, and for restoring it upon release, and then | 1481 | * that need it, and for restoring it upon release, and then |
1475 | * set it to the master's address | 1482 | * set it to the master's address |
1476 | */ | 1483 | */ |
1477 | ether_addr_copy(new_slave->perm_hwaddr, slave_dev->dev_addr); | 1484 | bond_hw_addr_copy(new_slave->perm_hwaddr, slave_dev->dev_addr, |
1485 | slave_dev->addr_len); | ||
1478 | 1486 | ||
1479 | if (!bond->params.fail_over_mac || | 1487 | if (!bond->params.fail_over_mac || |
1480 | BOND_MODE(bond) != BOND_MODE_ACTIVEBACKUP) { | 1488 | BOND_MODE(bond) != BOND_MODE_ACTIVEBACKUP) { |
1481 | /* Set slave to master's mac address. The application already | 1489 | /* Set slave to master's mac address. The application already |
1482 | * set the master's mac address to that of the first slave | 1490 | * set the master's mac address to that of the first slave |
1483 | */ | 1491 | */ |
1484 | memcpy(addr.sa_data, bond_dev->dev_addr, bond_dev->addr_len); | 1492 | memcpy(ss.__data, bond_dev->dev_addr, bond_dev->addr_len); |
1485 | addr.sa_family = slave_dev->type; | 1493 | ss.ss_family = slave_dev->type; |
1486 | res = dev_set_mac_address(slave_dev, &addr); | 1494 | res = dev_set_mac_address(slave_dev, (struct sockaddr *)&ss); |
1487 | if (res) { | 1495 | if (res) { |
1488 | netdev_dbg(bond_dev, "Error %d calling set_mac_address\n", res); | 1496 | netdev_dbg(bond_dev, "Error %d calling set_mac_address\n", res); |
1489 | goto err_restore_mtu; | 1497 | goto err_restore_mtu; |
@@ -1767,9 +1775,10 @@ err_restore_mac: | |||
1767 | * MAC if this slave's MAC is in use by the bond, or at | 1775 | * MAC if this slave's MAC is in use by the bond, or at |
1768 | * least print a warning. | 1776 | * least print a warning. |
1769 | */ | 1777 | */ |
1770 | ether_addr_copy(addr.sa_data, new_slave->perm_hwaddr); | 1778 | bond_hw_addr_copy(ss.__data, new_slave->perm_hwaddr, |
1771 | addr.sa_family = slave_dev->type; | 1779 | new_slave->dev->addr_len); |
1772 | dev_set_mac_address(slave_dev, &addr); | 1780 | ss.ss_family = slave_dev->type; |
1781 | dev_set_mac_address(slave_dev, (struct sockaddr *)&ss); | ||
1773 | } | 1782 | } |
1774 | 1783 | ||
1775 | err_restore_mtu: | 1784 | err_restore_mtu: |
@@ -1812,7 +1821,7 @@ static int __bond_release_one(struct net_device *bond_dev, | |||
1812 | { | 1821 | { |
1813 | struct bonding *bond = netdev_priv(bond_dev); | 1822 | struct bonding *bond = netdev_priv(bond_dev); |
1814 | struct slave *slave, *oldcurrent; | 1823 | struct slave *slave, *oldcurrent; |
1815 | struct sockaddr addr; | 1824 | struct sockaddr_storage ss; |
1816 | int old_flags = bond_dev->flags; | 1825 | int old_flags = bond_dev->flags; |
1817 | netdev_features_t old_features = bond_dev->features; | 1826 | netdev_features_t old_features = bond_dev->features; |
1818 | 1827 | ||
@@ -1947,9 +1956,10 @@ static int __bond_release_one(struct net_device *bond_dev, | |||
1947 | if (bond->params.fail_over_mac != BOND_FOM_ACTIVE || | 1956 | if (bond->params.fail_over_mac != BOND_FOM_ACTIVE || |
1948 | BOND_MODE(bond) != BOND_MODE_ACTIVEBACKUP) { | 1957 | BOND_MODE(bond) != BOND_MODE_ACTIVEBACKUP) { |
1949 | /* restore original ("permanent") mac address */ | 1958 | /* restore original ("permanent") mac address */ |
1950 | ether_addr_copy(addr.sa_data, slave->perm_hwaddr); | 1959 | bond_hw_addr_copy(ss.__data, slave->perm_hwaddr, |
1951 | addr.sa_family = slave_dev->type; | 1960 | slave->dev->addr_len); |
1952 | dev_set_mac_address(slave_dev, &addr); | 1961 | ss.ss_family = slave_dev->type; |
1962 | dev_set_mac_address(slave_dev, (struct sockaddr *)&ss); | ||
1953 | } | 1963 | } |
1954 | 1964 | ||
1955 | dev_set_mtu(slave_dev, slave->original_mtu); | 1965 | dev_set_mtu(slave_dev, slave->original_mtu); |
@@ -3626,7 +3636,7 @@ static int bond_set_mac_address(struct net_device *bond_dev, void *addr) | |||
3626 | { | 3636 | { |
3627 | struct bonding *bond = netdev_priv(bond_dev); | 3637 | struct bonding *bond = netdev_priv(bond_dev); |
3628 | struct slave *slave, *rollback_slave; | 3638 | struct slave *slave, *rollback_slave; |
3629 | struct sockaddr *sa = addr, tmp_sa; | 3639 | struct sockaddr_storage *ss = addr, tmp_ss; |
3630 | struct list_head *iter; | 3640 | struct list_head *iter; |
3631 | int res = 0; | 3641 | int res = 0; |
3632 | 3642 | ||
@@ -3643,7 +3653,7 @@ static int bond_set_mac_address(struct net_device *bond_dev, void *addr) | |||
3643 | BOND_MODE(bond) == BOND_MODE_ACTIVEBACKUP) | 3653 | BOND_MODE(bond) == BOND_MODE_ACTIVEBACKUP) |
3644 | return 0; | 3654 | return 0; |
3645 | 3655 | ||
3646 | if (!is_valid_ether_addr(sa->sa_data)) | 3656 | if (!is_valid_ether_addr(ss->__data)) |
3647 | return -EADDRNOTAVAIL; | 3657 | return -EADDRNOTAVAIL; |
3648 | 3658 | ||
3649 | bond_for_each_slave(bond, slave, iter) { | 3659 | bond_for_each_slave(bond, slave, iter) { |
@@ -3662,12 +3672,12 @@ static int bond_set_mac_address(struct net_device *bond_dev, void *addr) | |||
3662 | } | 3672 | } |
3663 | 3673 | ||
3664 | /* success */ | 3674 | /* success */ |
3665 | memcpy(bond_dev->dev_addr, sa->sa_data, bond_dev->addr_len); | 3675 | memcpy(bond_dev->dev_addr, ss->__data, bond_dev->addr_len); |
3666 | return 0; | 3676 | return 0; |
3667 | 3677 | ||
3668 | unwind: | 3678 | unwind: |
3669 | memcpy(tmp_sa.sa_data, bond_dev->dev_addr, bond_dev->addr_len); | 3679 | memcpy(tmp_ss.__data, bond_dev->dev_addr, bond_dev->addr_len); |
3670 | tmp_sa.sa_family = bond_dev->type; | 3680 | tmp_ss.ss_family = bond_dev->type; |
3671 | 3681 | ||
3672 | /* unwind from head to the slave that failed */ | 3682 | /* unwind from head to the slave that failed */ |
3673 | bond_for_each_slave(bond, rollback_slave, iter) { | 3683 | bond_for_each_slave(bond, rollback_slave, iter) { |
@@ -3676,7 +3686,8 @@ unwind: | |||
3676 | if (rollback_slave == slave) | 3686 | if (rollback_slave == slave) |
3677 | break; | 3687 | break; |
3678 | 3688 | ||
3679 | tmp_res = dev_set_mac_address(rollback_slave->dev, &tmp_sa); | 3689 | tmp_res = dev_set_mac_address(rollback_slave->dev, |
3690 | (struct sockaddr *)&tmp_ss); | ||
3680 | if (tmp_res) { | 3691 | if (tmp_res) { |
3681 | netdev_dbg(bond_dev, "unwind err %d dev %s\n", | 3692 | netdev_dbg(bond_dev, "unwind err %d dev %s\n", |
3682 | tmp_res, rollback_slave->dev->name); | 3693 | tmp_res, rollback_slave->dev->name); |