netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net 0/2] tunnels: don't allow to add the same tunnel twice
@ 2014-04-11 13:51 Nicolas Dichtel
  2014-04-11 13:51 ` [PATCH net 1/2] gre: " Nicolas Dichtel
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Nicolas Dichtel @ 2014-04-11 13:51 UTC (permalink / raw)
  To: davem; +Cc: netdev


This serie fix the check of an existing tunnel with the same parameters when
a new tunnel is added.
I've checked all users of ip_tunnel_newlink(): gre, gretap, ipip and vti. The
bug exists only for gre and vti.

 net/ipv4/ip_gre.c | 2 +-
 net/ipv4/ip_vti.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Regards,
Nicolas

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH net 1/2] gre: don't allow to add the same tunnel twice
  2014-04-11 13:51 [PATCH net 0/2] tunnels: don't allow to add the same tunnel twice Nicolas Dichtel
@ 2014-04-11 13:51 ` Nicolas Dichtel
  2014-04-11 13:51 ` [PATCH net 2/2] vti: " Nicolas Dichtel
  2014-04-12 21:04 ` [PATCH net 0/2] tunnels: " David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Nicolas Dichtel @ 2014-04-11 13:51 UTC (permalink / raw)
  To: davem; +Cc: netdev, Nicolas Dichtel, Pravin B Shelar

Before the patch, it was possible to add two times the same tunnel:
ip l a gre1 type gre remote 10.16.0.121 local 10.16.0.249
ip l a gre2 type gre remote 10.16.0.121 local 10.16.0.249

It was possible, because ip_tunnel_newlink() calls ip_tunnel_find() with the
argument dev->type, which was set only later (when calling ndo_init handler
in register_netdevice()). Let's set this type in the setup handler, which is
called before newlink handler.

Introduced by commit c54419321455 ("GRE: Refactor GRE tunneling code.").

CC: Pravin B Shelar <pshelar@nicira.com>
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
---
 net/ipv4/ip_gre.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index ec4f762efda5..94213c891565 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -463,6 +463,7 @@ static const struct net_device_ops ipgre_netdev_ops = {
 static void ipgre_tunnel_setup(struct net_device *dev)
 {
 	dev->netdev_ops		= &ipgre_netdev_ops;
+	dev->type		= ARPHRD_IPGRE;
 	ip_tunnel_setup(dev, ipgre_net_id);
 }
 
@@ -501,7 +502,6 @@ static int ipgre_tunnel_init(struct net_device *dev)
 	memcpy(dev->dev_addr, &iph->saddr, 4);
 	memcpy(dev->broadcast, &iph->daddr, 4);
 
-	dev->type		= ARPHRD_IPGRE;
 	dev->flags		= IFF_NOARP;
 	dev->priv_flags		&= ~IFF_XMIT_DST_RELEASE;
 	dev->addr_len		= 4;
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH net 2/2] vti: don't allow to add the same tunnel twice
  2014-04-11 13:51 [PATCH net 0/2] tunnels: don't allow to add the same tunnel twice Nicolas Dichtel
  2014-04-11 13:51 ` [PATCH net 1/2] gre: " Nicolas Dichtel
@ 2014-04-11 13:51 ` Nicolas Dichtel
  2014-04-12 21:04 ` [PATCH net 0/2] tunnels: " David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Nicolas Dichtel @ 2014-04-11 13:51 UTC (permalink / raw)
  To: davem; +Cc: netdev, Nicolas Dichtel, Cong Wang, Steffen Klassert

Before the patch, it was possible to add two times the same tunnel:
ip l a vti1 type vti remote 10.16.0.121 local 10.16.0.249 key 41
ip l a vti2 type vti remote 10.16.0.121 local 10.16.0.249 key 41

It was possible, because ip_tunnel_newlink() calls ip_tunnel_find() with the
argument dev->type, which was set only later (when calling ndo_init handler
in register_netdevice()). Let's set this type in the setup handler, which is
called before newlink handler.

Introduced by commit b9959fd3b0fa ("vti: switch to new ip tunnel code").

CC: Cong Wang <amwang@redhat.com>
CC: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
---
 net/ipv4/ip_vti.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
index 687ddef4e574..afcee51b90ed 100644
--- a/net/ipv4/ip_vti.c
+++ b/net/ipv4/ip_vti.c
@@ -337,6 +337,7 @@ static const struct net_device_ops vti_netdev_ops = {
 static void vti_tunnel_setup(struct net_device *dev)
 {
 	dev->netdev_ops		= &vti_netdev_ops;
+	dev->type		= ARPHRD_TUNNEL;
 	ip_tunnel_setup(dev, vti_net_id);
 }
 
@@ -348,7 +349,6 @@ static int vti_tunnel_init(struct net_device *dev)
 	memcpy(dev->dev_addr, &iph->saddr, 4);
 	memcpy(dev->broadcast, &iph->daddr, 4);
 
-	dev->type		= ARPHRD_TUNNEL;
 	dev->hard_header_len	= LL_MAX_HEADER + sizeof(struct iphdr);
 	dev->mtu		= ETH_DATA_LEN;
 	dev->flags		= IFF_NOARP;
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net 0/2] tunnels: don't allow to add the same tunnel twice
  2014-04-11 13:51 [PATCH net 0/2] tunnels: don't allow to add the same tunnel twice Nicolas Dichtel
  2014-04-11 13:51 ` [PATCH net 1/2] gre: " Nicolas Dichtel
  2014-04-11 13:51 ` [PATCH net 2/2] vti: " Nicolas Dichtel
@ 2014-04-12 21:04 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2014-04-12 21:04 UTC (permalink / raw)
  To: nicolas.dichtel; +Cc: netdev

From: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Date: Fri, 11 Apr 2014 15:51:17 +0200

> This serie fix the check of an existing tunnel with the same parameters when
> a new tunnel is added.
> I've checked all users of ip_tunnel_newlink(): gre, gretap, ipip and vti. The
> bug exists only for gre and vti.

Series applied and queued up for -stable, thanks Nicolas.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-04-12 21:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-11 13:51 [PATCH net 0/2] tunnels: don't allow to add the same tunnel twice Nicolas Dichtel
2014-04-11 13:51 ` [PATCH net 1/2] gre: " Nicolas Dichtel
2014-04-11 13:51 ` [PATCH net 2/2] vti: " Nicolas Dichtel
2014-04-12 21:04 ` [PATCH net 0/2] tunnels: " David Miller

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).