From patchwork Sat Oct 22 07:21:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7234 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1090786wrr; Sat, 22 Oct 2022 00:48:26 -0700 (PDT) X-Google-Smtp-Source: AMsMyM43tzkC1CLFAHsBeBqqfVtcFjCPqOzW3Z5PKvy5bMRfy52U25IXbh9R81qvAkqI6FaNkTnw X-Received: by 2002:a17:90a:e548:b0:211:2c0c:cb74 with SMTP id ei8-20020a17090ae54800b002112c0ccb74mr16593349pjb.69.1666424906689; Sat, 22 Oct 2022 00:48:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666424906; cv=none; d=google.com; s=arc-20160816; b=WYs5GovVjqE1kdT7hreaD8nyd9u27ZMYP9a/LAp3koR06eEHNTHA62FCPkxVZf0U5+ upTTpvEQ9gaq0Q1bhh2hN37ugxkKNj3q7QOPcSUQCg/66nSfcGKncKS9bCIoaijG/MKh N7kn2CbAf4z/58Y0SO7/F+vxQGdkdosUkkIDVx6A+L/9TDiWkhonIN0VnWVqvUKnyLBX uw8Ot9FxpVN+VswOsEh18HV19eE18RmCqxG8SpF1UVpX+TGMTQmysm008p9uZhtu0hrC TAqWaFRhK81oTRxkFCwRVFa6Crdjj/Z8vBAGQPloEwMLHYhf7nk4OsGf/eLZ97GQ+lKJ J3AQ== 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=cs6XxY+iMPAUcRsVQ4RKpP2wpDoD3KmLeGYn/S5GBfEZCYQdltzZ3SPbn1Mb4BpOKe +YXHH5u3P2JpgbxA1gFlz+DCIFNtXmB5G1ehA5XWu6X7CODYBn6or9mf4a+W+TTJ1X0C 1lcKhjE+5A+6NVgRG7EAouu6SAGUSmziUPYgbDHZ82AO/K2Ah4TVMiY0dskZOL46Os+U ucvDMzn/Nk3QDgBEUiSR8h0uTjYImOFVE9w/epDpvCMWdnlePsUWaeJqEk9I1jwXv6wQ dTecXTjGAUdL7asD/16nQBmvmhYcG0efDpWgCy82yNB80iYZUHUrTjQU8KUz42q/mz1R 3YWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=i6SYq41i; 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 h13-20020a65480d000000b0041c506dde92si26200168pgs.636.2022.10.22.00.48.14; Sat, 22 Oct 2022 00:48:26 -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=i6SYq41i; 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 S231574AbiJVHro (ORCPT + 99 others); Sat, 22 Oct 2022 03:47:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231552AbiJVHrN (ORCPT ); Sat, 22 Oct 2022 03:47:13 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CFFE15FCD; Sat, 22 Oct 2022 00:44:37 -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 ams.source.kernel.org (Postfix) with ESMTPS id EAC4AB82E13; Sat, 22 Oct 2022 07:43:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0D3AFC433C1; Sat, 22 Oct 2022 07:43:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666424616; bh=yVMy2NWsVdNDP54jbBTFxUQN5uZNosG28yGa4Gw8At0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i6SYq41iOjb1giQvKHakgz8nr/MnGMX2770riDDAzMbXgU8G2y/I8M+kgwUCPFSJU TbbSjxyFTnntLMa7kvAL9yQR2qgoDbKtsMEFup5Dvq+O1qfsciIy/qaFh8WFeTpEbQ Uovn9LI5j0atNhgtn/ppfAaFNy3RlH39kSI2OHJU= 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 5.19 213/717] esp: choose the correct inner protocol for GSO on inter address family tunnels Date: Sat, 22 Oct 2022 09:21:32 +0200 Message-Id: <20221022072452.962173379@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.3 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?1747373162810123568?= X-GMAIL-MSGID: =?utf-8?q?1747373162810123568?= 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,