From patchwork Wed Jun 27 13:34:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Flavio Leitner X-Patchwork-Id: 935503 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 41G3mx1GDFz9s2L for ; Wed, 27 Jun 2018 23:34:57 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965495AbeF0Nez (ORCPT ); Wed, 27 Jun 2018 09:34:55 -0400 Received: from mail-qk0-f196.google.com ([209.85.220.196]:42512 "EHLO mail-qk0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965477AbeF0Nev (ORCPT ); Wed, 27 Jun 2018 09:34:51 -0400 Received: by mail-qk0-f196.google.com with SMTP id u62-v6so1007097qkf.9 for ; Wed, 27 Jun 2018 06:34:51 -0700 (PDT) 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:in-reply-to :references; bh=79Uk65XgbyRfK88sUMew2Mu6YghEyEOZ6u9fjGNvB6k=; b=sGZI+12BTEr/uTfPsd/1qpNMZPBpBwtW0+Zkq4cPoi8QSYTAWWXGskzQdjLO6DvWFJ xRyUgfvlOUINtwFAyqJ4yv35fjd99ngR7uGGsYlywFIRx3mviwGRXw0JTOBuYYaIHDRB l77cGjEiuBz9QM4tgZvlzwcps4l+zO7j0PbMh3fAwYKEOi24f1GCD4QAd6fMaSbmJQ7n vrqKne5pp/XqZzIA2Jxj+xHQZQfuqCOFMzeco0YvvgwfTpbwo1HJHm61nWUn0iUCOMDm QEADLHHWf96baRLGxLjBPGJtwcSaIo8UlU3ABo6Q70ZlLvd9DjsZZwuWiaPdIAc7qYo+ Ifvw== X-Gm-Message-State: APt69E3MMRmumyT8sgzWSNP1ZjGOP8XQvvckkRzrSq59qot5hCj4tk3p pei5pJaK45sdgXPVNh9xKMCSJwPsxCU= X-Google-Smtp-Source: AAOMgpefOCD2qckJ1m+gsxIdZnGbaAv6OfZnKJ+y6RxFUAAF91nfKDQLF8DLWp8Sl6qf9QqfxZeHJA== X-Received: by 2002:a37:c887:: with SMTP id t7-v6mr5210342qkl.300.1530106490937; Wed, 27 Jun 2018 06:34:50 -0700 (PDT) Received: from localhost ([177.183.215.231]) by smtp.gmail.com with ESMTPSA id e68-v6sm2716272qkd.15.2018.06.27.06.34.49 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 27 Jun 2018 06:34:50 -0700 (PDT) From: Flavio Leitner To: netdev@vger.kernel.org Cc: Eric Dumazet , Paolo Abeni , David Miller , Florian Westphal , netfilter-devel@vger.kernel.org, Flavio Leitner Subject: [PATCH v2 net-next 2/2] skbuff: preserve sock reference when scrubbing the skb. Date: Wed, 27 Jun 2018 10:34:26 -0300 Message-Id: <20180627133426.3858-3-fbl@redhat.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180627133426.3858-1-fbl@redhat.com> References: <20180627133426.3858-1-fbl@redhat.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The sock reference is lost when scrubbing the packet and that breaks TSQ (TCP Small Queues) and XPS (Transmit Packet Steering) causing performance impacts of about 50% in a single TCP stream when crossing network namespaces. XPS breaks because the queue mapping stored in the socket is not available, so another random queue might be selected when the stack needs to transmit something like a TCP ACK, or TCP Retransmissions. That causes packet re-ordering and/or performance issues. TSQ breaks because it orphans the packet while it is still in the host, so packets are queued contributing to the buffer bloat problem. Preserving the sock reference fixes both issues. The socket is orphaned anyways in the receiving path before any relevant action and on TX side the netfilter checks if the reference is local before use it. Signed-off-by: Flavio Leitner --- Documentation/networking/ip-sysctl.txt | 10 +++++----- net/core/skbuff.c | 1 - 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Documentation/networking/ip-sysctl.txt b/Documentation/networking/ip-sysctl.txt index ce8fbf5aa63c..f4c042be0216 100644 --- a/Documentation/networking/ip-sysctl.txt +++ b/Documentation/networking/ip-sysctl.txt @@ -733,11 +733,11 @@ tcp_limit_output_bytes - INTEGER Controls TCP Small Queue limit per tcp socket. TCP bulk sender tends to increase packets in flight until it gets losses notifications. With SNDBUF autotuning, this can - result in a large amount of packets queued in qdisc/device - on the local machine, hurting latency of other flows, for - typical pfifo_fast qdiscs. - tcp_limit_output_bytes limits the number of bytes on qdisc - or device to reduce artificial RTT/cwnd and reduce bufferbloat. + result in a large amount of packets queued on the local machine + (e.g.: qdiscs, CPU backlog, or device) hurting latency of other + flows, for typical pfifo_fast qdiscs. tcp_limit_output_bytes + limits the number of bytes on qdisc or device to reduce artificial + RTT/cwnd and reduce bufferbloat. Default: 262144 tcp_challenge_ack_limit - INTEGER diff --git a/net/core/skbuff.c b/net/core/skbuff.c index b1f274f22d85..f59e98ca72c5 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -4911,7 +4911,6 @@ void skb_scrub_packet(struct sk_buff *skb, bool xnet) return; ipvs_reset(skb); - skb_orphan(skb); skb->mark = 0; } EXPORT_SYMBOL_GPL(skb_scrub_packet);