Commit 0c06d166 authored by Xin Long's avatar Xin Long Committed by David S. Miller

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: 3093fbe7 ("route: Per route IP tunnel metadata via lightweight tunnel")
Fixes: 32a2b002 ("ipv6: route: per route IP tunnel metadata via lightweight tunnel")
Signed-off-by: default avatarXin Long <lucien.xin@gmail.com>
Reviewed-by: default avatarSimon Horman <simon.horman@netronome.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 58e8494e
...@@ -451,7 +451,9 @@ static int ip_tun_build_state(struct nlattr *attr, ...@@ -451,7 +451,9 @@ static int ip_tun_build_state(struct nlattr *attr,
tun_info->key.tos = nla_get_u8(tb[LWTUNNEL_IP_TOS]); tun_info->key.tos = nla_get_u8(tb[LWTUNNEL_IP_TOS]);
if (tb[LWTUNNEL_IP_FLAGS]) if (tb[LWTUNNEL_IP_FLAGS])
tun_info->key.tun_flags |= nla_get_be16(tb[LWTUNNEL_IP_FLAGS]); tun_info->key.tun_flags |=
(nla_get_be16(tb[LWTUNNEL_IP_FLAGS]) &
~TUNNEL_OPTIONS_PRESENT);
tun_info->mode = IP_TUNNEL_INFO_TX; tun_info->mode = IP_TUNNEL_INFO_TX;
tun_info->options_len = opt_len; tun_info->options_len = opt_len;
...@@ -550,8 +552,7 @@ static int ip_tun_fill_encap_opts(struct sk_buff *skb, int type, ...@@ -550,8 +552,7 @@ static int ip_tun_fill_encap_opts(struct sk_buff *skb, int type,
struct nlattr *nest; struct nlattr *nest;
int err = 0; int err = 0;
if (!(tun_info->key.tun_flags & if (!(tun_info->key.tun_flags & TUNNEL_OPTIONS_PRESENT))
(TUNNEL_GENEVE_OPT | TUNNEL_VXLAN_OPT | TUNNEL_ERSPAN_OPT)))
return 0; return 0;
nest = nla_nest_start_noflag(skb, type); nest = nla_nest_start_noflag(skb, type);
...@@ -596,8 +597,7 @@ static int ip_tun_opts_nlsize(struct ip_tunnel_info *info) ...@@ -596,8 +597,7 @@ static int ip_tun_opts_nlsize(struct ip_tunnel_info *info)
{ {
int opt_len; int opt_len;
if (!(info->key.tun_flags & if (!(info->key.tun_flags & TUNNEL_OPTIONS_PRESENT))
(TUNNEL_GENEVE_OPT | TUNNEL_VXLAN_OPT | TUNNEL_ERSPAN_OPT)))
return 0; return 0;
opt_len = nla_total_size(0); /* LWTUNNEL_IP_OPTS */ opt_len = nla_total_size(0); /* LWTUNNEL_IP_OPTS */
...@@ -718,7 +718,9 @@ static int ip6_tun_build_state(struct nlattr *attr, ...@@ -718,7 +718,9 @@ static int ip6_tun_build_state(struct nlattr *attr,
tun_info->key.tos = nla_get_u8(tb[LWTUNNEL_IP6_TC]); tun_info->key.tos = nla_get_u8(tb[LWTUNNEL_IP6_TC]);
if (tb[LWTUNNEL_IP6_FLAGS]) if (tb[LWTUNNEL_IP6_FLAGS])
tun_info->key.tun_flags |= nla_get_be16(tb[LWTUNNEL_IP6_FLAGS]); tun_info->key.tun_flags |=
(nla_get_be16(tb[LWTUNNEL_IP6_FLAGS]) &
~TUNNEL_OPTIONS_PRESENT);
tun_info->mode = IP_TUNNEL_INFO_TX | IP_TUNNEL_INFO_IPV6; tun_info->mode = IP_TUNNEL_INFO_TX | IP_TUNNEL_INFO_IPV6;
tun_info->options_len = opt_len; tun_info->options_len = opt_len;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment