Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

bonding: add support for per-port LACP actor priority

Introduce a new netlink attribute 'actor_port_prio' to allow setting
the LACP actor port priority on a per-slave basis. This extends the
existing bonding infrastructure to support more granular control over
LACP negotiations.

The priority value is embedded in LACPDU packets and will be used by
subsequent patches to influence aggregator selection policies.

Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Link: https://patch.msgid.link/20250902064501.360822-2-liuhangbin@gmail.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Hangbin Liu and committed by
Paolo Abeni
6b6dc81e 389cca2b

+68
+9
Documentation/networking/bonding.rst
··· 193 193 This parameter has effect only in 802.3ad mode and is available through 194 194 SysFs interface. 195 195 196 + actor_port_prio 197 + 198 + In an AD system, this specifies the port priority. The allowed range 199 + is 1 - 65535. If the value is not specified, it takes 255 as the 200 + default value. 201 + 202 + This parameter has effect only in 802.3ad mode and is available through 203 + netlink interface. 204 + 196 205 ad_actor_system 197 206 198 207 In an AD system, this specifies the mac-address for the actor in
+4
drivers/net/bonding/bond_3ad.c
··· 436 436 437 437 port->actor_system = BOND_AD_INFO(bond).system.sys_mac_addr; 438 438 port->actor_system_priority = BOND_AD_INFO(bond).system.sys_priority; 439 + port->actor_port_priority = SLAVE_AD_INFO(port->slave)->port_priority; 439 440 } 440 441 441 442 /* Conversions */ ··· 2209 2208 port = &(SLAVE_AD_INFO(slave)->port); 2210 2209 2211 2210 ad_initialize_port(port, &bond->params); 2211 + 2212 + /* Port priority is initialized. Update it to slave's ad info */ 2213 + SLAVE_AD_INFO(slave)->port_priority = port->actor_port_priority; 2212 2214 2213 2215 port->slave = slave; 2214 2216 port->actor_port_number = SLAVE_AD_INFO(slave)->id;
+16
drivers/net/bonding/bond_netlink.c
··· 28 28 nla_total_size(sizeof(u8)) + /* IFLA_BOND_SLAVE_AD_ACTOR_OPER_PORT_STATE */ 29 29 nla_total_size(sizeof(u16)) + /* IFLA_BOND_SLAVE_AD_PARTNER_OPER_PORT_STATE */ 30 30 nla_total_size(sizeof(s32)) + /* IFLA_BOND_SLAVE_PRIO */ 31 + nla_total_size(sizeof(u16)) + /* IFLA_BOND_SLAVE_ACTOR_PORT_PRIO */ 31 32 0; 32 33 } 33 34 ··· 78 77 ad_port->partner_oper.port_state)) 79 78 goto nla_put_failure; 80 79 } 80 + 81 + if (nla_put_u16(skb, IFLA_BOND_SLAVE_ACTOR_PORT_PRIO, 82 + SLAVE_AD_INFO(slave)->port_priority)) 83 + goto nla_put_failure; 81 84 } 82 85 83 86 return 0; ··· 135 130 static const struct nla_policy bond_slave_policy[IFLA_BOND_SLAVE_MAX + 1] = { 136 131 [IFLA_BOND_SLAVE_QUEUE_ID] = { .type = NLA_U16 }, 137 132 [IFLA_BOND_SLAVE_PRIO] = { .type = NLA_S32 }, 133 + [IFLA_BOND_SLAVE_ACTOR_PORT_PRIO] = { .type = NLA_U16 }, 138 134 }; 139 135 140 136 static int bond_validate(struct nlattr *tb[], struct nlattr *data[], ··· 182 176 bond_opt_slave_initval(&newval, &slave_dev, prio); 183 177 err = __bond_opt_set(bond, BOND_OPT_PRIO, &newval, 184 178 data[IFLA_BOND_SLAVE_PRIO], extack); 179 + if (err) 180 + return err; 181 + } 182 + 183 + if (data[IFLA_BOND_SLAVE_ACTOR_PORT_PRIO]) { 184 + u16 ad_prio = nla_get_u16(data[IFLA_BOND_SLAVE_ACTOR_PORT_PRIO]); 185 + 186 + bond_opt_slave_initval(&newval, &slave_dev, ad_prio); 187 + err = __bond_opt_set(bond, BOND_OPT_ACTOR_PORT_PRIO, &newval, 188 + data[IFLA_BOND_SLAVE_ACTOR_PORT_PRIO], extack); 185 189 if (err) 186 190 return err; 187 191 }
+36
drivers/net/bonding/bond_options.c
··· 79 79 const struct bond_opt_value *newval); 80 80 static int bond_option_ad_actor_sys_prio_set(struct bonding *bond, 81 81 const struct bond_opt_value *newval); 82 + static int bond_option_actor_port_prio_set(struct bonding *bond, 83 + const struct bond_opt_value *newval); 82 84 static int bond_option_ad_actor_system_set(struct bonding *bond, 83 85 const struct bond_opt_value *newval); 84 86 static int bond_option_ad_user_port_key_set(struct bonding *bond, ··· 221 219 static const struct bond_opt_value bond_ad_actor_sys_prio_tbl[] = { 222 220 { "minval", 1, BOND_VALFLAG_MIN}, 223 221 { "maxval", 65535, BOND_VALFLAG_MAX | BOND_VALFLAG_DEFAULT}, 222 + { NULL, -1, 0}, 223 + }; 224 + 225 + static const struct bond_opt_value bond_actor_port_prio_tbl[] = { 226 + { "minval", 0, BOND_VALFLAG_MIN}, 227 + { "maxval", 65535, BOND_VALFLAG_MAX}, 228 + { "default", 255, BOND_VALFLAG_DEFAULT}, 224 229 { NULL, -1, 0}, 225 230 }; 226 231 ··· 491 482 .unsuppmodes = BOND_MODE_ALL_EX(BIT(BOND_MODE_8023AD)), 492 483 .values = bond_ad_actor_sys_prio_tbl, 493 484 .set = bond_option_ad_actor_sys_prio_set, 485 + }, 486 + [BOND_OPT_ACTOR_PORT_PRIO] = { 487 + .id = BOND_OPT_ACTOR_PORT_PRIO, 488 + .name = "actor_port_prio", 489 + .unsuppmodes = BOND_MODE_ALL_EX(BIT(BOND_MODE_8023AD)), 490 + .values = bond_actor_port_prio_tbl, 491 + .set = bond_option_actor_port_prio_set, 494 492 }, 495 493 [BOND_OPT_AD_ACTOR_SYSTEM] = { 496 494 .id = BOND_OPT_AD_ACTOR_SYSTEM, ··· 1823 1807 newval->value); 1824 1808 1825 1809 bond->params.ad_actor_sys_prio = newval->value; 1810 + bond_3ad_update_ad_actor_settings(bond); 1811 + 1812 + return 0; 1813 + } 1814 + 1815 + static int bond_option_actor_port_prio_set(struct bonding *bond, 1816 + const struct bond_opt_value *newval) 1817 + { 1818 + struct slave *slave; 1819 + 1820 + slave = bond_slave_get_rtnl(newval->slave_dev); 1821 + if (!slave) { 1822 + netdev_dbg(bond->dev, "%s called on NULL slave\n", __func__); 1823 + return -ENODEV; 1824 + } 1825 + 1826 + netdev_dbg(newval->slave_dev, "Setting actor_port_prio to %llu\n", 1827 + newval->value); 1828 + 1829 + SLAVE_AD_INFO(slave)->port_priority = newval->value; 1826 1830 bond_3ad_update_ad_actor_settings(bond); 1827 1831 1828 1832 return 0;
+1
include/net/bond_3ad.h
··· 274 274 struct port port; /* 802.3ad port structure */ 275 275 struct bond_3ad_stats stats; 276 276 u16 id; 277 + u16 port_priority; 277 278 }; 278 279 279 280 static inline const char *bond_3ad_churn_desc(churn_state_t state)
+1
include/net/bond_options.h
··· 78 78 BOND_OPT_PRIO, 79 79 BOND_OPT_COUPLED_CONTROL, 80 80 BOND_OPT_BROADCAST_NEIGH, 81 + BOND_OPT_ACTOR_PORT_PRIO, 81 82 BOND_OPT_LAST 82 83 }; 83 84
+1
include/uapi/linux/if_link.h
··· 1564 1564 IFLA_BOND_SLAVE_AD_ACTOR_OPER_PORT_STATE, 1565 1565 IFLA_BOND_SLAVE_AD_PARTNER_OPER_PORT_STATE, 1566 1566 IFLA_BOND_SLAVE_PRIO, 1567 + IFLA_BOND_SLAVE_ACTOR_PORT_PRIO, 1567 1568 __IFLA_BOND_SLAVE_MAX, 1568 1569 }; 1569 1570