Skip to contentSkip to conversation

bonding: print churn state via netlink

PATCH Applied Hangbin Liu 4 participants 7 messages Feb 24 – Feb 26

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bonding: print churn state via netlink

Currently, the churn state is printed only in sysfs. Add netlink support so users could get the state via netlink.

---
 drivers/net/bonding/bond_netlink.c | 9 +++++++++
 include/uapi/linux/if_link.h       | 2 ++
 2 files changed, 11 insertions(+)
drivers/net/bonding/bond_netlink.c +9 -0
index 286f11c517f7..ea1a80e658ae 100644
@@ -29,6 +29,8 @@ static size_t bond_get_slave_size(const struct net_device *bond_dev,
 		nla_total_size(sizeof(u16)) +	/* IFLA_BOND_SLAVE_AD_PARTNER_OPER_PORT_STATE */
 		nla_total_size(sizeof(s32)) +	/* IFLA_BOND_SLAVE_PRIO */
 		nla_total_size(sizeof(u16)) +	/* IFLA_BOND_SLAVE_ACTOR_PORT_PRIO */
+		nla_total_size(sizeof(u8)) +	/* IFLA_BOND_SLAVE_AD_CHURN_ACTOR_STATE */
+		nla_total_size(sizeof(u8)) +	/* IFLA_BOND_SLAVE_AD_CHURN_PARTNER_STATE */
 		0;
 }
 
@@ -77,6 +79,13 @@ static int bond_fill_slave_info(struct sk_buff *skb,
 					IFLA_BOND_SLAVE_AD_PARTNER_OPER_PORT_STATE,
 					ad_port->partner_oper.port_state))
 				goto nla_put_failure;
