[1/5] sit: Fail to create tunnel, if it already exists

Submitted by Sascha Hlusiak on May 19, 2009, 9:03 p.m.

Details

Message ID 1242767023-9501-1-git-send-email-contact@saschahlusiak.de
State Superseded
Delegated to: David Miller
Headers show

Commit Message

Sascha Hlusiak May 19, 2009, 9:03 p.m.
When locating the tunnel, do not continue if it is found. Otherwise
a different tunnel with similar configuration would be returned and
parts could be overwritten.

Signed-off-by: Sascha Hlusiak <contact@saschahlusiak.de>
---
 net/ipv6/sit.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index 664ab82..e625041 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -165,8 +165,13 @@  static struct ip_tunnel * ipip6_tunnel_locate(struct net *net,
 	struct sit_net *sitn = net_generic(net, sit_net_id);
 
 	for (tp = __ipip6_bucket(sitn, parms); (t = *tp) != NULL; tp = &t->next) {
-		if (local == t->parms.iph.saddr && remote == t->parms.iph.daddr)
-			return t;
+		if (local == t->parms.iph.saddr &&
+		    remote == t->parms.iph.daddr) {
+			if (create)
+				return NULL;
+			else
+				return t;
+		}
 	}
 	if (!create)
 		goto failed;