| Lorenz Brun | d842aaf | 2025-02-17 17:39:46 +0100 | [diff] [blame] | 1 | From faa5b0ac734399a5dd4458545484d22b2234c184 Mon Sep 17 00:00:00 2001 |
| Lorenz Brun | 8bc8286 | 2024-04-30 11:47:09 +0000 | [diff] [blame] | 2 | From: Lorenz Brun <lorenz@monogon.tech> |
| 3 | Date: Thu, 2 May 2024 10:17:14 +0200 |
| 4 | Subject: [PATCH] bonding: 3ad: fix carrier and tx with no active ports |
| 5 | |
| 6 | bond carrier state should not be be up when no ports are in |
| 7 | aggregation. Ports should only be enabled when they are in aggregation. |
| 8 | |
| 9 | While in there, set the default template to fast mode to quickly recover |
| 10 | links and shorten the non-standard aggregator selection timer. |
| 11 | --- |
| 12 | drivers/net/bonding/bond_3ad.c | 39 ++++++++++++++++++---------------- |
| 13 | 1 file changed, 21 insertions(+), 18 deletions(-) |
| 14 | |
| 15 | diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c |
| Lorenz Brun | d842aaf | 2025-02-17 17:39:46 +0100 | [diff] [blame] | 16 | index c6807e473ab7..27dc5f2f8cf1 100644 |
| Lorenz Brun | 8bc8286 | 2024-04-30 11:47:09 +0000 | [diff] [blame] | 17 | --- a/drivers/net/bonding/bond_3ad.c |
| 18 | +++ b/drivers/net/bonding/bond_3ad.c |
| Lorenz Brun | d842aaf | 2025-02-17 17:39:46 +0100 | [diff] [blame] | 19 | @@ -746,6 +746,22 @@ static int __agg_active_ports(struct aggregator *agg) |
| Lorenz Brun | 8bc8286 | 2024-04-30 11:47:09 +0000 | [diff] [blame] | 20 | return active; |
| 21 | } |
| 22 | |
| 23 | +// __agg_enabled_ports counts the number of ports which are currently in |
| 24 | +// aggregation, different from __agg_active_ports which counts ports which |
| 25 | +// are up (but not in aggregation because of LACP). |
| 26 | +static int __agg_enabled_ports(struct aggregator *agg) { |
| 27 | + struct port *port; |
| 28 | + int en_count = 0; |
| 29 | + |
| 30 | + for (port = agg->lag_ports; port; |
| 31 | + port = port->next_port_in_aggregator) { |
| Lorenz Brun | d842aaf | 2025-02-17 17:39:46 +0100 | [diff] [blame] | 32 | + if (__port_is_collecting_distributing(port)) |
| Lorenz Brun | 8bc8286 | 2024-04-30 11:47:09 +0000 | [diff] [blame] | 33 | + en_count++; |
| 34 | + } |
| 35 | + |
| 36 | + return en_count; |
| 37 | +} |
| 38 | + |
| 39 | /** |
| 40 | * __get_agg_bandwidth - get the total bandwidth of an aggregator |
| 41 | * @aggregator: the aggregator we're looking at |
| Lorenz Brun | d842aaf | 2025-02-17 17:39:46 +0100 | [diff] [blame] | 42 | @@ -1186,6 +1202,8 @@ static void ad_mux_machine(struct port *port, bool *update_slave_arr) |
| Lorenz Brun | 8bc8286 | 2024-04-30 11:47:09 +0000 | [diff] [blame] | 43 | break; |
| 44 | } |
| 45 | } |
| 46 | + // Update carrier state as we might have enabled/disabled ports |
| 47 | + bond_3ad_set_carrier(__get_bond_by_port(port)); |
| 48 | } |
| 49 | |
| 50 | /** |
| Lorenz Brun | d842aaf | 2025-02-17 17:39:46 +0100 | [diff] [blame] | 51 | @@ -1880,21 +1898,6 @@ static void ad_agg_selection_logic(struct aggregator *agg, |
| Lorenz Brun | 8bc8286 | 2024-04-30 11:47:09 +0000 | [diff] [blame] | 52 | *update_slave_arr = true; |
| 53 | } |
| 54 | |
| 55 | - /* if the selected aggregator is of join individuals |
| 56 | - * (partner_system is NULL), enable their ports |
| 57 | - */ |
| 58 | - active = __get_active_agg(origin); |
| 59 | - |
| 60 | - if (active) { |
| 61 | - if (!__agg_has_partner(active)) { |
| 62 | - for (port = active->lag_ports; port; |
| 63 | - port = port->next_port_in_aggregator) { |
| 64 | - __enable_port(port); |
| 65 | - } |
| 66 | - *update_slave_arr = true; |
| 67 | - } |
| 68 | - } |
| 69 | - |
| 70 | rcu_read_unlock(); |
| 71 | |
| 72 | bond_3ad_set_carrier(bond); |
| Lorenz Brun | d842aaf | 2025-02-17 17:39:46 +0100 | [diff] [blame] | 73 | @@ -1952,7 +1955,7 @@ static void ad_initialize_port(struct port *port, int lacp_fast) |
| Lorenz Brun | 8bc8286 | 2024-04-30 11:47:09 +0000 | [diff] [blame] | 74 | .key = 1, |
| 75 | .port_number = 1, |
| 76 | .port_priority = 0xff, |
| 77 | - .port_state = 1, |
| 78 | + .port_state = LACP_STATE_LACP_ACTIVITY | LACP_STATE_LACP_TIMEOUT, |
| 79 | }; |
| 80 | static const struct lacpdu lacpdu = { |
| 81 | .subtype = 0x01, |
| Lorenz Brun | d842aaf | 2025-02-17 17:39:46 +0100 | [diff] [blame] | 82 | @@ -2129,7 +2132,7 @@ static void ad_marker_response_received(struct bond_marker *marker, |
| Lorenz Brun | 8bc8286 | 2024-04-30 11:47:09 +0000 | [diff] [blame] | 83 | /* ========= AD exported functions to the main bonding code ========= */ |
| 84 | |
| 85 | /* Check aggregators status in team every T seconds */ |
| 86 | -#define AD_AGGREGATOR_SELECTION_TIMER 8 |
| 87 | +#define AD_AGGREGATOR_SELECTION_TIMER 3 |
| 88 | |
| 89 | /** |
| 90 | * bond_3ad_initiate_agg_selection - initate aggregator selection |
| Lorenz Brun | d842aaf | 2025-02-17 17:39:46 +0100 | [diff] [blame] | 91 | @@ -2754,7 +2757,7 @@ int bond_3ad_set_carrier(struct bonding *bond) |
| Lorenz Brun | 8bc8286 | 2024-04-30 11:47:09 +0000 | [diff] [blame] | 92 | active = __get_active_agg(&(SLAVE_AD_INFO(first_slave)->aggregator)); |
| 93 | if (active) { |
| 94 | /* are enough slaves available to consider link up? */ |
| 95 | - if (__agg_active_ports(active) < bond->params.min_links) { |
| 96 | + if (__agg_enabled_ports(active) < bond->params.min_links) { |
| 97 | if (netif_carrier_ok(bond->dev)) { |
| 98 | netif_carrier_off(bond->dev); |
| 99 | goto out; |
| 100 | -- |
| Lorenz Brun | d842aaf | 2025-02-17 17:39:46 +0100 | [diff] [blame] | 101 | 2.47.2 |
| Lorenz Brun | 8bc8286 | 2024-04-30 11:47:09 +0000 | [diff] [blame] | 102 | |