Skip to contentSkip to conversation

ipv6: Return an error when adding an already existing tunnel

PATCH In review Steffen Klassert 2 participants 5 messages Sep 22, 2014 – Sep 26, 2014

Subsystems (4)
lore
Share & tools
lore
author maintainer
#3 lore raw

PATCH 3/3 ip6_gre: Return an error when adding an existing tunnel.

In reply to Steffen Klassert

ip6gre_tunnel_locate() should not return an existing tunnel if create is true. Otherwise it is possible to add the same tunnel multiple times without getting an error.

So return NULL if the tunnel that should be created already exists.

---
 net/ipv6/ip6_gre.c | 2 ++
 1 file changed, 2 insertions(+)
net/ipv6/ip6_gre.c +2 -0
index 5f19dfb..2e5a882 100644
@@ -314,6 +314,8 @@ static struct ip6_tnl *ip6gre_tunnel_locate(struct net *net,
 	struct ip6gre_net *ign = net_generic(net, ip6gre_net_id);
 
 	t = ip6gre_tunnel_find(net, parms, ARPHRD_IP6GRE);
+	if (t && create)
+		return NULL;
 	if (t || !create)
 		return t;
 
Signature · 1 line
1.9.1
author maintainer
#1 lore raw

PATCH 1/3 ip6_tunnel: Return an error when adding an existing tunnel.

In reply to Steffen Klassert

ip6_tnl_locate() should not return an existing tunnel if create is true. Otherwise it is possible to add the same tunnel multiple times without getting an error.

So return NULL if the tunnel that should be created already exists.

---
 net/ipv6/ip6_tunnel.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
net/ipv6/ip6_tunnel.c +5 -1
index f9de5a6..69a84b4 100644
@@ -364,8 +364,12 @@ static struct ip6_tnl *ip6_tnl_locate(struct net *net,
 	     (t = rtnl_dereference(*tp)) != NULL;
 	     tp = &t->next) {
 		if (ipv6_addr_equal(local, &t->parms.laddr) &&
-		    ipv6_addr_equal(remote, &t->parms.raddr))
+		    ipv6_addr_equal(remote, &t->parms.raddr)) {
+			if (create)
+				return NULL;
+
 			return t;
+		}
 	}
 	if (!create)
 		return NULL;
Signature · 1 line
1.9.1
author maintainer
#2 lore raw

PATCH 2/3 ip6_vti: Return an error when adding an existing tunnel.

In reply to Steffen Klassert

vti6_locate() should not return an existing tunnel if create is true. Otherwise it is possible to add the same tunnel multiple times without getting an error.

So return NULL if the tunnel that should be created already exists.

---
 net/ipv6/ip6_vti.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
net/ipv6/ip6_vti.c +5 -1
index 7f52fd9..5833a22 100644
@@ -253,8 +253,12 @@ static struct ip6_tnl *vti6_locate(struct net *net, struct __ip6_tnl_parm *p,
 	     (t = rtnl_dereference(*tp)) != NULL;
 	     tp = &t->next) {
 		if (ipv6_addr_equal(local, &t->parms.laddr) &&
-		    ipv6_addr_equal(remote, &t->parms.raddr))
+		    ipv6_addr_equal(remote, &t->parms.raddr)) {
+			if (create)
+				return NULL;
+
 			return t;
+		}
 	}
 	if (!create)
 		return NULL;
Signature · 1 line
1.9.1

Steffen Klassert

author maintainer
#0 lore raw

cover ipv6: Return an error when adding an already existing tunnel

The ipv6 tunnel locate functions should not return an existing tunnel if create is true. Otherwise it is possible to add the same tunnel multiple times without getting an error.

All our ipv6 tunnels have this bug from the very beginning. Only the sit tunnel was fixed some years ago with:

commit 8db99e57175 ("sit: Fail to create tunnel, if it already exists").

This patchset fixes the remaining ipv6 tunnels.

maintainer
#4 lore raw

From: Steffen Klassert <[email protected]>
Date: Mon, 22 Sep 2014 10:07:23 +0200

Quoted 10 lines

The ipv6 tunnel locate functions should not return an existing tunnel if create is true. Otherwise it is possible to add the same tunnel multiple times without getting an error.

All our ipv6 tunnels have this bug from the very beginning. Only the sit tunnel was fixed some years ago with:

commit 8db99e57175 ("sit: Fail to create tunnel, if it already exists").

This patchset fixes the remaining ipv6 tunnels.

Series applied and queued up for -stable, thanks.