From patchwork Thu Oct 12 00:16:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mahesh Bandewar X-Patchwork-Id: 824613 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=bandewar-net.20150623.gappssmtp.com header.i=@bandewar-net.20150623.gappssmtp.com header.b="1neGyh6t"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3yCBGv03WSz9t16 for ; Thu, 12 Oct 2017 11:16:39 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752654AbdJLAQg (ORCPT ); Wed, 11 Oct 2017 20:16:36 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:50187 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752626AbdJLAQe (ORCPT ); Wed, 11 Oct 2017 20:16:34 -0400 Received: by mail-pf0-f196.google.com with SMTP id m63so2556664pfk.7 for ; Wed, 11 Oct 2017 17:16:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bandewar-net.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=ero6FpptELJ2QJiJlw+Th7YgKtwBRjgI+a1Z6jb/EiI=; b=1neGyh6t25qZPv1TaSJGsCX9x2AAOrblGDdI4houNMvxQAKkF2Zz9c1MrzmBYFgaMP O6bpfHyISgb55HKZZPEw1Au0HqexIYBq59PvP9hn92IS9pkE19PnVdSjOvpM9Ee1zWFL /7ZOG74P7MVzcxvsf4WE4IvcOv5NDdmlyVK7OfnMVgW0Is20KgVMlTUMwtNrvS6zST9N A8CtZOyHL3mSWjT16u+o7eGLEJ8+CXfR1PBSdv78q5PUWWv5RfkerSQkxaFYYE4/fCtv ZtOXArIRl+zP8t7Fs9GBtkNyKFZR87A/GCDHMpZlwXmdV55TwylbDgnWS7G0KgZQUd3C QC5A== 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; bh=ero6FpptELJ2QJiJlw+Th7YgKtwBRjgI+a1Z6jb/EiI=; b=X3rQSZIBGKka90nxr1dv+HofQtMjHvueO+w764bD347tgMdrb+l0u6NX3uUpqevMJU Ky2MqCDxNKHh9/odXRakIiORd//vK8J6QN2k7npNQEhpnVg6I/1lPWLvkggroZ1PTIk6 /hc7Za0O+SmkrYa7B5eaFdzdVK8mqg6sLvcE+WaKPjoUXSb0sw3lzH8JaNn0XP53y6mk tbtOAUaPA5nmGhrAYP50BpRjGJbjXRAWfNY5e+hyi0YR31sPGhZnAleVXMpBslkI3AVW zQJevpUlLjYx1BtoddDJ0aXdc3CltMAUV+qsEAvTT/GIq3GaZHr8VuJaPhibnQVwRszx vTBg== X-Gm-Message-State: AMCzsaWPJneqe1yS8eqd93SjuzqBO8Avt/1Yu3p8apTCF8efbrR2U/Hd SuwfebSuqBLVkXiwkuuhtblY91zWTX4= X-Google-Smtp-Source: AOwi7QCYCRBe7SeBnwsxYM7qYjaLVNdGUoZB7HsNBL8DPQUwEWLNFZLWuHlPi8lVRU3rEkG7i5juew== X-Received: by 10.98.204.69 with SMTP id a66mr634088pfg.132.1507767393515; Wed, 11 Oct 2017 17:16:33 -0700 (PDT) Received: from localhost ([2620:15c:2cb:201:acd5:9ee2:cd8f:df9f]) by smtp.gmail.com with ESMTPSA id z1sm25696267pge.45.2017.10.11.17.16.31 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Wed, 11 Oct 2017 17:16:31 -0700 (PDT) From: Mahesh Bandewar To: Netdev Cc: Eric Dumazet , David Miller , Mahesh Bandewar , Mahesh Bandewar Subject: [PATCH next] ipvlan: always use the current L2 addr of the master Date: Wed, 11 Oct 2017 17:16:26 -0700 Message-Id: <20171012001626.3255-1-mahesh@bandewar.net> X-Mailer: git-send-email 2.15.0.rc0.271.g36b669edcc-goog Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Mahesh Bandewar If the underlying master ever changes its L2 (e.g. bonding device), then make sure that the IPvlan slaves always emit packets with the current L2 of the master instead of the stale mac addr which was copied during the device creation. The problem can be seen with following script - #!/bin/bash # Create a vEth pair ip link add dev veth0 type veth peer name veth1 ip link set veth0 up ip link set veth1 up ip link show veth0 ip link show veth1 # Create an IPvlan device on one end of this vEth pair. ip link add link veth0 dev ipvl0 type ipvlan mode l2 ip link show ipvl0 # Change the mac-address of the vEth master. ip link set veth0 address 02:11:22:33:44:55 Fixes: 2ad7bf363841 ("ipvlan: Initial check-in of the IPVLAN driver.") Signed-off-by: Mahesh Bandewar --- drivers/net/ipvlan/ipvlan_main.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/net/ipvlan/ipvlan_main.c b/drivers/net/ipvlan/ipvlan_main.c index c74893c1e620..5832091680f4 100644 --- a/drivers/net/ipvlan/ipvlan_main.c +++ b/drivers/net/ipvlan/ipvlan_main.c @@ -407,7 +407,7 @@ static int ipvlan_hard_header(struct sk_buff *skb, struct net_device *dev, * while the packets use the mac-addr on the physical device. */ return dev_hard_header(skb, phy_dev, type, daddr, - saddr ? : dev->dev_addr, len); + saddr ? : phy_dev->dev_addr, len); } static const struct header_ops ipvlan_header_ops = { @@ -730,6 +730,11 @@ static int ipvlan_device_event(struct notifier_block *unused, ipvlan_adjust_mtu(ipvlan, dev); break; + case NETDEV_CHANGEADDR: + list_for_each_entry(ipvlan, &port->ipvlans, pnode) + ether_addr_copy(ipvlan->dev->dev_addr, dev->dev_addr); + break; + case NETDEV_PRE_TYPE_CHANGE: /* Forbid underlying device to change its type. */ return NOTIFY_BAD;