Received: by 2002:a17:90a:88:0:0:0:0 with SMTP id a8csp4562492pja; Thu, 21 Nov 2019 21:55:29 -0800 (PST) X-Google-Smtp-Source: APXvYqwLcpz0XbSbYicV0rlpzttI6qhUDBWf9ziPckRNwAXjyye5e1MbgXguDUVXWxufysm6uwni X-Received: by 2002:a17:906:8319:: with SMTP id j25mr18843123ejx.170.1574402129849; Thu, 21 Nov 2019 21:55:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574402129; cv=none; d=google.com; s=arc-20160816; b=DbRYBPPTyIAxEvOcGA2rKJ53hcuSms/7eivXmA6eh2PgVM+Bh2/cO36zM72FpP7Z4u u4gocPuPQypX1MVzjNFZneViSOrW0jM6I7d1r+gXyxHhIx1aGcBaUQequ6rTgjhVcN79 k8ERg3BXVZREzv/I6fRN5jHvnA6DlpTBHhR9+ItVEj0PZwJHN7/0Ukk1OpDOcKz67+4W iyaH+b+BihDJE0JRd5OTJL1nqnThUjx+1klRdNo+hVVE2zFqIfF8Wrx18k2wdQitCQKZ /fUELy2a8/ZgmjRiGKzMm4+34pTMjiWgPl+tPrNOfLjyiGKDmwG/lcFvXwfR7RSNZK3n pw4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=WDM0X+qRxoSpeR3v+6XFZP2ffDpLQXcM8XcAYTqXDu0=; b=xDLJYvK095X3yryzn+rKWm53WgYgRPrUzll502+wyjxEIXBedJ1fqh17fiKz51rkUI o9WrHoWRQM1AWbFk7vAXAxFUybMthuyQGACTQFOQoQ3tyE5AJZq5BaUxxS48vhFATAue Rgjrb1ylwfpKmE2Wg9baCrHhmsmoahpMf5Q6jLPwvsXYVO47/9YwzIL55PrlHBhKmuTu TbHYm6HPAAsU7BHJccXgvsuGjE4WgOvr6sOQV4dNQSoQMDP4B8DTB4d6TwW0hfFB7FvO VbZrIhznTTlHWrgVR5FiTHbGYn/lQTZdv5dbvoOkN1iRqxvcAUNamsUbvHjEmfPmyx2h XfnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=liGRPSwN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i20si3872557edq.275.2019.11.21.21.55.06; Thu, 21 Nov 2019 21:55:29 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=liGRPSwN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728728AbfKVFwz (ORCPT + 99 others); Fri, 22 Nov 2019 00:52:55 -0500 Received: from mail.kernel.org ([198.145.29.99]:58776 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728706AbfKVFwx (ORCPT ); Fri, 22 Nov 2019 00:52:53 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9E60A207FC; Fri, 22 Nov 2019 05:52:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574401972; bh=8YOr+nplVL0sHcQdaELPR2NwqO4VVeaDQAo+Wi/u2aA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=liGRPSwNZ+ELLQUn8t63H+Au+2WcfyJjFjpKCqbFRWOf5KUAny21fC0TxIbunTuaC 2yG2HEu87lxTkUTMe+b0B6sgvwrlXG5PK1zAI0si8ws4aJudH8yC1wndAURlJNxYbg oz9tvZQnttUImEicGc6TiurtJRaaZ7HXTJzdvrXI= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Lorenzo Bianconi , "David S . Miller" , Sasha Levin , netdev@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 192/219] net: ip_gre: do not report erspan_ver for gre or gretap Date: Fri, 22 Nov 2019 00:48:44 -0500 Message-Id: <20191122054911.1750-185-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191122054911.1750-1-sashal@kernel.org> References: <20191122054911.1750-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lorenzo Bianconi [ Upstream commit 2bdf700e538828d6456150b9319e5f689b062d54 ] Report erspan version field to userspace in ipgre_fill_info just for erspan tunnels. The issue can be triggered with the following reproducer: $ip link add name gre1 type gre local 192.168.0.1 remote 192.168.1.1 $ip link set dev gre1 up $ip -d link sh gre1 13: gre1@NONE: mtu 1476 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000 link/gre 192.168.0.1 peer 192.168.1.1 promiscuity 0 minmtu 0 maxmtu 0 gre remote 192.168.1.1 local 192.168.0.1 ttl inherit erspan_ver 0 addrgenmode eui64 numtxqueues 1 numrxqueues 1 Fixes: f551c91de262 ("net: erspan: introduce erspan v2 for ip_gre") Signed-off-by: Lorenzo Bianconi Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/ipv4/ip_gre.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c index 758a0f86d499f..1cb6142532536 100644 --- a/net/ipv4/ip_gre.c +++ b/net/ipv4/ip_gre.c @@ -1469,9 +1469,23 @@ static int ipgre_fill_info(struct sk_buff *skb, const struct net_device *dev) struct ip_tunnel_parm *p = &t->parms; __be16 o_flags = p->o_flags; - if ((t->erspan_ver == 1 || t->erspan_ver == 2) && - !t->collect_md) - o_flags |= TUNNEL_KEY; + if (t->erspan_ver == 1 || t->erspan_ver == 2) { + if (!t->collect_md) + o_flags |= TUNNEL_KEY; + + if (nla_put_u8(skb, IFLA_GRE_ERSPAN_VER, t->erspan_ver)) + goto nla_put_failure; + + if (t->erspan_ver == 1) { + if (nla_put_u32(skb, IFLA_GRE_ERSPAN_INDEX, t->index)) + goto nla_put_failure; + } else { + if (nla_put_u8(skb, IFLA_GRE_ERSPAN_DIR, t->dir)) + goto nla_put_failure; + if (nla_put_u16(skb, IFLA_GRE_ERSPAN_HWID, t->hwid)) + goto nla_put_failure; + } + } if (nla_put_u32(skb, IFLA_GRE_LINK, p->link) || nla_put_be16(skb, IFLA_GRE_IFLAGS, @@ -1507,19 +1521,6 @@ static int ipgre_fill_info(struct sk_buff *skb, const struct net_device *dev) goto nla_put_failure; } - if (nla_put_u8(skb, IFLA_GRE_ERSPAN_VER, t->erspan_ver)) - goto nla_put_failure; - - if (t->erspan_ver == 1) { - if (nla_put_u32(skb, IFLA_GRE_ERSPAN_INDEX, t->index)) - goto nla_put_failure; - } else if (t->erspan_ver == 2) { - if (nla_put_u8(skb, IFLA_GRE_ERSPAN_DIR, t->dir)) - goto nla_put_failure; - if (nla_put_u16(skb, IFLA_GRE_ERSPAN_HWID, t->hwid)) - goto nla_put_failure; - } - return 0; nla_put_failure: -- 2.20.1