From patchwork Thu May 11 00:01:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuchung Cheng X-Patchwork-Id: 760886 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3wNYDf3fp4z9s8F for ; Thu, 11 May 2017 10:01:38 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="wOWyjPhB"; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753913AbdEKABg (ORCPT ); Wed, 10 May 2017 20:01:36 -0400 Received: from mail-pf0-f179.google.com ([209.85.192.179]:34734 "EHLO mail-pf0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751096AbdEKABf (ORCPT ); Wed, 10 May 2017 20:01:35 -0400 Received: by mail-pf0-f179.google.com with SMTP id e64so5093653pfd.1 for ; Wed, 10 May 2017 17:01:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=0M1M+gUxzyKtfUf7YI9zTibR+5j135GoPa264VbwRHE=; b=wOWyjPhBZx0cqS1LpTZ/dgN2ykUG8k33aVvgbDsnWZWZZCum9tdCrrcQ8/9Ccv5EMW 6Z+V6EJKC13EuQM4ofrERUd3P+r5/xrsdVFEnjFUAOIvZ0uEIsPbPz2+FJ0RWOLlIb/W 0thn0Ls5jsTb2O4wuqZ+B/AI5HFV5LDmO2yjx7Tp3vkzTpJNlr6yviTxRbRwZHi7nDSg n0BkJxWNl4oanSngM9XhMdFgrIdyUaPTdmJ0e4MVdpGUsbwPYdHWEINNa6NMdpGEcu+q P1s7P/OHJIGp4loePYRF5De5eNFA5SvgF0FvR6scbjxOnxS66cS2FlvH3+Sslfp2mTHL rLQA== 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=0M1M+gUxzyKtfUf7YI9zTibR+5j135GoPa264VbwRHE=; b=ZotDCH4VnaoKmc633tqGxeqeFde9ruUwr3MeXGMamnAfTecg2RouebMedxTr9cNJGL ieXyNXM2Uqh2Iyn0okChSCqi2955e9ULCKsJ9pZSEt71YB3mRW9RUY7q/Huv8LbGR4BK rh3iv+TQJ2wGvoPTfbrR9bkurCynKnLOzucKr0L5kgt7pPYWcBZuH/g9PjiNYdjxbLbY 2q0sk0P+Ml/6O3glo58MO9fiXWQ6ooTk9VaS1utI2zxPHKdraFXXRxH7beP4km9psq7j OI8MrKY3ZLVNDF83dQRdeOOglYIrjHlrrhAcAdwfqAA0tsJg2TNW8N9nl9HZxo4hshMm h1Hg== X-Gm-Message-State: AODbwcBDdYUtiY7JJA2My1gx/a36q0SPx+jn61AcV6XTV/P0KlzrQgmj sY5aSh73SkO2JKme X-Received: by 10.98.200.23 with SMTP id z23mr9199626pff.18.1494460894506; Wed, 10 May 2017 17:01:34 -0700 (PDT) Received: from ycheng2.svl.corp.google.com ([100.123.228.89]) by smtp.gmail.com with ESMTPSA id d123sm55517pga.61.2017.05.10.17.01.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 10 May 2017 17:01:33 -0700 (PDT) From: Yuchung Cheng To: davem@davemloft.net Cc: netdev@vger.kernel.org, ncardwell@google.com, edumazet@google.com, soheil@google.com, Yuchung Cheng Subject: [PATCH net] tcp: avoid fragmenting peculiar skbs in SACK Date: Wed, 10 May 2017 17:01:27 -0700 Message-Id: <20170511000127.4249-1-ycheng@google.com> X-Mailer: git-send-email 2.13.0.rc2.291.g57267f2277-goog Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patch fixes a bug in splitting an SKB during SACK processing. Specifically if an skb contains multiple packets and is only partially sacked in the higher sequences, tcp_match_sack_to_skb() splits the skb and marks the second fragment as SACKed. The current code further attempts rounding up the first fragment to MSS boundaries. But it misses a boundary condition when the rounded-up fragment size (pkt_len) is exactly skb size. Spliting such an skb is pointless and causses a kernel warning and aborts the SACK processing. This patch universally checks such over-split before calling tcp_fragment to prevent these unnecessary warnings. Fixes: adb92db857ee ("tcp: Make SACK code to split only at mss boundaries") Signed-off-by: Yuchung Cheng Signed-off-by: Eric Dumazet Signed-off-by: Soheil Hassas Yeganeh Acked-by: Neal Cardwell --- net/ipv4/tcp_input.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 5a3ad09e2786..06e2dbc2b4a2 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -1179,13 +1179,14 @@ static int tcp_match_skb_to_sack(struct sock *sk, struct sk_buff *skb, */ if (pkt_len > mss) { unsigned int new_len = (pkt_len / mss) * mss; - if (!in_sack && new_len < pkt_len) { + if (!in_sack && new_len < pkt_len) new_len += mss; - if (new_len >= skb->len) - return 0; - } pkt_len = new_len; } + + if (pkt_len >= skb->len && !in_sack) + return 0; + err = tcp_fragment(sk, skb, pkt_len, mss, GFP_ATOMIC); if (err < 0) return err;