Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp631481pxb; Wed, 16 Feb 2022 00:23:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJxJkn202kMkiimO5YxGk0MTt2rlobFzp4+wCfHos5uTmOy5Ah1rFX+bHLcZcESrwJ6ev4zK X-Received: by 2002:a17:902:d4d2:b0:14d:6060:718c with SMTP id o18-20020a170902d4d200b0014d6060718cmr1804292plg.90.1644999816768; Wed, 16 Feb 2022 00:23:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644999816; cv=none; d=google.com; s=arc-20160816; b=QqKnJ7kJKYDb4nMVME2cQ++npwEtAlT+J2JczstiwjQMnu6hUmSI/BNng6Qh6vU2So ClunnlUlYVKNLR/eXROqU2HAXq2yp8oUtXGWSNmmevArjt9td24fh7DEq8gU9xlvULzQ +GOVmB01qmjm+SsvT8auy4Op1PnjPKj7SmH4gVz4VoNhg+1K4qXUMo5Wh4PXSaUB+Z8g EA7nO+BEsjAq6JILGCX3z+iCIlg8o6unC9H8q+bQ3C86jfCqc2MEappnkJZ+v1gQpw1a 2cCVhnXWkJ9/YHaLDaMAQ3VduFyd4vtZBzn9Wp4HqUxmsdcuavVI7FC5BoG8crsmdOfz bqDQ== 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 :message-id:date:subject:cc:to:from; bh=wivTCp0yMsl+t04p0EGbCN5HvdexeH+ULg8eeGstwWQ=; b=b/49Tw9xsKricZKi659tJseJa0Gm5xKSbCp6x7FX+SDVb3Z8aZaFrVpfx7ymRJ0UmD acduTACBISyilRGflcHz27zI6oNIqiWfTn9uGz+jxLgV+QlylYr3uHefUTlTkenFked0 UUzElhWCnrGggSVPjz1InhJVbJmXH/6FO/s0BmG5kZ0Fz2UzgDGxL6nV9+IqI53MYNTS +AfLVOVCvNGjpSlw+Fq3Kv9MHyYE+9F18Q06WwHqDLMRxYeeMIlfMUaIuxxR4OXMSdNZ DQZCHco2IR48ZAbjtjbb+cXWxWzuu/g8ERHpq0xQBljjDT8HHs8DmQNI/dpktcqDZD4Z vxHg== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ucloud.cn Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id go24si15760206pjb.109.2022.02.16.00.23.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 00:23:36 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ucloud.cn Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7FC11B23AD; Wed, 16 Feb 2022 00:11:00 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231447AbiBPILJ (ORCPT + 99 others); Wed, 16 Feb 2022 03:11:09 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:57888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230232AbiBPILG (ORCPT ); Wed, 16 Feb 2022 03:11:06 -0500 Received: from mail-m2458.qiye.163.com (mail-m2458.qiye.163.com [220.194.24.58]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B784D60DB4; Wed, 16 Feb 2022 00:10:50 -0800 (PST) Received: from localhost.localdomain (unknown [117.48.120.186]) by mail-m2458.qiye.163.com (Hmail) with ESMTPA id 4EE69740148; Wed, 16 Feb 2022 16:10:48 +0800 (CST) From: Tao Liu To: davem@davemloft.net, yoshfuji@linux-ipv6.org, dsahern@kernel.org, kuba@kernel.org, edumazet@google.com, sridhar.samudrala@intel.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Tao Liu Subject: [PATCH net v2] gso: do not skip outer ip header in case of ipip and net_failover Date: Wed, 16 Feb 2022 16:10:41 +0800 Message-Id: <20220216081041.70831-1-thomas.liu@ucloud.cn> X-Mailer: git-send-email 2.30.1 (Apple Git-130) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-HM-Spam-Status: e1kfGhgUHx5ZQUtXWQgPGg8OCBgUHx5ZQUlOS1dZCBgUCR5ZQVlLVUtZV1 kWDxoPAgseWUFZKDYvK1lXWShZQUlCN1dZLVlBSVdZDwkaFQgSH1lBWUNLQxpWHU1PQx9ISkhMSE xPVRkRExYaEhckFA4PWVdZFhoPEhUdFFlBWVVLWQY+ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6MAg6Kjo*MTI2Nwg2NTgJMi1K Sw8aC1FVSlVKTU9PQkJCS09DTEtOVTMWGhIXVQ8TFBYaCFUXEg47DhgXFA4fVRgVRVlXWRILWUFZ SkpMVU9DVUpJS1VKQ01ZV1kIAVlBT0tLSzcG X-HM-Tid: 0a7f01957d358c17kuqt4ee69740148 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 We encounter a tcp drop issue in our cloud environment. Packet GROed in host forwards to a VM virtio_net nic with net_failover enabled. VM acts as a IPVS LB with ipip encapsulation. The full path like: host gro -> vm virtio_net rx -> net_failover rx -> ipvs fullnat -> ipip encap -> net_failover tx -> virtio_net tx When net_failover transmits a ipip pkt (gso_type = 0x0103), there is no gso did because it supports TSO and GSO_IPXIP4. But network_header points to inner ip header. Call Trace: tcp4_gso_segment ------> return NULL inet_gso_segment ------> inner iph, network_header points to ipip_gso_segment inet_gso_segment ------> outer iph skb_mac_gso_segment Afterwards virtio_net transmits the pkt, only inner ip header is modified. And the outer one just keeps unchanged. The pkt will be dropped in remote host. So we need to reset network header in this case. Call Trace: inet_gso_segment ------> inner iph, outer iph is skipped skb_mac_gso_segment __skb_gso_segment validate_xmit_skb validate_xmit_skb_list sch_direct_xmit __qdisc_run __dev_queue_xmit ------> virtio_net dev_hard_start_xmit __dev_queue_xmit ------> net_failover ip_finish_output2 ip_output iptunnel_xmit ip_tunnel_xmit ipip_tunnel_xmit ------> ipip dev_hard_start_xmit __dev_queue_xmit ip_finish_output2 ip_output ip_forward ip_rcv __netif_receive_skb_one_core netif_receive_skb_internal napi_gro_receive receive_buf virtnet_poll net_rx_action This patch also includes ipv6_gso_segment(), considering SIT, etc. Fixes: cb32f511a70b ("ipip: add GSO/TSO support") Fixes: cfc80d9a1163 ("net: Introduce net_failover driver") Signed-off-by: Tao Liu --- net/ipv4/af_inet.c | 5 ++++- net/ipv6/ip6_offload.c | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index 9c465ba..72fde28 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c @@ -1376,8 +1376,11 @@ struct sk_buff *inet_gso_segment(struct sk_buff *skb, } ops = rcu_dereference(inet_offloads[proto]); - if (likely(ops && ops->callbacks.gso_segment)) + if (likely(ops && ops->callbacks.gso_segment)) { segs = ops->callbacks.gso_segment(skb, features); + if (!segs) + skb->network_header = skb_mac_header(skb) + nhoff - skb->head; + } if (IS_ERR_OR_NULL(segs)) goto out; diff --git a/net/ipv6/ip6_offload.c b/net/ipv6/ip6_offload.c index b29e9ba..5f577e2 100644 --- a/net/ipv6/ip6_offload.c +++ b/net/ipv6/ip6_offload.c @@ -114,6 +114,8 @@ static struct sk_buff *ipv6_gso_segment(struct sk_buff *skb, if (likely(ops && ops->callbacks.gso_segment)) { skb_reset_transport_header(skb); segs = ops->callbacks.gso_segment(skb, features); + if (!segs) + skb->network_header = skb_mac_header(skb) + nhoff - skb->head; } if (IS_ERR_OR_NULL(segs)) -- 1.8.3.1