All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ip_tunnel: fix i_key matching in ip_tunnel_find
@ 2014-06-07 23:03 Dmitry Popov
  2014-06-11  7:43 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Dmitry Popov @ 2014-06-07 23:03 UTC (permalink / raw)
  To: David S. Miller, Alexey Kuznetsov, James Morris,
	Hideaki YOSHIFUJI, Patrick McHardy, Steffen Klassert, Herbert Xu
  Cc: netdev, linux-kernel

Some tunnels (though only vti as for now) can use i_key just for internal use: 
for example vti uses it for fwmark'ing incoming packets. So raw i_key value 
shouldn't be treated as a distinguisher for them. ip_tunnel_key_match exists for
cases when we want to compare two ip_tunnel_parms' i_keys.

Example bug:
ip link add type vti ikey 1 local 1.0.0.1 remote 2.0.0.2
ip link add type vti ikey 2 local 1.0.0.1 remote 2.0.0.2
spawned two tunnels, although it doesn't make sense.

Signed-off-by: Dmitry Popov <ixaphire@qrator.net>
---
 net/ipv4/ip_tunnel.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c
index 2acc233..cf67fe1 100644
--- a/net/ipv4/ip_tunnel.c
+++ b/net/ipv4/ip_tunnel.c
@@ -268,6 +268,7 @@ static struct ip_tunnel *ip_tunnel_find(struct ip_tunnel_net *itn,
 	__be32 remote = parms->iph.daddr;
 	__be32 local = parms->iph.saddr;
 	__be32 key = parms->i_key;
+	__be16 flags = parms->i_flags;
 	int link = parms->link;
 	struct ip_tunnel *t = NULL;
 	struct hlist_head *head = ip_bucket(itn, parms);
@@ -275,9 +276,9 @@ static struct ip_tunnel *ip_tunnel_find(struct ip_tunnel_net *itn,
 	hlist_for_each_entry_rcu(t, head, hash_node) {
 		if (local == t->parms.iph.saddr &&
 		    remote == t->parms.iph.daddr &&
-		    key == t->parms.i_key &&
 		    link == t->parms.link &&
-		    type == t->dev->type)
+		    type == t->dev->type &&
+		    ip_tunnel_key_match(&t->parms, flags, key))
 			break;
 	}
 	return t;

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

* Re: [PATCH] ip_tunnel: fix i_key matching in ip_tunnel_find
  2014-06-07 23:03 [PATCH] ip_tunnel: fix i_key matching in ip_tunnel_find Dmitry Popov
@ 2014-06-11  7:43 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2014-06-11  7:43 UTC (permalink / raw)
  To: ixaphire
  Cc: kuznet, jmorris, yoshfuji, kaber, steffen.klassert, herbert,
	netdev, linux-kernel

From: Dmitry Popov <ixaphire@qrator.net>
Date: Sun, 8 Jun 2014 03:03:08 +0400

> Some tunnels (though only vti as for now) can use i_key just for internal use: 
> for example vti uses it for fwmark'ing incoming packets. So raw i_key value 
> shouldn't be treated as a distinguisher for them. ip_tunnel_key_match exists for
> cases when we want to compare two ip_tunnel_parms' i_keys.
> 
> Example bug:
> ip link add type vti ikey 1 local 1.0.0.1 remote 2.0.0.2
> ip link add type vti ikey 2 local 1.0.0.1 remote 2.0.0.2
> spawned two tunnels, although it doesn't make sense.
> 
> Signed-off-by: Dmitry Popov <ixaphire@qrator.net>

Applied, thanks.

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

end of thread, other threads:[~2014-06-11  7:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-07 23:03 [PATCH] ip_tunnel: fix i_key matching in ip_tunnel_find Dmitry Popov
2014-06-11  7:43 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.