* [PATCH] ip6_tunnel: copy parms.name after register_netdevice
@ 2011-11-11 1:10 Josh Boyer
2011-11-14 5:24 ` David Miller
0 siblings, 1 reply; 3+ messages in thread
From: Josh Boyer @ 2011-11-11 1:10 UTC (permalink / raw)
To: Jiri Pirko, David S. Miller; +Cc: netdev, linux-kernel, stable
Commit 1c5cae815d 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>
---
net/ipv6/ip6_tunnel.c | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index bdc15c9..09b50d6 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -288,6 +288,8 @@ static struct ip6_tnl *ip6_tnl_create(struct net *net, struct ip6_tnl_parm *p)
if ((err = register_netdevice(dev)) < 0)
goto failed_free;
+
+ strcpy(t->parms.name, dev->name);
dev_hold(dev);
ip6_tnl_link(ip6n, t);
@@ -1407,7 +1409,6 @@ ip6_tnl_dev_init_gen(struct net_device *dev)
struct ip6_tnl *t = netdev_priv(dev);
t->dev = dev;
- strcpy(t->parms.name, dev->name);
dev->tstats = alloc_percpu(struct pcpu_tstats);
if (!dev->tstats)
return -ENOMEM;
@@ -1487,6 +1488,7 @@ static void __net_exit ip6_tnl_destroy_tunnels(struct ip6_tnl_net *ip6n)
static int __net_init ip6_tnl_init_net(struct net *net)
{
struct ip6_tnl_net *ip6n = net_generic(net, ip6_tnl_net_id);
+ struct ip6_tnl *t = NULL;
int err;
ip6n->tnls[0] = ip6n->tnls_wc;
@@ -1507,6 +1509,10 @@ static int __net_init ip6_tnl_init_net(struct net *net)
err = register_netdev(ip6n->fb_tnl_dev);
if (err < 0)
goto err_register;
+
+ t = netdev_priv(ip6n->fb_tnl_dev);
+
+ strcpy(t->parms.name, ip6n->fb_tnl_dev->name);
return 0;
err_register:
--
1.7.7
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] ip6_tunnel: copy parms.name after register_netdevice
2011-11-11 1:10 [PATCH] ip6_tunnel: copy parms.name after register_netdevice Josh Boyer
@ 2011-11-14 5:24 ` David Miller
2011-11-14 14:02 ` Josh Boyer
0 siblings, 1 reply; 3+ messages in thread
From: David Miller @ 2011-11-14 5:24 UTC (permalink / raw)
To: jwboyer; +Cc: jpirko, netdev, linux-kernel, stable
From: Josh Boyer <jwboyer@redhat.com>
Date: Thu, 10 Nov 2011 20:10:23 -0500
> @@ -288,6 +288,8 @@ static struct ip6_tnl *ip6_tnl_create(struct net *net, struct ip6_tnl_parm *p)
>
> if ((err = register_netdevice(dev)) < 0)
> goto failed_free;
> +
> + strcpy(t->parms.name, dev->name);
Trailing whitespace on that blank line you're adding.
I fixed this up, applied, and queued up for -stable, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ip6_tunnel: copy parms.name after register_netdevice
2011-11-14 5:24 ` David Miller
@ 2011-11-14 14:02 ` Josh Boyer
0 siblings, 0 replies; 3+ messages in thread
From: Josh Boyer @ 2011-11-14 14:02 UTC (permalink / raw)
To: David Miller; +Cc: jpirko, netdev, linux-kernel, stable
On Mon, Nov 14, 2011 at 12:24:56AM -0500, David Miller wrote:
> From: Josh Boyer <jwboyer@redhat.com>
> Date: Thu, 10 Nov 2011 20:10:23 -0500
>
> > @@ -288,6 +288,8 @@ static struct ip6_tnl *ip6_tnl_create(struct net *net, struct ip6_tnl_parm *p)
> >
> > if ((err = register_netdevice(dev)) < 0)
> > goto failed_free;
> > +
> > + strcpy(t->parms.name, dev->name);
>
> Trailing whitespace on that blank line you're adding.
Ugh. Forgot to run checkpatch. Apologies.
> I fixed this up, applied, and queued up for -stable, thanks.
Thank you.
josh
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-11-14 14:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-11 1:10 [PATCH] ip6_tunnel: copy parms.name after register_netdevice Josh Boyer
2011-11-14 5:24 ` David Miller
2011-11-14 14:02 ` Josh Boyer
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).