Skip to content

Commit 9c2e14b

Browse files
YiHungWeikuba-moo
authored andcommitted
ip_tunnels: Set tunnel option flag when tunnel metadata is present
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/[email protected]/T/#u Fixes: 256c87c ("net: check tunnel option type in tunnel flags") Signed-off-by: Yi-Hung Wei <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 81e329e commit 9c2e14b

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

drivers/net/geneve.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,7 @@ static void geneve_rx(struct geneve_dev *geneve, struct geneve_sock *gs,
224224
if (ip_tunnel_collect_metadata() || gs->collect_md) {
225225
__be16 flags;
226226

227-
flags = TUNNEL_KEY | TUNNEL_GENEVE_OPT |
228-
(gnvh->oam ? TUNNEL_OAM : 0) |
227+
flags = TUNNEL_KEY | (gnvh->oam ? TUNNEL_OAM : 0) |
229228
(gnvh->critical ? TUNNEL_CRIT_OPT : 0);
230229

231230
tun_dst = udp_tun_rx_dst(skb, geneve_get_sk_family(gs), flags,

include/net/ip_tunnels.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -478,9 +478,11 @@ static inline void ip_tunnel_info_opts_set(struct ip_tunnel_info *info,
478478
const void *from, int len,
479479
__be16 flags)
480480
{
481-
memcpy(ip_tunnel_info_opts(info), from, len);
482481
info->options_len = len;
483-
info->key.tun_flags |= flags;
482+
if (len > 0) {
483+
memcpy(ip_tunnel_info_opts(info), from, len);
484+
info->key.tun_flags |= flags;
485+
}
484486
}
485487

486488
static inline struct ip_tunnel_info *lwt_tun_info(struct lwtunnel_state *lwtstate)
@@ -526,7 +528,6 @@ static inline void ip_tunnel_info_opts_set(struct ip_tunnel_info *info,
526528
__be16 flags)
527529
{
528530
info->options_len = 0;
529-
info->key.tun_flags |= flags;
530531
}
531532

532533
#endif /* CONFIG_INET */

0 commit comments

Comments
 (0)