bonding: Add independent control state machine
Subsystems (4)
PATCH v6 1/1 bonding: Add independent control state machine
Add support for the independent control state machine per IEEE 802.1AX-2008 5.4.15 in addition to the existing implementation of the coupled control state machine.
Introduces two new states, AD_MUX_COLLECTING and AD_MUX_DISTRIBUTING in the LACP MUX state machine for separated handling of an initial Collecting state before the Collecting and Distributing state. This enables a port to be in a state where it can receive incoming packets while not still distributing. This is useful for reducing packet loss when a port begins distributing before its partner is able to collect.
Added new functions such as bond_set_slave_tx_disabled_flags and bond_set_slave_rx_enabled_flags to precisely manage the port's collecting and distributing states. Previously, there was no dedicated method to disable TX while keeping RX enabled, which this patch addresses.
Note that the regular flow process in the kernel's bonding driver remains unaffected by this patch. The extension requires explicit opt-in by the user (in order to ensure no disruptions for existing setups) via netlink support using the new bonding parameter coupled_control. The default value for coupled_control is set to 1 so as to preserve existing behaviour.
v6:
Added coupled_control to procfs
v5:
Merge documentation patch with changes patch
Add version history in comment description
v4:
Remove inline references from c source files
v3:
Edited commit description
Edited documentation description
Changed function names
Only allow coupled_control change when the bond is down
v2:
Removed sysfs changes
Added documentation for new paramater
Renamed parameter to coupled_control
Update bond_set_slave_inactive_flags() with a 8023ad check
--- Documentation/networking/bonding.rst | 12 ++ drivers/net/bonding/bond_3ad.c | 157 +++++++++++++++++++++++++-- drivers/net/bonding/bond_main.c | 1 + drivers/net/bonding/bond_netlink.c | 16 +++ drivers/net/bonding/bond_options.c | 28 ++++- drivers/net/bonding/bond_procfs.c | 2 + include/net/bond_3ad.h | 2 + include/net/bond_options.h | 1 + include/net/bonding.h | 23 ++++ include/uapi/linux/if_link.h | 1 + tools/include/uapi/linux/if_link.h | 1 + 11 files changed, 236 insertions(+), 8 deletions(-)
Documentation/networking/bonding.rst +12 -0
@@ -444,6 +444,18 @@ arp_missed_max The default value is 2, and the allowable range is 1 - 255. +coupled_control + + Specifies whether the LACP state machine's MUX in the 802.3ad mode + should have separate Collecting and Distributing states. + + This is by implementing the independent control state machine per + IEEE 802.1AX-2008 5.4.15 in addition to the existing coupled control + state machine. + + The default value is 1. This setting does not separate the Collecting + and Distributing states, maintaining the bond in coupled control. + downdelay Specifies the time, in milliseconds, to wait before disabling
drivers/net/bonding/bond_3ad.c +150 -7
226 lines not on this page · raw message
drivers/net/bonding/bond_main.c +1 -0
@@ -6331,6 +6331,7 @@ static int __init bond_check_params(struct bond_params *params) params->ad_actor_sys_prio = ad_actor_sys_prio;eth_zero_addr (params->ad_actor_system); params->ad_user_port_key = ad_user_port_key; + params->coupled_control =1 ;if (packets_per_slave >0 ) { params->reciprocal_packets_per_slave =reciprocal_value (packets_per_slave);
drivers/net/bonding/bond_netlink.c +16 -0
@@ -122,6 +122,7 @@ static const struct nla_policy bond_policy[IFLA_BOND_MAX + 1] = { [IFLA_BOND_PEER_NOTIF_DELAY] = NLA_POLICY_FULL_RANGE(NLA_U32, &delay_range), [IFLA_BOND_MISSED_MAX] = { .type = NLA_U8 }, [IFLA_BOND_NS_IP6_TARGET] = { .type = NLA_NESTED }, + [IFLA_BOND_COUPLED_CONTROL] = { .type = NLA_U8 }, };static const struct nla_policy bond_slave_policy[IFLA_BOND_SLAVE_MAX +1 ] = {
@@ -549,6 +550,16 @@ static int bond_changelink(struct net_device *bond_dev, struct nlattr *tb[],return err; } +if (data[IFLA_BOND_COUPLED_CONTROL ]) { +int coupled_control =nla_get_u8 (data[IFLA_BOND_COUPLED_CONTROL ]); + +bond_opt_initval (&newval, coupled_control); + err =__bond_opt_set (bond,BOND_OPT_COUPLED_CONTROL , &newval, + data[IFLA_BOND_COUPLED_CONTROL ], extack); +if (err) +return err; + } +return 0 ; }
@@ -615,6 +626,7 @@ static size_t bond_get_size(const struct net_device *bond_dev)/* IFLA_BOND_NS_IP6_TARGET */ nla_total_size (sizeof (struct nlattr )) +nla_total_size (sizeof (struct in6_addr )) *BOND_MAX_NS_TARGETS + +nla_total_size (sizeof (u8)) +/* IFLA_BOND_COUPLED_CONTROL */ 0 ; }
@@ -774,6 +786,10 @@ static int bond_fill_info(struct sk_buff *skb, bond->params.missed_max)) goto nla_put_failure; +if (nla_put_u8 (skb,IFLA_BOND_COUPLED_CONTROL , + bond->params.coupled_control)) + goto nla_put_failure; +if (BOND_MODE (bond) ==BOND_MODE_8023AD ) {struct ad_info info;
drivers/net/bonding/bond_options.c +27 -1
@@ -84,7 +84,8 @@ static int bond_option_ad_user_port_key_set(struct bonding *bond, const struct bond_opt_value *newval);static int bond_option_missed_max_set (struct bonding *bond,const struct bond_opt_value *newval); - +static int bond_option_coupled_control_set (struct bonding *bond, +const struct bond_opt_value *newval);static const struct bond_opt_value bond_mode_tbl[] = { {"balance-rr" ,BOND_MODE_ROUNDROBIN ,BOND_VALFLAG_DEFAULT },
@@ -232,6 +233,12 @@ static const struct bond_opt_value bond_missed_max_tbl[] = { { NULL, -1, 0}, }; +static const struct bond_opt_value bond_coupled_control_tbl[] = { + { "on", 1, BOND_VALFLAG_DEFAULT}, + { "off", 0, 0}, + { NULL, -1, 0}, +}; + static const struct bond_option bond_opts[BOND_OPT_LAST] = { [BOND_OPT_MODE] = { .id = BOND_OPT_MODE,
@@ -496,6 +503,15 @@ static const struct bond_option bond_opts[BOND_OPT_LAST] = { .desc = "Delay between each peer notification on failover event, in milliseconds", .values = bond_peer_notif_delay_tbl, .set = bond_option_peer_notif_delay_set + }, + [BOND_OPT_COUPLED_CONTROL] = { + .id = BOND_OPT_COUPLED_CONTROL, + .name = "coupled_control", + .desc = "Opt into using coupled control MUX for LACP states", + .unsuppmodes = BOND_MODE_ALL_EX(BIT(BOND_MODE_8023AD)), + .flags = BOND_OPTFLAG_IFDOWN, + .values = bond_coupled_control_tbl, + .set = bond_option_coupled_control_set, } };
@@ -1692,3 +1708,13 @@ static int bond_option_ad_user_port_key_set(struct bonding *bond, bond->params.ad_user_port_key = newval->value;return 0 ; } + +static int bond_option_coupled_control_set (struct bonding *bond, +const struct bond_opt_value *newval) +{ +netdev_info (bond->dev,"Setting coupled_control to %s (%llu)\n" , + newval->string, newval->value); + + bond->params.coupled_control = newval->value; +return 0 ; +}
drivers/net/bonding/bond_procfs.c +2 -0
@@ -154,6 +154,8 @@ static void bond_info_show_master(struct seq_file *seq) (bond->params.lacp_active) ? "on" : "off");seq_printf (seq,"LACP rate: %s\n" , (bond->params.lacp_fast) ?"fast" :"slow" ); +seq_printf (seq,"LACP coupled_control: %s\n" , + (bond->params.coupled_control) ?"on" :"off" );seq_printf (seq,"Min links: %d\n" , bond->params.min_links); optval =bond_opt_get_val (BOND_OPT_AD_SELECT , bond->params.ad_select);
include/net/bond_3ad.h +2 -0
@@ -54,6 +54,8 @@ typedef enum {AD_MUX_DETACHED ,/* mux machine */ AD_MUX_WAITING ,/* mux machine */ AD_MUX_ATTACHED ,/* mux machine */ +AD_MUX_COLLECTING ,/* mux machine */ +AD_MUX_DISTRIBUTING ,/* mux machine */ AD_MUX_COLLECTING_DISTRIBUTING /* mux machine */ } mux_states_t;
include/net/bond_options.h +1 -0
@@ -76,6 +76,7 @@ enum {BOND_OPT_MISSED_MAX ,BOND_OPT_NS_TARGETS ,BOND_OPT_PRIO , +BOND_OPT_COUPLED_CONTROL , BOND_OPT_LAST };
include/net/bonding.h +23 -0
@@ -148,6 +148,7 @@ struct bond_params {#if IS_ENABLED (CONFIG_IPV6 )struct in6_addr ns_targets[BOND_MAX_NS_TARGETS ];#endif +int coupled_control;/* 2 bytes of padding : see ether_addr_equal_64bits() */ u8 ad_actor_system[ETH_ALEN +2 ];
@@ -167,6 +168,7 @@ struct slave { u8 backup:1, /* indicates backup slave. Value corresponds withBOND_STATE_ACTIVE and BOND_STATE_BACKUP */ inactive:1, /* indicates inactive slave */ + rx_disabled:1, /* indicates whether slave's Rx is disabled */ should_notify:1, /* indicates whether the state changed */ should_notify_link:1; /* indicates whether the link changed */u8 duplex;
@@ -568,6 +570,14 @@ static inline void bond_set_slave_inactive_flags(struct slave *slave,bond_set_slave_state (slave,BOND_STATE_BACKUP , notify);if (!slave->bond->params.all_slaves_active) slave->inactive =1 ; +if (BOND_MODE (slave->bond) ==BOND_MODE_8023AD ) + slave->rx_disabled =1 ; +} + +static inline void bond_set_slave_tx_disabled_flags (struct slave *slave, +bool notify) +{ +bond_set_slave_state (slave,BOND_STATE_BACKUP , notify); } static inline void bond_set_slave_active_flags(struct slave *slave,
@@ -575,6 +585,14 @@ static inline void bond_set_slave_active_flags(struct slave *slave, {bond_set_slave_state (slave,BOND_STATE_ACTIVE , notify); slave->inactive =0 ; +if (BOND_MODE (slave->bond) ==BOND_MODE_8023AD ) + slave->rx_disabled =0 ; +} + +static inline void bond_set_slave_rx_enabled_flags (struct slave *slave, +bool notify) +{ + slave->rx_disabled =0 ; }static inline bool bond_is_slave_inactive (struct slave *slave)
@@ -582,6 +600,11 @@ static inline bool bond_is_slave_inactive(struct slave *slave)return slave->inactive; } +static inline bool bond_is_slave_rx_disabled (struct slave *slave) +{ +return slave->rx_disabled; +} +static inline void bond_propose_link_state (struct slave *slave,int state) { slave->link_new_state = state;
include/uapi/linux/if_link.h +1 -0
@@ -976,6 +976,7 @@ enum {IFLA_BOND_AD_LACP_ACTIVE ,IFLA_BOND_MISSED_MAX ,IFLA_BOND_NS_IP6_TARGET , +IFLA_BOND_COUPLED_CONTROL , __IFLA_BOND_MAX, };
tools/include/uapi/linux/if_link.h +1 -0
@@ -974,6 +974,7 @@ enum {IFLA_BOND_AD_LACP_ACTIVE ,IFLA_BOND_MISSED_MAX ,IFLA_BOND_NS_IP6_TARGET , +IFLA_BOND_COUPLED_CONTROL , __IFLA_BOND_MAX, };
Signature · 1 line
2.43.0.429.g432eaa2c6b-goog
Paolo Abeni
maintainerQuoted 10 lines · Aahil Awatramani
Add support for the independent control state machine per IEEE 802.1AX-2008 5.4.15 in addition to the existing implementation of the coupled control state machine.
Introduces two new states,
AD_MUX_COLLECTINGandAD_MUX_DISTRIBUTINGin the LACP MUX state machine for separated handling of an initial Collecting state before the Collecting and Distributing state. This enables a port to be in a state where it can receive incoming packets while not still distributing. This is useful for reducing packet loss when a port begins distributing before its partner is able to collect.
If I read the code correctly, the transition AD_MUX_COLLECTING_DISTRIBUTING -> AD_MUX_DISTRIBUTING is not possible, am I correct?
Any chance we can have some coverage via self-tests?
Thanks,
Paolo
Quoted 12 lines · Paolo Abeni
Quoted 10 lines · Aahil Awatramani
Add support for the independent control state machine per IEEE 802.1AX-2008 5.4.15 in addition to the existing implementation of the coupled control state machine.
Introduces two new states,
AD_MUX_COLLECTINGandAD_MUX_DISTRIBUTINGin the LACP MUX state machine for separated handling of an initial Collecting state before the Collecting and Distributing state. This enables a port to be in a state where it can receive incoming packets while not still distributing. This is useful for reducing packet loss when a port begins distributing before its partner is able to collect.
Quoted 3 lines
If I read the code correctly, the transition
AD_MUX_COLLECTING_DISTRIBUTING->AD_MUX_DISTRIBUTINGis not possible, am I correct?
That's correct. There are two completely separate state
machines in the 2008 standard, one for coupled control and one for independent control. The state machines utilize the same states other than COLLECTING_DISTRIBUTING in the coupled control mode, and COLLECTING and DISTRIBUTING in the independent control mode.
Essentially, the two machines differ in the transition out from
ATTACHED state; coupled control moves to COLLECTING_DISTRIBUTING, whereas independent control moves to COLLECTING then DISTRIBUTING.
The 2020 edition of the standard combines the two state machines
into one, and changes the set of states. Bonding does not implement this version of the standard.
-J
---
-Jay Vosburgh, [email protected]
Quoted 24 lines · Jay Vosburgh
Quoted 12 lines · Paolo Abeni
Quoted 10 lines · Aahil Awatramani
Add support for the independent control state machine per IEEE 802.1AX-2008 5.4.15 in addition to the existing implementation of the coupled control state machine.
Introduces two new states,
AD_MUX_COLLECTINGandAD_MUX_DISTRIBUTINGin the LACP MUX state machine for separated handling of an initial Collecting state before the Collecting and Distributing state. This enables a port to be in a state where it can receive incoming packets while not still distributing. This is useful for reducing packet loss when a port begins distributing before its partner is able to collect.Quoted 3 lines
If I read the code correctly, the transition
AD_MUX_COLLECTING_DISTRIBUTING->AD_MUX_DISTRIBUTINGis not possible, am I correct?That's correct. There are two completely separate state
machines in the 2008 standard, one for coupled control and one for independent control. The state machines utilize the same states other thanCOLLECTING_DISTRIBUTINGin the coupled control mode, and COLLECTING and DISTRIBUTING in the independent control mode.
Quoted 7 lines
Essentially, the two machines differ in the transition out from
ATTACHED state; coupled control moves toCOLLECTING_DISTRIBUTING, whereas independent control moves to COLLECTING then DISTRIBUTING.The 2020 edition of the standard combines the two state machines
into one, and changes the set of states. Bonding does not implement this version of the standard.
Thanks for the clarification, given that the patch LGTM!
Mon, Jan 29, 2024 at 09:27:41PM CET, [email protected] wrote:
[...]
drivers/net/bonding/bond_procfs.c static void bond_info_show_master(struct seq_file *seq) · line 158
Quoted 10 lines
drivers/net/bonding/bond_procfs.c +2
-0@@ -154,6 +154,8 @@ static void bond_info_show_master(struct seq_file *seq) (bond->params.lacp_active) ? "on" : "off");seq_printf (seq,"LACP rate: %s\n" , (bond->params.lacp_fast) ?"fast" :"slow" ); +seq_printf (seq,"LACP coupled_control: %s\n" , + (bond->params.coupled_control) ?"on" :"off" );
Hmm, I wonder how it makes sense to add new features here. This should rot.
Quoted 3 lines
drivers/net/bonding/bond_procfs.c +0
-0seq_printf (seq,"Min links: %d\n" , bond->params.min_links); optval =bond_opt_get_val (BOND_OPT_AD_SELECT , bond->params.ad_select);
[...]
Quoted 1 line
Any chance we can have some coverage via self-tests?
I plan to work on these self-tests decoupled from the current patch.
Quoted 2 lines
Hmm, I wonder how it makes sense to add new features here. This should rot.
Could you clarify what you are suggesting here?
Quoted 26 lines · Jiri Pirko
Mon, Jan 29, 2024 at 09:27:41PM CET, [email protected] wrote:
[...]
drivers/net/bonding/bond_procfs.c static void bond_info_show_master(struct seq_file *seq) · line 158
Quoted 10 lines
drivers/net/bonding/bond_procfs.c +2
-0@@ -154,6 +154,8 @@ static void bond_info_show_master(struct seq_file *seq) (bond->params.lacp_active) ? "on" : "off");seq_printf (seq,"LACP rate: %s\n" , (bond->params.lacp_fast) ?"fast" :"slow" ); +seq_printf (seq,"LACP coupled_control: %s\n" , + (bond->params.coupled_control) ?"on" :"off" );Hmm, I wonder how it makes sense to add new features here. This should rot.
Quoted 3 lines
drivers/net/bonding/bond_procfs.c +0
-0seq_printf (seq,"Min links: %d\n" , bond->params.min_links); optval =bond_opt_get_val (BOND_OPT_AD_SELECT , bond->params.ad_select);[...]
Quoted 8 lines · Thu, Feb 01, 2024 at 07:45:23PM CET, [email protected] wrote:
Quoted 1 line
Any chance we can have some coverage via self-tests?
I plan to work on these self-tests decoupled from the current patch.
Quoted 2 lines
Hmm, I wonder how it makes sense to add new features here. This should rot.
Could you clarify what you are suggesting here?
Don't touch procfs here.
Quoted 29 lines · Jiri Pirko
Quoted 26 lines
Mon, Jan 29, 2024 at 09:27:41PM CET, [email protected] wrote:
[...]
drivers/net/bonding/bond_procfs.c static void bond_info_show_master(struct seq_file *seq) · line 158
Quoted 10 lines
drivers/net/bonding/bond_procfs.c +2
-0@@ -154,6 +154,8 @@ static void bond_info_show_master(struct seq_file *seq) (bond->params.lacp_active) ? "on" : "off");seq_printf (seq,"LACP rate: %s\n" , (bond->params.lacp_fast) ?"fast" :"slow" ); +seq_printf (seq,"LACP coupled_control: %s\n" , + (bond->params.coupled_control) ?"on" :"off" );Hmm, I wonder how it makes sense to add new features here. This should rot.
Quoted 3 lines
drivers/net/bonding/bond_procfs.c +0
-0seq_printf (seq,"Min links: %d\n" , bond->params.min_links); optval =bond_opt_get_val (BOND_OPT_AD_SELECT , bond->params.ad_select);[...]
Quoted 1 line
Don't touch procfs here.
OK removing procfs changes.
Quoted 42 lines · Jiri Pirko
Quoted 8 lines · Thu, Feb 01, 2024 at 07:45:23PM CET, [email protected] wrote:
Quoted 1 line
Any chance we can have some coverage via self-tests?
I plan to work on these self-tests decoupled from the current patch.
Quoted 2 lines
Hmm, I wonder how it makes sense to add new features here. This should rot.
Could you clarify what you are suggesting here?
Don't touch procfs here.
Quoted 29 lines · Jiri Pirko
Quoted 26 lines
Mon, Jan 29, 2024 at 09:27:41PM CET, [email protected] wrote:
[...]
drivers/net/bonding/bond_procfs.c static void bond_info_show_master(struct seq_file *seq) · line 158
Quoted 10 lines
drivers/net/bonding/bond_procfs.c +2
-0@@ -154,6 +154,8 @@ static void bond_info_show_master(struct seq_file *seq) (bond->params.lacp_active) ? "on" : "off");seq_printf (seq,"LACP rate: %s\n" , (bond->params.lacp_fast) ?"fast" :"slow" ); +seq_printf (seq,"LACP coupled_control: %s\n" , + (bond->params.coupled_control) ?"on" :"off" );Hmm, I wonder how it makes sense to add new features here. This should rot.
Quoted 3 lines
drivers/net/bonding/bond_procfs.c +0
-0seq_printf (seq,"Min links: %d\n" , bond->params.min_links); optval =bond_opt_get_val (BOND_OPT_AD_SELECT , bond->params.ad_select);[...]