* [PATCH net-next] lwtunnel: ignore any TUNNEL_OPTIONS_PRESENT flags set by users
@ 2019-11-10 4:26 Xin Long
2019-11-11 12:40 ` Simon Horman
2019-11-11 22:44 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: Xin Long @ 2019-11-10 4:26 UTC (permalink / raw)
To: network dev; +Cc: davem, David Ahern, Thomas Graf, Jiri Benc
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: 3093fbe7ff4b ("route: Per route IP tunnel metadata via lightweight tunnel")
Fixes: 32a2b002ce61 ("ipv6: route: per route IP tunnel metadata via lightweight tunnel")
Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
net/ipv4/ip_tunnel_core.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/net/ipv4/ip_tunnel_core.c b/net/ipv4/ip_tunnel_core.c
index e444cd1..c724fb3 100644
--- a/net/ipv4/ip_tunnel_core.c
+++ b/net/ipv4/ip_tunnel_core.c
@@ -451,7 +451,9 @@ static int ip_tun_build_state(struct nlattr *attr,
tun_info->key.tos = nla_get_u8(tb[LWTUNNEL_IP_TOS]);
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->options_len = opt_len;
@@ -550,8 +552,7 @@ static int ip_tun_fill_encap_opts(struct sk_buff *skb, int type,
struct nlattr *nest;
int err = 0;
- if (!(tun_info->key.tun_flags &
- (TUNNEL_GENEVE_OPT | TUNNEL_VXLAN_OPT | TUNNEL_ERSPAN_OPT)))
+ if (!(tun_info->key.tun_flags & TUNNEL_OPTIONS_PRESENT))
return 0;
nest = nla_nest_start_noflag(skb, type);
@@ -596,8 +597,7 @@ static int ip_tun_opts_nlsize(struct ip_tunnel_info *info)
{
int opt_len;
- if (!(info->key.tun_flags &
- (TUNNEL_GENEVE_OPT | TUNNEL_VXLAN_OPT | TUNNEL_ERSPAN_OPT)))
+ if (!(info->key.tun_flags & TUNNEL_OPTIONS_PRESENT))
return 0;
opt_len = nla_total_size(0); /* LWTUNNEL_IP_OPTS */
@@ -718,7 +718,9 @@ static int ip6_tun_build_state(struct nlattr *attr,
tun_info->key.tos = nla_get_u8(tb[LWTUNNEL_IP6_TC]);
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->options_len = opt_len;
--
2.1.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] lwtunnel: ignore any TUNNEL_OPTIONS_PRESENT flags set by users
2019-11-10 4:26 [PATCH net-next] lwtunnel: ignore any TUNNEL_OPTIONS_PRESENT flags set by users Xin Long
@ 2019-11-11 12:40 ` Simon Horman
2019-11-11 22:44 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Simon Horman @ 2019-11-11 12:40 UTC (permalink / raw)
To: Xin Long; +Cc: network dev, davem, David Ahern, Thomas Graf, Jiri Benc
On Sun, Nov 10, 2019 at 12:26:21PM +0800, Xin Long wrote:
> 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: 3093fbe7ff4b ("route: Per route IP tunnel metadata via lightweight tunnel")
> Fixes: 32a2b002ce61 ("ipv6: route: per route IP tunnel metadata via lightweight tunnel")
> Signed-off-by: Xin Long <lucien.xin@gmail.com>
Reviewed-by: Simon Horman <simon.horman@netronome.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] lwtunnel: ignore any TUNNEL_OPTIONS_PRESENT flags set by users
2019-11-10 4:26 [PATCH net-next] lwtunnel: ignore any TUNNEL_OPTIONS_PRESENT flags set by users Xin Long
2019-11-11 12:40 ` Simon Horman
@ 2019-11-11 22:44 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2019-11-11 22:44 UTC (permalink / raw)
To: lucien.xin; +Cc: netdev, dsahern, tgraf, jbenc
From: Xin Long <lucien.xin@gmail.com>
Date: Sun, 10 Nov 2019 12:26:21 +0800
> 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: 3093fbe7ff4b ("route: Per route IP tunnel metadata via lightweight tunnel")
> Fixes: 32a2b002ce61 ("ipv6: route: per route IP tunnel metadata via lightweight tunnel")
> Signed-off-by: Xin Long <lucien.xin@gmail.com>
Applied.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-11-12 20:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-10 4:26 [PATCH net-next] lwtunnel: ignore any TUNNEL_OPTIONS_PRESENT flags set by users Xin Long
2019-11-11 12:40 ` Simon Horman
2019-11-11 22:44 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).