diff options
| author | Ted Feng <artisdom@gmail.com> | 2011-12-07 19:46:21 -0500 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2011-12-12 18:50:51 -0500 |
| commit | 72b36015ba43a3cca5303f5534d2c3e1899eae29 (patch) | |
| tree | f22cdff528a87b5b86bfc285c95dd40d5d55202e /net/ipv4 | |
| parent | 4af04aba93f47699e7ac33e7cfd4da22550e6114 (diff) | |
ipip, sit: copy parms.name after register_netdevice
Same fix as 731abb9cb2 for ipip and sit tunnel.
Commit 1c5cae815d 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
Cc: stable@vger.kernel.org
Signed-off-by: Ted Feng <artisdom@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
| -rw-r--r-- | net/ipv4/ipip.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c index 065effd8349a..0b2e7329abda 100644 --- a/net/ipv4/ipip.c +++ b/net/ipv4/ipip.c | |||
| @@ -285,6 +285,8 @@ static struct ip_tunnel * ipip_tunnel_locate(struct net *net, | |||
| 285 | if (register_netdevice(dev) < 0) | 285 | if (register_netdevice(dev) < 0) |
| 286 | goto failed_free; | 286 | goto failed_free; |
| 287 | 287 | ||
| 288 | strcpy(nt->parms.name, dev->name); | ||
| 289 | |||
| 288 | dev_hold(dev); | 290 | dev_hold(dev); |
| 289 | ipip_tunnel_link(ipn, nt); | 291 | ipip_tunnel_link(ipn, nt); |
| 290 | return nt; | 292 | return nt; |
| @@ -759,7 +761,6 @@ static int ipip_tunnel_init(struct net_device *dev) | |||
| 759 | struct ip_tunnel *tunnel = netdev_priv(dev); | 761 | struct ip_tunnel *tunnel = netdev_priv(dev); |
| 760 | 762 | ||
| 761 | tunnel->dev = dev; | 763 | tunnel->dev = dev; |
| 762 | strcpy(tunnel->parms.name, dev->name); | ||
| 763 | 764 | ||
| 764 | memcpy(dev->dev_addr, &tunnel->parms.iph.saddr, 4); | 765 | memcpy(dev->dev_addr, &tunnel->parms.iph.saddr, 4); |
| 765 | memcpy(dev->broadcast, &tunnel->parms.iph.daddr, 4); | 766 | 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) | |||
| 825 | static int __net_init ipip_init_net(struct net *net) | 826 | static int __net_init ipip_init_net(struct net *net) |
| 826 | { | 827 | { |
| 827 | struct ipip_net *ipn = net_generic(net, ipip_net_id); | 828 | struct ipip_net *ipn = net_generic(net, ipip_net_id); |
| 829 | struct ip_tunnel *t; | ||
| 828 | int err; | 830 | int err; |
| 829 | 831 | ||
| 830 | ipn->tunnels[0] = ipn->tunnels_wc; | 832 | ipn->tunnels[0] = ipn->tunnels_wc; |
| @@ -848,6 +850,9 @@ static int __net_init ipip_init_net(struct net *net) | |||
| 848 | if ((err = register_netdev(ipn->fb_tunnel_dev))) | 850 | if ((err = register_netdev(ipn->fb_tunnel_dev))) |
| 849 | goto err_reg_dev; | 851 | goto err_reg_dev; |
| 850 | 852 | ||
| 853 | t = netdev_priv(ipn->fb_tunnel_dev); | ||
| 854 | |||
| 855 | strcpy(t->parms.name, ipn->fb_tunnel_dev->name); | ||
| 851 | return 0; | 856 | return 0; |
| 852 | 857 | ||
| 853 | err_reg_dev: | 858 | err_reg_dev: |
