All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ip/bond: add coupled_control support
@ 2024-01-25  0:38 Aahil Awatramani
  2024-01-25  1:55 ` Stephen Hemminger
  2024-01-25 18:08 ` David Ahern
  0 siblings, 2 replies; 4+ messages in thread
From: Aahil Awatramani @ 2024-01-25  0:38 UTC (permalink / raw)
  To: Aahil Awatramani, Mahesh Bandewar, David Dillow, Jay Vosburgh,
	David Ahern, Hangbin Liu, netdev

coupled_control specifies whether the LACP state machine's MUX in the
802.3ad mode should have separate Collecting and Distributing states per
IEEE 802.1AX-2008 5.4.15 for coupled and independent control state.

By default this setting is on and does not separate the Collecting and
Distributing states, maintaining the bond in coupled control. If set off,
will toggle independent control state machine which will seperate
Collecting and Distributing states.

Signed-off-by: Aahil Awatramani <aahila@google.com>
---
 include/uapi/linux/if_link.h |  1 +
 ip/iplink_bond.c             | 26 +++++++++++++++++++++++++-
 2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h
index d17271fb..ff4ceeaf 100644
--- a/include/uapi/linux/if_link.h
+++ b/include/uapi/linux/if_link.h
@@ -1503,6 +1503,7 @@ enum {
 	IFLA_BOND_AD_LACP_ACTIVE,
 	IFLA_BOND_MISSED_MAX,
 	IFLA_BOND_NS_IP6_TARGET,
+	IFLA_BOND_COUPLED_CONTROL,
 	__IFLA_BOND_MAX,
 };
 
diff --git a/ip/iplink_bond.c b/ip/iplink_bond.c
index 214244da..68bc157a 100644
--- a/ip/iplink_bond.c
+++ b/ip/iplink_bond.c
@@ -87,6 +87,12 @@ static const char *lacp_rate_tbl[] = {
 	NULL,
 };
 
+static const char *coupled_control_tbl[] = {
+	"off",
+	"on",
+	NULL,
+};
+
 static const char *ad_select_tbl[] = {
 	"stable",
 	"bandwidth",
@@ -148,6 +154,7 @@ static void print_explain(FILE *f)
 		"                [ tlb_dynamic_lb TLB_DYNAMIC_LB ]\n"
 		"                [ lacp_rate LACP_RATE ]\n"
 		"                [ lacp_active LACP_ACTIVE]\n"
+		"                [ coupled_control COUPLED_CONTROL]\n"
 		"                [ ad_select AD_SELECT ]\n"
 		"                [ ad_user_port_key PORTKEY ]\n"
 		"                [ ad_actor_sys_prio SYSPRIO ]\n"
@@ -162,6 +169,7 @@ static void print_explain(FILE *f)
 		"XMIT_HASH_POLICY := layer2|layer2+3|layer3+4|encap2+3|encap3+4|vlan+srcmac\n"
 		"LACP_ACTIVE := off|on\n"
 		"LACP_RATE := slow|fast\n"
+		"COUPLED_CONTROL := on|off\n"
 		"AD_SELECT := stable|bandwidth|count\n"
 	);
 }
