Message ID | 1441994781-2718585-2-git-send-email-kafai@fb.com |
---|---|
State | Changes Requested, archived |
Delegated to: | David Miller |
Headers | show |
From: Martin KaFai Lau <kafai@fb.com> Date: Fri, 11 Sep 2015 11:06:17 -0700 > @@ -1460,19 +1474,16 @@ static void ip6gre_netlink_parms(struct nlattr *data[], > static int ip6gre_tap_init(struct net_device *dev) > { > struct ip6_tnl *tunnel; > + int ret; > > - tunnel = netdev_priv(dev); > + ret = ip6gre_tunnel_init_common(dev); > + if (ret) > + return ret; > > - tunnel->dev = dev; > - tunnel->net = dev_net(dev); > - strcpy(tunnel->parms.name, dev->name); > + tunnel = netdev_priv(dev); > > ip6gre_tnl_link_config(tunnel, 1); > > - dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats); > - if (!dev->tstats) > - return -ENOMEM; > - > return 0; > } Is this really equivalent? The existing code for GRE tap device initialization would use whatever ether_setup() left in the broadcast address, it would leave dev->dev_addr alone, and unconditionally use eth_header_ops. You are changing behavior here, and it's been like this has been this way long enough that I can't see clearly whether this is a valid change or not. It probably is not. Either way, even if it is valid, you have to document what is happening here and why it's ok. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Fri, Sep 11, 2015 at 03:30:59PM -0700, David Miller wrote: > From: Martin KaFai Lau <kafai@fb.com> > Date: Fri, 11 Sep 2015 11:06:17 -0700 > > > @@ -1460,19 +1474,16 @@ static void ip6gre_netlink_parms(struct nlattr *data[], > > static int ip6gre_tap_init(struct net_device *dev) > > { > > struct ip6_tnl *tunnel; > > + int ret; > > > > - tunnel = netdev_priv(dev); > > + ret = ip6gre_tunnel_init_common(dev); > > + if (ret) > > + return ret; > > > > - tunnel->dev = dev; > > - tunnel->net = dev_net(dev); > > - strcpy(tunnel->parms.name, dev->name); > > + tunnel = netdev_priv(dev); > > > > ip6gre_tnl_link_config(tunnel, 1); > > > > - dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats); > > - if (!dev->tstats) > > - return -ENOMEM; > > - > > return 0; > > } > > Is this really equivalent? > > The existing code for GRE tap device initialization would use whatever > ether_setup() left in the broadcast address, it would leave > dev->dev_addr alone, and unconditionally use eth_header_ops. The new ip6gre_tunnel_init_common() does not set the dev->dev_addr or dev->header_ops. The change in ip6gre_tap_init() is to initialize dev->tstats before ip6gre_tnl_link_config(). or I am missing something and have overlooked a bug? Thanks, Martin -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
From: Martin KaFai Lau <kafai@fb.com> Date: Fri, 11 Sep 2015 16:20:26 -0700 > or I am missing something and have overlooked a bug? My bad, I simply misread your patch. Sorry about that. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c index 4038c69..af60d46 100644 --- a/net/ipv6/ip6_gre.c +++ b/net/ipv6/ip6_gre.c @@ -1245,7 +1245,7 @@ static void ip6gre_tunnel_setup(struct net_device *dev) netif_keep_dst(dev); } -static int ip6gre_tunnel_init(struct net_device *dev) +static int ip6gre_tunnel_init_common(struct net_device *dev) { struct ip6_tnl *tunnel; @@ -1255,16 +1255,30 @@ static int ip6gre_tunnel_init(struct net_device *dev) tunnel->net = dev_net(dev); strcpy(tunnel->parms.name, dev->name); + dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats); + if (!dev->tstats) + return -ENOMEM; + + return 0; +} + +static int ip6gre_tunnel_init(struct net_device *dev) +{ + struct ip6_tnl *tunnel; + int ret; + + ret = ip6gre_tunnel_init_common(dev); + if (ret) + return ret; + + tunnel = netdev_priv(dev); + memcpy(dev->dev_addr, &tunnel->parms.laddr, sizeof(struct in6_addr)); memcpy(dev->broadcast, &tunnel->parms.raddr, sizeof(struct in6_addr)); if (ipv6_addr_any(&tunnel->parms.raddr)) dev->header_ops = &ip6gre_header_ops; - dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats); - if (!dev->tstats) - return -ENOMEM; - return 0; } @@ -1460,19 +1474,16 @@ static void ip6gre_netlink_parms(struct nlattr *data[], static int ip6gre_tap_init(struct net_device *dev) { struct ip6_tnl *tunnel; + int ret; - tunnel = netdev_priv(dev); + ret = ip6gre_tunnel_init_common(dev); + if (ret) + return ret; - tunnel->dev = dev; - tunnel->net = dev_net(dev); - strcpy(tunnel->parms.name, dev->name); + tunnel = netdev_priv(dev); ip6gre_tnl_link_config(tunnel, 1); - dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats); - if (!dev->tstats) - return -ENOMEM; - return 0; }
It is a prep work to fix the dst_entry refcnt bugs in ip6_tunnel. This patch refactors some common init codes used by both ip6gre_tunnel_init and ip6gre_tap_init. Signed-off-by: Martin KaFai Lau <kafai@fb.com> --- net/ipv6/ip6_gre.c | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-)