Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net, ip_tunnel: fix interface lookup with no key

when creating a new ipip interface with no local/remote configuration,
the lookup is done with TUNNEL_NO_KEY flag, making it impossible to
match the new interface (only possible match being fallback or metada
case interface); e.g: `ip link add tunl1 type ipip dev eth0`

To fix this case, adding a flag check before the key comparison so we
permit to match an interface with no local/remote config; it also avoids
breaking possible userland tools relying on TUNNEL_NO_KEY flag and
uninitialised key.

context being on my side, I'm creating an extra ipip interface attached
to the physical one, and moving it to a dedicated namespace.

Fixes: c54419321455 ("GRE: Refactor GRE tunneling code.")
Signed-off-by: William Dauchy <w.dauchy@criteo.com>
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

William Dauchy and committed by
David S. Miller
25629fda 582eea23

+1 -5
+1 -5
net/ipv4/ip_tunnel.c
··· 142 142 cand = t; 143 143 } 144 144 145 - if (flags & TUNNEL_NO_KEY) 146 - goto skip_key_lookup; 147 - 148 145 hlist_for_each_entry_rcu(t, head, hash_node) { 149 - if (t->parms.i_key != key || 146 + if ((!(flags & TUNNEL_NO_KEY) && t->parms.i_key != key) || 150 147 t->parms.iph.saddr != 0 || 151 148 t->parms.iph.daddr != 0 || 152 149 !(t->dev->flags & IFF_UP)) ··· 155 158 cand = t; 156 159 } 157 160 158 - skip_key_lookup: 159 161 if (cand) 160 162 return cand; 161 163