Received: by 2002:a17:90a:88:0:0:0:0 with SMTP id a8csp4565108pja; Thu, 21 Nov 2019 21:58:46 -0800 (PST) X-Google-Smtp-Source: APXvYqxyikZMzCzS/MJayvPbKJy8U+R9wVMT+BxnLcYncHmUOIg/vcEXXUpFSmiAyGuEPbAhoA3G X-Received: by 2002:a17:906:b819:: with SMTP id dv25mr1270537ejb.182.1574402326221; Thu, 21 Nov 2019 21:58:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574402326; cv=none; d=google.com; s=arc-20160816; b=rU3JbsEajtilc0uFDH9Nb46PX1FXdhFW+0MYsL2HipQTTuOELgIqfcX4rOkPjY5W9F cY/vRmzMziFaimXJgUh1ozsLBhETR1jh/aszh+ApEbhApnIrWWHI9kut+Sx074jD7WTq uehPEo9Jl9nRdfpEfCUsYlhsF3nipQG8wgmqpm/dWhkICyyBUcvg9MaCk8chvxIeoaPA pdP7fNlUCPbKaPVcvzKS55uNA8Rw8Aj+xfvFIzHp/UHqSL1tbEUDctbYXa8DrpkJNYEe jBJUZRNb3CNGXhpoloiIJuvu2bRxS53fAHZKuk4mwNJEp+tNEOpidufN6YdDqq6uZ1fx znCQ== 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=LYLmPxbkxWRKWsPoL/mjv/+LQMOJN4qfDNUjjc9ilkY=; b=cQgHgZf9odqeHC0hrDjnBq5vWQ+dMF1pGVY465aY6UoOKdsg7mqWjH+H9F/JFPyx3P G387pE/rTQ0TgH4V5lJgubMCzhN+qmGRU6ujtDiXrehEEPvDOPNyiQb/hyNizFauXjbg kwTB+6BN8Bs8pZG4KzA7lR5xglGjmBu11QIFNgTRgDwi2bd0AWbAG7SOQdCRAN0nqFoy juypzO3X+uWXjXcRk3maLPEoVVPAOYTxrSEX6GQS9IT1IfaZAjZIMZeitZzZYoBy4R2m VKxms37cfJjE+ApWohNE/ARSXB5B1ryq3vbXhki3D25uZDvkc2kuyJo+RzeS+3SQ3qd0 yBMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=PBVrful9; 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 b22si3608907ejv.159.2019.11.21.21.58.16; Thu, 21 Nov 2019 21:58:46 -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=PBVrful9; 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 S1728347AbfKVFzX (ORCPT + 99 others); Fri, 22 Nov 2019 00:55:23 -0500 Received: from mail.kernel.org ([198.145.29.99]:58768 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728713AbfKVFwy (ORCPT ); Fri, 22 Nov 2019 00:52:54 -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 AB04A2075E; Fri, 22 Nov 2019 05:52:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574401973; bh=XWGD5FnpioMR5ta8+wtIT9CfYIjrrA31YwBBRXFFIKQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PBVrful9rxQa+j21/+kmsWivxUDdi8NHMSVYP/sPSDAAYssrtYKrQ5WCVQPrMI4ro KR4sI+/ZWNLdR2UpcoYUqiB8fqu37WcA9BjhQ/CymzOwPQfc3u0iwlzJ5ahTQ64zOo IM4sOlk+zjkrZXUDfptJQPYvof+QON9Y8ZHuR/qU= 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 193/219] net: ip6_gre: do not report erspan_ver for ip6gre or ip6gretap Date: Fri, 22 Nov 2019 00:48:45 -0500 Message-Id: <20191122054911.1750-186-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 103d0244d29fcaf38f1339d4538919bbbc051490 ] Report erspan version field to userspace in ip6gre_fill_info just for erspan_v6 tunnels. Moreover report IFLA_GRE_ERSPAN_INDEX only for erspan version 1. The issue can be triggered with the following reproducer: $ip link add name gre6 type ip6gre local 2001::1 remote 2002::2 $ip link set gre6 up $ip -d link sh gre6 14: grep6@NONE: mtu 1448 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000 link/gre6 2001::1 peer 2002::2 promiscuity 0 minmtu 0 maxmtu 0 ip6gre remote 2002::2 local 2001::1 hoplimit 64 encaplimit 4 tclass 0x00 flowlabel 0x00000 erspan_index 0 erspan_ver 0 addrgenmode eui64 Fixes: 94d7d8f29287 ("ip6_gre: add erspan v2 support") Signed-off-by: Lorenzo Bianconi Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/ipv6/ip6_gre.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c index dee4113f21a9a..8fd28edd6ac57 100644 --- a/net/ipv6/ip6_gre.c +++ b/net/ipv6/ip6_gre.c @@ -2135,9 +2135,23 @@ static int ip6gre_fill_info(struct sk_buff *skb, const struct net_device *dev) struct __ip6_tnl_parm *p = &t->parms; __be16 o_flags = p->o_flags; - if ((p->erspan_ver == 1 || p->erspan_ver == 2) && - !p->collect_md) - o_flags |= TUNNEL_KEY; + if (p->erspan_ver == 1 || p->erspan_ver == 2) { + if (!p->collect_md) + o_flags |= TUNNEL_KEY; + + if (nla_put_u8(skb, IFLA_GRE_ERSPAN_VER, p->erspan_ver)) + goto nla_put_failure; + + if (p->erspan_ver == 1) { + if (nla_put_u32(skb, IFLA_GRE_ERSPAN_INDEX, p->index)) + goto nla_put_failure; + } else { + if (nla_put_u8(skb, IFLA_GRE_ERSPAN_DIR, p->dir)) + goto nla_put_failure; + if (nla_put_u16(skb, IFLA_GRE_ERSPAN_HWID, p->hwid)) + goto nla_put_failure; + } + } if (nla_put_u32(skb, IFLA_GRE_LINK, p->link) || nla_put_be16(skb, IFLA_GRE_IFLAGS, @@ -2152,8 +2166,7 @@ static int ip6gre_fill_info(struct sk_buff *skb, const struct net_device *dev) nla_put_u8(skb, IFLA_GRE_ENCAP_LIMIT, p->encap_limit) || nla_put_be32(skb, IFLA_GRE_FLOWINFO, p->flowinfo) || nla_put_u32(skb, IFLA_GRE_FLAGS, p->flags) || - nla_put_u32(skb, IFLA_GRE_FWMARK, p->fwmark) || - nla_put_u32(skb, IFLA_GRE_ERSPAN_INDEX, p->index)) + nla_put_u32(skb, IFLA_GRE_FWMARK, p->fwmark)) goto nla_put_failure; if (nla_put_u16(skb, IFLA_GRE_ENCAP_TYPE, @@ -2171,19 +2184,6 @@ static int ip6gre_fill_info(struct sk_buff *skb, const struct net_device *dev) goto nla_put_failure; } - if (nla_put_u8(skb, IFLA_GRE_ERSPAN_VER, p->erspan_ver)) - goto nla_put_failure; - - if (p->erspan_ver == 1) { - if (nla_put_u32(skb, IFLA_GRE_ERSPAN_INDEX, p->index)) - goto nla_put_failure; - } else if (p->erspan_ver == 2) { - if (nla_put_u8(skb, IFLA_GRE_ERSPAN_DIR, p->dir)) - goto nla_put_failure; - if (nla_put_u16(skb, IFLA_GRE_ERSPAN_HWID, p->hwid)) - goto nla_put_failure; - } - return 0; nla_put_failure: -- 2.20.1