summaryrefslogtreecommitdiffstats
path: root/drivers/net/macvlan.c
diff options
context:
space:
mode:
authorMatteo Croce <mcroce@redhat.com>2018-11-30 18:26:27 -0500
committerDavid S. Miller <davem@davemloft.net>2018-12-03 19:02:43 -0500
commit59f997b088d26a774958cb7b17b0763cd82de7ec (patch)
tree69b496f969579416c1358e43b8abdce94f7af5ec /drivers/net/macvlan.c
parentfb6df5a6234c38a9c551559506a49a677ac6f07a (diff)
macvlan: return correct error value
A MAC address must be unique among all the macvlan devices with the same lower device. The only exception is the passthru [sic] mode, which shares the lower device address. When duplicate addresses are detected, EBUSY is returned when bringing the interface up: # ip link add macvlan0 link eth0 type macvlan # read addr </sys/class/net/eth0/address # ip link set macvlan0 address $addr # ip link set macvlan0 up RTNETLINK answers: Device or resource busy Use correct error code which is EADDRINUSE, and do the check also earlier, on address change: # ip link set macvlan0 address $addr RTNETLINK answers: Address already in use Signed-off-by: Matteo Croce <mcroce@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/macvlan.c')
-rw-r--r--drivers/net/macvlan.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index fc8d5f1ee1ad..0da3d36b283b 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -608,7 +608,7 @@ static int macvlan_open(struct net_device *dev)
608 goto hash_add; 608 goto hash_add;
609 } 609 }
610 610
611 err = -EBUSY; 611 err = -EADDRINUSE;
612 if (macvlan_addr_busy(vlan->port, dev->dev_addr)) 612 if (macvlan_addr_busy(vlan->port, dev->dev_addr))
613 goto out; 613 goto out;
614 614
@@ -706,7 +706,7 @@ static int macvlan_sync_address(struct net_device *dev, unsigned char *addr)
706 } else { 706 } else {
707 /* Rehash and update the device filters */ 707 /* Rehash and update the device filters */
708 if (macvlan_addr_busy(vlan->port, addr)) 708 if (macvlan_addr_busy(vlan->port, addr))
709 return -EBUSY; 709 return -EADDRINUSE;
710 710
711 if (!macvlan_passthru(port)) { 711 if (!macvlan_passthru(port)) {
712 err = dev_uc_add(lowerdev, addr); 712 err = dev_uc_add(lowerdev, addr);
@@ -747,6 +747,9 @@ static int macvlan_set_mac_address(struct net_device *dev, void *p)
747 return dev_set_mac_address(vlan->lowerdev, addr); 747 return dev_set_mac_address(vlan->lowerdev, addr);
748 } 748 }
749 749
750 if (macvlan_addr_busy(vlan->port, addr->sa_data))
751 return -EADDRINUSE;
752
750 return macvlan_sync_address(dev, addr->sa_data); 753 return macvlan_sync_address(dev, addr->sa_data);
751} 754}
752 755