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

bonding: support aggregator selection based on port priority

Add a new ad_select policy 'port_priority' that uses the per-port
actor priority values (set via ad_actor_port_prio) to determine
aggregator selection.

This allows administrators to influence which ports are preferred
for aggregation by assigning different priority values, providing
more flexible load balancing control in LACP configurations.

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

authored by

Hangbin Liu and committed by
Paolo Abeni
e5a66434 6b6dc81e

+45 -8
+12 -4
Documentation/networking/bonding.rst
··· 250 250 ports (slaves). Reselection occurs as described under the 251 251 "bandwidth" setting, above. 252 252 253 - The bandwidth and count selection policies permit failover of 254 - 802.3ad aggregations when partial failure of the active aggregator 255 - occurs. This keeps the aggregator with the highest availability 256 - (either in bandwidth or in number of ports) active at all times. 253 + actor_port_prio or 3 254 + 255 + The active aggregator is chosen by the highest total sum of 256 + actor port priorities across its active ports. Note this 257 + priority is actor_port_prio, not per port prio, which is 258 + used for primary reselect. 259 + 260 + The bandwidth, count and actor_port_prio selection policies permit 261 + failover of 802.3ad aggregations when partial failure of the active 262 + aggregator occurs. This keeps the aggregator with the highest 263 + availability (either in bandwidth, number of ports, or total value 264 + of port priorities) active at all times. 257 265 258 266 This option was added in bonding version 3.4.0. 259 267
+27
drivers/net/bonding/bond_3ad.c
··· 747 747 return active; 748 748 } 749 749 750 + static unsigned int __agg_ports_priority(const struct aggregator *agg) 751 + { 752 + struct port *port = agg->lag_ports; 753 + unsigned int prio = 0; 754 + 755 + for (; port; port = port->next_port_in_aggregator) 756 + if (port->is_enabled) 757 + prio += port->actor_port_priority; 758 + 759 + return prio; 760 + } 761 + 750 762 /** 751 763 * __get_agg_bandwidth - get the total bandwidth of an aggregator 752 764 * @aggregator: the aggregator we're looking at ··· 1720 1708 * 4. Therefore, current and best both have partner replies or 1721 1709 * both do not, so perform selection policy: 1722 1710 * 1711 + * BOND_AD_PRIO: Select by total priority of ports. If priority 1712 + * is equal, select by count. 1713 + * 1723 1714 * BOND_AD_COUNT: Select by count of ports. If count is equal, 1724 1715 * select by bandwidth. 1725 1716 * ··· 1744 1729 return best; 1745 1730 1746 1731 switch (__get_agg_selection_mode(curr->lag_ports)) { 1732 + case BOND_AD_PRIO: 1733 + if (__agg_ports_priority(curr) > __agg_ports_priority(best)) 1734 + return curr; 1735 + 1736 + if (__agg_ports_priority(curr) < __agg_ports_priority(best)) 1737 + return best; 1738 + 1739 + fallthrough; 1747 1740 case BOND_AD_COUNT: 1748 1741 if (__agg_active_ports(curr) > __agg_active_ports(best)) 1749 1742 return curr; ··· 1814 1791 * set of slaves in the bond changes. 1815 1792 * 1816 1793 * BOND_AD_COUNT: select the aggregator with largest number of ports 1794 + * (slaves), and reselect whenever a link state change takes place or the 1795 + * set of slaves in the bond changes. 1796 + * 1797 + * BOND_AD_PRIO: select the aggregator with highest total priority of ports 1817 1798 * (slaves), and reselect whenever a link state change takes place or the 1818 1799 * set of slaves in the bond changes. 1819 1800 *
+5 -4
drivers/net/bonding/bond_options.c
··· 162 162 }; 163 163 164 164 static const struct bond_opt_value bond_ad_select_tbl[] = { 165 - { "stable", BOND_AD_STABLE, BOND_VALFLAG_DEFAULT}, 166 - { "bandwidth", BOND_AD_BANDWIDTH, 0}, 167 - { "count", BOND_AD_COUNT, 0}, 168 - { NULL, -1, 0}, 165 + { "stable", BOND_AD_STABLE, BOND_VALFLAG_DEFAULT}, 166 + { "bandwidth", BOND_AD_BANDWIDTH, 0}, 167 + { "count", BOND_AD_COUNT, 0}, 168 + { "actor_port_prio", BOND_AD_PRIO, 0}, 169 + { NULL, -1, 0}, 169 170 }; 170 171 171 172 static const struct bond_opt_value bond_num_peer_notif_tbl[] = {
+1
include/net/bond_3ad.h
··· 26 26 BOND_AD_STABLE = 0, 27 27 BOND_AD_BANDWIDTH = 1, 28 28 BOND_AD_COUNT = 2, 29 + BOND_AD_PRIO = 3, 29 30 }; 30 31 31 32 /* rx machine states(43.4.11 in the 802.3ad standard) */