Skip to content

Commit 731abb9

Browse files
jwboyerdavem330
authored andcommitted
ip6_tunnel: copy parms.name after register_netdevice
Commit 1c5cae8 removed an explicit call to dev_alloc_name in ip6_tnl_create because register_netdevice will now create a valid name. This works for the net_device itself. However the tunnel keeps a copy of the name in the parms structure for the ip6_tnl associated with the tunnel. parms.name is set by copying the net_device name in ip6_tnl_dev_init_gen. That function is called from ip6_tnl_dev_init in ip6_tnl_create, but it is done before register_netdevice is called so the name is set to a bogus value in the parms.name structure. This shows up if you do a simple tunnel add, followed by a tunnel show: [root@localhost ~]# ip -6 tunnel add remote fec0::100 local fec0::200 [root@localhost ~]# ip -6 tunnel show ip6tnl0: ipv6/ipv6 remote :: local :: encaplimit 0 hoplimit 0 tclass 0x00 flowlabel 0x00000 (flowinfo 0x00000000) ip6tnl%d: ipv6/ipv6 remote fec0::100 local fec0::200 encaplimit 4 hoplimit 64 tclass 0x00 flowlabel 0x00000 (flowinfo 0x00000000) [root@localhost ~]# Fix this by moving the strcpy out of ip6_tnl_dev_init_gen, and calling it after register_netdevice has successfully returned. Cc: stable@vger.kernel.org Signed-off-by: Josh Boyer <jwboyer@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 898bdf2 commit 731abb9

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

‎net/ipv6/ip6_tunnel.c‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,8 @@ static struct ip6_tnl *ip6_tnl_create(struct net *net, struct ip6_tnl_parm *p)
289289
if ((err = register_netdevice(dev)) < 0)
290290
goto failed_free;
291291

292+
strcpy(t->parms.name, dev->name);
293+
292294
dev_hold(dev);
293295
ip6_tnl_link(ip6n, t);
294296
return t;
@@ -1407,7 +1409,6 @@ ip6_tnl_dev_init_gen(struct net_device *dev)
14071409
struct ip6_tnl *t = netdev_priv(dev);
14081410

14091411
t->dev = dev;
1410-
strcpy(t->parms.name, dev->name);
14111412
dev->tstats = alloc_percpu(struct pcpu_tstats);
14121413
if (!dev->tstats)
14131414
return -ENOMEM;
@@ -1487,6 +1488,7 @@ static void __net_exit ip6_tnl_destroy_tunnels(struct ip6_tnl_net *ip6n)
14871488
static int __net_init ip6_tnl_init_net(struct net *net)
14881489
{
14891490
struct ip6_tnl_net *ip6n = net_generic(net, ip6_tnl_net_id);
1491+
struct ip6_tnl *t = NULL;
14901492
int err;
14911493

14921494
ip6n->tnls[0] = ip6n->tnls_wc;
@@ -1507,6 +1509,10 @@ static int __net_init ip6_tnl_init_net(struct net *net)
15071509
err = register_netdev(ip6n->fb_tnl_dev);
15081510
if (err < 0)
15091511
goto err_register;
1512+
1513+
t = netdev_priv(ip6n->fb_tnl_dev);
1514+
1515+
strcpy(t->parms.name, ip6n->fb_tnl_dev->name);
15101516
return 0;
15111517

15121518
err_register:

0 commit comments

Comments
 (0)