Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp832884pxu; Mon, 23 Nov 2020 05:27:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJwDXVkiT5bBwS4QZGN5IIyaooifhEe662N60snC2ycqy/a6zPNeycfdiMbDp6KPTSKULAp8 X-Received: by 2002:aa7:c30e:: with SMTP id l14mr47459271edq.315.1606138019971; Mon, 23 Nov 2020 05:26:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606138019; cv=none; d=google.com; s=arc-20160816; b=Sr56qgsvJ8cRsGTj1gYvzVpFF7hwLmKnd/ECvIxXMTUxY4iIKJ7vCOBt/CrxeNuFvW N5X1osvmeVEOz5bQbVfMnyyN83Khg97diFgGrK1sMwAqjK5MIIAjvm9kqviT2jGcL5wz TJ/b1QNfMOPp3Q35A9LwjtOediay/v6GZIxI96AegJqMPZDn3dC6jlePlQCU8Bo83PbI ZR0kAHXxXeQQSOJk5HYKOf/uDgoA0GKUksBeP2g7K055fiAD+3NzG8ICu7SfcghMRHx1 XHSjgNdsz7wYmCP3Tji4h4vbznssY0s06jNdm1MB/n4xQYq6NUiT4f41dKmhJgZ6kaTl BB4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Rp+KkwcAA0nnlaDFhqCFAcGKhXMsEstt5ElS9eQ0BW8=; b=hdWnKECfuvoda4aLittHWcJ8iCM/B3rvRpUnpF7FW2jk527Ux+zXAs+QM6OscphpK+ 6vV90yHLVgVJexfAC8RjkG6dtULcpUaAmYgcveLjLA/zlgzYgKWbc2iwVM9OSGHZ6b8v dQ+OXnqxVC6U/r/MI4I26gADVNsHMDYq5TBO3wy7tve2DXHON+Ag6Qulea7z4DK1w1Sw 5v91N8yP98mA5vzTMZAjVR7Q2SoZC0W9puquWztIwPyLCNcPX0dTLAqAKTHkXg4Brkjn sD4687Use5qyI10fI1rjvNAR0APALOvgZ8gRzIFyZ2lWSviAJsPtK55HAuihNLHyHzVx qfNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0bqcMCJp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bu10si4080349ejb.483.2020.11.23.05.26.36; Mon, 23 Nov 2020 05:26:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0bqcMCJp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388963AbgKWNWM (ORCPT + 99 others); Mon, 23 Nov 2020 08:22:12 -0500 Received: from mail.kernel.org ([198.145.29.99]:49128 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731840AbgKWMg6 (ORCPT ); Mon, 23 Nov 2020 07:36:58 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2B0C420857; Mon, 23 Nov 2020 12:36:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1606135017; bh=NloPI28+U5uT9HfwbMIsGovgtDmuJDWGVYeZ5ho+LwA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0bqcMCJpIVdVARUbsQa7bfyAfxAATeGD7VyAgwZjHUGVPQy2JxxO+/3AxpaX47Qeh YjO1/JtEnjFpbKRzLheN+EQ0Jhy6e5ke+iJoHVoXV5CQqGISTKC8uH58wLanyeA1YH 6PjGdXX4OcFXNgNOFEbN31AbK/L+cvuojlwx7DJ8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yi-Hung Wei , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.4 074/158] ip_tunnels: Set tunnel option flag when tunnel metadata is present Date: Mon, 23 Nov 2020 13:21:42 +0100 Message-Id: <20201123121823.508265910@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201123121819.943135899@linuxfoundation.org> References: <20201123121819.943135899@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yi-Hung Wei [ 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: 256c87c17c53 ("net: check tunnel option type in tunnel flags") Signed-off-by: Yi-Hung Wei Link: https://lore.kernel.org/r/1605053800-74072-1-git-send-email-yihung.wei@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/net/geneve.c | 3 +-- include/net/ip_tunnels.h | 7 ++++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c index fcb7a6b4cc02a..c7ec3d24eabc8 100644 --- a/drivers/net/geneve.c +++ b/drivers/net/geneve.c @@ -221,8 +221,7 @@ static void geneve_rx(struct geneve_dev *geneve, struct geneve_sock *gs, if (ip_tunnel_collect_metadata() || gs->collect_md) { __be16 flags; - flags = TUNNEL_KEY | TUNNEL_GENEVE_OPT | - (gnvh->oam ? TUNNEL_OAM : 0) | + flags = TUNNEL_KEY | (gnvh->oam ? TUNNEL_OAM : 0) | (gnvh->critical ? TUNNEL_CRIT_OPT : 0); tun_dst = udp_tun_rx_dst(skb, geneve_get_sk_family(gs), flags, diff --git a/include/net/ip_tunnels.h b/include/net/ip_tunnels.h index af645604f3289..56deb2501e962 100644 --- a/include/net/ip_tunnels.h +++ b/include/net/ip_tunnels.h @@ -472,9 +472,11 @@ static inline void ip_tunnel_info_opts_set(struct ip_tunnel_info *info, const void *from, int len, __be16 flags) { - memcpy(ip_tunnel_info_opts(info), from, len); info->options_len = len; - info->key.tun_flags |= flags; + if (len > 0) { + memcpy(ip_tunnel_info_opts(info), from, len); + info->key.tun_flags |= flags; + } } static inline struct ip_tunnel_info *lwt_tun_info(struct lwtunnel_state *lwtstate) @@ -520,7 +522,6 @@ static inline void ip_tunnel_info_opts_set(struct ip_tunnel_info *info, __be16 flags) { info->options_len = 0; - info->key.tun_flags |= flags; } #endif /* CONFIG_INET */ -- 2.27.0