Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4575478imu; Tue, 29 Jan 2019 04:05:13 -0800 (PST) X-Google-Smtp-Source: ALg8bN77pFfR4MauwsWLjyscUGLC9TtrFwAAQ9X8QqLrNCbxB1aCXxCdhIRj8XhSCVo1kskDI0O6 X-Received: by 2002:a17:902:b83:: with SMTP id 3mr24546868plr.42.1548763512857; Tue, 29 Jan 2019 04:05:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548763512; cv=none; d=google.com; s=arc-20160816; b=T3jwN1eCcRfAEj9TYfuxTC5IXySete+vJocZja4u658xyXl7N6y1Sh3yRrMAcQFg6p fnMwruicXufbKL6U1J83FDytPi3sPEIj5qnhkV1rzFGqrC0/MMPx+aggiDMJieikSZYu p0c3i5nZO25XeEyC6lc8lO+ViBLyfjKdVRiKLa/2UglZR2RwqGtJ59tHr+y2a8DSqkWy hXpg5dcndkymoYFmfKjrOpfcZq8YHoT9w8Af3ft1yvyHyH04mt1PpNFEwU852Ay7t4+c 30H1VsFeUgeNQvjKKAmLdtHcg25vCASd/xuKAgqkJryBCTjjl5SKWbDqzR86JOtDE2GY gwtw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=sLC40D7JPciPiJr+J3IUAAX/Ev+qRUYBx+u41rRqLnI=; b=cgw8Z9zwpO+VNWwoApHpAEFLJ4PTSTFiL3NFsoKt7khrGh0Gcm74/0I5iR76F+ivRY 0hKc3MJV6iFzHtjglE5HVjfI6///C0EzqOWAaHZm0dKfz2OpL/1LEp6/e++tb44/aulX O7GnvCpGGPoDtyCAlXJDy79j39+sm5bcsoFP9lun8T4WtSq1vk/U3EE1Jtl372gYyluj f33Jb3+oIMmQe+MLM5kBB/2XYXm6wy46qIXCD69cEF5st/uI4CUy6AhqFOULj1HgGzo1 4nwuI7Pwv/7O055visGe/bQyyv0s4bHLI6q/kGSENJ0D6emeXPickccLlG/xXWrDHAbo A/wA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fLNMP45t; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j20si33245541pgb.520.2019.01.29.04.04.55; Tue, 29 Jan 2019 04:05:12 -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=fLNMP45t; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730197AbfA2LnB (ORCPT + 99 others); Tue, 29 Jan 2019 06:43:01 -0500 Received: from mail.kernel.org ([198.145.29.99]:60956 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729546AbfA2Lm6 (ORCPT ); Tue, 29 Jan 2019 06:42:58 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (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 42B9E20857; Tue, 29 Jan 2019 11:42:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548762177; bh=Yet7FJNEhCRy/fZ5vFRKss+R9yQMpzurNylOT5qOqZU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fLNMP45txVCm7SqVHQ3kYUwWhYMBVZacmtvxnSyKD1hlYeOmD1clwsR+DmjkgfKzc GWTyKD1kEoWwWs7qqI6n+JlL48dkKPwsxCgvm4IVB9BIIyQhZLYwD6HjpsV47ciTlS /hJ9YglP6Oo+Jt+JqihdLApF68Xn6+rHXG2zosZI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jianlin Shi , Xin Long , "David S. Miller" Subject: [PATCH 4.19 018/103] erspan: build the header with the right proto according to erspan_ver Date: Tue, 29 Jan 2019 12:34:55 +0100 Message-Id: <20190129113200.616238957@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190129113159.567154026@linuxfoundation.org> References: <20190129113159.567154026@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Xin Long [ Upstream commit 20704bd1633dd5afb29a321d3a615c9c8e9c9d05 ] As said in draft-foschiano-erspan-03#section4: Different frame variants known as "ERSPAN Types" can be distinguished based on the GRE "Protocol Type" field value: Type I and II's value is 0x88BE while Type III's is 0x22EB [ETYPES]. So set it properly in erspan_xmit() according to erspan_ver. While at it, also remove the unused parameter 'proto' in erspan_fb_xmit(). Fixes: 94d7d8f29287 ("ip6_gre: add erspan v2 support") Reported-by: Jianlin Shi Signed-off-by: Xin Long Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv4/ip_gre.c | 23 ++++++++++++++--------- net/ipv6/ip6_gre.c | 6 ++++-- 2 files changed, 18 insertions(+), 11 deletions(-) --- a/net/ipv4/ip_gre.c +++ b/net/ipv4/ip_gre.c @@ -570,8 +570,7 @@ err_free_skb: dev->stats.tx_dropped++; } -static void erspan_fb_xmit(struct sk_buff *skb, struct net_device *dev, - __be16 proto) +static void erspan_fb_xmit(struct sk_buff *skb, struct net_device *dev) { struct ip_tunnel *tunnel = netdev_priv(dev); struct ip_tunnel_info *tun_info; @@ -579,10 +578,10 @@ static void erspan_fb_xmit(struct sk_buf struct erspan_metadata *md; struct rtable *rt = NULL; bool truncate = false; + __be16 df, proto; struct flowi4 fl; int tunnel_hlen; int version; - __be16 df; int nhoff; int thoff; @@ -627,18 +626,20 @@ static void erspan_fb_xmit(struct sk_buf if (version == 1) { erspan_build_header(skb, ntohl(tunnel_id_to_key32(key->tun_id)), ntohl(md->u.index), truncate, true); + proto = htons(ETH_P_ERSPAN); } else if (version == 2) { erspan_build_header_v2(skb, ntohl(tunnel_id_to_key32(key->tun_id)), md->u.md2.dir, get_hwid(&md->u.md2), truncate, true); + proto = htons(ETH_P_ERSPAN2); } else { goto err_free_rt; } gre_build_header(skb, 8, TUNNEL_SEQ, - htons(ETH_P_ERSPAN), 0, htonl(tunnel->o_seqno++)); + proto, 0, htonl(tunnel->o_seqno++)); df = key->tun_flags & TUNNEL_DONT_FRAGMENT ? htons(IP_DF) : 0; @@ -722,12 +723,13 @@ static netdev_tx_t erspan_xmit(struct sk { struct ip_tunnel *tunnel = netdev_priv(dev); bool truncate = false; + __be16 proto; if (!pskb_inet_may_pull(skb)) goto free_skb; if (tunnel->collect_md) { - erspan_fb_xmit(skb, dev, skb->protocol); + erspan_fb_xmit(skb, dev); return NETDEV_TX_OK; } @@ -743,19 +745,22 @@ static netdev_tx_t erspan_xmit(struct sk } /* Push ERSPAN header */ - if (tunnel->erspan_ver == 1) + if (tunnel->erspan_ver == 1) { erspan_build_header(skb, ntohl(tunnel->parms.o_key), tunnel->index, truncate, true); - else if (tunnel->erspan_ver == 2) + proto = htons(ETH_P_ERSPAN); + } else if (tunnel->erspan_ver == 2) { erspan_build_header_v2(skb, ntohl(tunnel->parms.o_key), tunnel->dir, tunnel->hwid, truncate, true); - else + proto = htons(ETH_P_ERSPAN2); + } else { goto free_skb; + } tunnel->parms.o_flags &= ~TUNNEL_KEY; - __gre_xmit(skb, dev, &tunnel->parms.iph, htons(ETH_P_ERSPAN)); + __gre_xmit(skb, dev, &tunnel->parms.iph, proto); return NETDEV_TX_OK; free_skb: --- a/net/ipv6/ip6_gre.c +++ b/net/ipv6/ip6_gre.c @@ -938,6 +938,7 @@ static netdev_tx_t ip6erspan_tunnel_xmit __u8 dsfield = false; struct flowi6 fl6; int err = -EINVAL; + __be16 proto; __u32 mtu; int nhoff; int thoff; @@ -1051,8 +1052,9 @@ static netdev_tx_t ip6erspan_tunnel_xmit } /* Push GRE header. */ - gre_build_header(skb, 8, TUNNEL_SEQ, - htons(ETH_P_ERSPAN), 0, htonl(t->o_seqno++)); + proto = (t->parms.erspan_ver == 1) ? htons(ETH_P_ERSPAN) + : htons(ETH_P_ERSPAN2); + gre_build_header(skb, 8, TUNNEL_SEQ, proto, 0, htonl(t->o_seqno++)); /* TooBig packet may have updated dst->dev's mtu */ if (!t->parms.collect_md && dst && dst_mtu(dst) > dst->dev->mtu)