diff mbox

[net,v2] ipv4: ip_tunnels: disable cache for nbma gre tunnels

Message ID 1400218479-10166-1-git-send-email-timo.teras@iki.fi
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Timo Teras May 16, 2014, 5:34 a.m. UTC
The connected check fails to check for ip_gre nbma mode tunnels
properly. ip_gre creates temporary tnl_params with daddr specified
to pass-in the actual target on per-packet basis from neighbor
layer. Detect these tunnels by inspecting the actual tunnel
configuration.

Minimal test case:
 ip route add 192.168.1.1/32 via 10.0.0.1
 ip route add 192.168.1.2/32 via 10.0.0.2
 ip tunnel add nbma0 mode gre key 1 tos c0
 ip addr add 172.17.0.0/16 dev nbma0
 ip link set nbma0 up
 ip neigh add 172.17.0.1 lladdr 192.168.1.1 dev nbma0
 ip neigh add 172.17.0.2 lladdr 192.168.1.2 dev nbma0
 ping 172.17.0.1
 ping 172.17.0.2

The second ping should be going to 192.168.1.2 and head 10.0.0.2;
but cached gre tunnel level route is used and it's actually going
to 192.168.1.1 via 10.0.0.1.

The lladdr's need to go to separate dst for the bug to trigger.
Test case uses separate route entries, but this can also happen
when the route entry is same: if there is a nexthop exception or
the GRE tunnel is IPsec'ed in which case the dst points to xfrm
bundle unique to the gre lladdr.

Fixes: 7d442fab0a67 ("ipv4: Cache dst in tunnels")
Signed-off-by: Timo Teräs <timo.teras@iki.fi>
Cc: Tom Herbert <therbert@google.com>
Cc: Eric Dumazet <edumazet@google.com>
---
Should go to 3.14-stable too.

 net/ipv4/ip_tunnel.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

David Miller May 16, 2014, 8:59 p.m. UTC | #1
From: Timo Teräs <timo.teras@iki.fi>
Date: Fri, 16 May 2014 08:34:39 +0300

> The connected check fails to check for ip_gre nbma mode tunnels
> properly. ip_gre creates temporary tnl_params with daddr specified
> to pass-in the actual target on per-packet basis from neighbor
> layer. Detect these tunnels by inspecting the actual tunnel
> configuration.
> 
> Minimal test case:
>  ip route add 192.168.1.1/32 via 10.0.0.1
>  ip route add 192.168.1.2/32 via 10.0.0.2
>  ip tunnel add nbma0 mode gre key 1 tos c0
>  ip addr add 172.17.0.0/16 dev nbma0
>  ip link set nbma0 up
>  ip neigh add 172.17.0.1 lladdr 192.168.1.1 dev nbma0
>  ip neigh add 172.17.0.2 lladdr 192.168.1.2 dev nbma0
>  ping 172.17.0.1
>  ping 172.17.0.2
> 
> The second ping should be going to 192.168.1.2 and head 10.0.0.2;
> but cached gre tunnel level route is used and it's actually going
> to 192.168.1.1 via 10.0.0.1.
> 
> The lladdr's need to go to separate dst for the bug to trigger.
> Test case uses separate route entries, but this can also happen
> when the route entry is same: if there is a nexthop exception or
> the GRE tunnel is IPsec'ed in which case the dst points to xfrm
> bundle unique to the gre lladdr.
> 
> Fixes: 7d442fab0a67 ("ipv4: Cache dst in tunnels")
> Signed-off-by: Timo Teräs <timo.teras@iki.fi>

Yeah, this one compiles :-)

Applied and queued up for -stable, thanks!
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c
index e77381d..4eb9196 100644
--- a/net/ipv4/ip_tunnel.c
+++ b/net/ipv4/ip_tunnel.c
@@ -538,9 +538,10 @@  void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
 	unsigned int max_headroom;	/* The extra header space needed */
 	__be32 dst;
 	int err;
-	bool connected = true;
+	bool connected;
 
 	inner_iph = (const struct iphdr *)skb_inner_network_header(skb);
+	connected = (tunnel->parms.iph.daddr != 0);
 
 	dst = tnl_params->daddr;
 	if (dst == 0) {