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

bonding: add new option lacp_active

Add an option lacp_active, which is similar with team's runner.active.
This option specifies whether to send LACPDU frames periodically. If set
on, the LACPDU frames are sent along with the configured lacp_rate
setting. If set off, the LACPDU frames acts as "speak when spoken to".

Note, the LACPDU state frames still will be sent when init or unbind port.

v2: remove module parameter

Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Hangbin Liu and committed by
David S. Miller
3a755cd8 2414d628

+89 -10
+12
Documentation/networking/bonding.rst
··· 501 501 This option was added in bonding version 3.2.0. The "follow" 502 502 policy was added in bonding version 3.3.0. 503 503 504 + lacp_active 505 + Option specifying whether to send LACPDU frames periodically. 506 + 507 + off or 0 508 + LACPDU frames acts as "speak when spoken to". 509 + 510 + on or 1 511 + LACPDU frames are sent along the configured links 512 + periodically. See lacp_rate for more details. 513 + 514 + The default is on. 515 + 504 516 lacp_rate 505 517 506 518 Option specifying the rate in which we'll ask our link partner
+6 -5
drivers/net/bonding/bond_3ad.c
··· 96 96 static void ad_mux_machine(struct port *port, bool *update_slave_arr); 97 97 static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port); 98 98 static void ad_tx_machine(struct port *port); 99 - static void ad_periodic_machine(struct port *port); 99 + static void ad_periodic_machine(struct port *port, struct bond_params bond_params); 100 100 static void ad_port_selection_logic(struct port *port, bool *update_slave_arr); 101 101 static void ad_agg_selection_logic(struct aggregator *aggregator, 102 102 bool *update_slave_arr); ··· 1294 1294 /** 1295 1295 * ad_periodic_machine - handle a port's periodic state machine 1296 1296 * @port: the port we're looking at 1297 + * @bond_params: bond parameters we will use 1297 1298 * 1298 1299 * Turn ntt flag on priodically to perform periodic transmission of lacpdu's. 1299 1300 */ 1300 - static void ad_periodic_machine(struct port *port) 1301 + static void ad_periodic_machine(struct port *port, struct bond_params bond_params) 1301 1302 { 1302 1303 periodic_states_t last_state; 1303 1304 ··· 1307 1306 1308 1307 /* check if port was reinitialized */ 1309 1308 if (((port->sm_vars & AD_PORT_BEGIN) || !(port->sm_vars & AD_PORT_LACP_ENABLED) || !port->is_enabled) || 1310 - (!(port->actor_oper_port_state & LACP_STATE_LACP_ACTIVITY) && !(port->partner_oper.port_state & LACP_STATE_LACP_ACTIVITY)) 1311 - ) { 1309 + (!(port->actor_oper_port_state & LACP_STATE_LACP_ACTIVITY) && !(port->partner_oper.port_state & LACP_STATE_LACP_ACTIVITY)) || 1310 + !bond_params.lacp_active) { 1312 1311 port->sm_periodic_state = AD_NO_PERIODIC; 1313 1312 } 1314 1313 /* check if state machine should change state */ ··· 2342 2341 } 2343 2342 2344 2343 ad_rx_machine(NULL, port); 2345 - ad_periodic_machine(port); 2344 + ad_periodic_machine(port, bond->params); 2346 2345 ad_port_selection_logic(port, &update_slave_arr); 2347 2346 ad_mux_machine(port, &update_slave_arr); 2348 2347 ad_tx_machine(port);
+1
drivers/net/bonding/bond_main.c
··· 5478 5478 params->downdelay = downdelay; 5479 5479 params->peer_notif_delay = 0; 5480 5480 params->use_carrier = use_carrier; 5481 + params->lacp_active = 1; 5481 5482 params->lacp_fast = lacp_fast; 5482 5483 params->primary[0] = 0; 5483 5484 params->primary_reselect = primary_reselect_value;
+16
drivers/net/bonding/bond_netlink.c
··· 100 100 [IFLA_BOND_MIN_LINKS] = { .type = NLA_U32 }, 101 101 [IFLA_BOND_LP_INTERVAL] = { .type = NLA_U32 }, 102 102 [IFLA_BOND_PACKETS_PER_SLAVE] = { .type = NLA_U32 }, 103 + [IFLA_BOND_AD_LACP_ACTIVE] = { .type = NLA_U8 }, 103 104 [IFLA_BOND_AD_LACP_RATE] = { .type = NLA_U8 }, 104 105 [IFLA_BOND_AD_SELECT] = { .type = NLA_U8 }, 105 106 [IFLA_BOND_AD_INFO] = { .type = NLA_NESTED }, ··· 388 387 if (err) 389 388 return err; 390 389 } 390 + 391 + if (data[IFLA_BOND_AD_LACP_ACTIVE]) { 392 + int lacp_active = nla_get_u8(data[IFLA_BOND_AD_LACP_ACTIVE]); 393 + 394 + bond_opt_initval(&newval, lacp_active); 395 + err = __bond_opt_set(bond, BOND_OPT_LACP_ACTIVE, &newval); 396 + if (err) 397 + return err; 398 + } 399 + 391 400 if (data[IFLA_BOND_AD_LACP_RATE]) { 392 401 int lacp_rate = 393 402 nla_get_u8(data[IFLA_BOND_AD_LACP_RATE]); ··· 501 490 nla_total_size(sizeof(u32)) + /* IFLA_BOND_MIN_LINKS */ 502 491 nla_total_size(sizeof(u32)) + /* IFLA_BOND_LP_INTERVAL */ 503 492 nla_total_size(sizeof(u32)) + /* IFLA_BOND_PACKETS_PER_SLAVE */ 493 + nla_total_size(sizeof(u8)) + /* IFLA_BOND_AD_LACP_ACTIVE */ 504 494 nla_total_size(sizeof(u8)) + /* IFLA_BOND_AD_LACP_RATE */ 505 495 nla_total_size(sizeof(u8)) + /* IFLA_BOND_AD_SELECT */ 506 496 nla_total_size(sizeof(struct nlattr)) + /* IFLA_BOND_AD_INFO */ ··· 632 620 packets_per_slave = bond->params.packets_per_slave; 633 621 if (nla_put_u32(skb, IFLA_BOND_PACKETS_PER_SLAVE, 634 622 packets_per_slave)) 623 + goto nla_put_failure; 624 + 625 + if (nla_put_u8(skb, IFLA_BOND_AD_LACP_ACTIVE, 626 + bond->params.lacp_active)) 635 627 goto nla_put_failure; 636 628 637 629 if (nla_put_u8(skb, IFLA_BOND_AD_LACP_RATE,
+27
drivers/net/bonding/bond_options.c
··· 58 58 const struct bond_opt_value *newval); 59 59 static int bond_option_pps_set(struct bonding *bond, 60 60 const struct bond_opt_value *newval); 61 + static int bond_option_lacp_active_set(struct bonding *bond, 62 + const struct bond_opt_value *newval); 61 63 static int bond_option_lacp_rate_set(struct bonding *bond, 62 64 const struct bond_opt_value *newval); 63 65 static int bond_option_ad_select_set(struct bonding *bond, ··· 135 133 { "off", 0, BOND_VALFLAG_DEFAULT}, 136 134 { "maxval", INT_MAX, BOND_VALFLAG_MAX}, 137 135 { NULL, -1, 0} 136 + }; 137 + 138 + static const struct bond_opt_value bond_lacp_active[] = { 139 + { "off", 0, 0}, 140 + { "on", 1, BOND_VALFLAG_DEFAULT}, 141 + { NULL, -1, 0} 138 142 }; 139 143 140 144 static const struct bond_opt_value bond_lacp_rate_tbl[] = { ··· 290 282 .desc = "Delay before considering link up, in milliseconds", 291 283 .values = bond_intmax_tbl, 292 284 .set = bond_option_updelay_set 285 + }, 286 + [BOND_OPT_LACP_ACTIVE] = { 287 + .id = BOND_OPT_LACP_ACTIVE, 288 + .name = "lacp_active", 289 + .desc = "Send LACPDU frames with configured lacp rate or acts as speak when spoken to", 290 + .flags = BOND_OPTFLAG_IFDOWN, 291 + .unsuppmodes = BOND_MODE_ALL_EX(BIT(BOND_MODE_8023AD)), 292 + .values = bond_lacp_active, 293 + .set = bond_option_lacp_active_set 293 294 }, 294 295 [BOND_OPT_LACP_RATE] = { 295 296 .id = BOND_OPT_LACP_RATE, ··· 1346 1329 bond->params.reciprocal_packets_per_slave = 1347 1330 (struct reciprocal_value) { 0 }; 1348 1331 } 1332 + 1333 + return 0; 1334 + } 1335 + 1336 + static int bond_option_lacp_active_set(struct bonding *bond, 1337 + const struct bond_opt_value *newval) 1338 + { 1339 + netdev_dbg(bond->dev, "Setting LACP active to %s (%llu)\n", 1340 + newval->string, newval->value); 1341 + bond->params.lacp_active = newval->value; 1349 1342 1350 1343 return 0; 1351 1344 }
+2
drivers/net/bonding/bond_procfs.c
··· 133 133 struct ad_info ad_info; 134 134 135 135 seq_puts(seq, "\n802.3ad info\n"); 136 + seq_printf(seq, "LACP active: %s\n", 137 + (bond->params.lacp_active) ? "on" : "off"); 136 138 seq_printf(seq, "LACP rate: %s\n", 137 139 (bond->params.lacp_fast) ? "fast" : "slow"); 138 140 seq_printf(seq, "Min links: %d\n", bond->params.min_links);
+20 -5
drivers/net/bonding/bond_sysfs.c
··· 339 339 static DEVICE_ATTR(peer_notif_delay, 0644, 340 340 bonding_show_peer_notif_delay, bonding_sysfs_store_option); 341 341 342 - /* Show the LACP interval. */ 343 - static ssize_t bonding_show_lacp(struct device *d, 344 - struct device_attribute *attr, 345 - char *buf) 342 + /* Show the LACP activity and interval. */ 343 + static ssize_t bonding_show_lacp_active(struct device *d, 344 + struct device_attribute *attr, 345 + char *buf) 346 + { 347 + struct bonding *bond = to_bond(d); 348 + const struct bond_opt_value *val; 349 + 350 + val = bond_opt_get_val(BOND_OPT_LACP_ACTIVE, bond->params.lacp_active); 351 + 352 + return sprintf(buf, "%s %d\n", val->string, bond->params.lacp_active); 353 + } 354 + static DEVICE_ATTR(lacp_active, 0644, 355 + bonding_show_lacp_active, bonding_sysfs_store_option); 356 + 357 + static ssize_t bonding_show_lacp_rate(struct device *d, 358 + struct device_attribute *attr, 359 + char *buf) 346 360 { 347 361 struct bonding *bond = to_bond(d); 348 362 const struct bond_opt_value *val; ··· 366 352 return sprintf(buf, "%s %d\n", val->string, bond->params.lacp_fast); 367 353 } 368 354 static DEVICE_ATTR(lacp_rate, 0644, 369 - bonding_show_lacp, bonding_sysfs_store_option); 355 + bonding_show_lacp_rate, bonding_sysfs_store_option); 370 356 371 357 static ssize_t bonding_show_min_links(struct device *d, 372 358 struct device_attribute *attr, ··· 752 738 &dev_attr_downdelay.attr, 753 739 &dev_attr_updelay.attr, 754 740 &dev_attr_peer_notif_delay.attr, 741 + &dev_attr_lacp_active.attr, 755 742 &dev_attr_lacp_rate.attr, 756 743 &dev_attr_ad_select.attr, 757 744 &dev_attr_xmit_hash_policy.attr,
+1
include/net/bond_3ad.h
··· 303 303 int bond_3ad_lacpdu_recv(const struct sk_buff *skb, struct bonding *bond, 304 304 struct slave *slave); 305 305 int bond_3ad_set_carrier(struct bonding *bond); 306 + void bond_3ad_update_lacp_active(struct bonding *bond); 306 307 void bond_3ad_update_lacp_rate(struct bonding *bond); 307 308 void bond_3ad_update_ad_actor_settings(struct bonding *bond); 308 309 int bond_3ad_stats_fill(struct sk_buff *skb, struct bond_3ad_stats *stats);
+1
include/net/bond_options.h
··· 64 64 BOND_OPT_AD_USER_PORT_KEY, 65 65 BOND_OPT_NUM_PEER_NOTIF_ALIAS, 66 66 BOND_OPT_PEER_NOTIF_DELAY, 67 + BOND_OPT_LACP_ACTIVE, 67 68 BOND_OPT_LAST 68 69 }; 69 70
+1
include/net/bonding.h
··· 129 129 int updelay; 130 130 int downdelay; 131 131 int peer_notif_delay; 132 + int lacp_active; 132 133 int lacp_fast; 133 134 unsigned int min_links; 134 135 int ad_select;
+1
include/uapi/linux/if_link.h
··· 855 855 IFLA_BOND_AD_ACTOR_SYSTEM, 856 856 IFLA_BOND_TLB_DYNAMIC_LB, 857 857 IFLA_BOND_PEER_NOTIF_DELAY, 858 + IFLA_BOND_AD_LACP_ACTIVE, 858 859 __IFLA_BOND_MAX, 859 860 }; 860 861
+1
tools/include/uapi/linux/if_link.h
··· 653 653 IFLA_BOND_AD_ACTOR_SYSTEM, 654 654 IFLA_BOND_TLB_DYNAMIC_LB, 655 655 IFLA_BOND_PEER_NOTIF_DELAY, 656 + IFLA_BOND_AD_LACP_ACTIVE, 656 657 __IFLA_BOND_MAX, 657 658 }; 658 659