add broadcast_neighbor for no-stacking networking arch
Subsystems (5)
v6 cover add broadcast_neighbor for no-stacking networking arch
For no-stacking networking arch, and enable the bond mode 4(lacp) in datacenter, the switch require arp/nd packets as session synchronization. More details please see patch.
v6 change log:
- del unnecessary rcu_read_lock in bond_xmit_broadcast
v5 change log:
- format commit message of all patches
- use skb_header_pointer instead of pskb_may_pull
- send only packets to active slaves instead of all ports, and add more commit log
v4 change log:
- fix dec option in bond_close
v3 change log:
- inc/dec broadcast_neighbor option in bond_open/close and UP state.
- remove explicit inline of bond_should_broadcast_neighbor
- remove sysfs option
- remove EXPORT_SYMBOL_GPL
- reorder option bond_opt_value
- use rcu_xxx in bond_should_notify_peers.
v2 change log:
- add static branch for performance
- add more info about no-stacking arch in commit message
- add broadcast_neighbor info and format doc
- invoke bond_should_broadcast_neighbor only in BOND_MODE_8023AD mode for performance
- explain why we need sending peer notify when failure recovery
- change the doc about num_unsol_na
- refine function name to ad_cond_set_peer_notif
- ad_cond_set_peer_notif invoked in ad_enable_collecting_distributing
- refine bond_should_notify_peers for lacp mode.
Tonghao Zhang (4):
net: bonding: add broadcast_neighbor option for 802.3ad
net: bonding: add broadcast_neighbor netlink option
net: bonding: send peer notify when failure recovery
net: bonding: add tracepoint for 802.3ad
Documentation/networking/bonding.rst | 11 +++- drivers/net/bonding/bond_3ad.c | 19 ++++++ drivers/net/bonding/bond_main.c | 87 ++++++++++++++++++++++++---- drivers/net/bonding/bond_netlink.c | 16 +++++ drivers/net/bonding/bond_options.c | 35 +++++++++++ include/net/bond_options.h | 1 + include/net/bonding.h | 3 + include/trace/events/bonding.h | 37 ++++++++++++ include/uapi/linux/if_link.h | 1 + 9 files changed, 197 insertions(+), 13 deletions(-) create mode 100644 include/trace/events/bonding.h
Signature · 1 line
2.34.1
PATCH v6 1/4 net: bonding: add broadcast_neighbor option for 802.3ad
Stacking technology is a type of technology used to expand ports on Ethernet switches. It is widely used as a common access method in large-scale Internet data center architectures. Years of practice have proved that stacking technology has advantages and disadvantages in high-reliability network architecture scenarios. For instance, in stacking networking arch, conventional switch system upgrades require multiple stacked devices to restart at the same time. Therefore, it is inevitable that the business will be interrupted for a while. It is for this reason that "no-stacking" in data centers has become a trend. Additionally, when the stacking link connecting the switches fails or is abnormal, the stack will split. Although it is not common, it still happens in actual operation. The problem is that after the split, it is equivalent to two switches with the same configuration appearing in the network, causing network configuration conflicts and ultimately interrupting the services carried by the stacking system.
To improve network stability, "non-stacking" solutions have been increasingly adopted, particularly by public cloud providers and tech companies like Alibaba, Tencent, and Didi. "non-stacking" is a method of mimicing switch stacking that convinces a LACP peer, bonding in this case, connected to a set of "non-stacked" switches that all of its ports are connected to a single switch (i.e., LACP aggregator), as if those switches were stacked. This enables the LACP peer's ports to aggregate together, and requires
(a) special switch configuration, described in the linked article, and (b) modifications to the bonding 802.3ad (LACP) mode to send all ARP/ND packets across all ports of the active aggregator.
Note that, with multiple aggregators, the current broadcast mode logic will send only packets to the selected aggregator(s).
+-----------+ +-----------+
| switch1 | | switch2 |
+-----------+ +-----------+
^ ^
| |
+-----------------+
| bond4 lacp |
+-----------------+
| |
| NIC1 | NIC2
+-----------------+
| server |
+-----------------+- https://www.ruijie.com/fr-fr/support/tech-gallery/de-stack-data-center-network-architecture/
--- Documentation/networking/bonding.rst | 6 +++ drivers/net/bonding/bond_main.c | 66 +++++++++++++++++++++++++--- drivers/net/bonding/bond_options.c | 35 +++++++++++++++ include/net/bond_options.h | 1 + include/net/bonding.h | 3 ++ 5 files changed, 105 insertions(+), 6 deletions(-)
Documentation/networking/bonding.rst +6 -0
@@ -562,6 +562,12 @@ lacp_rate The default is slow. +broadcast_neighbor + + Option specifying whether to broadcast ARP/ND packets to all + active slaves. This option has no effect in modes other than + 802.3ad mode. The default is off (0). + max_bonds Specifies the number of bonding devices to create for this
drivers/net/bonding/bond_main.c +60 -6
117 lines not on this page · raw message
drivers/net/bonding/bond_options.c +35 -0
@@ -87,6 +87,8 @@ 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 int bond_option_broadcast_neigh_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 },
@@ -240,6 +242,12 @@ static const struct bond_opt_value bond_coupled_control_tbl[] = { { NULL, -1, 0}, }; +static const struct bond_opt_value bond_broadcast_neigh_tbl[] = { + { "off", 0, BOND_VALFLAG_DEFAULT}, + { "on", 1, 0}, + { NULL, -1, 0} +}; + static const struct bond_option bond_opts[BOND_OPT_LAST] = { [BOND_OPT_MODE] = { .id = BOND_OPT_MODE,
@@ -513,6 +521,14 @@ static const struct bond_option bond_opts[BOND_OPT_LAST] = { .flags = BOND_OPTFLAG_IFDOWN, .values = bond_coupled_control_tbl, .set = bond_option_coupled_control_set, + }, + [BOND_OPT_BROADCAST_NEIGH] = { + .id = BOND_OPT_BROADCAST_NEIGH, + .name = "broadcast_neighbor", + .desc = "Broadcast neighbor packets to all slaves", + .unsuppmodes = BOND_MODE_ALL_EX(BIT(BOND_MODE_8023AD)), + .values = bond_broadcast_neigh_tbl, + .set = bond_option_broadcast_neigh_set, } };
@@ -1840,3 +1856,22 @@ static int bond_option_coupled_control_set(struct bonding *bond, bond->params.coupled_control = newval->value;return 0 ; } + +static int bond_option_broadcast_neigh_set (struct bonding *bond, +const struct bond_opt_value *newval) +{ +if (bond->params.broadcast_neighbor == newval->value) +return 0 ; + + bond->params.broadcast_neighbor = newval->value; +if (bond->dev->flags &IFF_UP ) { +if (bond->params.broadcast_neighbor) +static_branch_inc (&bond_bcast_neigh_enabled); +else +static_branch_dec (&bond_bcast_neigh_enabled); + } + +netdev_dbg (bond->dev,"Setting broadcast_neighbor to %s (%llu)\n" , + newval->string, newval->value); +return 0 ; +}
include/net/bond_options.h +1 -0
@@ -77,6 +77,7 @@ enum {BOND_OPT_NS_TARGETS ,BOND_OPT_PRIO ,BOND_OPT_COUPLED_CONTROL , +BOND_OPT_BROADCAST_NEIGH , BOND_OPT_LAST };
include/net/bonding.h +3 -0
@@ -115,6 +115,8 @@ static inline int is_netpoll_tx_blocked(struct net_device *dev)#define is_netpoll_tx_blocked (dev) (0)#endif +DECLARE_STATIC_KEY_FALSE (bond_bcast_neigh_enabled); +struct bond_params {int mode;int xmit_policy;
@@ -149,6 +151,7 @@ struct bond_params {struct in6_addr ns_targets[BOND_MAX_NS_TARGETS ];#endif int coupled_control; +int broadcast_neighbor;/* 2 bytes of padding : see ether_addr_equal_64bits() */ u8 ad_actor_system[ETH_ALEN +2 ];
Signature · 1 line
2.34.1
Jakub Kicinski
maintainerRe: [net-next v6 1/4] net: bonding: add broadcast_neighbor option for 802.3ad
drivers/net/bonding/bond_main.c static int bond_close(struct net_device *bond_dev) · line 4485
Quoted 12 lines · On Tue, 10 Jun 2025 11:44:42 +0800 Tonghao Zhang wrote:
drivers/net/bonding/bond_main.c +5
-0+if (bond->params.broadcast_neighbor) +static_branch_inc (&bond_bcast_neigh_enabled); }if (bond_mode_can_use_xmit_hash (bond))@@ -4475,6 +4480,10 @@ static int bond_close(struct net_device *bond_dev)bond_alb_deinitialize (bond); bond->recv_probe =NULL ; +if (BOND_MODE (bond) ==BOND_MODE_8023AD && + bond->params.broadcast_neighbor) +static_branch_dec (&bond_bcast_neigh_enabled);
is .broadcast_neighbor automatically cleared when mode is changed? I don't see it in the code.
Signature · 1 line
pw-bot: cr
Re: [net-next v6 1/4] net: bonding: add broadcast_neighbor option for 802.3ad
Quoted 14 lines
2025年6月17日 07:04,Jakub Kicinski <[email protected]> 写道:
Quoted 9 lines · On Tue, 10 Jun 2025 11:44:42 +0800 Tonghao Zhang wrote:
+ if (
bond->params.broadcast_neighbor)
+static_branch_inc(&bond_bcast_neigh_enabled);
}if (
bond_mode_can_use_xmit_hash(bond))drivers/net/bonding/bond_main.c +0
-0@@ -4475,6 +4480,10 @@ static int bond_close(struct net_device *bond_dev)bond_alb_deinitialize (bond); bond->recv_probe =NULL ;
Quoted 6 lines
drivers/net/bonding/bond_main.c static int bond_close(struct net_device *bond_dev) · line 4485
Quoted 3 lines
drivers/net/bonding/bond_main.c +3
-0+if (BOND_MODE (bond) ==BOND_MODE_8023AD && + bond->params.broadcast_neighbor) +static_branch_dec (&bond_bcast_neigh_enabled);is .broadcast_neighbor automatically cleared when mode is changed? I don't see it in the code.
No clean this value when changing the mode, this option don’t work in other mode. But it is better to clean up it.
Quoted 4 lines
Signature · 1 line
pw-bot: cr
PATCH v6 2/4 net: bonding: add broadcast_neighbor netlink option
In reply to Tonghao ZhangUser can config or display the bonding broadcast_neighbor option via iproute2/netlink.
--- drivers/net/bonding/bond_netlink.c | 16 ++++++++++++++++ include/uapi/linux/if_link.h | 1 + 2 files changed, 17 insertions(+)
drivers/net/bonding/bond_netlink.c +16 -0
@@ -124,6 +124,7 @@ static const struct nla_policy bond_policy[IFLA_BOND_MAX + 1] = { [IFLA_BOND_MISSED_MAX] = { .type = NLA_U8 }, [IFLA_BOND_NS_IP6_TARGET] = { .type = NLA_NESTED }, [IFLA_BOND_COUPLED_CONTROL] = { .type = NLA_U8 }, + [IFLA_BOND_BROADCAST_NEIGH] = { .type = NLA_U8 }, };static const struct nla_policy bond_slave_policy[IFLA_BOND_SLAVE_MAX +1 ] = {
@@ -561,6 +562,16 @@ static int bond_changelink(struct net_device *bond_dev, struct nlattr *tb[],return err; } +if (data[IFLA_BOND_BROADCAST_NEIGH ]) { +int broadcast_neigh =nla_get_u8 (data[IFLA_BOND_BROADCAST_NEIGH ]); + +bond_opt_initval (&newval, broadcast_neigh); + err =__bond_opt_set (bond,BOND_OPT_BROADCAST_NEIGH , &newval, + data[IFLA_BOND_BROADCAST_NEIGH ], extack); +if (err) +return err; + } +return 0 ; }
@@ -630,6 +641,7 @@ static size_t bond_get_size(const struct net_device *bond_dev)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 */ +nla_total_size (sizeof (u8)) +/* IFLA_BOND_BROADCAST_NEIGH */ 0 ; }
@@ -793,6 +805,10 @@ static int bond_fill_info(struct sk_buff *skb, bond->params.coupled_control)) goto nla_put_failure; +if (nla_put_u8 (skb,IFLA_BOND_BROADCAST_NEIGH , + bond->params.broadcast_neighbor)) + goto nla_put_failure; +if (BOND_MODE (bond) ==BOND_MODE_8023AD ) {struct ad_info info;
include/uapi/linux/if_link.h +1 -0
@@ -1534,6 +1534,7 @@ enum {IFLA_BOND_MISSED_MAX ,IFLA_BOND_NS_IP6_TARGET ,IFLA_BOND_COUPLED_CONTROL , +IFLA_BOND_BROADCAST_NEIGH , __IFLA_BOND_MAX, };
Signature · 1 line
2.34.1
PATCH v6 3/4 net: bonding: send peer notify when failure recovery
In reply to Tonghao ZhangAfter LACP protocol recovery, the port can transmit packets. However, if the bond port doesn't send gratuitous ARP/ND packets to the switch, the switch won't return packets through the current interface. This causes traffic imbalance. To resolve this issue, when LACP protocol recovers, send ARP/ND packets.
--- Documentation/networking/bonding.rst | 5 +++-- drivers/net/bonding/bond_3ad.c | 13 +++++++++++++ drivers/net/bonding/bond_main.c | 21 ++++++++++++++++----- 3 files changed, 32 insertions(+), 7 deletions(-)
Documentation/networking/bonding.rst +3 -2
@@ -773,8 +773,9 @@ num_unsol_na greater than 1. The valid range is 0 - 255; the default value is 1. These options - affect only the active-backup mode. These options were added for - bonding versions 3.3.0 and 3.4.0 respectively. + affect the active-backup or 802.3ad (broadcast_neighbor enabled) mode. + These options were added for bonding versions 3.3.0 and 3.4.0 + respectively. From Linux 3.0 and bonding version 3.7.1, these notifications are generated by the ipv4 and ipv6 code and the numbers of
drivers/net/bonding/bond_3ad.c +13 -0
@@ -982,6 +982,17 @@ static int ad_marker_send(struct port *port, struct bond_marker *marker)return 0 ; } +static void ad_cond_set_peer_notif (struct port *port) +{ +struct bonding *bond = port->slave->bond; + +if (bond->params.broadcast_neighbor &&rtnl_trylock ()) { + bond->send_peer_notif = bond->params.num_peer_notif * +max (1 , bond->params.peer_notif_delay); +rtnl_unlock (); + } +} +/** * ad_mux_machine - handle a port's mux state machine * @port: the port we're looking at
@@ -2061,6 +2072,8 @@ static void ad_enable_collecting_distributing(struct port *port,__enable_port (port);/* Slave array needs update */ *update_slave_arr = true; +/* Should notify peers if possible */ +ad_cond_set_peer_notif (port); } }
drivers/net/bonding/bond_main.c +16 -5
@@ -1237,17 +1237,28 @@ static struct slave *bond_find_best_slave(struct bonding *bond)/* must be called in RCU critical section or with RTNL held */ static bool bond_should_notify_peers (struct bonding *bond) { -struct slave *slave =rcu_dereference_rtnl (bond->curr_active_slave); +struct bond_up_slave *usable; +struct slave *slave =NULL ; -if (!slave || !bond->send_peer_notif || +if (!bond->send_peer_notif || bond->send_peer_notif %max (1 , bond->params.peer_notif_delay) !=0 || - !netif_carrier_ok (bond->dev) || -test_bit (__LINK_STATE_LINKWATCH_PENDING, &slave->dev->state)) + !netif_carrier_ok (bond->dev))return false; +if (BOND_MODE (bond) ==BOND_MODE_8023AD ) { + usable =rcu_dereference_rtnl (bond->usable_slaves); +if (!usable || !READ_ONCE (usable->count)) +return false; + }else { + slave =rcu_dereference_rtnl (bond->curr_active_slave); +if (!slave ||test_bit (__LINK_STATE_LINKWATCH_PENDING, + &slave->dev->state)) +return false; + } +netdev_dbg (bond->dev,"bond_should_notify_peers: slave %s\n" , - slave ? slave->dev->name :"NULL" ); + slave ? slave->dev->name :"all" );return true; }
Signature · 1 line
2.34.1
Jay Vosburgh
maintainerRe: [net-next v6 3/4] net: bonding: send peer notify when failure recovery
Quoted 5 lines · Tonghao Zhang
After LACP protocol recovery, the port can transmit packets. However, if the bond port doesn't send gratuitous ARP/ND packets to the switch, the switch won't return packets through the current interface. This causes traffic imbalance. To resolve this issue, when LACP protocol recovers, send ARP/ND packets.
I think the description above needs to mention that the
gratuitous ARP/ND only happens if broadcast_neighbor is enabled.
I'll note that the documentation update does include this
caveat.
Quoted 93 lines
Cc Jay Vosburgh <[email protected]>Cc "David S. Miller" <[email protected]>Cc Eric Dumazet <[email protected]>Cc Jakub Kicinski <[email protected]>Cc Paolo Abeni <[email protected]>Cc Simon Horman <[email protected]>Cc Jonathan Corbet <[email protected]>Cc Andrew Lunn <[email protected]>Cc Steven Rostedt <[email protected]>Cc Masami Hiramatsu <[email protected]>Cc Mathieu Desnoyers <[email protected]>Cc Nikolay Aleksandrov <[email protected]>Signed-off-by Tonghao Zhang <[email protected]>Signed-off-by Zengbing Tu <[email protected]>Reviewed-by Nikolay Aleksandrov <[email protected]>---
Documentation/networking/bonding.rst | 5 +++-- drivers/net/bonding/bond_3ad.c | 13 +++++++++++++ drivers/net/bonding/bond_main.c | 21 ++++++++++++++++----- 3 files changed, 32 insertions(+), 7 deletions(-)Documentation/networking/bonding.rst +3
-2@@ -773,8 +773,9 @@ num_unsol_na greater than 1. The valid range is 0 - 255; the default value is 1. These options - affect only the active-backup mode. These options were added for - bonding versions 3.3.0 and 3.4.0 respectively. + affect the active-backup or 802.3ad (broadcast_neighbor enabled) mode. + These options were added for bonding versions 3.3.0 and 3.4.0 + respectively. From Linux 3.0 and bonding version 3.7.1, these notifications are generated by the ipv4 and ipv6 code and the numbers ofdrivers/net/bonding/bond_3ad.c +13
-0@@ -982,6 +982,17 @@ static int ad_marker_send(struct port *port, struct bond_marker *marker)return 0 ; } +static void ad_cond_set_peer_notif (struct port *port) +{ +struct bonding *bond = port->slave->bond; + +if (bond->params.broadcast_neighbor &&rtnl_trylock ()) { + bond->send_peer_notif = bond->params.num_peer_notif * +max (1 , bond->params.peer_notif_delay); +rtnl_unlock (); + } +} +/** * ad_mux_machine - handle a port's mux state machine * @port: the port we're looking at @@ -2061,6 +2072,8 @@ static void ad_enable_collecting_distributing(struct port *port,__enable_port (port);/* Slave array needs update */ *update_slave_arr = true; +/* Should notify peers if possible */ +ad_cond_set_peer_notif (port); } }drivers/net/bonding/bond_main.c +8
-4@@ -1237,17 +1237,28 @@ static struct slave *bond_find_best_slave(struct bonding *bond)/* must be called in RCU critical section or with RTNL held */ static bool bond_should_notify_peers (struct bonding *bond) { -struct slave *slave =rcu_dereference_rtnl (bond->curr_active_slave); +struct bond_up_slave *usable; +struct slave *slave =NULL ; -if (!slave || !bond->send_peer_notif || +if (!bond->send_peer_notif || bond->send_peer_notif %max (1 , bond->params.peer_notif_delay) !=0 || - !netif_carrier_ok (bond->dev) || -test_bit (__LINK_STATE_LINKWATCH_PENDING, &slave->dev->state)) + !netif_carrier_ok (bond->dev))return false; +if (BOND_MODE (bond) ==BOND_MODE_8023AD ) { + usable =rcu_dereference_rtnl (bond->usable_slaves); +if (!usable || !READ_ONCE (usable->count)) +return false;
drivers/net/bonding/bond_main.c static struct slave *bond_find_best_slave(struct bonding *bond) · line 1261
Quoted 10 lines
drivers/net/bonding/bond_main.c +8
-1+ }else { + slave =rcu_dereference_rtnl (bond->curr_active_slave); +if (!slave ||test_bit (__LINK_STATE_LINKWATCH_PENDING, + &slave->dev->state)) +return false; + } +netdev_dbg (bond->dev,"bond_should_notify_peers: slave %s\n" , - slave ? slave->dev->name :"NULL" ); + slave ? slave->dev->name :"all" );
Is it actually correct that if slave == NULL, the notify peers
logic will send to all ports? I'm not sure why this changed.
-J
Quoted 5 lines
drivers/net/bonding/bond_main.c +0
-0return true; }Signature · 1 line
2.34.1
---
-Jay Vosburgh, [email protected]
Re: [net-next v6 3/4] net: bonding: send peer notify when failure recovery
Quoted 6 lines
2025年6月17日 08:36,Jay Vosburgh <[email protected]> 写道:
Tonghao Zhang <[email protected]> wrote:
Quoted 8 lines
Quoted 5 lines
After LACP protocol recovery, the port can transmit packets. However, if the bond port doesn't send gratuitous ARP/ND packets to the switch, the switch won't return packets through the current interface. This causes traffic imbalance. To resolve this issue, when LACP protocol recovers, send ARP/ND packets.
I think the description above needs to mention that the gratuitous ARP/ND only happens if
broadcast_neighboris enabled.
Ok, thanks
Quoted 102 lines
I'll note that the documentation update does include this caveat.
Quoted 98 lines
Cc Jay Vosburgh <[email protected]>Cc "David S. Miller" <[email protected]>Cc Eric Dumazet <[email protected]>Cc Jakub Kicinski <[email protected]>Cc Paolo Abeni <[email protected]>Cc Simon Horman <[email protected]>Cc Jonathan Corbet <[email protected]>Cc Andrew Lunn <[email protected]>Cc Steven Rostedt <[email protected]>Cc Masami Hiramatsu <[email protected]>Cc Mathieu Desnoyers <[email protected]>Cc Nikolay Aleksandrov <[email protected]>Signed-off-by Tonghao Zhang <[email protected]>Signed-off-by Zengbing Tu <[email protected]>Reviewed-by Nikolay Aleksandrov <[email protected]>---
Documentation/networking/bonding.rst | 5 +++-- drivers/net/bonding/bond_3ad.c | 13 +++++++++++++ drivers/net/bonding/bond_main.c | 21 ++++++++++++++++----- 3 files changed, 32 insertions(+), 7 deletions(-)Documentation/networking/bonding.rst +0
-0@@ -773,8 +773,9 @@ num_unsol_nagreater than 1.
The valid range is 0 - 255; the default value is 1. These options
- affect only the active-backup mode. These options were added for
- bonding versions 3.3.0 and 3.4.0 respectively.
+ affect the active-backup or 802.3ad (broadcast_neighborenabled) mode.
+ These options were added for bonding versions 3.3.0 and 3.4.0
+ respectively.From Linux 3.0 and bonding version 3.7.1, these notifications are generated by the ipv4 and ipv6 code and the numbers of
drivers/net/bonding/bond_3ad.c +13
-0@@ -982,6 +982,17 @@ static int ad_marker_send(struct port *port, struct bond_marker *marker)return 0 ; } +static void ad_cond_set_peer_notif (struct port *port) +{ +struct bonding *bond = port->slave->bond; + +if (bond->params.broadcast_neighbor &&rtnl_trylock ()) { + bond->send_peer_notif = bond->params.num_peer_notif * +max (1 , bond->params.peer_notif_delay); +rtnl_unlock (); + } +} +/** * ad_mux_machine - handle a port's mux state machine * @port: the port we're looking at @@ -2061,6 +2072,8 @@ static void ad_enable_collecting_distributing(struct port *port,__enable_port (port);/* Slave array needs update */ *update_slave_arr = true; +/* Should notify peers if possible */ +ad_cond_set_peer_notif (port); } }drivers/net/bonding/bond_main.c +13
-4@@ -1237,17 +1237,28 @@ static struct slave *bond_find_best_slave(struct bonding *bond)/* must be called in RCU critical section or with RTNL held */ static bool bond_should_notify_peers (struct bonding *bond) { -struct slave *slave =rcu_dereference_rtnl (bond->curr_active_slave); +struct bond_up_slave *usable; +struct slave *slave =NULL ; -if (!slave || !bond->send_peer_notif || +if (!bond->send_peer_notif || bond->send_peer_notif %max (1 , bond->params.peer_notif_delay) !=0 || - !netif_carrier_ok (bond->dev) || -test_bit (__LINK_STATE_LINKWATCH_PENDING, &slave->dev->state)) + !netif_carrier_ok (bond->dev))return false; +if (BOND_MODE (bond) ==BOND_MODE_8023AD ) { + usable =rcu_dereference_rtnl (bond->usable_slaves); +if (!usable || !READ_ONCE (usable->count)) +return false; + }else { + slave =rcu_dereference_rtnl (bond->curr_active_slave); +if (!slave ||test_bit (__LINK_STATE_LINKWATCH_PENDING, + &slave->dev->state)) +return false;
Quoted 8 lines
drivers/net/bonding/bond_main.c static struct slave *bond_find_best_slave(struct bonding *bond) · line 1261
Quoted 5 lines
drivers/net/bonding/bond_main.c +3
-1+ } +netdev_dbg (bond->dev,"bond_should_notify_peers: slave %s\n" , - slave ? slave->dev->name :"NULL" ); + slave ? slave->dev->name :"all" );Is it actually correct that if slave == NULL, the notify peers logic will send to all ports? I'm not sure why this changed.
when bond is lacp mode, and send_peer_notif > 0, usable_slaves > 0, then slave == NULL, the debug log will print info "bond_should_notify_peers: slave all". In active-backup mode, slave is not NULL, that means "bond_should_notify_peers: slave xx".
Quoted 11 lines
-J
Quoted 5 lines
drivers/net/bonding/bond_main.c +0
-0return true; }Signature · 1 line
2.34.1---
-Jay Vosburgh, [email protected]
Re: [net-next v6 3/4] net: bonding: send peer notify when failure recovery
Quoted 129 lines
Quoted 4 lines · 2025年6月17日 18:47,Tonghao Zhang <[email protected]> 写道:
2025年6月17日 08:36,Jay Vosburgh <[email protected]> 写道:
Tonghao Zhang <[email protected]> wrote:
Quoted 8 lines
Quoted 5 lines
After LACP protocol recovery, the port can transmit packets. However, if the bond port doesn't send gratuitous ARP/ND packets to the switch, the switch won't return packets through the current interface. This causes traffic imbalance. To resolve this issue, when LACP protocol recovers, send ARP/ND packets.
I think the description above needs to mention that the gratuitous ARP/ND only happens if
broadcast_neighboris enabled.Ok, thanks
Quoted 102 lines
I'll note that the documentation update does include this caveat.
Quoted 98 lines
Cc Jay Vosburgh <[email protected]>Cc "David S. Miller" <[email protected]>Cc Eric Dumazet <[email protected]>Cc Jakub Kicinski <[email protected]>Cc Paolo Abeni <[email protected]>Cc Simon Horman <[email protected]>Cc Jonathan Corbet <[email protected]>Cc Andrew Lunn <[email protected]>Cc Steven Rostedt <[email protected]>Cc Masami Hiramatsu <[email protected]>Cc Mathieu Desnoyers <[email protected]>Cc Nikolay Aleksandrov <[email protected]>Signed-off-by Tonghao Zhang <[email protected]>Signed-off-by Zengbing Tu <[email protected]>Reviewed-by Nikolay Aleksandrov <[email protected]>---
Documentation/networking/bonding.rst | 5 +++-- drivers/net/bonding/bond_3ad.c | 13 +++++++++++++ drivers/net/bonding/bond_main.c | 21 ++++++++++++++++----- 3 files changed, 32 insertions(+), 7 deletions(-)Documentation/networking/bonding.rst +0
-0@@ -773,8 +773,9 @@ num_unsol_nagreater than 1.
The valid range is 0 - 255; the default value is 1. These options
- affect only the active-backup mode. These options were added for
- bonding versions 3.3.0 and 3.4.0 respectively.
+ affect the active-backup or 802.3ad (broadcast_neighborenabled) mode.
+ These options were added for bonding versions 3.3.0 and 3.4.0
+ respectively.From Linux 3.0 and bonding version 3.7.1, these notifications are generated by the ipv4 and ipv6 code and the numbers of
drivers/net/bonding/bond_3ad.c +13
-0@@ -982,6 +982,17 @@ static int ad_marker_send(struct port *port, struct bond_marker *marker)return 0 ; } +static void ad_cond_set_peer_notif (struct port *port) +{ +struct bonding *bond = port->slave->bond; + +if (bond->params.broadcast_neighbor &&rtnl_trylock ()) { + bond->send_peer_notif = bond->params.num_peer_notif * +max (1 , bond->params.peer_notif_delay); +rtnl_unlock (); + } +} +/** * ad_mux_machine - handle a port's mux state machine * @port: the port we're looking at @@ -2061,6 +2072,8 @@ static void ad_enable_collecting_distributing(struct port *port,__enable_port (port);/* Slave array needs update */ *update_slave_arr = true; +/* Should notify peers if possible */ +ad_cond_set_peer_notif (port); } }drivers/net/bonding/bond_main.c +13
-4@@ -1237,17 +1237,28 @@ static struct slave *bond_find_best_slave(struct bonding *bond)/* must be called in RCU critical section or with RTNL held */ static bool bond_should_notify_peers (struct bonding *bond) { -struct slave *slave =rcu_dereference_rtnl (bond->curr_active_slave); +struct bond_up_slave *usable; +struct slave *slave =NULL ; -if (!slave || !bond->send_peer_notif || +if (!bond->send_peer_notif || bond->send_peer_notif %max (1 , bond->params.peer_notif_delay) !=0 || - !netif_carrier_ok (bond->dev) || -test_bit (__LINK_STATE_LINKWATCH_PENDING, &slave->dev->state)) + !netif_carrier_ok (bond->dev))return false; +if (BOND_MODE (bond) ==BOND_MODE_8023AD ) { + usable =rcu_dereference_rtnl (bond->usable_slaves); +if (!usable || !READ_ONCE (usable->count)) +return false; + }else { + slave =rcu_dereference_rtnl (bond->curr_active_slave); +if (!slave ||test_bit (__LINK_STATE_LINKWATCH_PENDING, + &slave->dev->state)) +return false;Quoted 8 lines
drivers/net/bonding/bond_main.c static struct slave *bond_find_best_slave(struct bonding *bond) · line 1261
Quoted 5 lines
drivers/net/bonding/bond_main.c +3
-1+ } +netdev_dbg (bond->dev,"bond_should_notify_peers: slave %s\n" , - slave ? slave->dev->name :"NULL" ); + slave ? slave->dev->name :"all" );Is it actually correct that if slave == NULL, the notify peers logic will send to all ports? I'm not sure why this changed.
Quoted 1 line
when bond is lacp mode, and
send_peer_notif> 0,usable_slaves> 0, then slave == NULL, the debug log will print info "bond_should_notify_peers: slave all”.
In lacp mode, when broadcast_neighbor enabled, send_peer_notif will be set in ad_cond_set_peer_notif.
Quoted 13 lines
In active-backup mode, slave is not NULL, that means "
bond_should_notify_peers: slave xx".Quoted 11 lines
-J
Quoted 5 lines
drivers/net/bonding/bond_main.c +0
-0return true; }Signature · 1 line
2.34.1---
-Jay Vosburgh, [email protected]
Re: [net-next v6 3/4] net: bonding: send peer notify when failure recovery
Quoted 132 lines
Quoted 128 lines · 2025年6月17日 19:39,Tonghao Zhang <[email protected]> 写道:
Quoted 4 lines · 2025年6月17日 18:47,Tonghao Zhang <[email protected]> 写道:
2025年6月17日 08:36,Jay Vosburgh <[email protected]> 写道:
Tonghao Zhang <[email protected]> wrote:
Quoted 8 lines
Quoted 5 lines
After LACP protocol recovery, the port can transmit packets. However, if the bond port doesn't send gratuitous ARP/ND packets to the switch, the switch won't return packets through the current interface. This causes traffic imbalance. To resolve this issue, when LACP protocol recovers, send ARP/ND packets.
I think the description above needs to mention that the gratuitous ARP/ND only happens if
broadcast_neighboris enabled.Ok, thanks
Quoted 110 lines
I'll note that the documentation update does include this caveat.
Quoted 93 lines
Cc Jay Vosburgh <[email protected]>Cc "David S. Miller" <[email protected]>Cc Eric Dumazet <[email protected]>Cc Jakub Kicinski <[email protected]>Cc Paolo Abeni <[email protected]>Cc Simon Horman <[email protected]>Cc Jonathan Corbet <[email protected]>Cc Andrew Lunn <[email protected]>Cc Steven Rostedt <[email protected]>Cc Masami Hiramatsu <[email protected]>Cc Mathieu Desnoyers <[email protected]>Cc Nikolay Aleksandrov <[email protected]>Signed-off-by Tonghao Zhang <[email protected]>Signed-off-by Zengbing Tu <[email protected]>Reviewed-by Nikolay Aleksandrov <[email protected]>---
Documentation/networking/bonding.rst | 5 +++-- drivers/net/bonding/bond_3ad.c | 13 +++++++++++++ drivers/net/bonding/bond_main.c | 21 ++++++++++++++++----- 3 files changed, 32 insertions(+), 7 deletions(-)Documentation/networking/bonding.rst +0
-0@@ -773,8 +773,9 @@ num_unsol_nagreater than 1.
The valid range is 0 - 255; the default value is 1. These options
- affect only the active-backup mode. These options were added for
- bonding versions 3.3.0 and 3.4.0 respectively.
+ affect the active-backup or 802.3ad (broadcast_neighborenabled) mode.
+ These options were added for bonding versions 3.3.0 and 3.4.0
+ respectively.From Linux 3.0 and bonding version 3.7.1, these notifications are generated by the ipv4 and ipv6 code and the numbers of
drivers/net/bonding/bond_3ad.c +13
-0@@ -982,6 +982,17 @@ static int ad_marker_send(struct port *port, struct bond_marker *marker)return 0 ; } +static void ad_cond_set_peer_notif (struct port *port) +{ +struct bonding *bond = port->slave->bond; + +if (bond->params.broadcast_neighbor &&rtnl_trylock ()) { + bond->send_peer_notif = bond->params.num_peer_notif * +max (1 , bond->params.peer_notif_delay); +rtnl_unlock (); + } +} +/** * ad_mux_machine - handle a port's mux state machine * @port: the port we're looking at @@ -2061,6 +2072,8 @@ static void ad_enable_collecting_distributing(struct port *port,__enable_port (port);/* Slave array needs update */ *update_slave_arr = true; +/* Should notify peers if possible */ +ad_cond_set_peer_notif (port); } }drivers/net/bonding/bond_main.c +8
-4@@ -1237,17 +1237,28 @@ static struct slave *bond_find_best_slave(struct bonding *bond)/* must be called in RCU critical section or with RTNL held */ static bool bond_should_notify_peers (struct bonding *bond) { -struct slave *slave =rcu_dereference_rtnl (bond->curr_active_slave); +struct bond_up_slave *usable; +struct slave *slave =NULL ; -if (!slave || !bond->send_peer_notif || +if (!bond->send_peer_notif || bond->send_peer_notif %max (1 , bond->params.peer_notif_delay) !=0 || - !netif_carrier_ok (bond->dev) || -test_bit (__LINK_STATE_LINKWATCH_PENDING, &slave->dev->state)) + !netif_carrier_ok (bond->dev))return false; +if (BOND_MODE (bond) ==BOND_MODE_8023AD ) { + usable =rcu_dereference_rtnl (bond->usable_slaves); +if (!usable || !READ_ONCE (usable->count)) +return false;drivers/net/bonding/bond_main.c static struct slave *bond_find_best_slave(struct bonding *bond) · line 1261
Quoted 10 lines
drivers/net/bonding/bond_main.c +8
-1+ }else { + slave =rcu_dereference_rtnl (bond->curr_active_slave); +if (!slave ||test_bit (__LINK_STATE_LINKWATCH_PENDING, + &slave->dev->state)) +return false; + } +netdev_dbg (bond->dev,"bond_should_notify_peers: slave %s\n" , - slave ? slave->dev->name :"NULL" ); + slave ? slave->dev->name :"all" );Is it actually correct that if slave == NULL, the notify peers logic will send to all ports? I'm not sure why this changed.
Quoted 2 lines
Quoted 1 line
when bond is lacp mode, and
send_peer_notif> 0,usable_slaves> 0, then slave == NULL, the debug log will print info "bond_should_notify_peers: slave all”.In lacp mode, when
broadcast_neighborenabled,send_peer_notifwill be set inad_cond_set_peer_notif.
Hi Jay
This patch is ok? Or delete the debug info if you're confused. I think this is correct and useful to debug notify peers function.
Quoted 13 lines
Quoted 13 lines
In active-backup mode, slave is not NULL, that means "
bond_should_notify_peers: slave xx".Quoted 11 lines
-J
Quoted 5 lines
drivers/net/bonding/bond_main.c +0
-0return true; }Signature · 1 line
2.34.1---
-Jay Vosburgh, [email protected]
PATCH v6 4/4 net: bonding: add tracepoint for 802.3ad
In reply to Tonghao ZhangUsers can monitor NIC link status changes through netlink. However, LACP protocol failures may occur despite operational physical links. There is no way to detect LACP state changes. This patch adds tracepoint at LACP state transition.
--- drivers/net/bonding/bond_3ad.c | 6 ++++++ include/trace/events/bonding.h | 37 ++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 include/trace/events/bonding.h
drivers/net/bonding/bond_3ad.c +6 -0
@@ -16,6 +16,9 @@#include <net/bond_3ad.h> #include <net/netlink.h> +#define CREATE_TRACE_POINTS +#include <trace/events/bonding.h> +/* General definitions */ #define AD_SHORT_TIMEOUT 1#define AD_LONG_TIMEOUT 0
@@ -1146,6 +1149,9 @@ static void ad_mux_machine(struct port *port, bool *update_slave_arr) port->actor_port_number, last_state, port->sm_mux_state); + +trace_3ad_mux_state (port->slave->dev, last_state, port->sm_mux_state); +switch (port->sm_mux_state) {case AD_MUX_DETACHED : port->actor_oper_port_state &= ~LACP_STATE_SYNCHRONIZATION ;
include/trace/events/bonding.h new file +37 -0
@@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#if !defined(_TRACE_BONDING_H) || defined(TRACE_HEADER_MULTI_READ ) +#define _TRACE_BONDING_H + +#include <linux/netdevice.h> +#include <linux/tracepoint.h> + +#undef TRACE_SYSTEM +#define TRACE_SYSTEM bonding + +TRACE_EVENT(3ad_mux_state, + TP_PROTO(struct net_device *dev, u32 last_state, u32 curr_state), +TP_ARGS (dev, last_state, curr_state), + +TP_STRUCT__entry ( + __field(int, ifindex) + __string(dev_name, dev->name) + __field(u32, last_state) +__field (u32, curr_state) + ), + +TP_fast_assign ( + __entry->ifindex = dev->ifindex; + __assign_str(dev_name); + __entry->last_state = last_state; + __entry->curr_state = curr_state; + ), + +TP_printk ("ifindex %d dev %s last_state 0x%x curr_state 0x%x" , + __entry->ifindex,__get_str (dev_name), + __entry->last_state, __entry->curr_state) +); + +#endif /* _TRACE_BONDING_H */ + +#include <trace/define_trace.h>
Signature · 1 line
2.34.1
Jay Vosburgh
maintainerRe: [net-next v6 4/4] net: bonding: add tracepoint for 802.3ad
Quoted 4 lines · Tonghao Zhang
Users can monitor NIC link status changes through netlink. However, LACP protocol failures may occur despite operational physical links. There is no way to detect LACP state changes. This patch adds tracepoint at LACP state transition.
This patch really has nothing to do with the rest of the series
(it's unrelated to the broadcast_neighbor functionality), and should really be sent separately.
That said, I recall asking about work that was proposed some
time ago to create netlink events (visible to ip monitor, et al) when the LACP state changes. That would be a cleaner method to watch the LACP state machine (as it would integrate with all of the other event infrastructure). Maybe I missed the response, but what became of that work?
-J
Quoted 91 lines
Cc Jay Vosburgh <[email protected]>Cc "David S. Miller" <[email protected]>Cc Eric Dumazet <[email protected]>Cc Jakub Kicinski <[email protected]>Cc Paolo Abeni <[email protected]>Cc Simon Horman <[email protected]>Cc Jonathan Corbet <[email protected]>Cc Andrew Lunn <[email protected]>Cc Steven Rostedt <[email protected]>Cc Masami Hiramatsu <[email protected]>Cc Mathieu Desnoyers <[email protected]>Cc Nikolay Aleksandrov <[email protected]>Signed-off-by Tonghao Zhang <[email protected]>Signed-off-by Zengbing Tu <[email protected]>Reviewed-by Nikolay Aleksandrov <[email protected]>---
drivers/net/bonding/bond_3ad.c| 6 ++++++include/trace/events/bonding.h| 37 ++++++++++++++++++++++++++++++++++2 files changed, 43 insertions(+)create mode 100644
include/trace/events/bonding.hdrivers/net/bonding/bond_3ad.c +6
-0@@ -16,6 +16,9 @@#include <net/bond_3ad.h> #include <net/netlink.h> +#define CREATE_TRACE_POINTS +#include <trace/events/bonding.h> +/* General definitions */ #define AD_SHORT_TIMEOUT 1#define AD_LONG_TIMEOUT 0@@ -1146,6 +1149,9 @@ static void ad_mux_machine(struct port *port, bool *update_slave_arr) port->actor_port_number, last_state, port->sm_mux_state); + +trace_3ad_mux_state (port->slave->dev, last_state, port->sm_mux_state); +switch (port->sm_mux_state) {case AD_MUX_DETACHED : port->actor_oper_port_state &= ~LACP_STATE_SYNCHRONIZATION ;include/trace/events/bonding.h new file +37
-0@@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#if !defined(_TRACE_BONDING_H) || defined(TRACE_HEADER_MULTI_READ ) +#define _TRACE_BONDING_H + +#include <linux/netdevice.h> +#include <linux/tracepoint.h> + +#undef TRACE_SYSTEM +#define TRACE_SYSTEM bonding + +TRACE_EVENT(3ad_mux_state, + TP_PROTO(struct net_device *dev, u32 last_state, u32 curr_state), +TP_ARGS (dev, last_state, curr_state), + +TP_STRUCT__entry ( + __field(int, ifindex) + __string(dev_name, dev->name) + __field(u32, last_state) +__field (u32, curr_state) + ), + +TP_fast_assign ( + __entry->ifindex = dev->ifindex; + __assign_str(dev_name); + __entry->last_state = last_state; + __entry->curr_state = curr_state; + ), + +TP_printk ("ifindex %d dev %s last_state 0x%x curr_state 0x%x" , + __entry->ifindex,__get_str (dev_name), + __entry->last_state, __entry->curr_state) +); + +#endif /* _TRACE_BONDING_H */ + +#include <trace/define_trace.h> Signature · 1 line
2.34.1
---
-Jay Vosburgh, [email protected]
Re: [net-next v6 4/4] net: bonding: add tracepoint for 802.3ad
Quoted 6 lines
2025年6月17日 08:28,Jay Vosburgh <[email protected]> 写道:
Tonghao Zhang <[email protected]> wrote:
Quoted 8 lines
Quoted 4 lines
Users can monitor NIC link status changes through netlink. However, LACP protocol failures may occur despite operational physical links. There is no way to detect LACP state changes. This patch adds tracepoint at LACP state transition.
This patch really has nothing to do with the rest of the series (it's unrelated to the
broadcast_neighborfunctionality), and should really be sent separately.
… monitoring the lacp state is part of “no-stacking” arch solution. So I sent it as series. if unnecessary, I will set it separately.
Quoted 1 line
That said, I recall asking about work that was proposed some
Sorry I may miss your commits about this patch.
Quoted 3 lines
time ago to create netlink events (visible to ip monitor, et al) when the LACP state changes. That would be a cleaner method to watch the LACP state machine (as it would integrate with all of the other event
Why not consider a BPF+tracepoint solution? It provides more flexible LACP data collection with simpler implementation.
Quoted 99 lines
infrastructure). Maybe I missed the response, but what became of that work?
-J
Quoted 91 lines
Cc Jay Vosburgh <[email protected]>Cc "David S. Miller" <[email protected]>Cc Eric Dumazet <[email protected]>Cc Jakub Kicinski <[email protected]>Cc Paolo Abeni <[email protected]>Cc Simon Horman <[email protected]>Cc Jonathan Corbet <[email protected]>Cc Andrew Lunn <[email protected]>Cc Steven Rostedt <[email protected]>Cc Masami Hiramatsu <[email protected]>Cc Mathieu Desnoyers <[email protected]>Cc Nikolay Aleksandrov <[email protected]>Signed-off-by Tonghao Zhang <[email protected]>Signed-off-by Zengbing Tu <[email protected]>Reviewed-by Nikolay Aleksandrov <[email protected]>---
drivers/net/bonding/bond_3ad.c| 6 ++++++include/trace/events/bonding.h| 37 ++++++++++++++++++++++++++++++++++2 files changed, 43 insertions(+)create mode 100644
include/trace/events/bonding.hdrivers/net/bonding/bond_3ad.c +6
-0@@ -16,6 +16,9 @@#include <net/bond_3ad.h> #include <net/netlink.h> +#define CREATE_TRACE_POINTS +#include <trace/events/bonding.h> +/* General definitions */ #define AD_SHORT_TIMEOUT 1#define AD_LONG_TIMEOUT 0@@ -1146,6 +1149,9 @@ static void ad_mux_machine(struct port *port, bool *update_slave_arr) port->actor_port_number, last_state, port->sm_mux_state); + +trace_3ad_mux_state (port->slave->dev, last_state, port->sm_mux_state); +switch (port->sm_mux_state) {case
AD_MUX_DETACHED:port->actor_oper_port_state&= ~LACP_STATE_SYNCHRONIZATION;include/trace/events/bonding.h new file +37
-0@@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#if !defined(_TRACE_BONDING_H) || defined(TRACE_HEADER_MULTI_READ ) +#define _TRACE_BONDING_H + +#include <linux/netdevice.h> +#include <linux/tracepoint.h> + +#undef TRACE_SYSTEM +#define TRACE_SYSTEM bonding + +TRACE_EVENT(3ad_mux_state, + TP_PROTO(struct net_device *dev, u32 last_state, u32 curr_state), +TP_ARGS (dev, last_state, curr_state), + +TP_STRUCT__entry ( + __field(int, ifindex) + __string(dev_name, dev->name) + __field(u32, last_state) +__field (u32, curr_state) + ), + +TP_fast_assign ( + __entry->ifindex = dev->ifindex; + __assign_str(dev_name); + __entry->last_state = last_state; + __entry->curr_state = curr_state; + ), + +TP_printk ("ifindex %d dev %s last_state 0x%x curr_state 0x%x" , + __entry->ifindex,__get_str (dev_name), + __entry->last_state, __entry->curr_state) +); + +#endif /* _TRACE_BONDING_H */ + +#include <trace/define_trace.h> Signature · 1 line
2.34.1---
-Jay Vosburgh, [email protected]
Re: [net-next v6 4/4] net: bonding: add tracepoint for 802.3ad
Quoted 21 lines
Quoted 4 lines · 2025年6月17日 18:37,Tonghao Zhang <[email protected]> 写道:
2025年6月17日 08:28,Jay Vosburgh <[email protected]> 写道:
Tonghao Zhang <[email protected]> wrote:
Quoted 8 lines
Quoted 4 lines
Users can monitor NIC link status changes through netlink. However, LACP protocol failures may occur despite operational physical links. There is no way to detect LACP state changes. This patch adds tracepoint at LACP state transition.
This patch really has nothing to do with the rest of the series (it's unrelated to the
broadcast_neighborfunctionality), and should really be sent separately.… monitoring the lacp state is part of “no-stacking” arch solution. So I sent it as series. if unnecessary, I will set it separately.
Quoted 6 lines
Quoted 1 line
That said, I recall asking about work that was proposed some
Sorry I may miss your commits about this patch.
Quoted 3 lines
time ago to create netlink events (visible to ip monitor, et al) when the LACP state changes. That would be a cleaner method to watch the LACP state machine (as it would integrate with all of the other event
Why not consider a BPF+tracepoint solution? It provides more flexible LACP data collection with simpler implementation.
We developed a component. It collects kernel events via kprobe, ftrace, and tracepoint. Events include:
- Scheduling latency
- Direct memory reclaim
- Network packets drop
- LACP state events
BPF + tracepoint is our optimal approach. I think we should support this method.
Quoted 99 lines
Quoted 99 lines
infrastructure). Maybe I missed the response, but what became of that work?
-J
Quoted 91 lines
Cc Jay Vosburgh <[email protected]>Cc "David S. Miller" <[email protected]>Cc Eric Dumazet <[email protected]>Cc Jakub Kicinski <[email protected]>Cc Paolo Abeni <[email protected]>Cc Simon Horman <[email protected]>Cc Jonathan Corbet <[email protected]>Cc Andrew Lunn <[email protected]>Cc Steven Rostedt <[email protected]>Cc Masami Hiramatsu <[email protected]>Cc Mathieu Desnoyers <[email protected]>Cc Nikolay Aleksandrov <[email protected]>Signed-off-by Tonghao Zhang <[email protected]>Signed-off-by Zengbing Tu <[email protected]>Reviewed-by Nikolay Aleksandrov <[email protected]>---
drivers/net/bonding/bond_3ad.c| 6 ++++++include/trace/events/bonding.h| 37 ++++++++++++++++++++++++++++++++++2 files changed, 43 insertions(+)create mode 100644
include/trace/events/bonding.hdrivers/net/bonding/bond_3ad.c +6
-0@@ -16,6 +16,9 @@#include <net/bond_3ad.h> #include <net/netlink.h> +#define CREATE_TRACE_POINTS +#include <trace/events/bonding.h> +/* General definitions */ #define AD_SHORT_TIMEOUT 1#define AD_LONG_TIMEOUT 0@@ -1146,6 +1149,9 @@ static void ad_mux_machine(struct port *port, bool *update_slave_arr) port->actor_port_number, last_state, port->sm_mux_state); + +trace_3ad_mux_state (port->slave->dev, last_state, port->sm_mux_state); +switch (port->sm_mux_state) {case
AD_MUX_DETACHED:port->actor_oper_port_state&= ~LACP_STATE_SYNCHRONIZATION;include/trace/events/bonding.h new file +37
-0@@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#if !defined(_TRACE_BONDING_H) || defined(TRACE_HEADER_MULTI_READ ) +#define _TRACE_BONDING_H + +#include <linux/netdevice.h> +#include <linux/tracepoint.h> + +#undef TRACE_SYSTEM +#define TRACE_SYSTEM bonding + +TRACE_EVENT(3ad_mux_state, + TP_PROTO(struct net_device *dev, u32 last_state, u32 curr_state), +TP_ARGS (dev, last_state, curr_state), + +TP_STRUCT__entry ( + __field(int, ifindex) + __string(dev_name, dev->name) + __field(u32, last_state) +__field (u32, curr_state) + ), + +TP_fast_assign ( + __entry->ifindex = dev->ifindex; + __assign_str(dev_name); + __entry->last_state = last_state; + __entry->curr_state = curr_state; + ), + +TP_printk ("ifindex %d dev %s last_state 0x%x curr_state 0x%x" , + __entry->ifindex,__get_str (dev_name), + __entry->last_state, __entry->curr_state) +); + +#endif /* _TRACE_BONDING_H */ + +#include <trace/define_trace.h> Signature · 1 line
2.34.1---
-Jay Vosburgh, [email protected]
Jay Vosburgh
maintainerRe: [net-next v6 4/4] net: bonding: add tracepoint for 802.3ad
Quoted 22 lines · Tonghao Zhang
Quoted 22 lines
Quoted 4 lines · 2025年6月17日 18:37,Tonghao Zhang <[email protected]> 写道:
2025年6月17日 08:28,Jay Vosburgh <[email protected]> 写道:
Tonghao Zhang <[email protected]> wrote:
Quoted 8 lines
Quoted 4 lines
Users can monitor NIC link status changes through netlink. However, LACP protocol failures may occur despite operational physical links. There is no way to detect LACP state changes. This patch adds tracepoint at LACP state transition.
This patch really has nothing to do with the rest of the series (it's unrelated to the
broadcast_neighborfunctionality), and should really be sent separately.… monitoring the lacp state is part of “no-stacking” arch solution. So I sent it as series. if unnecessary, I will set it separately.
Quoted 1 line
That said, I recall asking about work that was proposed some
Sorry I may miss your commits about this patch.
Quoted 3 lines
time ago to create netlink events (visible to ip monitor, et al) when the LACP state changes. That would be a cleaner method to watch the LACP state machine (as it would integrate with all of the other event
Quoted 8 lines
Quoted 1 line
Why not consider a BPF+tracepoint solution? It provides more flexible LACP data collection with simpler implementation.
We developed a component. It collects kernel events via kprobe, ftrace, and tracepoint. Events include:
- Scheduling latency
- Direct memory reclaim
- Network packets drop
- LACP state eventsBPF + tracepoint is our optimal approach. I think we should support this method.
At present, as far as I know, networking state change events are
exported to user space through netlink. Absent a compelling reason why the LACP state change cannot be exported via netlink, my view is that it should be consistent with all other network events.
Also, to be clear, I'm asking for justification because this is
a request to do something in a special bonding-unique way. There are already a lot of special cases in bonding, in which things are done differently than the usual practice. Adding an API element, such as a tracepoint, is forever, and as such adding one that also differs from the usual practice deserves scrutiny.
-J
Quoted 91 lines
Quoted 91 lines
Quoted 91 lines
infrastructure). Maybe I missed the response, but what became of that work?
-J
Quoted 86 lines
Cc Jay Vosburgh <[email protected]>Cc "David S. Miller" <[email protected]>Cc Eric Dumazet <[email protected]>Cc Jakub Kicinski <[email protected]>Cc Paolo Abeni <[email protected]>Cc Simon Horman <[email protected]>Cc Jonathan Corbet <[email protected]>Cc Andrew Lunn <[email protected]>Cc Steven Rostedt <[email protected]>Cc Masami Hiramatsu <[email protected]>Cc Mathieu Desnoyers <[email protected]>Cc Nikolay Aleksandrov <[email protected]>Signed-off-by Tonghao Zhang <[email protected]>Signed-off-by Zengbing Tu <[email protected]>Reviewed-by Nikolay Aleksandrov <[email protected]>---
drivers/net/bonding/bond_3ad.c| 6 ++++++include/trace/events/bonding.h| 37 ++++++++++++++++++++++++++++++++++2 files changed, 43 insertions(+)create mode 100644
include/trace/events/bonding.hdrivers/net/bonding/bond_3ad.c +6
-0@@ -16,6 +16,9 @@#include <net/bond_3ad.h> #include <net/netlink.h> +#define CREATE_TRACE_POINTS +#include <trace/events/bonding.h> +/* General definitions */ #define AD_SHORT_TIMEOUT 1#define AD_LONG_TIMEOUT 0@@ -1146,6 +1149,9 @@ static void ad_mux_machine(struct port *port, bool *update_slave_arr) port->actor_port_number, last_state, port->sm_mux_state); + +trace_3ad_mux_state (port->slave->dev, last_state, port->sm_mux_state); +switch (port->sm_mux_state) {case
AD_MUX_DETACHED:port->actor_oper_port_state&= ~LACP_STATE_SYNCHRONIZATION;include/trace/events/bonding.h new file +35
-0@@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#if !defined(_TRACE_BONDING_H) || defined(TRACE_HEADER_MULTI_READ ) +#define _TRACE_BONDING_H + +#include <linux/netdevice.h> +#include <linux/tracepoint.h> + +#undef TRACE_SYSTEM +#define TRACE_SYSTEM bonding + +TRACE_EVENT(3ad_mux_state, + TP_PROTO(struct net_device *dev, u32 last_state, u32 curr_state), +TP_ARGS (dev, last_state, curr_state), + +TP_STRUCT__entry ( + __field(int, ifindex) + __string(dev_name, dev->name) + __field(u32, last_state) +__field (u32, curr_state) + ), + +TP_fast_assign ( + __entry->ifindex = dev->ifindex; + __assign_str(dev_name); + __entry->last_state = last_state; + __entry->curr_state = curr_state; + ), + +TP_printk ("ifindex %d dev %s last_state 0x%x curr_state 0x%x" , + __entry->ifindex,__get_str (dev_name), + __entry->last_state, __entry->curr_state) +); + +#endif /* _TRACE_BONDING_H */
Quoted 11 lines
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
include/trace/events/bonding.h new file +2
-0+ +#include <trace/define_trace.h> Signature · 1 line
2.34.1---
-Jay Vosburgh, [email protected]
---
-Jay Vosburgh, [email protected]
Re: [net-next v6 4/4] net: bonding: add tracepoint for 802.3ad
Quoted 42 lines
2025年6月25日 03:43,Jay Vosburgh <[email protected]> 写道:
Quoted 22 lines · Tonghao Zhang
Quoted 22 lines
Quoted 4 lines · 2025年6月17日 18:37,Tonghao Zhang <[email protected]> 写道:
2025年6月17日 08:28,Jay Vosburgh <[email protected]> 写道:
Tonghao Zhang <[email protected]> wrote:
Quoted 8 lines
Quoted 4 lines
Users can monitor NIC link status changes through netlink. However, LACP protocol failures may occur despite operational physical links. There is no way to detect LACP state changes. This patch adds tracepoint at LACP state transition.
This patch really has nothing to do with the rest of the series (it's unrelated to the
broadcast_neighborfunctionality), and should really be sent separately.… monitoring the lacp state is part of “no-stacking” arch solution. So I sent it as series. if unnecessary, I will set it separately.
Quoted 1 line
That said, I recall asking about work that was proposed some
Sorry I may miss your commits about this patch.
Quoted 3 lines
time ago to create netlink events (visible to ip monitor, et al) when the LACP state changes. That would be a cleaner method to watch the LACP state machine (as it would integrate with all of the other event
Quoted 8 lines
Quoted 1 line
Why not consider a BPF+tracepoint solution? It provides more flexible LACP data collection with simpler implementation.
We developed a component. It collects kernel events via kprobe, ftrace, and tracepoint. Events include:
- Scheduling latency
- Direct memory reclaim
- Network packets drop
- LACP state eventsBPF + tracepoint is our optimal approach. I think we should support this method.
At present, as far as I know, networking state change events are exported to user space through netlink. Absent a compelling reason why the LACP state change cannot be exported via netlink, my view is that it should be consistent with all other network events.
Quoted 6 lines
Also, to be clear, I'm asking for justification because this is a request to do something in a special bonding-unique way. There are already a lot of special cases in bonding, in which things are done differently than the usual practice. Adding an API element, such as a tracepoint, is forever, and as such adding one that also differs from the usual practice deserves scrutiny.
I will research the netlink notification method and post a patch when it's ready.
Quoted 108 lines
-J
Quoted 91 lines
Quoted 91 lines
Quoted 91 lines
infrastructure). Maybe I missed the response, but what became of that work?
-J
Quoted 86 lines
Cc Jay Vosburgh <[email protected]>Cc "David S. Miller" <[email protected]>Cc Eric Dumazet <[email protected]>Cc Jakub Kicinski <[email protected]>Cc Paolo Abeni <[email protected]>Cc Simon Horman <[email protected]>Cc Jonathan Corbet <[email protected]>Cc Andrew Lunn <[email protected]>Cc Steven Rostedt <[email protected]>Cc Masami Hiramatsu <[email protected]>Cc Mathieu Desnoyers <[email protected]>Cc Nikolay Aleksandrov <[email protected]>Signed-off-by Tonghao Zhang <[email protected]>Signed-off-by Zengbing Tu <[email protected]>Reviewed-by Nikolay Aleksandrov <[email protected]>---
drivers/net/bonding/bond_3ad.c| 6 ++++++include/trace/events/bonding.h| 37 ++++++++++++++++++++++++++++++++++2 files changed, 43 insertions(+)create mode 100644
include/trace/events/bonding.hdrivers/net/bonding/bond_3ad.c +6
-0@@ -16,6 +16,9 @@#include <net/bond_3ad.h> #include <net/netlink.h> +#define CREATE_TRACE_POINTS +#include <trace/events/bonding.h> +/* General definitions */ #define AD_SHORT_TIMEOUT 1#define AD_LONG_TIMEOUT 0@@ -1146,6 +1149,9 @@ static void ad_mux_machine(struct port *port, bool *update_slave_arr) port->actor_port_number, last_state, port->sm_mux_state); + +trace_3ad_mux_state (port->slave->dev, last_state, port->sm_mux_state); +switch (port->sm_mux_state) {case
AD_MUX_DETACHED:port->actor_oper_port_state&= ~LACP_STATE_SYNCHRONIZATION;include/trace/events/bonding.h new file +35
-0@@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#if !defined(_TRACE_BONDING_H) || defined(TRACE_HEADER_MULTI_READ ) +#define _TRACE_BONDING_H + +#include <linux/netdevice.h> +#include <linux/tracepoint.h> + +#undef TRACE_SYSTEM +#define TRACE_SYSTEM bonding + +TRACE_EVENT(3ad_mux_state, + TP_PROTO(struct net_device *dev, u32 last_state, u32 curr_state), +TP_ARGS (dev, last_state, curr_state), + +TP_STRUCT__entry ( + __field(int, ifindex) + __string(dev_name, dev->name) + __field(u32, last_state) +__field (u32, curr_state) + ), + +TP_fast_assign ( + __entry->ifindex = dev->ifindex; + __assign_str(dev_name); + __entry->last_state = last_state; + __entry->curr_state = curr_state; + ), + +TP_printk ("ifindex %d dev %s last_state 0x%x curr_state 0x%x" , + __entry->ifindex,__get_str (dev_name), + __entry->last_state, __entry->curr_state) +); + +#endif /* _TRACE_BONDING_H */ Quoted 11 lines
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
include/trace/events/bonding.h new file +2
-0+ +#include <trace/define_trace.h> Signature · 1 line
2.34.1---
-Jay Vosburgh, [email protected]---
-Jay Vosburgh, [email protected]
ping
Quoted 73 lines
2025年6月10日 11:44,Tonghao Zhang <[email protected]> 写道:
For no-stacking networking arch, and enable the bond mode 4(lacp) in datacenter, the switch require arp/nd packets as session synchronization. More details please see patch.
v6 change log:
- del unnecessaryrcu_read_lockinbond_xmit_broadcastv5 change log:
- format commit message of all patches
- useskb_header_pointerinstead ofpskb_may_pull
- send only packets to active slaves instead of all ports, and add more commit logv4 change log:
- fix dec option inbond_closev3 change log:
- inc/decbroadcast_neighboroption in bond_open/close and UP state.
- remove explicit inline ofbond_should_broadcast_neighbor
- remove sysfs option
- removeEXPORT_SYMBOL_GPL
- reorder optionbond_opt_value
- usercu_xxxinbond_should_notify_peers.v2 change log:
- add static branch for performance
- add more info about no-stacking arch in commit message
- addbroadcast_neighborinfo and format doc
- invokebond_should_broadcast_neighboronly inBOND_MODE_8023ADmode for performance
- explain why we need sending peer notify when failure recovery
- change the doc aboutnum_unsol_na
- refine function name toad_cond_set_peer_notif
-ad_cond_set_peer_notifinvoked inad_enable_collecting_distributing
- refinebond_should_notify_peersfor lacp mode.Cc Jay Vosburgh <[email protected]>Cc "David S. Miller" <[email protected]>Cc Eric Dumazet <[email protected]>Cc Jakub Kicinski <[email protected]>Cc Paolo Abeni <[email protected]>Cc Simon Horman <[email protected]>Cc Jonathan Corbet <[email protected]>Cc Andrew Lunn <[email protected]>Cc Steven Rostedt <[email protected]>Cc Masami Hiramatsu <[email protected]>Cc Mathieu Desnoyers <[email protected]>Cc Nikolay Aleksandrov <[email protected]>Cc Zengbing Tu <[email protected]>Tonghao Zhang (4):
net: bonding: addbroadcast_neighboroption for 802.3ad
net: bonding: addbroadcast_neighbornetlink option
net: bonding: send peer notify when failure recovery
net: bonding: add tracepoint for 802.3adDocumentation/networking/bonding.rst | 11 +++- drivers/net/bonding/bond_3ad.c | 19 ++++++ drivers/net/bonding/bond_main.c | 87 ++++++++++++++++++++++++---- drivers/net/bonding/bond_netlink.c | 16 +++++ drivers/net/bonding/bond_options.c | 35 +++++++++++ include/net/bond_options.h | 1 + include/net/bonding.h | 3 + include/trace/events/bonding.h | 37 ++++++++++++ include/uapi/linux/if_link.h | 1 + 9 files changed, 197 insertions(+), 13 deletions(-)create mode 100644
include/trace/events/bonding.hSignature · 1 line
2.34.1