diff mbox series

[ovs-dev,v5] gre: Rename fallback devices to avoid udev's interference

Message ID 1537292159-25750-1-git-send-email-pkusunyifeng@gmail.com
State Accepted
Headers show
Series [ovs-dev,v5] gre: Rename fallback devices to avoid udev's interference | expand

Commit Message

Yifeng Sun Sept. 18, 2018, 5:35 p.m. UTC
On certain kernel versions, when openvswitch kernel module creates
a gre0 interface, the kernel’s gre module will jump out and compete
to control the gre0 interface. This will cause the failure of
openvswitch kernel module loading.

This fix renames fallback devices by adding a prefix "ovs-".

Signed-off-by: Yifeng Sun <pkusunyifeng@gmail.com>
VMware Issue: #2162866
---
Please backport this patch to upstream OVS down to 2.9, thanks.

v1->v2: Added sanity check for device names, thanks Justin.
v2->v3: Fix an indent error.
v3->v4: Fix by code review, also fix a potenial bug.
v4->v5: Remove unnecessary code by code review, thanks Greg!

 datapath/linux/compat/ip6_gre.c    | 5 +++--
 datapath/linux/compat/ip6_tunnel.c | 6 +++---
 datapath/linux/compat/ip_gre.c     | 2 +-
 3 files changed, 7 insertions(+), 6 deletions(-)

Comments

Gregory Rose Sept. 18, 2018, 9:43 p.m. UTC | #1
On 9/18/2018 10:35 AM, Yifeng Sun wrote:
> On certain kernel versions, when openvswitch kernel module creates
> a gre0 interface, the kernel’s gre module will jump out and compete
> to control the gre0 interface. This will cause the failure of
> openvswitch kernel module loading.
>
> This fix renames fallback devices by adding a prefix "ovs-".
>
> Signed-off-by: Yifeng Sun <pkusunyifeng@gmail.com>
> VMware Issue: #2162866
> ---

LGTM.  Thanks Yifeng!

Reviewed-by: Greg Rose <gvrose8192@gmail.com>
Tested-by: Greg Rose <gvrose8192@gmail.com>

