Commit 59f997b0 authored by Matteo Croce's avatar Matteo Croce Committed by David S. Miller

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: default avatarMatteo Croce <mcroce@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent fb6df5a6
...@@ -608,7 +608,7 @@ static int macvlan_open(struct net_device *dev) ...@@ -608,7 +608,7 @@ static int macvlan_open(struct net_device *dev)
goto hash_add; goto hash_add;
} }
err = -EBUSY; err = -EADDRINUSE;
if (macvlan_addr_busy(vlan->port, dev->dev_addr)) if (macvlan_addr_busy(vlan->port, dev->dev_addr))
goto out; goto out;
...@@ -706,7 +706,7 @@ static int macvlan_sync_address(struct net_device *dev, unsigned char *addr) ...@@ -706,7 +706,7 @@ static int macvlan_sync_address(struct net_device *dev, unsigned char *addr)
} else { } else {
/* Rehash and update the device filters */ /* Rehash and update the device filters */
if (macvlan_addr_busy(vlan->port, addr)) if (macvlan_addr_busy(vlan->port, addr))
return -EBUSY; return -EADDRINUSE;
if (!macvlan_passthru(port)) { if (!macvlan_passthru(port)) {
err = dev_uc_add(lowerdev, addr); err = dev_uc_add(lowerdev, addr);
...@@ -747,6 +747,9 @@ static int macvlan_set_mac_address(struct net_device *dev, void *p) ...@@ -747,6 +747,9 @@ static int macvlan_set_mac_address(struct net_device *dev, void *p)
return dev_set_mac_address(vlan->lowerdev, addr); return dev_set_mac_address(vlan->lowerdev, addr);
} }
if (macvlan_addr_busy(vlan->port, addr->sa_data))
return -EADDRINUSE;
return macvlan_sync_address(dev, addr->sa_data); return macvlan_sync_address(dev, addr->sa_data);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment