Skip to content

Commit 0c06d16

Browse files
lxindavem330
authored andcommitted
lwtunnel: ignore any TUNNEL_OPTIONS_PRESENT flags set by users
TUNNEL_OPTIONS_PRESENT (TUNNEL_GENEVE_OPT|TUNNEL_VXLAN_OPT| TUNNEL_ERSPAN_OPT) flags should be set only according to tb[LWTUNNEL_IP_OPTS], which is done in ip_tun_parse_opts(). When setting info key.tun_flags, the TUNNEL_OPTIONS_PRESENT bits in tb[LWTUNNEL_IP(6)_FLAGS] passed from users should be ignored. While at it, replace all (TUNNEL_GENEVE_OPT|TUNNEL_VXLAN_OPT| TUNNEL_ERSPAN_OPT) with 'TUNNEL_OPTIONS_PRESENT'. Fixes: 3093fbe ("route: Per route IP tunnel metadata via lightweight tunnel") Fixes: 32a2b00 ("ipv6: route: per route IP tunnel metadata via lightweight tunnel") Signed-off-by: Xin Long <[email protected]> Reviewed-by: Simon Horman <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 58e8494 commit 0c06d16

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

net/ipv4/ip_tunnel_core.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,9 @@ static int ip_tun_build_state(struct nlattr *attr,
451451
tun_info->key.tos = nla_get_u8(tb[LWTUNNEL_IP_TOS]);
452452

453453
if (tb[LWTUNNEL_IP_FLAGS])
454-
tun_info->key.tun_flags |= nla_get_be16(tb[LWTUNNEL_IP_FLAGS]);
454+
tun_info->key.tun_flags |=
455+
(nla_get_be16(tb[LWTUNNEL_IP_FLAGS]) &
456+
~TUNNEL_OPTIONS_PRESENT);
455457

456458
tun_info->mode = IP_TUNNEL_INFO_TX;
457459
tun_info->options_len = opt_len;
@@ -550,8 +552,7 @@ static int ip_tun_fill_encap_opts(struct sk_buff *skb, int type,
550552
struct nlattr *nest;
551553
int err = 0;
552554

553-
if (!(tun_info->key.tun_flags &
554-
(TUNNEL_GENEVE_OPT | TUNNEL_VXLAN_OPT | TUNNEL_ERSPAN_OPT)))
555+
if (!(tun_info->key.tun_flags & TUNNEL_OPTIONS_PRESENT))
555556
return 0;
556557

557558
nest = nla_nest_start_noflag(skb, type);
@@ -596,8 +597,7 @@ static int ip_tun_opts_nlsize(struct ip_tunnel_info *info)
596597
{
597598
int opt_len;
598599

599-
if (!(info->key.tun_flags &
600-
(TUNNEL_GENEVE_OPT | TUNNEL_VXLAN_OPT | TUNNEL_ERSPAN_OPT)))
600+
if (!(info->key.tun_flags & TUNNEL_OPTIONS_PRESENT))
601601
return 0;
602602

603603
opt_len = nla_total_size(0); /* LWTUNNEL_IP_OPTS */
@@ -718,7 +718,9 @@ static int ip6_tun_build_state(struct nlattr *attr,
718718
tun_info->key.tos = nla_get_u8(tb[LWTUNNEL_IP6_TC]);
719719

720720
if (tb[LWTUNNEL_IP6_FLAGS])
721-
tun_info->key.tun_flags |= nla_get_be16(tb[LWTUNNEL_IP6_FLAGS]);
721+
tun_info->key.tun_flags |=
722+
(nla_get_be16(tb[LWTUNNEL_IP6_FLAGS]) &
723+
~TUNNEL_OPTIONS_PRESENT);
722724

723725
tun_info->mode = IP_TUNNEL_INFO_TX | IP_TUNNEL_INFO_IPV6;
724726
tun_info->options_len = opt_len;

0 commit comments

Comments
 (0)