Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp1190130ybn; Wed, 2 Oct 2019 12:11:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqxaJyd6tb2BGWF1sTieT1vlB+L6Pg8W6E1VsQ4JVfwqhPsEYoqM/a+/nAaOCitSH/ouBkng X-Received: by 2002:a17:906:139b:: with SMTP id f27mr4343387ejc.195.1570043471395; Wed, 02 Oct 2019 12:11:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570043471; cv=none; d=google.com; s=arc-20160816; b=OaZCaK/D6p9/tWG431nspCHOB5/UyycEGjAjKDsUgxTwsAZHuzqmnESGuaSN+fI7si bln4XKW7XntW3Jk89Bon4T15bPAsz0X90FK1nqTGxgCPgzbD491baPCrzFO96UXxLObb 2gRJJRqI06sL3oONDF3zUHJmSZ1m1arhpU1bdjtCsnr43acAMpYRsax7fz9f8L/awS9H kcBJtqRf59UuWY8cCcBuYb2ok7IOYqBJFzB9nL1NPVXUJMJb6mm/fdppBXiKmVhA79/N RO59FSgQDFerGcRF3N6+dF75SjWWqnMAHvfaVa9eoZEHgbQ3czSRFz2rnCcwZV4lSaky j3UQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=S2R3nbudgdOiji6XVcllGhQSY5kwA8n11qmZ6pRc0Oc=; b=tJCpkI4SfHInD1h0mpJMMqmZm3dtUS1/91V1HTPxHKKK9kiNqV2+sy0Cyr8b5mTme6 Ds6CsEP1KKA7zeRT3sh3NTa2YLCZTxvAicNR06YBbz7vNVYKhIYbxAKyQte/yn3qUo5i rvps8F4Qtyeju2wc+gy4Mgm5f+8fLwZoIJsV9KmlhCnw107UUo05MjQkaUq1FvT+ob+x Aauh16FlQBYTXOKyHxjzT+vsK2T6WsAfLRkOZ/FHNYuqZqkuMJ1HWkSYRoWKA6yCQqTm rmhHJ1AHGv4xVIlXhWNayXjgRe8voT5Ac0AM3ux6NBVIgA9b1FCzy895Y2cD1q608TgX lCvg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c21si2518ejx.295.2019.10.02.12.10.47; Wed, 02 Oct 2019 12:11:11 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729713AbfJBTJx (ORCPT + 99 others); Wed, 2 Oct 2019 15:09:53 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:35952 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729335AbfJBTIS (ORCPT ); Wed, 2 Oct 2019 15:08:18 -0400 Received: from [192.168.4.242] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iFjyx-000364-Qb; Wed, 02 Oct 2019 20:08:15 +0100 Received: from ben by deadeye with local (Exim 4.92.1) (envelope-from ) id 1iFjyp-0003fP-K9; Wed, 02 Oct 2019 20:08:07 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, Denis Kirjanov , "Dirk van der Merwe" , "Jakub Kicinski" , "Cong Wang" , "David S. Miller" Date: Wed, 02 Oct 2019 20:06:51 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) X-Patchwork-Hint: ignore Subject: [PATCH 3.16 69/87] net: netem: fix backlog accounting for corrupted GSO frames In-Reply-To: X-SA-Exim-Connect-IP: 192.168.4.242 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.75-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Jakub Kicinski commit 177b8007463c4f36c9a2c7ce7aa9875a4cad9bd5 upstream. When GSO frame has to be corrupted netem uses skb_gso_segment() to produce the list of frames, and re-enqueues the segments one by one. The backlog length has to be adjusted to account for new frames. The current calculation is incorrect, leading to wrong backlog lengths in the parent qdisc (both bytes and packets), and incorrect packet backlog count in netem itself. Parent backlog goes negative, netem's packet backlog counts all non-first segments twice (thus remaining non-zero even after qdisc is emptied). Move the variables used to count the adjustment into local scope to make 100% sure they aren't used at any stage in backports. Fixes: 6071bd1aa13e ("netem: Segment GSO packets on enqueue") Signed-off-by: Jakub Kicinski Reviewed-by: Dirk van der Merwe Acked-by: Cong Wang Signed-off-by: David S. Miller Signed-off-by: Ben Hutchings --- net/sched/sch_netem.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) --- a/net/sched/sch_netem.c +++ b/net/sched/sch_netem.c @@ -440,8 +440,7 @@ static int netem_enqueue(struct sk_buff struct netem_skb_cb *cb; struct sk_buff *skb2; struct sk_buff *segs = NULL; - unsigned int len = 0, last_len, prev_len = qdisc_pkt_len(skb); - int nb = 0; + unsigned int prev_len = qdisc_pkt_len(skb); int count = 1; int rc = NET_XMIT_SUCCESS; int rc_drop = NET_XMIT_DROP; @@ -495,6 +494,7 @@ static int netem_enqueue(struct sk_buff segs = netem_segment(skb, sch); if (!segs) return rc_drop; + qdisc_skb_cb(segs)->pkt_len = segs->len; } else { segs = skb; } @@ -575,6 +575,11 @@ static int netem_enqueue(struct sk_buff finish_segs: if (segs) { + unsigned int len, last_len; + int nb = 0; + + len = skb->len; + while (segs) { skb2 = segs->next; segs->next = NULL; @@ -590,9 +595,7 @@ finish_segs: } segs = skb2; } - sch->q.qlen += nb; - if (nb > 1) - qdisc_tree_reduce_backlog(sch, 1 - nb, prev_len - len); + qdisc_tree_reduce_backlog(sch, -nb, prev_len - len); } return NET_XMIT_SUCCESS; }