Skip to content

Commit 2d79849

Browse files
Jiri Bencdavem330
authored andcommitted
lwtunnel: ip tunnel: fix multiple routes with different encap
Currently, two routes going through the same tunnel interface are considered the same even when they are routed to a different host after encapsulation. This causes all routes added after the first one to have incorrect encapsulation parameters. This is nicely visible by doing: # ip r a 192.168.1.2/32 dev vxlan0 tunnel dst 10.0.0.2 # ip r a 192.168.1.3/32 dev vxlan0 tunnel dst 10.0.0.3 # ip r [...] 192.168.1.2/32 tunnel id 0 src 0.0.0.0 dst 10.0.0.2 [...] 192.168.1.3/32 tunnel id 0 src 0.0.0.0 dst 10.0.0.2 [...] Implement the missing comparison function. Fixes: 3093fbe ("route: Per route IP tunnel metadata via lightweight tunnel") Signed-off-by: Jiri Benc <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent df383e6 commit 2d79849

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

net/ipv4/ip_tunnel_core.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,10 +286,17 @@ static int ip_tun_encap_nlsize(struct lwtunnel_state *lwtstate)
286286
+ nla_total_size(2); /* LWTUNNEL_IP_FLAGS */
287287
}
288288

289+
static int ip_tun_cmp_encap(struct lwtunnel_state *a, struct lwtunnel_state *b)
290+
{
291+
return memcmp(lwt_tun_info(a), lwt_tun_info(b),
292+
sizeof(struct ip_tunnel_info));
293+
}
294+
289295
static const struct lwtunnel_encap_ops ip_tun_lwt_ops = {
290296
.build_state = ip_tun_build_state,
291297
.fill_encap = ip_tun_fill_encap_info,
292298
.get_encap_size = ip_tun_encap_nlsize,
299+
.cmp_encap = ip_tun_cmp_encap,
293300
};
294301

295302
void __init ip_tunnel_core_init(void)

0 commit comments

Comments
 (0)