Skip to content

Commit d853ba9

Browse files
artisdomgregkh
authored andcommitted
ipip, sit: copy parms.name after register_netdevice
commit 72b3601 upstream. Same fix as 731abb9 for ipip and sit tunnel. Commit 1c5cae8 removed an explicit call to dev_alloc_name in ipip_tunnel_locate and ipip6_tunnel_locate, because register_netdevice will now create a valid name, however the tunnel keeps a copy of the name in the private parms structure. Fix this by copying the name back after register_netdevice has successfully returned. This shows up if you do a simple tunnel add, followed by a tunnel show: $ sudo ip tunnel add mode ipip remote 10.2.20.211 $ ip tunnel tunl0: ip/ip remote any local any ttl inherit nopmtudisc tunl%d: ip/ip remote 10.2.20.211 local any ttl inherit $ sudo ip tunnel add mode sit remote 10.2.20.212 $ ip tunnel sit0: ipv6/ip remote any local any ttl 64 nopmtudisc 6rd-prefix 2002::/16 sit%d: ioctl 89f8 failed: No such device sit%d: ipv6/ip remote 10.2.20.212 local any ttl inherit Signed-off-by: Ted Feng <artisdom@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
1 parent 3d121b7 commit d853ba9

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

‎net/ipv4/ipip.c‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,8 @@ static struct ip_tunnel * ipip_tunnel_locate(struct net *net,
285285
if (register_netdevice(dev) < 0)
286286
goto failed_free;
287287

288+
strcpy(nt->parms.name, dev->name);
289+
288290
dev_hold(dev);
289291
ipip_tunnel_link(ipn, nt);
290292
return nt;
@@ -759,7 +761,6 @@ static int ipip_tunnel_init(struct net_device *dev)
759761
struct ip_tunnel *tunnel = netdev_priv(dev);
760762

761763
tunnel->dev = dev;
762-
strcpy(tunnel->parms.name, dev->name);
763764

764765
memcpy(dev->dev_addr, &tunnel->parms.iph.saddr, 4);
765766
memcpy(dev->broadcast, &tunnel->parms.iph.daddr, 4);
@@ -825,6 +826,7 @@ static void ipip_destroy_tunnels(struct ipip_net *ipn, struct list_head *head)
825826
static int __net_init ipip_init_net(struct net *net)
826827
{
827828
struct ipip_net *ipn = net_generic(net, ipip_net_id);
829+
struct ip_tunnel *t;
828830
int err;
829831

830832
ipn->tunnels[0] = ipn->tunnels_wc;
@@ -848,6 +850,9 @@ static int __net_init ipip_init_net(struct net *net)
848850
if ((err = register_netdev(ipn->fb_tunnel_dev)))
849851
goto err_reg_dev;
850852

853+
t = netdev_priv(ipn->fb_tunnel_dev);
854+
855+
strcpy(t->parms.name, ipn->fb_tunnel_dev->name);
851856
return 0;
852857

853858
err_reg_dev:

‎net/ipv6/sit.c‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,8 @@ static struct ip_tunnel *ipip6_tunnel_locate(struct net *net,
263263
if (register_netdevice(dev) < 0)
264264
goto failed_free;
265265

266+
strcpy(nt->parms.name, dev->name);
267+
266268
dev_hold(dev);
267269

268270
ipip6_tunnel_link(sitn, nt);
@@ -1144,7 +1146,6 @@ static int ipip6_tunnel_init(struct net_device *dev)
11441146
struct ip_tunnel *tunnel = netdev_priv(dev);
11451147

11461148
tunnel->dev = dev;
1147-
strcpy(tunnel->parms.name, dev->name);
11481149

11491150
memcpy(dev->dev_addr, &tunnel->parms.iph.saddr, 4);
11501151
memcpy(dev->broadcast, &tunnel->parms.iph.daddr, 4);
@@ -1207,6 +1208,7 @@ static void __net_exit sit_destroy_tunnels(struct sit_net *sitn, struct list_hea
12071208
static int __net_init sit_init_net(struct net *net)
12081209
{
12091210
struct sit_net *sitn = net_generic(net, sit_net_id);
1211+
struct ip_tunnel *t;
12101212
int err;
12111213

12121214
sitn->tunnels[0] = sitn->tunnels_wc;
@@ -1231,6 +1233,9 @@ static int __net_init sit_init_net(struct net *net)
12311233
if ((err = register_netdev(sitn->fb_tunnel_dev)))
12321234
goto err_reg_dev;
12331235

1236+
t = netdev_priv(sitn->fb_tunnel_dev);
1237+
1238+
strcpy(t->parms.name, sitn->fb_tunnel_dev->name);
12341239
return 0;
12351240

12361241
err_reg_dev:

0 commit comments

Comments
 (0)