OSDN Git Service

macvlan: return correct error value
authorMatteo Croce <mcroce@redhat.com>
Fri, 30 Nov 2018 23:26:27 +0000 (00:26 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 21 Dec 2018 13:15:20 +0000 (14:15 +0100)
commit2ef6e0fe383f797a5c492767b7ade124430e9018
treecb84742b227cc3d09081511a6ed1104b08720e7a
parent2ed4392b0bb3e80bdf9d0bfeffc2651910951ff1
macvlan: return correct error value

[ Upstream commit 59f997b088d26a774958cb7b17b0763cd82de7ec ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/macvlan.c