Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1171024pxu; Wed, 2 Dec 2020 12:59:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJxsTznvoDfYPDUGZLw73ORCmOOWvg0UDphvurXIMRf6r6SoVBDuv4pHXh+Nq7aqIU+PB8cN X-Received: by 2002:a50:8a02:: with SMTP id i2mr1872841edi.222.1606942799606; Wed, 02 Dec 2020 12:59:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606942799; cv=none; d=google.com; s=arc-20160816; b=SUZ4uUgclsyxjACY/xUvlSQz5w7gVsOFa3qZl6webT5bz57xQLyB02W5yjtzv++DNZ x8OSSVE4k40GLRdBKjXK8RgYk23f4sIm0I+P7BF7pmNjcUzERs+2i7L++Z5AqPCRZPeE Uz5ftFwbPNbHmSkEmSjaZYya4wq20ODv/JFGqSiLG8FxqYsn0MXBidqtilLgp0G9hQJb fL9fMOBHah+IHZ94vc2ktn5uDnDZP9a3FCC31paVD9JrrYacv3+VXtAhUKDDVzin+6be al8hY89Z6XmtLzb9myd/yZSkbh8sAe1wFLukag5XZqSx95Zxh9WnYdJtECNZDDi3flT4 6jNQ== 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:subject:reply-to:cc:from:to:dkim-signature:date; bh=FLkifQjXxyu0aeM6OMx13zZXQzHi1EHZwqH+p8C5HPI=; b=GCUMhHbWCqKrwO7vM+Au1XYlvYOlJNAa2OXdOY8tNYTmnzMYrGjr8oCaFbpxDVLdE2 tsnlhaN3yHC8TLqnXB7vLcZZIU3wsuZfJvY5OH9WFOiZmUkbqKW+qCJq5LDrOxn2BE2/ CKKdw8N43ZskLwzqHF3XxezeUtyBqQbtsY1Nf+WXh707f0bubM91P6paQkSOBxuRR64x MPAh1zlwbss9RhiKY5diZ3NjivK3mz34Ac8b0yN9143RG83QbsNh+dCmWM/waYNI4KtA DLcqn3i13+l1g5ljSxA9QiCPZAZZq05KvQHFfgj7CJPfg//2rkAH5+TgYd9ViMT+0169 aDnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@protonmail.com header.s=protonmail header.b=EQg8p9JM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=protonmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ec20si714201ejb.694.2020.12.02.12.59.36; Wed, 02 Dec 2020 12:59:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@protonmail.com header.s=protonmail header.b=EQg8p9JM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=protonmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388171AbgLBU4p (ORCPT + 99 others); Wed, 2 Dec 2020 15:56:45 -0500 Received: from mail-40131.protonmail.ch ([185.70.40.131]:40232 "EHLO mail-40131.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727737AbgLBU4p (ORCPT ); Wed, 2 Dec 2020 15:56:45 -0500 Date: Wed, 02 Dec 2020 20:55:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1606942562; bh=FLkifQjXxyu0aeM6OMx13zZXQzHi1EHZwqH+p8C5HPI=; h=Date:To:From:Cc:Reply-To:Subject:From; b=EQg8p9JMosMZx1q/xB8DGHRXAXIwzIecR+1PSI7WhZgo7cQjGCL6cXX+LndQHjIf1 ZwZlULhpXhC42Qw3RRUfAl8pRs7uO5ZGYJqE6lXwcKYgq51Fm4fl6rgtNq6OQbJkpW D1FBCN5dtQT5wIX1OLTVJEf364tL/w9wcpdyofNU= To: linux-kernel@vger.kernel.org From: Lars Everbrand Cc: Jay Vosburgh , Veaceslav Falico , Andy Gospodarek , "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org Reply-To: Lars Everbrand Subject: [PATCH net-next] bonding: correct rr balancing during link failure Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.2 required=10.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM shortcircuit=no autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on mailout.protonmail.ch Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch updates the sending algorithm for roundrobin to avoid over-subscribing interface(s) when one or more interfaces in the bond is not able to send packets. This happened when order was not random and more than 2 interfaces were used. Previously the algorithm would find the next available interface when an interface failed to send by, this means that most often it is current_interface + 1. The problem is that when the next packet is to be sent and the "normal" algorithm then continues with interface++ which then hits that same interface again. This patch updates the resending algorithm to update the global counter of the next interface to use. Example (prior to patch): Consider 6 x 100 Mbit/s interfaces in a rr bond. The normal order of links being used to send would look like: 1 2 3 4 5 6 1 2 3 4 5 6 1 2 3 4 5 6 ... If, for instance, interface 2 where unable to send the order would have bee= n: 1 3 3 4 5 6 1 3 3 4 5 6 1 3 3 4 5 6 ... The resulting speed (for TCP) would then become: 50 + 0 + 100 + 50 + 50 + 50 =3D 300 Mbit/s instead of the expected 500 Mbit/s. If interface 3 also would fail the resulting speed would be half of the expected 400 Mbit/s (33 + 0 + 0 + 100 + 33 + 33). Signed-off-by: Lars Everbrand --- drivers/net/bonding/bond_main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_mai= n.c index e0880a3840d7..e02d9c6d40ee 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -4107,6 +4107,7 @@ static struct slave *bond_get_slave_by_id(struct bond= ing *bond, =09=09if (--i < 0) { =09=09=09if (bond_slave_can_tx(slave)) =09=09=09=09return slave; +=09=09=09bond->rr_tx_counter++; =09=09} =09} =20 @@ -4117,6 +4118,7 @@ static struct slave *bond_get_slave_by_id(struct bond= ing *bond, =09=09=09break; =09=09if (bond_slave_can_tx(slave)) =09=09=09return slave; +=09=09bond->rr_tx_counter++; =09} =09/* no slave that can tx has been found */ =09return NULL; --=20 2.29.2