Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2397983imm; Sun, 5 Aug 2018 03:26:45 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcWXgys9leUCSWzKPRMe2y2hdUaUpIlGmqNLQDWHd3/lyhsQ9HrEvRXR3u32vd5ZBsAORVG X-Received: by 2002:a62:225d:: with SMTP id i90-v6mr12274920pfi.246.1533464805411; Sun, 05 Aug 2018 03:26:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533464805; cv=none; d=google.com; s=arc-20160816; b=mIAEUvBanSeT+pCNiKhDRwcoEBdODdXVFZKXBUTdKk1I0aBhxsyZnuPi2Xp+HiL1N9 6oUpiOVfO5pWLaCcEYWgDlqWqBXOZCccoYDNy9/HgYAsLbHnr7R+mGTCq7YPx27Mb9d0 8OSfLaOx8c16jemIdO+VOyT+0LgJgHFDtas6NhsrSgE/AIYTh9y4YOoZdxL5k1KXbwPB v3LzSAzSM0yIMQdnrkz4NRo2wlWDmmgwkovlVCGujowYc2YiO0TPjvQTJ3/9t0s3rRm7 qEWj023BQeAqQMw8I43eUjt8inaEp1z0kjhspRF0llU6CAbZjiRGy4+du3NrVwrwnS3r nFaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=6lpnBrpOld5lBf2pMgr2oP18H94RaA9HBcmfI6pGCiM=; b=kgE2OOF01zIOqs1qLB95hApX/NUH6e0zSUu3t5zSiQr4jDl0GgFDUoNarFqkFC7KCV 9dqKHvBT2nOPiaUKOc/qCkcpar5WF3n+UOrtpreE8soa5J24n6Fm8dB99L4OEDx776u9 Thty+y2Wp5JMh0yapVY/6jm4h5qHAxNph1gYpsxLpVVKGVUCU8Zkm7AIdP+ZlI7kuNpb p2stBHJo3wM5Hst9XeLeoBfoiSELy8ZzwMEi/q0tmsGOXbpsgERNIzHfH1g8e5du+nOL wv9VazoAK9hcCZkb57YaAuupVGqgPgjcjA/dMmT4uDLbeRkMuKcPwvU4rTxuJMjH3MzX cuag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=oZMlv2Mm; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l26-v6si10378130pfj.188.2018.08.05.03.26.30; Sun, 05 Aug 2018 03:26:45 -0700 (PDT) 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=@gmail.com header.s=20161025 header.b=oZMlv2Mm; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726433AbeHEM3p (ORCPT + 99 others); Sun, 5 Aug 2018 08:29:45 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:45048 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726130AbeHEM3p (ORCPT ); Sun, 5 Aug 2018 08:29:45 -0400 Received: by mail-pf1-f196.google.com with SMTP id k21-v6so5408845pff.11; Sun, 05 Aug 2018 03:25:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=6lpnBrpOld5lBf2pMgr2oP18H94RaA9HBcmfI6pGCiM=; b=oZMlv2Mmpgp6FpBSke2wwlNFzIBPa4EVeFPExn4u5t2g4UI14Gx1wRkhY7q943nJ6+ SQumI6ZxeHxlf7mcWta3EI3XZvEQku9hnj5kziaMU6DzBegkKQ+BYcw6zyHnAa1XbpfH ucoszwiVZvYeGfupaCUcAnfy09U9rY0v/8sJNG36u2IdxS0SmKeIjkhxT44gF9IGw4lo hr3JuEyfLVn/BYaV5R4Y5fecO28kohjrXII2sijkHofy/X3lTve/OQVusznQO6vnrDAU +nGen7knOgwu1UWRVb+qAoLO2KV3D7hYkYtHJzJdMQ9gMzoddr7CnD5t0ji1Tm4LESNu cXFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=6lpnBrpOld5lBf2pMgr2oP18H94RaA9HBcmfI6pGCiM=; b=Ffw4HR1rFFYWYAmruYKV7T+fHVYpCklIVFj2rrUlvsOAgdjO0i1oWRN5YLp08GfvvN 6hS9JdeVk84jdcPzwN90HqOg5qNIliX0AR+bBBsyjcNF2ax2Wi7g4HGBGjgWRpzhrY5t DYnAcWxHIUSpoVzYveYAO3hNXwA7rXYR0uE5bEYIzF3USPbqMtaAqH/maeeugcQVh9sF Zj++dBt15dJSwX1NADqp3vHoyp04KEmFk2auQyZ4dHoyPXGOh3a4pbSRqxO8RtDtWaGv 0RxfD40rCq69cGtloXwso2uSgnvh3RoYPmLyCQPovoexLwGAURHI/PA2KPnzswsZDKQb qncg== X-Gm-Message-State: AOUpUlH3PrZ6TZZL1i6/964A7ev7Zo7mezE7ja8lpkze/KUGtIuth19G FZU7GWol6IYor81yF0Z6lts= X-Received: by 2002:a63:686:: with SMTP id 128-v6mr10369439pgg.338.1533464739697; Sun, 05 Aug 2018 03:25:39 -0700 (PDT) Received: from bogon.didichuxing.com ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id b192-v6sm9351692pga.7.2018.08.05.03.25.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 05 Aug 2018 03:25:39 -0700 (PDT) From: Yafang Shao To: edumazet@google.com, davem@davemloft.net Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Yafang Shao Subject: [PATCH net-next v2] tcp: propagate gso_segs to the new skb built in tcp collapse Date: Sun, 5 Aug 2018 18:25:07 +0800 Message-Id: <1533464707-11777-1-git-send-email-laoar.shao@gmail.com> X-Mailer: git-send-email 1.8.3.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The gso_segs of the new built SKB in tcp collapse is inited to 0, that makes us hard to know the accurate segments number of this new SKB. We'd better propagate the gso_segs of the collapsed SKB to the new built one, so when this SKB is dropped (for example when doing tcp prune) the sk_drops will be added to the correct value. If the collapsed SKB is fully copied to the new built one, we just add its gso_segs to the new SKB. While if the collapsed SKB is partially copied to the new built SKB, we have to caculate how many segments are copied. Furthemore, we have to reset the gso_segs of this SKB if is is partially copied, so in the next round when the left segments are copied it could propagate the correct value. Signed-off-by: Yafang Shao --- net/ipv4/tcp_input.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 715d541..72d4fc8 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -4915,12 +4915,23 @@ void tcp_rbtree_insert(struct rb_root *root, struct sk_buff *skb) /* Copy data, releasing collapsed skbs. */ while (copy > 0) { - int offset = start - TCP_SKB_CB(skb)->seq; int size = TCP_SKB_CB(skb)->end_seq - start; + int offset = start - TCP_SKB_CB(skb)->seq; BUG_ON(offset < 0); if (size > 0) { size = min(copy, size); + if (copy >= size) { + skb_shinfo(nskb)->gso_segs += + max_t(u16, 1, skb_shinfo(skb)->gso_segs); + } else { + skb_shinfo(nskb)->gso_segs += + DIV_ROUND_UP(copy, skb_shinfo(skb)->gso_size); + skb_shinfo(skb)->gso_segs = + DIV_ROUND_UP(size - copy, skb_shinfo(skb)->gso_size); + size = copy; + } + if (skb_copy_bits(skb, offset, skb_put(nskb, size), size)) BUG(); TCP_SKB_CB(nskb)->end_seq += size; -- 1.8.3.1