Skip to content

Commit 0eb8eb2

Browse files
lxindavem330
authored andcommitted
lwtunnel: add options process for cmp_encap
When comparing two tun_info, dst_cache member should have been skipped, as dst_cache is a per cpu pointer and they are always different values even in two tun_info with the same keys. So this patch is to skip dst_cache member and compare the key, mode and options_len only. For the future opts setting support, also to compare options. Fixes: 2d79849 ("lwtunnel: ip tunnel: fix multiple routes with different encap") Signed-off-by: Xin Long <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent f52f11e commit 0eb8eb2

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

net/ipv4/ip_tunnel_core.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,14 @@ static int ip_tun_encap_nlsize(struct lwtunnel_state *lwtstate)
315315

316316
static int ip_tun_cmp_encap(struct lwtunnel_state *a, struct lwtunnel_state *b)
317317
{
318-
return memcmp(lwt_tun_info(a), lwt_tun_info(b),
319-
sizeof(struct ip_tunnel_info));
318+
struct ip_tunnel_info *info_a = lwt_tun_info(a);
319+
struct ip_tunnel_info *info_b = lwt_tun_info(b);
320+
321+
return memcmp(info_a, info_b, sizeof(info_a->key)) ||
322+
info_a->mode != info_b->mode ||
323+
info_a->options_len != info_b->options_len ||
324+
memcmp(ip_tunnel_info_opts(info_a),
325+
ip_tunnel_info_opts(info_b), info_a->options_len);
320326
}
321327

322328
static const struct lwtunnel_encap_ops ip_tun_lwt_ops = {

0 commit comments

Comments
 (0)