From: Matteo Croce Subject: [PATCH net] macvlan: return correct error value Date: Sat, 1 Dec 2018 00:26:27 +0100 Message-ID: <20181130232627.8524-1-mcroce@redhat.com> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Cc: Patrick McHardy , Jeff Kirsher , Alexander Duyck To: netdev@vger.kernel.org Return-path: Received: from mail-wm1-f67.google.com ([209.85.128.67]:54215 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725790AbeLAKhZ (ORCPT ); Sat, 1 Dec 2018 05:37:25 -0500 Received: by mail-wm1-f67.google.com with SMTP id y1so505866wmi.3 for ; Fri, 30 Nov 2018 15:26:29 -0800 (PST) Sender: netdev-owner@vger.kernel.org List-ID: 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 --- drivers/net/macvlan.c | 7 +++++-- 1 file 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) goto hash_add; } - err = -EBUSY; + err = -EADDRINUSE; if (macvlan_addr_busy(vlan->port, dev->dev_addr)) goto out; @@ -706,7 +706,7 @@ static int macvlan_sync_address(struct net_device *dev, unsigned char *addr) } else { /* Rehash and update the device filters */ if (macvlan_addr_busy(vlan->port, addr)) - return -EBUSY; + return -EADDRINUSE; if (!macvlan_passthru(port)) { err = dev_uc_add(lowerdev, addr); @@ -747,6 +747,9 @@ static int macvlan_set_mac_address(struct net_device *dev, void *p) 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); } -- 2.19.1