aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ipvlan/ipvlan_main.c
diff options
context:
space:
mode:
authorMahesh Bandewar <maheshb@google.com>2017-10-11 20:16:26 -0400
committerDavid S. Miller <davem@davemloft.net>2017-10-13 01:54:22 -0400
commit32c10bbfe914c76d8802be33c97b59be9582df1b (patch)
treeeafc0f002c5e84bebc6bb5cad5138cf32ddabdf1 /drivers/net/ipvlan/ipvlan_main.c
parent743b8bb6a247c1aed3f86c144786e778adb65e3a (diff)
ipvlan: always use the current L2 addr of the master
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 <maheshb@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ipvlan/ipvlan_main.c')
-rw-r--r--drivers/net/ipvlan/ipvlan_main.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/drivers/net/ipvlan/ipvlan_main.c b/drivers/net/ipvlan/ipvlan_main.c
index 57c3856bab05..3cf67db513e2 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,
407 * while the packets use the mac-addr on the physical device. 407 * while the packets use the mac-addr on the physical device.
408 */ 408 */
409 return dev_hard_header(skb, phy_dev, type, daddr, 409 return dev_hard_header(skb, phy_dev, type, daddr,
410 saddr ? : dev->dev_addr, len); 410 saddr ? : phy_dev->dev_addr, len);
411} 411}
412 412
413static const struct header_ops ipvlan_header_ops = { 413static const struct header_ops ipvlan_header_ops = {
@@ -730,6 +730,11 @@ static int ipvlan_device_event(struct notifier_block *unused,
730 ipvlan_adjust_mtu(ipvlan, dev); 730 ipvlan_adjust_mtu(ipvlan, dev);
731 break; 731 break;
732 732
733 case NETDEV_CHANGEADDR:
734 list_for_each_entry(ipvlan, &port->ipvlans, pnode)
735 ether_addr_copy(ipvlan->dev->dev_addr, dev->dev_addr);
736 break;
737
733 case NETDEV_PRE_TYPE_CHANGE: 738 case NETDEV_PRE_TYPE_CHANGE:
734 /* Forbid underlying device to change its type. */ 739 /* Forbid underlying device to change its type. */
735 return NOTIFY_BAD; 740 return NOTIFY_BAD;