+
+			if (nla_put_u8(skb, IFLA_BOND_SLAVE_AD_CHURN_ACTOR_STATE,
+				       ad_port->sm_churn_actor_state))
+				goto nla_put_failure;
+			if (nla_put_u8(skb, IFLA_BOND_SLAVE_AD_CHURN_PARTNER_STATE,
+				       ad_port->sm_churn_partner_state))
+				goto nla_put_failure;
 		}
 
 		if (nla_put_u16(skb, IFLA_BOND_SLAVE_ACTOR_PORT_PRIO,
include/uapi/linux/if_link.h +2 -0
index e9b5f79e1ee1..83a96c56b8ca 100644
@@ -1568,6 +1568,8 @@ enum {
 	IFLA_BOND_SLAVE_AD_PARTNER_OPER_PORT_STATE,
 	IFLA_BOND_SLAVE_PRIO,
 	IFLA_BOND_SLAVE_ACTOR_PORT_PRIO,
+	IFLA_BOND_SLAVE_AD_CHURN_ACTOR_STATE,
+	IFLA_BOND_SLAVE_AD_CHURN_PARTNER_STATE,
 	__IFLA_BOND_SLAVE_MAX,
 };
 
Signature · 1 line
2.50.1
#1 lore raw

PATCH 1/1 iplink: bond_slave: print actor and partner churn state

Add ability to print both actor and partner port churn states (MONITOR/CHURN/NO_CHURN) via netlink attributes. This provides visibility into the LACP churn detection state for bond slaves.

---
 ip/iplink_bond_slave.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
ip/iplink_bond_slave.c +26 -0
index c88100e248dd..5dfe2970941e 100644
@@ -86,6 +86,12 @@ static void print_slave_oper_state(FILE *fp, const char *name, __u16 state)
 	close_json_array(PRINT_ANY, "> ");
 }
 
+static const char *port_churn_state[] = {
+	"MONITOR",
+	"CHURN",
+	"NO_CHURN",
+};
+
 static void bond_slave_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
 {
 	SPRINT_BUF(b1);
@@ -148,6 +154,26 @@ static void bond_slave_print_opt(struct link_util *lu, FILE *f, struct rtattr *t
 		print_slave_oper_state(f, "ad_partner_oper_port_state_str", state);
 	}
 
+	if (tb[IFLA_BOND_SLAVE_AD_CHURN_ACTOR_STATE]) {
+		__u8 state = rta_getattr_u8(tb[IFLA_BOND_SLAVE_AD_CHURN_ACTOR_STATE]);
+
+		if (state >= ARRAY_SIZE(port_churn_state))
+			print_int(PRINT_ANY, "churn_actor_state", "churn_actor_state %u ", state);
+		else
+			print_string(PRINT_ANY, "churn_actor_state", "churn_actor_state %s ",
+				     port_churn_state[state]);
+	}
+
+	if (tb[IFLA_BOND_SLAVE_AD_CHURN_PARTNER_STATE]) {
+		__u8 state = rta_getattr_u8(tb[IFLA_BOND_SLAVE_AD_CHURN_PARTNER_STATE]);
+
+		if (state >= ARRAY_SIZE(port_churn_state))
+			print_int(PRINT_ANY, "churn_partner_state", "churn_partner_state %u ", state);
+		else
+			print_string(PRINT_ANY, "churn_partner_state", "churn_partner_state %s ",
+				     port_churn_state[state]);
+	}
+
 	if (tb[IFLA_BOND_SLAVE_ACTOR_PORT_PRIO])
 		print_int(PRINT_ANY,
 			  "actor_port_prio",
Signature · 1 line
2.50.1
#2 lore raw

Re: [PATCH iproute2-next] iplink: bond_slave: print actor and partner churn state

ip/iplink_bond_slave.c static void bond_slave_print_opt(struct link_util *lu, FILE *f, struct rtattr *t · line 161

Quoted 5 lines · On Tue, 24 Feb 2026 02:02:15 +0000 Hangbin Liu <[email protected]> wrote:
ip/iplink_bond_slave.c +5 -0
+	if (tb[IFLA_BOND_SLAVE_AD_CHURN_ACTOR_STATE]) {
+		__u8 state = rta_getattr_u8(tb[IFLA_BOND_SLAVE_AD_CHURN_ACTOR_STATE]);
+
+		if (state >= ARRAY_SIZE(port_churn_state))
+			print_int(PRINT_ANY, "churn_actor_state", "churn_actor_state %u ", state);

You should use print_uint for unsigned values.

#3 lore raw

Re: [PATCH iproute2-next] iplink: bond_slave: print actor and partner churn state

Quoted 10 lines · Stephen Hemminger

ip/iplink_bond_slave.c static void bond_slave_print_opt(struct link_util *lu, FILE *f, struct rtattr *t · line 161

Quoted 5 lines · On Tue, 24 Feb 2026 02:02:15 +0000 Hangbin Liu <[email protected]> wrote:
ip/iplink_bond_slave.c +5 -0
+	if (tb[IFLA_BOND_SLAVE_AD_CHURN_ACTOR_STATE]) {
+		__u8 state = rta_getattr_u8(tb[IFLA_BOND_SLAVE_AD_CHURN_ACTOR_STATE]);
+
+		if (state >= ARRAY_SIZE(port_churn_state))
+			print_int(PRINT_ANY, "churn_actor_state", "churn_actor_state %u ", state);

You should use print_uint for unsigned values.

Thanks, should I post a v2 version for both the kernel and iproute2 patches, Or just the iproute2 patch?

Hangbin

maintainer
#4 lore raw

Re: [PATCH iproute2-next] iplink: bond_slave: print actor and partner churn state

Quoted 4 lines · On Thu, 26 Feb 2026 02:10:21 +0000 Hangbin Liu wrote:
Quoted 1 line

You should use print_uint for unsigned values.

Thanks, should I post a v2 version for both the kernel and iproute2 patches, Or just the iproute2 patch?

Just iproute2, they aren't bundled by patchwork (please refer to the netdev maintainer faq for the correct way to co-post iproute2)

#5 lore raw

Re: [PATCH iproute2-next] iplink: bond_slave: print actor and partner churn state

Quoted 8 lines · Jakub Kicinski
Quoted 4 lines · On Thu, 26 Feb 2026 02:10:21 +0000 Hangbin Liu wrote:
Quoted 1 line

You should use print_uint for unsigned values.

Thanks, should I post a v2 version for both the kernel and iproute2 patches, Or just the iproute2 patch?

Just iproute2, they aren't bundled by patchwork (please refer to the netdev maintainer faq for the correct way to co-post iproute2)

Got it. I will post the iproute2 as a new series.

#6 lore raw
In reply to Hangbin Liu
This patch was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:

Quoted 8 lines · On Tue, 24 Feb 2026 02:02:14 +0000 you wrote:

Currently, the churn state is printed only in sysfs. Add netlink support so users could get the state via netlink.

---
 drivers/net/bonding/bond_netlink.c | 9 +++++++++
 include/uapi/linux/if_link.h       | 2 ++
 2 files changed, 11 insertions(+)

Here is the summary with links:
- [net-next] bonding: print churn state via netlink

    https://git.kernel.org/netdev/net-next/c/4916f2e2f3fc

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html