Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 901e04cd authored by Yi-Hung Wei's avatar Yi-Hung Wei Committed by Greg Kroah-Hartman
Browse files

ip_tunnels: Set tunnel option flag when tunnel metadata is present

[ Upstream commit 9c2e14b48119b39446031d29d994044ae958d8fc ]

Currently, we may set the tunnel option flag when the size of metadata
is zero.  For example, we set TUNNEL_GENEVE_OPT in the receive function
no matter the geneve option is present or not.  As this may result in
issues on the tunnel flags consumers, this patch fixes the issue.

Related discussion:
* https://lore.kernel.org/netdev/1604448694-19351-1-git-send-email-yihung.wei@gmail.com/T/#u



Fixes: 256c87c1 ("net: check tunnel option type in tunnel flags")
Signed-off-by: default avatarYi-Hung Wei <yihung.wei@gmail.com>
Link: https://lore.kernel.org/r/1605053800-74072-1-git-send-email-yihung.wei@gmail.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent c4d54937
Loading
Loading
Loading
Loading
+1 −2
Original line number Original line Diff line number Diff line
@@ -223,8 +223,7 @@ static void geneve_rx(struct geneve_dev *geneve, struct geneve_sock *gs,
	if (ip_tunnel_collect_metadata() || gs->collect_md) {
	if (ip_tunnel_collect_metadata() || gs->collect_md) {
		__be16 flags;
		__be16 flags;


		flags = TUNNEL_KEY | TUNNEL_GENEVE_OPT |
		flags = TUNNEL_KEY | (gnvh->oam ? TUNNEL_OAM : 0) |
			(gnvh->oam ? TUNNEL_OAM : 0) |
			(gnvh->critical ? TUNNEL_CRIT_OPT : 0);
			(gnvh->critical ? TUNNEL_CRIT_OPT : 0);


		tun_dst = udp_tun_rx_dst(skb, geneve_get_sk_family(gs), flags,
		tun_dst = udp_tun_rx_dst(skb, geneve_get_sk_family(gs), flags,
+4 −3
Original line number Original line Diff line number Diff line
@@ -489,10 +489,12 @@ static inline void ip_tunnel_info_opts_set(struct ip_tunnel_info *info,
					   const void *from, int len,
					   const void *from, int len,
					   __be16 flags)
					   __be16 flags)
{
{
	memcpy(ip_tunnel_info_opts(info), from, len);
	info->options_len = len;
	info->options_len = len;
	if (len > 0) {
		memcpy(ip_tunnel_info_opts(info), from, len);
		info->key.tun_flags |= flags;
		info->key.tun_flags |= flags;
	}
	}
}


static inline struct ip_tunnel_info *lwt_tun_info(struct lwtunnel_state *lwtstate)
static inline struct ip_tunnel_info *lwt_tun_info(struct lwtunnel_state *lwtstate)
{
{
@@ -537,7 +539,6 @@ static inline void ip_tunnel_info_opts_set(struct ip_tunnel_info *info,
					   __be16 flags)
					   __be16 flags)
{
{
	info->options_len = 0;
	info->options_len = 0;
	info->key.tun_flags |= flags;
}
}


#endif /* CONFIG_INET */
#endif /* CONFIG_INET */