From patchwork Wed Dec 2 20:55:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lars Everbrand X-Patchwork-Id: 1409977 Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=protonmail.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=protonmail.com header.i=@protonmail.com header.a=rsa-sha256 header.s=protonmail header.b=EQg8p9JM; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4CmWW06n8Nz9sT5 for ; Thu, 3 Dec 2020 07:57:16 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388259AbgLBU4p (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 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: netdev@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 been: 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 = 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_main.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 bonding *bond, if (--i < 0) { if (bond_slave_can_tx(slave)) return slave; + bond->rr_tx_counter++; } } @@ -4117,6 +4118,7 @@ static struct slave *bond_get_slave_by_id(struct bonding *bond, break; if (bond_slave_can_tx(slave)) return slave; + bond->rr_tx_counter++; } /* no slave that can tx has been found */ return NULL;