From patchwork Mon Jul 31 17:53:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Semwal X-Patchwork-Id: 109041 Delivered-To: patch@linaro.org Received: by 10.140.101.6 with SMTP id t6csp495068qge; Mon, 31 Jul 2017 10:54:27 -0700 (PDT) X-Received: by 10.84.224.134 with SMTP id s6mr18259154plj.4.1501523666932; Mon, 31 Jul 2017 10:54:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501523666; cv=none; d=google.com; s=arc-20160816; b=SmEpmoLkLg/iPUZU8Xi2uLqOrmSqJNPAm/jFl88TjwiZ4RflT0EoQRT4oeQeHxRCV/ +VLYT7WbLSX8EsK8yrUN2/MCBEiUU6t95aCzlAZRRrr+X/JQOsvkRc1ILv4kfOLnNoe/ 6MiwtNugXXRmhYTxQnLAKhfaKiPyqu2+CVA2OkRZZJn0+X+GZaHr2vBmZ4JLTxQzaA+E cr5FcGx1kz+zVTT1O+c3NFB+4gMSLVET2SdIDMIqqwhx/17FsdA7KsExIbNsFbp0kY17 9jpz93WspmBKSQ1sUZ0O2cVLcCkGJfbaUoNCH3388MgTmbdk5+ewiZDsTNQFdYhjy9Uf RiuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=4rskKmvpmqzfu1wfXAapOBcW12fp+S+nn0/h7WUFWzE=; b=umBHm9P4G+qxIQGZB7BYznFgFw/5Kl/1niFTFGgZpCD8bP9L1Ysb8fGiwgYJNbT/l8 ZJHZNWvhxGNKCiRifEAGmohsYneuaTTYRHr3xEXSRyAz3hBW7kmjlsiFLCjmevllMlAn iWr9Ahe5G7x0eK9AqLgXu5YlMlvMOSeGjndp9BOFFWgUL6cJcqW1wLyLqBg64EEwQkWg 5ZCF5noUHQ29wmZ0r1y3J4o3AElbGfLH+ZekJg+zjwZIJCsIsh+Xez1mp9mP+J3JRzd9 IlqxNbQGDyjG+7AevkqBjmA2Fsj16vRIxXnl4ENVpBLz7G5FMuCg5gyudEAWkBnfQ4Dt 1bWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=VgI/R6NU; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d2si17444585pln.785.2017.07.31.10.54.26; Mon, 31 Jul 2017 10:54:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.b=VgI/R6NU; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751563AbdGaRyZ (ORCPT + 6 others); Mon, 31 Jul 2017 13:54:25 -0400 Received: from mail-pg0-f42.google.com ([74.125.83.42]:35275 "EHLO mail-pg0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751533AbdGaRyX (ORCPT ); Mon, 31 Jul 2017 13:54:23 -0400 Received: by mail-pg0-f42.google.com with SMTP id v189so11772391pgd.2 for ; Mon, 31 Jul 2017 10:54:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=4rskKmvpmqzfu1wfXAapOBcW12fp+S+nn0/h7WUFWzE=; b=VgI/R6NUt/+GicWxMAqBp7A5DWowA+t2pN41u37GdZ7Yl8e3xiZIQQUwB15T5uc+Er Icj7GYclims8vUWflSRBulRJDIRjXfZdtjR5BIxzWHyN0wuD0DLsyiIb0uqdpbXpVBnW +jnpByQGVxJtocCuCUVvtK/SQcb4i4RqrYRUA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=4rskKmvpmqzfu1wfXAapOBcW12fp+S+nn0/h7WUFWzE=; b=lHTohePcJSTQvhagKap13CMLsNJgeiO4JEXAJ3Wd25TZtU3eXjx5tRgkzKg7F7d0sX WfmJ1pDqujS77TdF2BOd6KTy1UBD9sQXwii1isCfi6Dx7/a459QYqzUqCiPKAktNW4mH Oq3Xd/1WBrkomKxnJ4R4ZjuXd/erAse5jvpzPlnu5Iapr7lRjmKSf96oKL/WKd7YFK5C j1KJwT//dxK/fzR9jXvVE5fdZhCnDtPcJcHH59kHxlvu8UThBQXAvAGL2bt2pQRvZCFR k0qnbjSrEUBYy4ByYoqGd3/GLn2TXgypnihM6t79satwgcqea7uMjbyddglc1fYa5GOT Jbgw== X-Gm-Message-State: AIVw110rl6M18Rv1bQGFohZdZIYDZ8f5+Bvut+fAtWh3Ddl5L/K0H+Xk FCVGxmRIVrC5tDNkW2R0tA== X-Received: by 10.99.180.8 with SMTP id s8mr2293808pgf.166.1501523661872; Mon, 31 Jul 2017 10:54:21 -0700 (PDT) Received: from phantom.lan ([106.51.116.52]) by smtp.gmail.com with ESMTPSA id j29sm62148749pfj.68.2017.07.31.10.54.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 31 Jul 2017 10:54:20 -0700 (PDT) From: Sumit Semwal To: stable@vger.kernel.org Cc: Mike Manning , "David S . Miller" , Sumit Semwal Subject: [PATCH for-4.4 3/3] vlan: Propagate MAC address to VLANs Date: Mon, 31 Jul 2017 23:23:31 +0530 Message-Id: <1501523611-18222-4-git-send-email-sumit.semwal@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1501523611-18222-1-git-send-email-sumit.semwal@linaro.org> References: <1501523611-18222-1-git-send-email-sumit.semwal@linaro.org> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Mike Manning Commit 308453aa9156a3b8ee382c0949befb507a32b0c1 Upstream. The MAC address of the physical interface is only copied to the VLAN when it is first created, resulting in an inconsistency after MAC address changes of only newly created VLANs having an up-to-date MAC. The VLANs should continue inheriting the MAC address of the physical interface until the VLAN MAC address is explicitly set to any value. This allows IPv6 EUI64 addresses for the VLAN to reflect any changes to the MAC of the physical interface and thus for DAD to behave as expected. Signed-off-by: Mike Manning Signed-off-by: David S. Miller Signed-off-by: Sumit Semwal --- net/8021q/vlan.c | 5 +++++ net/8021q/vlan.h | 2 ++ net/8021q/vlan_dev.c | 20 +++++++++++++++++--- 3 files changed, 24 insertions(+), 3 deletions(-) -- 2.7.4 diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c index e20ae2d3c498..5e4199d5a388 100644 --- a/net/8021q/vlan.c +++ b/net/8021q/vlan.c @@ -292,6 +292,10 @@ static void vlan_sync_address(struct net_device *dev, if (ether_addr_equal(vlan->real_dev_addr, dev->dev_addr)) return; + /* vlan continues to inherit address of lower device */ + if (vlan_dev_inherit_address(vlandev, dev)) + goto out; + /* vlan address was different from the old address and is equal to * the new address */ if (!ether_addr_equal(vlandev->dev_addr, vlan->real_dev_addr) && @@ -304,6 +308,7 @@ static void vlan_sync_address(struct net_device *dev, !ether_addr_equal(vlandev->dev_addr, dev->dev_addr)) dev_uc_add(dev, vlandev->dev_addr); +out: ether_addr_copy(vlan->real_dev_addr, dev->dev_addr); } diff --git a/net/8021q/vlan.h b/net/8021q/vlan.h index 9d010a09ab98..cc1557978066 100644 --- a/net/8021q/vlan.h +++ b/net/8021q/vlan.h @@ -109,6 +109,8 @@ int vlan_check_real_dev(struct net_device *real_dev, void vlan_setup(struct net_device *dev); int register_vlan_dev(struct net_device *dev); void unregister_vlan_dev(struct net_device *dev, struct list_head *head); +bool vlan_dev_inherit_address(struct net_device *dev, + struct net_device *real_dev); static inline u32 vlan_get_ingress_priority(struct net_device *dev, u16 vlan_tci) diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c index fded86508117..ca4dc9031073 100644 --- a/net/8021q/vlan_dev.c +++ b/net/8021q/vlan_dev.c @@ -244,6 +244,17 @@ void vlan_dev_get_realdev_name(const struct net_device *dev, char *result) strncpy(result, vlan_dev_priv(dev)->real_dev->name, 23); } +bool vlan_dev_inherit_address(struct net_device *dev, + struct net_device *real_dev) +{ + if (dev->addr_assign_type != NET_ADDR_STOLEN) + return false; + + ether_addr_copy(dev->dev_addr, real_dev->dev_addr); + call_netdevice_notifiers(NETDEV_CHANGEADDR, dev); + return true; +} + static int vlan_dev_open(struct net_device *dev) { struct vlan_dev_priv *vlan = vlan_dev_priv(dev); @@ -254,7 +265,8 @@ static int vlan_dev_open(struct net_device *dev) !(vlan->flags & VLAN_FLAG_LOOSE_BINDING)) return -ENETDOWN; - if (!ether_addr_equal(dev->dev_addr, real_dev->dev_addr)) { + if (!ether_addr_equal(dev->dev_addr, real_dev->dev_addr) && + !vlan_dev_inherit_address(dev, real_dev)) { err = dev_uc_add(real_dev, dev->dev_addr); if (err < 0) goto out; @@ -558,8 +570,10 @@ static int vlan_dev_init(struct net_device *dev) /* ipv6 shared card related stuff */ dev->dev_id = real_dev->dev_id; - if (is_zero_ether_addr(dev->dev_addr)) - eth_hw_addr_inherit(dev, real_dev); + if (is_zero_ether_addr(dev->dev_addr)) { + ether_addr_copy(dev->dev_addr, real_dev->dev_addr); + dev->addr_assign_type = NET_ADDR_STOLEN; + } if (is_zero_ether_addr(dev->broadcast)) memcpy(dev->broadcast, real_dev->broadcast, dev->addr_len);