From patchwork Wed Oct 19 08:25:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 5460 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp331168wrs; Wed, 19 Oct 2022 06:36:09 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7fgRvBJTB4STSAsq+l6ZmdU3mfBI+iHd6edO8Y8rhbzm9OurrOBTtoLbNXv5WwYa6W8UTO X-Received: by 2002:a17:902:b402:b0:179:e5b0:96d3 with SMTP id x2-20020a170902b40200b00179e5b096d3mr8414112plr.142.1666186569017; Wed, 19 Oct 2022 06:36:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666186569; cv=none; d=google.com; s=arc-20160816; b=R7GznHrjSL3XJmTGMz4z3qT7LVG8hnRxcv/jYmadqEhelnzBB5iAcmGGP2IRd2fJBB 1UriUs7+vCxEU5ZztIn/m6Q87JrZkQimh3Cz669eQhp8Td6aL28Z7tLkaWhor5/GkDSB 8YCLSKwmb/SmLSU3nGJPPJODv2kKSQQtBEWPHL7os6IQV+jhUaY0R7Lyad+03Vt4S+6T D50xvkhmRzUJE/D8nhPaJuMdq4mY6Is/TDLVCr3ACcUsOqGdIVDL4rZZjQ+XhtaeoTfv iBhPCc5mkR0l7clUFKyLCS940T8DYmtLV7Rzn2ftEaEcVqqN5EBmtmo7kTUhNYSotdKF Esjg== 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=6Luwm+6V4EnEcJDN6jv3v3LMxZdE/VcwQnoGBPu0axQ=; b=JkEV5SYOaLwNd4CvfX6tEgFHmeqwS+8JMmc8jpOLhhsD/8YT7Z1Io3n/FPyr8roksC JdqyPt9dXTUIWAcPgiNxI9HIB11fB25KG16z6lCJ++fLrdhoRb6d4Yzgp0MXi1KErAPc vDPQ3jn0eodOePG0CUMFEQJDq7GKx7Kz/XHSR8eQT7rPp20aTvgZAyK9EB0rlEvIBT6o MNsn19GamswjVyaU63g0XG1UjzWUntrB/Gq4bTcrLyoZx8ivXqrkTuPKvcdiVFZ3ga9I eypyTBoWWFxRaCr5ms4M7cbc1mnUb6EpbGnikekRp3HG5nHa3J05obT3Jktx/5OFTprU nxGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=B4xxqNBi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a9-20020a170902ecc900b00179e70b9e6csi23514954plh.519.2022.10.19.06.35.55; Wed, 19 Oct 2022 06:36:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=B4xxqNBi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S231437AbiJSNZ3 (ORCPT + 99 others); Wed, 19 Oct 2022 09:25:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231349AbiJSNZD (ORCPT ); Wed, 19 Oct 2022 09:25:03 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36A1912D34; Wed, 19 Oct 2022 06:11:39 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id EBE86CE20FA; Wed, 19 Oct 2022 08:49:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D606EC433D6; Wed, 19 Oct 2022 08:49:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666169360; bh=yVMy2NWsVdNDP54jbBTFxUQN5uZNosG28yGa4Gw8At0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B4xxqNBi8FNH54s9Y/Hjlchqc6mXkxtuAuXjlPsYAq8rKgEN3RjRRfgs5X6tDCVS7 +8a9vwbOsM2GCg+GgFHD3MRxDa4Gk0wUlQKjFJtgcXpuAom57LJInVFoiQR0+/0y9P p2tUNLE1Az5pqOHPb/0u/aFgBAi5vI7P4X+I3gG0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sabrina Dubroca , Steffen Klassert , Sasha Levin Subject: [PATCH 6.0 248/862] esp: choose the correct inner protocol for GSO on inter address family tunnels Date: Wed, 19 Oct 2022 10:25:35 +0200 Message-Id: <20221019083300.992358478@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747123247502354378?= X-GMAIL-MSGID: =?utf-8?q?1747123247502354378?= From: Sabrina Dubroca [ Upstream commit 26dbd66eab8080be51759e48280da04015221e22 ] Commit 23c7f8d7989e ("net: Fix esp GSO on inter address family tunnels.") is incomplete. It passes to skb_eth_gso_segment the protocol for the outer IP version, instead of the inner IP version, so we end up calling inet_gso_segment on an inner IPv6 packet and ipv6_gso_segment on an inner IPv4 packet and the packets are dropped. This patch completes the fix by selecting the correct protocol based on the inner mode's family. Fixes: c35fe4106b92 ("xfrm: Add mode handlers for IPsec on layer 2") Signed-off-by: Sabrina Dubroca Signed-off-by: Steffen Klassert Signed-off-by: Sasha Levin --- net/ipv4/esp4_offload.c | 5 ++++- net/ipv6/esp6_offload.c | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/net/ipv4/esp4_offload.c b/net/ipv4/esp4_offload.c index 935026f4c807..170152772d33 100644 --- a/net/ipv4/esp4_offload.c +++ b/net/ipv4/esp4_offload.c @@ -110,7 +110,10 @@ static struct sk_buff *xfrm4_tunnel_gso_segment(struct xfrm_state *x, struct sk_buff *skb, netdev_features_t features) { - return skb_eth_gso_segment(skb, features, htons(ETH_P_IP)); + __be16 type = x->inner_mode.family == AF_INET6 ? htons(ETH_P_IPV6) + : htons(ETH_P_IP); + + return skb_eth_gso_segment(skb, features, type); } static struct sk_buff *xfrm4_transport_gso_segment(struct xfrm_state *x, diff --git a/net/ipv6/esp6_offload.c b/net/ipv6/esp6_offload.c index 3a293838a91d..79d43548279c 100644 --- a/net/ipv6/esp6_offload.c +++ b/net/ipv6/esp6_offload.c @@ -145,7 +145,10 @@ static struct sk_buff *xfrm6_tunnel_gso_segment(struct xfrm_state *x, struct sk_buff *skb, netdev_features_t features) { - return skb_eth_gso_segment(skb, features, htons(ETH_P_IPV6)); + __be16 type = x->inner_mode.family == AF_INET ? htons(ETH_P_IP) + : htons(ETH_P_IPV6); + + return skb_eth_gso_segment(skb, features, type); } static struct sk_buff *xfrm6_transport_gso_segment(struct xfrm_state *x,