Skip to content

Commit 3a755cd

Browse files
liuhangbindavem330
authored andcommitted
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 2414d62 commit 3a755cd

File tree

12 files changed

+89
-10
lines changed

12 files changed

+89
-10
lines changed

Documentation/networking/bonding.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,18 @@ fail_over_mac
501501
This option was added in bonding version 3.2.0. The "follow"
502502
policy was added in bonding version 3.3.0.
503503

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+
504516
lacp_rate
505517

506518
Option specifying the rate in which we'll ask our link partner

drivers/net/bonding/bond_3ad.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ static int ad_marker_send(struct port *port, struct bond_marker *marker);
9696
static void ad_mux_machine(struct port *port, bool *update_slave_arr);
9797
static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port);
9898
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);
100100
static void ad_port_selection_logic(struct port *port, bool *update_slave_arr);
101101
static void ad_agg_selection_logic(struct aggregator *aggregator,
102102
bool *update_slave_arr);
@@ -1294,10 +1294,11 @@ static void ad_tx_machine(struct port *port)
12941294
/**
12951295
* ad_periodic_machine - handle a port's periodic state machine
12961296
* @port: the port we're looking at
1297+
* @bond_params: bond parameters we will use
12971298
*
12981299
* Turn ntt flag on priodically to perform periodic transmission of lacpdu's.
12991300
*/
1300-
static void ad_periodic_machine(struct port *port)
1301+
static void ad_periodic_machine(struct port *port, struct bond_params bond_params)
13011302
{
13021303
periodic_states_t last_state;
13031304

@@ -1306,8 +1307,8 @@ static void ad_periodic_machine(struct port *port)
13061307

13071308
/* check if port was reinitialized */
13081309
if (((port->sm_vars & AD_PORT_BEGIN) || !(port->sm_vars & AD_PORT_LACP_ENABLED) || !port->is_enabled) ||
1309-
(!(port->actor_oper_port_state & LACP_STATE_LACP_ACTIVITY) && !(port->partner_oper.port_state & LACP_STATE_LACP_ACTIVITY))
1310-
) {
1310+
(!(port->actor_oper_port_state & LACP_STATE_LACP_ACTIVITY) && !(port->partner_oper.port_state & LACP_STATE_LACP_ACTIVITY)) ||
1311+
!bond_params.lacp_active) {
13111312
port->sm_periodic_state = AD_NO_PERIODIC;
13121313
}
13131314
/* check if state machine should change state */
@@ -2341,7 +2342,7 @@ void bond_3ad_state_machine_handler(struct work_struct *work)
23412342
}
23422343

23432344
ad_rx_machine(NULL, port);
2344-
ad_periodic_machine(port);
2345+
ad_periodic_machine(port, bond->params);
23452346
ad_port_selection_logic(port, &update_slave_arr);
23462347
ad_mux_machine(port, &update_slave_arr);
23472348
ad_tx_machine(port);

drivers/net/bonding/bond_main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5478,6 +5478,7 @@ static int bond_check_params(struct bond_params *params)
54785478
params->downdelay = downdelay;
54795479
params->peer_notif_delay = 0;
54805480
params->use_carrier = use_carrier;
5481+
params->lacp_active = 1;
54815482
params->lacp_fast = lacp_fast;
54825483
params->primary[0] = 0;
54835484
params->primary_reselect = primary_reselect_value;

