linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] veth: Initialize dev->perm_addr
@ 2020-08-24 14:38 Mira Ressel
  2020-08-24 14:47 ` [PATCH 2/2] vlan: " Mira Ressel
  2020-08-24 17:25 ` [PATCH 1/2] veth: " David Miller
  0 siblings, 2 replies; 8+ messages in thread
From: Mira Ressel @ 2020-08-24 14:38 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski, open list:NETWORKING DRIVERS, open list
  Cc: Mira Ressel

Set the perm_addr of veth devices to whatever MAC has been assigned to
the device. Otherwise, it remains all zero, with the consequence that
ipv6_generate_stable_address() (which is used if the sysctl
net.ipv6.conf.DEV.addr_gen_mode is set to 2 or 3) assigns every veth
interface on a host the same link-local address.

The new behaviour matches that of several other virtual interface types
(such as gre), and as far as I can tell, perm_addr isn't used by any
other code sites that are relevant to veth.

Signed-off-by: Mira Ressel <aranea@aixah.de>
---
 drivers/net/veth.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/veth.c b/drivers/net/veth.c
index e56cd562a664..af1a7cda6205 100644
--- a/drivers/net/veth.c
+++ b/drivers/net/veth.c
@@ -1342,6 +1342,8 @@ static int veth_newlink(struct net *src_net, struct net_device *dev,
 	if (!ifmp || !tbp[IFLA_ADDRESS])
 		eth_hw_addr_random(peer);
 
+	memcpy(peer->perm_addr, peer->dev_addr, peer->addr_len);
+
 	if (ifmp && (dev->ifindex != 0))
 		peer->ifindex = ifmp->ifi_index;
 
@@ -1370,6 +1372,8 @@ static int veth_newlink(struct net *src_net, struct net_device *dev,
 	if (tb[IFLA_ADDRESS] == NULL)
 		eth_hw_addr_random(dev);
 
+	memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
+
 	if (tb[IFLA_IFNAME])
 		nla_strlcpy(dev->name, tb[IFLA_IFNAME], IFNAMSIZ);
 	else
-- 
2.25.4


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-08-27  1:04 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-24 14:38 [PATCH 1/2] veth: Initialize dev->perm_addr Mira Ressel
2020-08-24 14:47 ` [PATCH 2/2] vlan: " Mira Ressel
2020-08-24 17:25 ` [PATCH 1/2] veth: " David Miller
2020-08-26 15:20   ` Mira Ressel
2020-08-26 15:28     ` David Miller
2020-08-26 16:29       ` Mira Ressel
2020-08-26 16:33         ` David Miller
2020-08-27  1:04           ` Mira Ressel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).