| From 06bcae0551a2e06d86eac4d89f4e396d4f40be75 Mon Sep 17 00:00:00 2001 |
| From: Sasha Levin <sashal@kernel.org> |
| Date: Fri, 15 Aug 2025 06:19:58 +0000 |
| Subject: bonding: update LACP activity flag after setting lacp_active |
| |
| From: Hangbin Liu <liuhangbin@gmail.com> |
| |
| [ Upstream commit b64d035f77b1f02ab449393342264b44950a75ae ] |
| |
| The port's actor_oper_port_state activity flag should be updated immediately |
| after changing the lacp_active option to reflect the current mode correctly. |
| |
| Fixes: 3a755cd8b7c6 ("bonding: add new option lacp_active") |
| Signed-off-by: Hangbin Liu <liuhangbin@gmail.com> |
| Link: https://patch.msgid.link/20250815062000.22220-2-liuhangbin@gmail.com |
| Signed-off-by: Paolo Abeni <pabeni@redhat.com> |
| Signed-off-by: Sasha Levin <sashal@kernel.org> |
| --- |
| drivers/net/bonding/bond_3ad.c | 25 +++++++++++++++++++++++++ |
| drivers/net/bonding/bond_options.c | 1 + |
| include/net/bond_3ad.h | 1 + |
| 3 files changed, 27 insertions(+) |
| |
| diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c |
| index 9270977e6c7f..7557c525615e 100644 |
| --- a/drivers/net/bonding/bond_3ad.c |
| +++ b/drivers/net/bonding/bond_3ad.c |
| @@ -2725,6 +2725,31 @@ void bond_3ad_update_lacp_rate(struct bonding *bond) |
| spin_unlock_bh(&bond->mode_lock); |
| } |
| |
| +/** |
| + * bond_3ad_update_lacp_active - change the lacp active |
| + * @bond: bonding struct |
| + * |
| + * Update actor_oper_port_state when lacp_active is modified. |
| + */ |
| +void bond_3ad_update_lacp_active(struct bonding *bond) |
| +{ |
| + struct port *port = NULL; |
| + struct list_head *iter; |
| + struct slave *slave; |
| + int lacp_active; |
| + |
| + lacp_active = bond->params.lacp_active; |
| + spin_lock_bh(&bond->mode_lock); |
| + bond_for_each_slave(bond, slave, iter) { |
| + port = &(SLAVE_AD_INFO(slave)->port); |
| + if (lacp_active) |
| + port->actor_oper_port_state |= LACP_STATE_LACP_ACTIVITY; |
| + else |
| + port->actor_oper_port_state &= ~LACP_STATE_LACP_ACTIVITY; |
| + } |
| + spin_unlock_bh(&bond->mode_lock); |
| +} |
| + |
| size_t bond_3ad_stats_size(void) |
| { |
| return nla_total_size_64bit(sizeof(u64)) + /* BOND_3AD_STAT_LACPDU_RX */ |
| diff --git a/drivers/net/bonding/bond_options.c b/drivers/net/bonding/bond_options.c |
| index 21ca95cdef42..8a24c016f667 100644 |
| --- a/drivers/net/bonding/bond_options.c |
| +++ b/drivers/net/bonding/bond_options.c |
| @@ -1634,6 +1634,7 @@ static int bond_option_lacp_active_set(struct bonding *bond, |
| netdev_dbg(bond->dev, "Setting LACP active to %s (%llu)\n", |
| newval->string, newval->value); |
| bond->params.lacp_active = newval->value; |
| + bond_3ad_update_lacp_active(bond); |
| |
| return 0; |
| } |
| diff --git a/include/net/bond_3ad.h b/include/net/bond_3ad.h |
| index a016f275cb01..2d9596dba84d 100644 |
| --- a/include/net/bond_3ad.h |
| +++ b/include/net/bond_3ad.h |
| @@ -303,6 +303,7 @@ int bond_3ad_lacpdu_recv(const struct sk_buff *skb, struct bonding *bond, |
| int bond_3ad_set_carrier(struct bonding *bond); |
| void bond_3ad_update_lacp_active(struct bonding *bond); |
| void bond_3ad_update_lacp_rate(struct bonding *bond); |
| +void bond_3ad_update_lacp_active(struct bonding *bond); |
| void bond_3ad_update_ad_actor_settings(struct bonding *bond); |
| int bond_3ad_stats_fill(struct sk_buff *skb, struct bond_3ad_stats *stats); |
| size_t bond_3ad_stats_size(void); |
| -- |
| 2.50.1 |
| |