Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1238433pxu; Mon, 23 Nov 2020 15:36:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJwttoNY3UG13bLmX1J+TkVtLBpfes4Hw/yDaR7kHdbI1rq01eMdigX8bLmQP9pfQPK4bt04 X-Received: by 2002:a17:906:329a:: with SMTP id 26mr1741900ejw.227.1606174609264; Mon, 23 Nov 2020 15:36:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606174609; cv=none; d=google.com; s=arc-20160816; b=hu2GvlFp9vnn6yzMzCyok2j3BgA+FGIq8JxjJj23FMvnhZQbY9GvyOzi3KfJ6hB5lm E9uGpd5XJTfs++vJ3mtTvHCts+8ytjEu7+4/S0JsTLCKRhfIgXW5mFy4orq40wvz2rUR Y+/qYPQTPQ10i1NjC7IqMB4Zr7Iw8VEGJFkRUS49rN7I4pKjjVC7rxMvWAXJCB93/JBn l9lrbFA3tMxpkVNHwC2wJbP+c+ixDX6h0oF2pIfNFypoWE/2v7V7FGDQn83zmrpbvNmT SDPRV1Ej7muyxts5gnqsVsW5GOTtYaOUgLjPkaxaDCc4noMs34rAqz9JX/Ahae2zrDPY peMA== 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=uGQo/4vBfpVaIs/uG/lrreTrQ7neNSdMMGO+tCMj6pk=; b=WMZjhvp2AgKLRHC7e3N79qngrCvKMwdFNagtTfv9odcS+F7XN0cjec0FixMdh/51de JcX5dyV819KWXKTpl9utvJW1N1kEiMfhihYp8aHQVatjd0+PwTU1i//rxPk5oCh/udin VomVnJjWWTpnA3BBMAztgcF7dy3jow6jUofw+L8l6L1XOPABgm6mOMl8uW89RPZhvo06 Eh+HvrvdsQl4bDsayQjIwmsLZaFPksiYHCYxXjOW8NxVSM+g/qQpV8M8AzE8dQZ3boF+ 4XR48iRTkCPBmyiB2Ri71hxVwsMAV3UoOh89Scf8WRzmgoS7dQbDxsEpOBAD20ZMp2sd WOoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=QyM1Fk28; 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 o8si7744617edh.211.2020.11.23.15.36.26; Mon, 23 Nov 2020 15:36:49 -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=QyM1Fk28; 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 S1730984AbgKWMb4 (ORCPT + 99 others); Mon, 23 Nov 2020 07:31:56 -0500 Received: from mail.kernel.org ([198.145.29.99]:42352 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730846AbgKWMb3 (ORCPT ); Mon, 23 Nov 2020 07:31:29 -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 486972158C; Mon, 23 Nov 2020 12:31:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1606134687; bh=auOGuJEDLaPCw2VKr2jkrhSJZxgBd7PTB515B4OxbrA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QyM1Fk28cgOogdKx1lWDuODe/wUtGF5RXRTPfly4b7wM9w2hT0eUR0W3Yfrgp7oxX PydFwZAzD7/rU9JMKfAlciVtZ+O7RieRKuhcCjynTqM9/w5JoBnKaMyAsPPSwOC1iF +rqijopkhEM3yngYsSHPJdVpkZIEiaQ7YPvmcShQ= 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 4.19 47/91] ip_tunnels: Set tunnel option flag when tunnel metadata is present Date: Mon, 23 Nov 2020 13:22:07 +0100 Message-Id: <20201123121811.605089318@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201123121809.285416732@linuxfoundation.org> References: <20201123121809.285416732@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 d0b5844c8a315..2e2afc824a6a8 100644 --- a/drivers/net/geneve.c +++ b/drivers/net/geneve.c @@ -223,8 +223,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 e11423530d642..f8873c4eb003a 100644 --- a/include/net/ip_tunnels.h +++ b/include/net/ip_tunnels.h @@ -489,9 +489,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) @@ -537,7 +539,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