@@ -176,7 +184,7 @@ static int bond_parse_opt(struct link_util *lu, int argc, char **argv,
 {
 	__u8 mode, use_carrier, primary_reselect, fail_over_mac;
 	__u8 xmit_hash_policy, num_peer_notif, all_slaves_active;
-	__u8 lacp_active, lacp_rate, ad_select, tlb_dynamic_lb;
+	__u8 lacp_active, lacp_rate, ad_select, tlb_dynamic_lb, coupled_control;
 	__u16 ad_user_port_key, ad_actor_sys_prio;
 	__u32 miimon, updelay, downdelay, peer_notify_delay, arp_interval, arp_validate;
 	__u32 arp_all_targets, resend_igmp, min_links, lp_interval;
@@ -367,6 +375,13 @@ static int bond_parse_opt(struct link_util *lu, int argc, char **argv,
 
 			lacp_active = get_index(lacp_active_tbl, *argv);
 			addattr8(n, 1024, IFLA_BOND_AD_LACP_ACTIVE, lacp_active);
+		} else if (strcmp(*argv, "coupled_control") == 0) {
+			NEXT_ARG();
+			if (get_index(coupled_control_tbl, *argv) < 0)
+				invarg("invalid coupled_control", *argv);
+
+			coupled_control = get_index(coupled_control_tbl, *argv);
+			addattr8(n, 1024, IFLA_BOND_COUPLED_CONTROL, coupled_control);
 		} else if (matches(*argv, "ad_select") == 0) {
 			NEXT_ARG();
 			if (get_index(ad_select_tbl, *argv) < 0)
@@ -659,6 +674,15 @@ static void bond_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
 			     lacp_rate);
 	}
 
+	if (tb[IFLA_BOND_COUPLED_CONTROL]) {
+		const char *coupled_control = get_name(coupled_control_tbl,
+						   rta_getattr_u8(tb[IFLA_BOND_COUPLED_CONTROL]));
+		print_string(PRINT_ANY,
+			     "coupled_control",
+			     "coupled_control %s ",
+			     coupled_control);
+	}
+
 	if (tb[IFLA_BOND_AD_SELECT]) {
 		const char *ad_select = get_name(ad_select_tbl,
 						 rta_getattr_u8(tb[IFLA_BOND_AD_SELECT]));
-- 
2.43.0.429.g432eaa2c6b-goog


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] ip/bond: add coupled_control support
  2024-01-25  0:38 [PATCH] ip/bond: add coupled_control support Aahil Awatramani
@ 2024-01-25  1:55 ` Stephen Hemminger
  2024-01-25 18:08 ` David Ahern
  1 sibling, 0 replies; 4+ messages in thread
From: Stephen Hemminger @ 2024-01-25  1:55 UTC (permalink / raw)
  To: Aahil Awatramani
  Cc: Mahesh Bandewar, David Dillow, Jay Vosburgh, David Ahern,
	Hangbin Liu, netdev

On Thu, 25 Jan 2024 00:38:16 +0000
Aahil Awatramani <aahila@google.com> wrote:

> coupled_control specifies whether the LACP state machine's MUX in the
> 802.3ad mode should have separate Collecting and Distributing states per
> IEEE 802.1AX-2008 5.4.15 for coupled and independent control state.
> 
> By default this setting is on and does not separate the Collecting and
> Distributing states, maintaining the bond in coupled control. If set off,
> will toggle independent control state machine which will seperate
> Collecting and Distributing states.
> 
> Signed-off-by: Aahil Awatramani <aahila@google.com>
> ---
>  include/uapi/linux/if_link.h |  1 +
>  ip/iplink_bond.c             | 26 +++++++++++++++++++++++++-
>  2 files changed, 26 insertions(+), 1 deletion(-)
> 
> diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h
> index d17271fb..ff4ceeaf 100644
> --- a/include/uapi/linux/if_link.h
> +++ b/include/uapi/linux/if_link.h
> @@ -1503,6 +1503,7 @@ enum {
>  	IFLA_BOND_AD_LACP_ACTIVE,
>  	IFLA_BOND_MISSED_MAX,
>  	IFLA_BOND_NS_IP6_TARGET,
> +	IFLA_BOND_COUPLED_CONTROL,
>  	__IFLA_BOND_MAX,
>  };

This patch needs to be targeted at iproute2-next 
Subject should be:
 [PATCH iproute2-next] ip/bond: add coupled_control_support

David will pick up the uapi header once the kernel part is merged.

Since it is a boolean option there is on need for on/off style here.
Just use presence of flag to indicate on state.

And use print_null() to indicate presence of  flag rather than using print_string.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ip/bond: add coupled_control support
  2024-01-25  0:38 [PATCH] ip/bond: add coupled_control support Aahil Awatramani
  2024-01-25  1:55 ` Stephen Hemminger
@ 2024-01-25 18:08 ` David Ahern
  2024-01-25 23:11   ` Aahil Awatramani
  1 sibling, 1 reply; 4+ messages in thread
From: David Ahern @ 2024-01-25 18:08 UTC (permalink / raw)
  To: Aahil Awatramani, Mahesh Bandewar, David Dillow, Jay Vosburgh,
	Hangbin Liu, netdev

On 1/24/24 5:38 PM, Aahil Awatramani wrote:
> diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h
> index d17271fb..ff4ceeaf 100644
> --- a/include/uapi/linux/if_link.h
> +++ b/include/uapi/linux/if_link.h
> @@ -1503,6 +1503,7 @@ enum {
>  	IFLA_BOND_AD_LACP_ACTIVE,
>  	IFLA_BOND_MISSED_MAX,
>  	IFLA_BOND_NS_IP6_TARGET,
> +	IFLA_BOND_COUPLED_CONTROL,
>  	__IFLA_BOND_MAX,
>  };
>  

at best uapi changes should be a separate patch which gets dropped when
we sync headers with the kernel.

> diff --git a/ip/iplink_bond.c b/ip/iplink_bond.c
> index 214244da..68bc157a 100644
> --- a/ip/iplink_bond.c
> +++ b/ip/iplink_bond.c
> @@ -176,7 +184,7 @@ static int bond_parse_opt(struct link_util *lu, int argc, char **argv,
>  {
>  	__u8 mode, use_carrier, primary_reselect, fail_over_mac;
>  	__u8 xmit_hash_policy, num_peer_notif, all_slaves_active;
> -	__u8 lacp_active, lacp_rate, ad_select, tlb_dynamic_lb;
> +	__u8 lacp_active, lacp_rate, ad_select, tlb_dynamic_lb, coupled_control;
>  	__u16 ad_user_port_key, ad_actor_sys_prio;
>  	__u32 miimon, updelay, downdelay, peer_notify_delay, arp_interval, arp_validate;
>  	__u32 arp_all_targets, resend_igmp, min_links, lp_interval;
> @@ -367,6 +375,13 @@ static int bond_parse_opt(struct link_util *lu, int argc, char **argv,
>  
>  			lacp_active = get_index(lacp_active_tbl, *argv);
>  			addattr8(n, 1024, IFLA_BOND_AD_LACP_ACTIVE, lacp_active);
> +		} else if (strcmp(*argv, "coupled_control") == 0) {
> +			NEXT_ARG();
> +			if (get_index(coupled_control_tbl, *argv) < 0)
> +				invarg("invalid coupled_control", *argv);
> +
> +			coupled_control = get_index(coupled_control_tbl, *argv);

parse_on_off

> +			addattr8(n, 1024, IFLA_BOND_COUPLED_CONTROL, coupled_control);
>  		} else if (matches(*argv, "ad_select") == 0) {
>  			NEXT_ARG();
>  			if (get_index(ad_select_tbl, *argv) < 0)
> @@ -659,6 +674,15 @@ static void bond_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
>  			     lacp_rate);
>  	}
>  
> +	if (tb[IFLA_BOND_COUPLED_CONTROL]) {
> +		const char *coupled_control = get_name(coupled_control_tbl,
> +						   rta_getattr_u8(tb[IFLA_BOND_COUPLED_CONTROL]));
> +		print_string(PRINT_ANY,
> +			     "coupled_control",
> +			     "coupled_control %s ",
> +			     coupled_control);

print_on_off

> +	}
> +
>  	if (tb[IFLA_BOND_AD_SELECT]) {
>  		const char *ad_select = get_name(ad_select_tbl,
>  						 rta_getattr_u8(tb[IFLA_BOND_AD_SELECT]));

pw-bot: cr

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ip/bond: add coupled_control support
  2024-01-25 18:08 ` David Ahern
@ 2024-01-25 23:11   ` Aahil Awatramani
  0 siblings, 0 replies; 4+ messages in thread
From: Aahil Awatramani @ 2024-01-25 23:11 UTC (permalink / raw)
  To: David Ahern
  Cc: Mahesh Bandewar, David Dillow, Jay Vosburgh, Hangbin Liu, netdev

> This patch needs to be targeted at iproute2-next

> parse_on_off

> print_on_off

Thank you for your feedback. I have modified the patch name. I have
also dropped uapi and implemented the use of print_on_off and
parse_on_off for coupled_control as per David's suggestion.

On Thu, Jan 25, 2024 at 10:08 AM David Ahern <dsahern@gmail.com> wrote:
>
> On 1/24/24 5:38 PM, Aahil Awatramani wrote:
> > diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h
> > index d17271fb..ff4ceeaf 100644
> > --- a/include/uapi/linux/if_link.h
> > +++ b/include/uapi/linux/if_link.h
> > @@ -1503,6 +1503,7 @@ enum {
> >       IFLA_BOND_AD_LACP_ACTIVE,
> >       IFLA_BOND_MISSED_MAX,
> >       IFLA_BOND_NS_IP6_TARGET,
> > +     IFLA_BOND_COUPLED_CONTROL,
> >       __IFLA_BOND_MAX,
> >  };
> >
>
> at best uapi changes should be a separate patch which gets dropped when
> we sync headers with the kernel.
>
> > diff --git a/ip/iplink_bond.c b/ip/iplink_bond.c
> > index 214244da..68bc157a 100644
> > --- a/ip/iplink_bond.c
> > +++ b/ip/iplink_bond.c
> > @@ -176,7 +184,7 @@ static int bond_parse_opt(struct link_util *lu, int argc, char **argv,
> >  {
> >       __u8 mode, use_carrier, primary_reselect, fail_over_mac;
> >       __u8 xmit_hash_policy, num_peer_notif, all_slaves_active;
> > -     __u8 lacp_active, lacp_rate, ad_select, tlb_dynamic_lb;
> > +     __u8 lacp_active, lacp_rate, ad_select, tlb_dynamic_lb, coupled_control;
> >       __u16 ad_user_port_key, ad_actor_sys_prio;
> >       __u32 miimon, updelay, downdelay, peer_notify_delay, arp_interval, arp_validate;
> >       __u32 arp_all_targets, resend_igmp, min_links, lp_interval;
> > @@ -367,6 +375,13 @@ static int bond_parse_opt(struct link_util *lu, int argc, char **argv,
> >
> >                       lacp_active = get_index(lacp_active_tbl, *argv);
> >                       addattr8(n, 1024, IFLA_BOND_AD_LACP_ACTIVE, lacp_active);
> > +             } else if (strcmp(*argv, "coupled_control") == 0) {
> > +                     NEXT_ARG();
> > +                     if (get_index(coupled_control_tbl, *argv) < 0)
> > +                             invarg("invalid coupled_control", *argv);
> > +
> > +                     coupled_control = get_index(coupled_control_tbl, *argv);
>
> parse_on_off
>
> > +                     addattr8(n, 1024, IFLA_BOND_COUPLED_CONTROL, coupled_control);
> >               } else if (matches(*argv, "ad_select") == 0) {
> >                       NEXT_ARG();
> >                       if (get_index(ad_select_tbl, *argv) < 0)
> > @@ -659,6 +674,15 @@ static void bond_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
> >                            lacp_rate);
> >       }
> >
> > +     if (tb[IFLA_BOND_COUPLED_CONTROL]) {
> > +             const char *coupled_control = get_name(coupled_control_tbl,
> > +                                                rta_getattr_u8(tb[IFLA_BOND_COUPLED_CONTROL]));
> > +             print_string(PRINT_ANY,
> > +                          "coupled_control",
> > +                          "coupled_control %s ",
> > +                          coupled_control);
>
> print_on_off
>
> > +     }
> > +
> >       if (tb[IFLA_BOND_AD_SELECT]) {
> >               const char *ad_select = get_name(ad_select_tbl,
> >                                                rta_getattr_u8(tb[IFLA_BOND_AD_SELECT]));
>
> pw-bot: cr

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-01-25 23:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-25  0:38 [PATCH] ip/bond: add coupled_control support Aahil Awatramani
2024-01-25  1:55 ` Stephen Hemminger
2024-01-25 18:08 ` David Ahern
2024-01-25 23:11   ` Aahil Awatramani

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.