From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE7BCC64E7C for ; Wed, 2 Dec 2020 20:57:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6CFAE22241 for ; Wed, 2 Dec 2020 20:57:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388274AbgLBU4p (ORCPT ); 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 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