drivers/net/bonding/bond_netlink.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ static const struct nla_policy bond_policy[IFLA_BOND_MAX + 1] = {
100100
[IFLA_BOND_MIN_LINKS] = { .type = NLA_U32 },
101101
[IFLA_BOND_LP_INTERVAL] = { .type = NLA_U32 },
102102
[IFLA_BOND_PACKETS_PER_SLAVE] = { .type = NLA_U32 },
103+
[IFLA_BOND_AD_LACP_ACTIVE] = { .type = NLA_U8 },
103104
[IFLA_BOND_AD_LACP_RATE] = { .type = NLA_U8 },
104105
[IFLA_BOND_AD_SELECT] = { .type = NLA_U8 },
105106
[IFLA_BOND_AD_INFO] = { .type = NLA_NESTED },
@@ -387,6 +388,16 @@ static int bond_changelink(struct net_device *bond_dev, struct nlattr *tb[],
387388
if (err)
388389
return err;
389390
}
391+
392+
if (data[IFLA_BOND_AD_LACP_ACTIVE]) {
393+
int lacp_active = nla_get_u8(data[IFLA_BOND_AD_LACP_ACTIVE]);
394+
395+
bond_opt_initval(&newval, lacp_active);
396+
err = __bond_opt_set(bond, BOND_OPT_LACP_ACTIVE, &newval);
397+
if (err)
398+
return err;
399+
}
400+
390401
if (data[IFLA_BOND_AD_LACP_RATE]) {
391402
int lacp_rate =
392403
nla_get_u8(data[IFLA_BOND_AD_LACP_RATE]);
@@ -490,6 +501,7 @@ static size_t bond_get_size(const struct net_device *bond_dev)
490501
nla_total_size(sizeof(u32)) + /* IFLA_BOND_MIN_LINKS */
491502
nla_total_size(sizeof(u32)) + /* IFLA_BOND_LP_INTERVAL */
492503
nla_total_size(sizeof(u32)) + /* IFLA_BOND_PACKETS_PER_SLAVE */
504+
nla_total_size(sizeof(u8)) + /* IFLA_BOND_AD_LACP_ACTIVE */
493505
nla_total_size(sizeof(u8)) + /* IFLA_BOND_AD_LACP_RATE */
494506
nla_total_size(sizeof(u8)) + /* IFLA_BOND_AD_SELECT */
495507
nla_total_size(sizeof(struct nlattr)) + /* IFLA_BOND_AD_INFO */
@@ -622,6 +634,10 @@ static int bond_fill_info(struct sk_buff *skb,
622634
packets_per_slave))
623635
goto nla_put_failure;
624636

637+
if (nla_put_u8(skb, IFLA_BOND_AD_LACP_ACTIVE,
638+
bond->params.lacp_active))
639+
goto nla_put_failure;
640+
625641
if (nla_put_u8(skb, IFLA_BOND_AD_LACP_RATE,
626642
bond->params.lacp_fast))
627643
goto nla_put_failure;

drivers/net/bonding/bond_options.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ static int bond_option_lp_interval_set(struct bonding *bond,
5858
const struct bond_opt_value *newval);
5959
static int bond_option_pps_set(struct bonding *bond,
6060
const struct bond_opt_value *newval);
61+
static int bond_option_lacp_active_set(struct bonding *bond,
62+
const struct bond_opt_value *newval);
6163
static int bond_option_lacp_rate_set(struct bonding *bond,
6264
const struct bond_opt_value *newval);
6365
static int bond_option_ad_select_set(struct bonding *bond,
@@ -135,6 +137,12 @@ static const struct bond_opt_value bond_intmax_tbl[] = {
135137
{ NULL, -1, 0}
136138
};
137139

140+
static const struct bond_opt_value bond_lacp_active[] = {
141+
{ "off", 0, 0},
142+
{ "on", 1, BOND_VALFLAG_DEFAULT},
143+
{ NULL, -1, 0}
144+
};
145+
138146
static const struct bond_opt_value bond_lacp_rate_tbl[] = {
139147
{ "slow", AD_LACP_SLOW, 0},
140148
{ "fast", AD_LACP_FAST, 0},
@@ -283,6 +291,15 @@ static const struct bond_option bond_opts[BOND_OPT_LAST] = {
283291
.values = bond_intmax_tbl,
284292
.set = bond_option_updelay_set
285293
},
294+
[BOND_OPT_LACP_ACTIVE] = {
295+
.id = BOND_OPT_LACP_ACTIVE,
296+
.name = "lacp_active",
297+
.desc = "Send LACPDU frames with configured lacp rate or acts as speak when spoken to",
298+
.flags = BOND_OPTFLAG_IFDOWN,
299+
.unsuppmodes = BOND_MODE_ALL_EX(BIT(BOND_MODE_8023AD)),
300+
.values = bond_lacp_active,
301+
.set = bond_option_lacp_active_set
302+
},
286303
[BOND_OPT_LACP_RATE] = {
287304
.id = BOND_OPT_LACP_RATE,
288305
.name = "lacp_rate",
@@ -1333,6 +1350,16 @@ static int bond_option_pps_set(struct bonding *bond,
13331350
return 0;
13341351
}
13351352

1353+
static int bond_option_lacp_active_set(struct bonding *bond,
1354+
const struct bond_opt_value *newval)
1355+
{
1356+
netdev_dbg(bond->dev, "Setting LACP active to %s (%llu)\n",
1357+
newval->string, newval->value);
1358+
bond->params.lacp_active = newval->value;
1359+
1360+
return 0;
1361+
}
1362+
13361363
static int bond_option_lacp_rate_set(struct bonding *bond,
13371364
const struct bond_opt_value *newval)
13381365
{

drivers/net/bonding/bond_procfs.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ static void bond_info_show_master(struct seq_file *seq)
133133
struct ad_info ad_info;
134134

135135
seq_puts(seq, "\n802.3ad info\n");
136+
seq_printf(seq, "LACP active: %s\n",
137+
(bond->params.lacp_active) ? "on" : "off");
136138
seq_printf(seq, "LACP rate: %s\n",
137139
(bond->params.lacp_fast) ? "fast" : "slow");
138140
seq_printf(seq, "Min links: %d\n", bond->params.min_links);

drivers/net/bonding/bond_sysfs.c

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -339,10 +339,24 @@ static ssize_t bonding_show_peer_notif_delay(struct device *d,
339339
static DEVICE_ATTR(peer_notif_delay, 0644,
340340
bonding_show_peer_notif_delay, bonding_sysfs_store_option);
341341

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)
346360
{
347361
struct bonding *bond = to_bond(d);
348362
const struct bond_opt_value *val;
@@ -352,7 +366,7 @@ static ssize_t bonding_show_lacp(struct device *d,
352366
return sprintf(buf, "%s %d\n", val->string, bond->params.lacp_fast);
353367
}
354368
static DEVICE_ATTR(lacp_rate, 0644,
355-
bonding_show_lacp, bonding_sysfs_store_option);
369+
bonding_show_lacp_rate, bonding_sysfs_store_option);
356370

357371
static ssize_t bonding_show_min_links(struct device *d,
358372
struct device_attribute *attr,
@@ -738,6 +752,7 @@ static struct attribute *per_bond_attrs[] = {
738752
&dev_attr_downdelay.attr,
739753
&dev_attr_updelay.attr,
740754
&dev_attr_peer_notif_delay.attr,
755+
&dev_attr_lacp_active.attr,
741756
&dev_attr_lacp_rate.attr,
742757
&dev_attr_ad_select.attr,
743758
&dev_attr_xmit_hash_policy.attr,

include/net/bond_3ad.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ int __bond_3ad_get_active_agg_info(struct bonding *bond,
303303
int bond_3ad_lacpdu_recv(const struct sk_buff *skb, struct bonding *bond,
304304
struct slave *slave);
305305
int bond_3ad_set_carrier(struct bonding *bond);
306+
void bond_3ad_update_lacp_active(struct bonding *bond);
306307
void bond_3ad_update_lacp_rate(struct bonding *bond);
307308
void bond_3ad_update_ad_actor_settings(struct bonding *bond);
308309
int bond_3ad_stats_fill(struct sk_buff *skb, struct bond_3ad_stats *stats);

include/net/bond_options.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ enum {
6464
BOND_OPT_AD_USER_PORT_KEY,
6565
BOND_OPT_NUM_PEER_NOTIF_ALIAS,
6666
BOND_OPT_PEER_NOTIF_DELAY,
67+
BOND_OPT_LACP_ACTIVE,
6768
BOND_OPT_LAST
6869
};
6970

include/net/bonding.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ struct bond_params {
129129
int updelay;
130130
int downdelay;
131131
int peer_notif_delay;
132+
int lacp_active;
132133
int lacp_fast;
133134
unsigned int min_links;
134135
int ad_select;

include/uapi/linux/if_link.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -855,6 +855,7 @@ enum {
855855
IFLA_BOND_AD_ACTOR_SYSTEM,
856856
IFLA_BOND_TLB_DYNAMIC_LB,
857857
IFLA_BOND_PEER_NOTIF_DELAY,
858+
IFLA_BOND_AD_LACP_ACTIVE,
858859
__IFLA_BOND_MAX,
859860
};
860861

tools/include/uapi/linux/if_link.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,7 @@ enum {
653653
IFLA_BOND_AD_ACTOR_SYSTEM,
654654
IFLA_BOND_TLB_DYNAMIC_LB,
655655
IFLA_BOND_PEER_NOTIF_DELAY,
656+
IFLA_BOND_AD_LACP_ACTIVE,
656657
__IFLA_BOND_MAX,
657658
};
658659

0 commit comments

Comments
 (0)