> Please backport this patch to upstream OVS down to 2.9, thanks.
>
> v1->v2: Added sanity check for device names, thanks Justin.
> v2->v3: Fix an indent error.
> v3->v4: Fix by code review, also fix a potenial bug.
> v4->v5: Remove unnecessary code by code review, thanks Greg!
>
>   datapath/linux/compat/ip6_gre.c    | 5 +++--
>   datapath/linux/compat/ip6_tunnel.c | 6 +++---
>   datapath/linux/compat/ip_gre.c     | 2 +-
>   3 files changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/datapath/linux/compat/ip6_gre.c b/datapath/linux/compat/ip6_gre.c
> index 00dbefc9b099..182785273c6f 100644
> --- a/datapath/linux/compat/ip6_gre.c
> +++ b/datapath/linux/compat/ip6_gre.c
> @@ -377,7 +377,7 @@ static struct ip6_tnl *ip6gre_tunnel_locate(struct net *net,
>   	if (parms->name[0])
>   		strlcpy(name, parms->name, IFNAMSIZ);
>   	else
> -		strcpy(name, "ip6gre%d");
> +		strlcpy(name, "ovs-ip6gre%d", IFNAMSIZ);
>   
>   	dev = alloc_netdev(sizeof(*t), name, NET_NAME_UNKNOWN,
>   			   ip6gre_tunnel_setup);
> @@ -1712,7 +1712,8 @@ static int __net_init ip6gre_init_net(struct net *net)
>   	struct ip6gre_net *ign = net_generic(net, ip6gre_net_id);
>   	int err;
>   
> -	ign->fb_tunnel_dev = alloc_netdev(sizeof(struct ip6_tnl), "ip6gre0",
> +	ign->fb_tunnel_dev = alloc_netdev(sizeof(struct ip6_tnl),
> +					  "ovs-ip6gre0",
>   					  NET_NAME_UNKNOWN,
>   					  ip6gre_tunnel_setup);
>   	if (!ign->fb_tunnel_dev) {
> diff --git a/datapath/linux/compat/ip6_tunnel.c b/datapath/linux/compat/ip6_tunnel.c
> index 56fd8b4dd342..9f4bae7dd3d1 100644
> --- a/datapath/linux/compat/ip6_tunnel.c
> +++ b/datapath/linux/compat/ip6_tunnel.c
> @@ -355,7 +355,7 @@ static struct ip6_tnl *ip6_tnl_create(struct net *net, struct __ip6_tnl_parm *p)
>   	if (p->name[0])
>   		strlcpy(name, p->name, IFNAMSIZ);
>   	else
> -		sprintf(name, "ip6tnl%%d");
> +		strlcpy(name, "ovs-ip6tnl%d", IFNAMSIZ);
>   
>   	dev = alloc_netdev(sizeof(*t), name, NET_NAME_UNKNOWN,
>   			   ip6_tnl_dev_setup);
> @@ -1410,7 +1410,7 @@ ip6_tnl_parm_to_user(struct ip6_tnl_parm *u, const struct __ip6_tnl_parm *p)
>    *     %SIOCCHGTUNNEL: change tunnel parameters to those given
>    *     %SIOCDELTUNNEL: delete tunnel
>    *
> - *   The fallback device "ip6tnl0", created during module
> + *   The fallback device "ovs-ip6tnl0", created during module
>    *   initialization, can be used for creating other tunnel devices.
>    *
>    * Return:
> @@ -2093,7 +2093,7 @@ static int __net_init ip6_tnl_init_net(struct net *net)
>   	ip6n->tnls[1] = ip6n->tnls_r_l;
>   
>   	err = -ENOMEM;
> -	ip6n->fb_tnl_dev = alloc_netdev(sizeof(struct ip6_tnl), "ip6tnl0",
> +	ip6n->fb_tnl_dev = alloc_netdev(sizeof(struct ip6_tnl), "ovs-ip6tnl0",
>   					NET_NAME_UNKNOWN, ip6_tnl_dev_setup);
>   
>   	if (!ip6n->fb_tnl_dev)
> diff --git a/datapath/linux/compat/ip_gre.c b/datapath/linux/compat/ip_gre.c
> index 05132ba9494a..b7322c58e420 100644
> --- a/datapath/linux/compat/ip_gre.c
> +++ b/datapath/linux/compat/ip_gre.c
> @@ -1463,7 +1463,7 @@ static struct pernet_operations erspan_net_ops = {
>   
>   static int __net_init ipgre_tap_init_net(struct net *net)
>   {
> -	return ip_tunnel_init_net(net, gre_tap_net_id, &ipgre_tap_ops, "gretap0");
> +	return ip_tunnel_init_net(net, gre_tap_net_id, &ipgre_tap_ops, "ovs-gretap0");
>   }
>   
>   static void __net_exit ipgre_tap_exit_net(struct net *net)
Justin Pettit Sept. 18, 2018, 10:51 p.m. UTC | #2
This patch seems to drop the change to __ip_tunnel_create().  Was that intentional?

--Justin


> On Sep 18, 2018, at 10:35 AM, Yifeng Sun <pkusunyifeng@gmail.com> wrote:
> 
> On certain kernel versions, when openvswitch kernel module creates
> a gre0 interface, the kernel’s gre module will jump out and compete
> to control the gre0 interface. This will cause the failure of
> openvswitch kernel module loading.
> 
> This fix renames fallback devices by adding a prefix "ovs-".
> 
> Signed-off-by: Yifeng Sun <pkusunyifeng@gmail.com>
> VMware Issue: #2162866
> ---
> Please backport this patch to upstream OVS down to 2.9, thanks.
> 
> v1->v2: Added sanity check for device names, thanks Justin.
> v2->v3: Fix an indent error.
> v3->v4: Fix by code review, also fix a potenial bug.
> v4->v5: Remove unnecessary code by code review, thanks Greg!
> 
> datapath/linux/compat/ip6_gre.c    | 5 +++--
> datapath/linux/compat/ip6_tunnel.c | 6 +++---
> datapath/linux/compat/ip_gre.c     | 2 +-
> 3 files changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/datapath/linux/compat/ip6_gre.c b/datapath/linux/compat/ip6_gre.c
> index 00dbefc9b099..182785273c6f 100644
> --- a/datapath/linux/compat/ip6_gre.c
> +++ b/datapath/linux/compat/ip6_gre.c
> @@ -377,7 +377,7 @@ static struct ip6_tnl *ip6gre_tunnel_locate(struct net *net,
> 	if (parms->name[0])
> 		strlcpy(name, parms->name, IFNAMSIZ);
> 	else
> -		strcpy(name, "ip6gre%d");
> +		strlcpy(name, "ovs-ip6gre%d", IFNAMSIZ);
> 
> 	dev = alloc_netdev(sizeof(*t), name, NET_NAME_UNKNOWN,
> 			   ip6gre_tunnel_setup);
> @@ -1712,7 +1712,8 @@ static int __net_init ip6gre_init_net(struct net *net)
> 	struct ip6gre_net *ign = net_generic(net, ip6gre_net_id);
> 	int err;
> 
> -	ign->fb_tunnel_dev = alloc_netdev(sizeof(struct ip6_tnl), "ip6gre0",
> +	ign->fb_tunnel_dev = alloc_netdev(sizeof(struct ip6_tnl),
> +					  "ovs-ip6gre0",
> 					  NET_NAME_UNKNOWN,
> 					  ip6gre_tunnel_setup);
> 	if (!ign->fb_tunnel_dev) {
> diff --git a/datapath/linux/compat/ip6_tunnel.c b/datapath/linux/compat/ip6_tunnel.c
> index 56fd8b4dd342..9f4bae7dd3d1 100644
> --- a/datapath/linux/compat/ip6_tunnel.c
> +++ b/datapath/linux/compat/ip6_tunnel.c
> @@ -355,7 +355,7 @@ static struct ip6_tnl *ip6_tnl_create(struct net *net, struct __ip6_tnl_parm *p)
> 	if (p->name[0])
> 		strlcpy(name, p->name, IFNAMSIZ);
> 	else
> -		sprintf(name, "ip6tnl%%d");
> +		strlcpy(name, "ovs-ip6tnl%d", IFNAMSIZ);
> 
> 	dev = alloc_netdev(sizeof(*t), name, NET_NAME_UNKNOWN,
> 			   ip6_tnl_dev_setup);
> @@ -1410,7 +1410,7 @@ ip6_tnl_parm_to_user(struct ip6_tnl_parm *u, const struct __ip6_tnl_parm *p)
>  *     %SIOCCHGTUNNEL: change tunnel parameters to those given
>  *     %SIOCDELTUNNEL: delete tunnel
>  *
> - *   The fallback device "ip6tnl0", created during module
> + *   The fallback device "ovs-ip6tnl0", created during module
>  *   initialization, can be used for creating other tunnel devices.
>  *
>  * Return:
> @@ -2093,7 +2093,7 @@ static int __net_init ip6_tnl_init_net(struct net *net)
> 	ip6n->tnls[1] = ip6n->tnls_r_l;
> 
> 	err = -ENOMEM;
> -	ip6n->fb_tnl_dev = alloc_netdev(sizeof(struct ip6_tnl), "ip6tnl0",
> +	ip6n->fb_tnl_dev = alloc_netdev(sizeof(struct ip6_tnl), "ovs-ip6tnl0",
> 					NET_NAME_UNKNOWN, ip6_tnl_dev_setup);
> 
> 	if (!ip6n->fb_tnl_dev)
> diff --git a/datapath/linux/compat/ip_gre.c b/datapath/linux/compat/ip_gre.c
> index 05132ba9494a..b7322c58e420 100644
> --- a/datapath/linux/compat/ip_gre.c
> +++ b/datapath/linux/compat/ip_gre.c
> @@ -1463,7 +1463,7 @@ static struct pernet_operations erspan_net_ops = {
> 
> static int __net_init ipgre_tap_init_net(struct net *net)
> {
> -	return ip_tunnel_init_net(net, gre_tap_net_id, &ipgre_tap_ops, "gretap0");
> +	return ip_tunnel_init_net(net, gre_tap_net_id, &ipgre_tap_ops, "ovs-gretap0");
> }
> 
> static void __net_exit ipgre_tap_exit_net(struct net *net)
> -- 
> 2.7.4
> 
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
Yifeng Sun Sept. 18, 2018, 11 p.m. UTC | #3
Yes, after testing and review, it is considered that part is unnecessary so
it is
removed.

Thanks,
Yifeng

On Tue, Sep 18, 2018 at 3:51 PM Justin Pettit <jpettit@ovn.org> wrote:

> This patch seems to drop the change to __ip_tunnel_create().  Was that
> intentional?
>
> --Justin
>
>
> > On Sep 18, 2018, at 10:35 AM, Yifeng Sun <pkusunyifeng@gmail.com> wrote:
> >
> > On certain kernel versions, when openvswitch kernel module creates
> > a gre0 interface, the kernel’s gre module will jump out and compete
> > to control the gre0 interface. This will cause the failure of
> > openvswitch kernel module loading.
> >
> > This fix renames fallback devices by adding a prefix "ovs-".
> >
> > Signed-off-by: Yifeng Sun <pkusunyifeng@gmail.com>
> > VMware Issue: #2162866
> > ---
> > Please backport this patch to upstream OVS down to 2.9, thanks.
> >
> > v1->v2: Added sanity check for device names, thanks Justin.
> > v2->v3: Fix an indent error.
> > v3->v4: Fix by code review, also fix a potenial bug.
> > v4->v5: Remove unnecessary code by code review, thanks Greg!
> >
> > datapath/linux/compat/ip6_gre.c    | 5 +++--
> > datapath/linux/compat/ip6_tunnel.c | 6 +++---
> > datapath/linux/compat/ip_gre.c     | 2 +-
> > 3 files changed, 7 insertions(+), 6 deletions(-)
> >
> > diff --git a/datapath/linux/compat/ip6_gre.c
> b/datapath/linux/compat/ip6_gre.c
> > index 00dbefc9b099..182785273c6f 100644
> > --- a/datapath/linux/compat/ip6_gre.c
> > +++ b/datapath/linux/compat/ip6_gre.c
> > @@ -377,7 +377,7 @@ static struct ip6_tnl *ip6gre_tunnel_locate(struct
> net *net,
> >       if (parms->name[0])
> >               strlcpy(name, parms->name, IFNAMSIZ);
> >       else
> > -             strcpy(name, "ip6gre%d");
> > +             strlcpy(name, "ovs-ip6gre%d", IFNAMSIZ);
> >
> >       dev = alloc_netdev(sizeof(*t), name, NET_NAME_UNKNOWN,
> >                          ip6gre_tunnel_setup);
> > @@ -1712,7 +1712,8 @@ static int __net_init ip6gre_init_net(struct net
> *net)
> >       struct ip6gre_net *ign = net_generic(net, ip6gre_net_id);
> >       int err;
> >
> > -     ign->fb_tunnel_dev = alloc_netdev(sizeof(struct ip6_tnl),
> "ip6gre0",
> > +     ign->fb_tunnel_dev = alloc_netdev(sizeof(struct ip6_tnl),
> > +                                       "ovs-ip6gre0",
> >                                         NET_NAME_UNKNOWN,
> >                                         ip6gre_tunnel_setup);
> >       if (!ign->fb_tunnel_dev) {
> > diff --git a/datapath/linux/compat/ip6_tunnel.c
> b/datapath/linux/compat/ip6_tunnel.c
> > index 56fd8b4dd342..9f4bae7dd3d1 100644
> > --- a/datapath/linux/compat/ip6_tunnel.c
> > +++ b/datapath/linux/compat/ip6_tunnel.c
> > @@ -355,7 +355,7 @@ static struct ip6_tnl *ip6_tnl_create(struct net
> *net, struct __ip6_tnl_parm *p)
> >       if (p->name[0])
> >               strlcpy(name, p->name, IFNAMSIZ);
> >       else
> > -             sprintf(name, "ip6tnl%%d");
> > +             strlcpy(name, "ovs-ip6tnl%d", IFNAMSIZ);
> >
> >       dev = alloc_netdev(sizeof(*t), name, NET_NAME_UNKNOWN,
> >                          ip6_tnl_dev_setup);
> > @@ -1410,7 +1410,7 @@ ip6_tnl_parm_to_user(struct ip6_tnl_parm *u, const
> struct __ip6_tnl_parm *p)
> >  *     %SIOCCHGTUNNEL: change tunnel parameters to those given
> >  *     %SIOCDELTUNNEL: delete tunnel
> >  *
> > - *   The fallback device "ip6tnl0", created during module
> > + *   The fallback device "ovs-ip6tnl0", created during module
> >  *   initialization, can be used for creating other tunnel devices.
> >  *
> >  * Return:
> > @@ -2093,7 +2093,7 @@ static int __net_init ip6_tnl_init_net(struct net
> *net)
> >       ip6n->tnls[1] = ip6n->tnls_r_l;
> >
> >       err = -ENOMEM;
> > -     ip6n->fb_tnl_dev = alloc_netdev(sizeof(struct ip6_tnl), "ip6tnl0",
> > +     ip6n->fb_tnl_dev = alloc_netdev(sizeof(struct ip6_tnl),
> "ovs-ip6tnl0",
> >                                       NET_NAME_UNKNOWN,
> ip6_tnl_dev_setup);
> >
> >       if (!ip6n->fb_tnl_dev)
> > diff --git a/datapath/linux/compat/ip_gre.c
> b/datapath/linux/compat/ip_gre.c
> > index 05132ba9494a..b7322c58e420 100644
> > --- a/datapath/linux/compat/ip_gre.c
> > +++ b/datapath/linux/compat/ip_gre.c
> > @@ -1463,7 +1463,7 @@ static struct pernet_operations erspan_net_ops = {
> >
> > static int __net_init ipgre_tap_init_net(struct net *net)
> > {
> > -     return ip_tunnel_init_net(net, gre_tap_net_id, &ipgre_tap_ops,
> "gretap0");
> > +     return ip_tunnel_init_net(net, gre_tap_net_id, &ipgre_tap_ops,
> "ovs-gretap0");
> > }
> >
> > static void __net_exit ipgre_tap_exit_net(struct net *net)
> > --
> > 2.7.4
> >
> > _______________________________________________
> > dev mailing list
> > dev@openvswitch.org
> > https://mail.openvswitch.org/mailman/listinfo/ovs-dev
>
>
Justin Pettit Sept. 18, 2018, 11:01 p.m. UTC | #4
Great.  Thanks.  I'll go ahead and apply this.

--Justin


> On Sep 18, 2018, at 4:00 PM, Yifeng Sun <pkusunyifeng@gmail.com> wrote:
> 
> Yes, after testing and review, it is considered that part is unnecessary so it is
> removed.
> 
> Thanks,
> Yifeng
> 
> On Tue, Sep 18, 2018 at 3:51 PM Justin Pettit <jpettit@ovn.org> wrote:
> This patch seems to drop the change to __ip_tunnel_create().  Was that intentional?
> 
> --Justin
> 
> 
> > On Sep 18, 2018, at 10:35 AM, Yifeng Sun <pkusunyifeng@gmail.com> wrote:
> > 
> > On certain kernel versions, when openvswitch kernel module creates
> > a gre0 interface, the kernel’s gre module will jump out and compete
> > to control the gre0 interface. This will cause the failure of
> > openvswitch kernel module loading.
> > 
> > This fix renames fallback devices by adding a prefix "ovs-".
> > 
> > Signed-off-by: Yifeng Sun <pkusunyifeng@gmail.com>
> > VMware Issue: #2162866
> > ---
> > Please backport this patch to upstream OVS down to 2.9, thanks.
> > 
> > v1->v2: Added sanity check for device names, thanks Justin.
> > v2->v3: Fix an indent error.
> > v3->v4: Fix by code review, also fix a potenial bug.
> > v4->v5: Remove unnecessary code by code review, thanks Greg!
> > 
> > datapath/linux/compat/ip6_gre.c    | 5 +++--
> > datapath/linux/compat/ip6_tunnel.c | 6 +++---
> > datapath/linux/compat/ip_gre.c     | 2 +-
> > 3 files changed, 7 insertions(+), 6 deletions(-)
> > 
> > diff --git a/datapath/linux/compat/ip6_gre.c b/datapath/linux/compat/ip6_gre.c
> > index 00dbefc9b099..182785273c6f 100644
> > --- a/datapath/linux/compat/ip6_gre.c
> > +++ b/datapath/linux/compat/ip6_gre.c
> > @@ -377,7 +377,7 @@ static struct ip6_tnl *ip6gre_tunnel_locate(struct net *net,
> >       if (parms->name[0])
> >               strlcpy(name, parms->name, IFNAMSIZ);
> >       else
> > -             strcpy(name, "ip6gre%d");
> > +             strlcpy(name, "ovs-ip6gre%d", IFNAMSIZ);
> > 
> >       dev = alloc_netdev(sizeof(*t), name, NET_NAME_UNKNOWN,
> >                          ip6gre_tunnel_setup);
> > @@ -1712,7 +1712,8 @@ static int __net_init ip6gre_init_net(struct net *net)
> >       struct ip6gre_net *ign = net_generic(net, ip6gre_net_id);
> >       int err;
> > 
> > -     ign->fb_tunnel_dev = alloc_netdev(sizeof(struct ip6_tnl), "ip6gre0",
> > +     ign->fb_tunnel_dev = alloc_netdev(sizeof(struct ip6_tnl),
> > +                                       "ovs-ip6gre0",
> >                                         NET_NAME_UNKNOWN,
> >                                         ip6gre_tunnel_setup);
> >       if (!ign->fb_tunnel_dev) {
> > diff --git a/datapath/linux/compat/ip6_tunnel.c b/datapath/linux/compat/ip6_tunnel.c
> > index 56fd8b4dd342..9f4bae7dd3d1 100644
> > --- a/datapath/linux/compat/ip6_tunnel.c
> > +++ b/datapath/linux/compat/ip6_tunnel.c
> > @@ -355,7 +355,7 @@ static struct ip6_tnl *ip6_tnl_create(struct net *net, struct __ip6_tnl_parm *p)
> >       if (p->name[0])
> >               strlcpy(name, p->name, IFNAMSIZ);
> >       else
> > -             sprintf(name, "ip6tnl%%d");
> > +             strlcpy(name, "ovs-ip6tnl%d", IFNAMSIZ);
> > 
> >       dev = alloc_netdev(sizeof(*t), name, NET_NAME_UNKNOWN,
> >                          ip6_tnl_dev_setup);
> > @@ -1410,7 +1410,7 @@ ip6_tnl_parm_to_user(struct ip6_tnl_parm *u, const struct __ip6_tnl_parm *p)
> >  *     %SIOCCHGTUNNEL: change tunnel parameters to those given
> >  *     %SIOCDELTUNNEL: delete tunnel
> >  *
> > - *   The fallback device "ip6tnl0", created during module
> > + *   The fallback device "ovs-ip6tnl0", created during module
> >  *   initialization, can be used for creating other tunnel devices.
> >  *
> >  * Return:
> > @@ -2093,7 +2093,7 @@ static int __net_init ip6_tnl_init_net(struct net *net)
> >       ip6n->tnls[1] = ip6n->tnls_r_l;
> > 
> >       err = -ENOMEM;
> > -     ip6n->fb_tnl_dev = alloc_netdev(sizeof(struct ip6_tnl), "ip6tnl0",
> > +     ip6n->fb_tnl_dev = alloc_netdev(sizeof(struct ip6_tnl), "ovs-ip6tnl0",
> >                                       NET_NAME_UNKNOWN, ip6_tnl_dev_setup);
> > 
> >       if (!ip6n->fb_tnl_dev)
> > diff --git a/datapath/linux/compat/ip_gre.c b/datapath/linux/compat/ip_gre.c
> > index 05132ba9494a..b7322c58e420 100644
> > --- a/datapath/linux/compat/ip_gre.c
> > +++ b/datapath/linux/compat/ip_gre.c
> > @@ -1463,7 +1463,7 @@ static struct pernet_operations erspan_net_ops = {
> > 
> > static int __net_init ipgre_tap_init_net(struct net *net)
> > {
> > -     return ip_tunnel_init_net(net, gre_tap_net_id, &ipgre_tap_ops, "gretap0");
> > +     return ip_tunnel_init_net(net, gre_tap_net_id, &ipgre_tap_ops, "ovs-gretap0");
> > }
> > 
> > static void __net_exit ipgre_tap_exit_net(struct net *net)
> > -- 
> > 2.7.4
> > 
> > _______________________________________________
> > dev mailing list
> > dev@openvswitch.org
> > https://mail.openvswitch.org/mailman/listinfo/ovs-dev
>
Justin Pettit Sept. 18, 2018, 11:53 p.m. UTC | #5
I committed this to master and branch-2.10.  (I skipped branch-2.9 based on an off-line conversation with Greg.)

--Justin


> On Sep 18, 2018, at 4:01 PM, Justin Pettit <jpettit@ovn.org> wrote:
> 
> Great.  Thanks.  I'll go ahead and apply this.
> 
> --Justin
> 
> 
>> On Sep 18, 2018, at 4:00 PM, Yifeng Sun <pkusunyifeng@gmail.com> wrote:
>> 
>> Yes, after testing and review, it is considered that part is unnecessary so it is
>> removed.
>> 
>> Thanks,
>> Yifeng
>> 
>> On Tue, Sep 18, 2018 at 3:51 PM Justin Pettit <jpettit@ovn.org> wrote:
>> This patch seems to drop the change to __ip_tunnel_create().  Was that intentional?
>> 
>> --Justin
>> 
>> 
>>> On Sep 18, 2018, at 10:35 AM, Yifeng Sun <pkusunyifeng@gmail.com> wrote:
>>> 
>>> On certain kernel versions, when openvswitch kernel module creates
>>> a gre0 interface, the kernel’s gre module will jump out and compete
>>> to control the gre0 interface. This will cause the failure of
>>> openvswitch kernel module loading.
>>> 
>>> This fix renames fallback devices by adding a prefix "ovs-".
>>> 
>>> Signed-off-by: Yifeng Sun <pkusunyifeng@gmail.com>
>>> VMware Issue: #2162866
>>> ---
>>> Please backport this patch to upstream OVS down to 2.9, thanks.
>>> 
>>> v1->v2: Added sanity check for device names, thanks Justin.
>>> v2->v3: Fix an indent error.
>>> v3->v4: Fix by code review, also fix a potenial bug.
>>> v4->v5: Remove unnecessary code by code review, thanks Greg!
>>> 
>>> datapath/linux/compat/ip6_gre.c    | 5 +++--
>>> datapath/linux/compat/ip6_tunnel.c | 6 +++---
>>> datapath/linux/compat/ip_gre.c     | 2 +-
>>> 3 files changed, 7 insertions(+), 6 deletions(-)
>>> 
>>> diff --git a/datapath/linux/compat/ip6_gre.c b/datapath/linux/compat/ip6_gre.c
>>> index 00dbefc9b099..182785273c6f 100644
>>> --- a/datapath/linux/compat/ip6_gre.c
>>> +++ b/datapath/linux/compat/ip6_gre.c
>>> @@ -377,7 +377,7 @@ static struct ip6_tnl *ip6gre_tunnel_locate(struct net *net,
>>>      if (parms->name[0])
>>>              strlcpy(name, parms->name, IFNAMSIZ);
>>>      else
>>> -             strcpy(name, "ip6gre%d");
>>> +             strlcpy(name, "ovs-ip6gre%d", IFNAMSIZ);
>>> 
>>>      dev = alloc_netdev(sizeof(*t), name, NET_NAME_UNKNOWN,
>>>                         ip6gre_tunnel_setup);
>>> @@ -1712,7 +1712,8 @@ static int __net_init ip6gre_init_net(struct net *net)
>>>      struct ip6gre_net *ign = net_generic(net, ip6gre_net_id);
>>>      int err;
>>> 
>>> -     ign->fb_tunnel_dev = alloc_netdev(sizeof(struct ip6_tnl), "ip6gre0",
>>> +     ign->fb_tunnel_dev = alloc_netdev(sizeof(struct ip6_tnl),
>>> +                                       "ovs-ip6gre0",
>>>                                        NET_NAME_UNKNOWN,
>>>                                        ip6gre_tunnel_setup);
>>>      if (!ign->fb_tunnel_dev) {
>>> diff --git a/datapath/linux/compat/ip6_tunnel.c b/datapath/linux/compat/ip6_tunnel.c
>>> index 56fd8b4dd342..9f4bae7dd3d1 100644
>>> --- a/datapath/linux/compat/ip6_tunnel.c
>>> +++ b/datapath/linux/compat/ip6_tunnel.c
>>> @@ -355,7 +355,7 @@ static struct ip6_tnl *ip6_tnl_create(struct net *net, struct __ip6_tnl_parm *p)
>>>      if (p->name[0])
>>>              strlcpy(name, p->name, IFNAMSIZ);
>>>      else
>>> -             sprintf(name, "ip6tnl%%d");
>>> +             strlcpy(name, "ovs-ip6tnl%d", IFNAMSIZ);
>>> 
>>>      dev = alloc_netdev(sizeof(*t), name, NET_NAME_UNKNOWN,
>>>                         ip6_tnl_dev_setup);
>>> @@ -1410,7 +1410,7 @@ ip6_tnl_parm_to_user(struct ip6_tnl_parm *u, const struct __ip6_tnl_parm *p)
>>> *     %SIOCCHGTUNNEL: change tunnel parameters to those given
>>> *     %SIOCDELTUNNEL: delete tunnel
>>> *
>>> - *   The fallback device "ip6tnl0", created during module
>>> + *   The fallback device "ovs-ip6tnl0", created during module
>>> *   initialization, can be used for creating other tunnel devices.
>>> *
>>> * Return:
>>> @@ -2093,7 +2093,7 @@ static int __net_init ip6_tnl_init_net(struct net *net)
>>>      ip6n->tnls[1] = ip6n->tnls_r_l;
>>> 
>>>      err = -ENOMEM;
>>> -     ip6n->fb_tnl_dev = alloc_netdev(sizeof(struct ip6_tnl), "ip6tnl0",
>>> +     ip6n->fb_tnl_dev = alloc_netdev(sizeof(struct ip6_tnl), "ovs-ip6tnl0",
>>>                                      NET_NAME_UNKNOWN, ip6_tnl_dev_setup);
>>> 
>>>      if (!ip6n->fb_tnl_dev)
>>> diff --git a/datapath/linux/compat/ip_gre.c b/datapath/linux/compat/ip_gre.c
>>> index 05132ba9494a..b7322c58e420 100644
>>> --- a/datapath/linux/compat/ip_gre.c
>>> +++ b/datapath/linux/compat/ip_gre.c
>>> @@ -1463,7 +1463,7 @@ static struct pernet_operations erspan_net_ops = {
>>> 
>>> static int __net_init ipgre_tap_init_net(struct net *net)
>>> {
>>> -     return ip_tunnel_init_net(net, gre_tap_net_id, &ipgre_tap_ops, "gretap0");
>>> +     return ip_tunnel_init_net(net, gre_tap_net_id, &ipgre_tap_ops, "ovs-gretap0");
>>> }
>>> 
>>> static void __net_exit ipgre_tap_exit_net(struct net *net)
>>> -- 
>>> 2.7.4
>>> 
>>> _______________________________________________
>>> dev mailing list
>>> dev@openvswitch.org
>>> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
>> 
>
diff mbox series

Patch

diff --git a/datapath/linux/compat/ip6_gre.c b/datapath/linux/compat/ip6_gre.c
index 00dbefc9b099..182785273c6f 100644
--- a/datapath/linux/compat/ip6_gre.c
+++ b/datapath/linux/compat/ip6_gre.c
@@ -377,7 +377,7 @@  static struct ip6_tnl *ip6gre_tunnel_locate(struct net *net,
 	if (parms->name[0])
 		strlcpy(name, parms->name, IFNAMSIZ);
 	else
-		strcpy(name, "ip6gre%d");
+		strlcpy(name, "ovs-ip6gre%d", IFNAMSIZ);
 
 	dev = alloc_netdev(sizeof(*t), name, NET_NAME_UNKNOWN,
 			   ip6gre_tunnel_setup);
@@ -1712,7 +1712,8 @@  static int __net_init ip6gre_init_net(struct net *net)
 	struct ip6gre_net *ign = net_generic(net, ip6gre_net_id);
 	int err;
 
-	ign->fb_tunnel_dev = alloc_netdev(sizeof(struct ip6_tnl), "ip6gre0",
+	ign->fb_tunnel_dev = alloc_netdev(sizeof(struct ip6_tnl),
+					  "ovs-ip6gre0",
 					  NET_NAME_UNKNOWN,
 					  ip6gre_tunnel_setup);
 	if (!ign->fb_tunnel_dev) {
diff --git a/datapath/linux/compat/ip6_tunnel.c b/datapath/linux/compat/ip6_tunnel.c
index 56fd8b4dd342..9f4bae7dd3d1 100644
--- a/datapath/linux/compat/ip6_tunnel.c
+++ b/datapath/linux/compat/ip6_tunnel.c
@@ -355,7 +355,7 @@  static struct ip6_tnl *ip6_tnl_create(struct net *net, struct __ip6_tnl_parm *p)
 	if (p->name[0])
 		strlcpy(name, p->name, IFNAMSIZ);
 	else
-		sprintf(name, "ip6tnl%%d");
+		strlcpy(name, "ovs-ip6tnl%d", IFNAMSIZ);
 
 	dev = alloc_netdev(sizeof(*t), name, NET_NAME_UNKNOWN,
 			   ip6_tnl_dev_setup);
@@ -1410,7 +1410,7 @@  ip6_tnl_parm_to_user(struct ip6_tnl_parm *u, const struct __ip6_tnl_parm *p)
  *     %SIOCCHGTUNNEL: change tunnel parameters to those given
  *     %SIOCDELTUNNEL: delete tunnel
  *
- *   The fallback device "ip6tnl0", created during module
+ *   The fallback device "ovs-ip6tnl0", created during module
  *   initialization, can be used for creating other tunnel devices.
  *
  * Return:
@@ -2093,7 +2093,7 @@  static int __net_init ip6_tnl_init_net(struct net *net)
 	ip6n->tnls[1] = ip6n->tnls_r_l;
 
 	err = -ENOMEM;
-	ip6n->fb_tnl_dev = alloc_netdev(sizeof(struct ip6_tnl), "ip6tnl0",
+	ip6n->fb_tnl_dev = alloc_netdev(sizeof(struct ip6_tnl), "ovs-ip6tnl0",
 					NET_NAME_UNKNOWN, ip6_tnl_dev_setup);
 
 	if (!ip6n->fb_tnl_dev)
diff --git a/datapath/linux/compat/ip_gre.c b/datapath/linux/compat/ip_gre.c
index 05132ba9494a..b7322c58e420 100644
--- a/datapath/linux/compat/ip_gre.c
+++ b/datapath/linux/compat/ip_gre.c
@@ -1463,7 +1463,7 @@  static struct pernet_operations erspan_net_ops = {
 
 static int __net_init ipgre_tap_init_net(struct net *net)
 {
-	return ip_tunnel_init_net(net, gre_tap_net_id, &ipgre_tap_ops, "gretap0");
+	return ip_tunnel_init_net(net, gre_tap_net_id, &ipgre_tap_ops, "ovs-gretap0");
 }
 
 static void __net_exit ipgre_tap_exit_net(struct net *net)