Skip to content

Commit 5944b5a

Browse files
liuhangbindavem330
authored andcommitted
Bonding: add arp_missed_max option
Currently, we use hard code number to verify if we are in the arp_interval timeslice. But some user may want to reduce/extend the verify timeslice. With the similar team option 'missed_max' the uers could change that number based on their own environment. Acked-by: Jay Vosburgh <[email protected]> Signed-off-by: Hangbin Liu <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 2680ce7 commit 5944b5a

File tree

10 files changed

+82
-8
lines changed

10 files changed

+82
-8
lines changed

Documentation/networking/bonding.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,17 @@ arp_all_targets
421421
consider the slave up only when all of the arp_ip_targets
422422
are reachable
423423

424+
arp_missed_max
425+
426+
Specifies the number of arp_interval monitor checks that must
427+
fail in order for an interface to be marked down by the ARP monitor.
428+
429+
In order to provide orderly failover semantics, backup interfaces
430+
are permitted an extra monitor check (i.e., they must fail
431+
arp_missed_max + 1 times before being marked down).
432+
433+
The default value is 2, and the allowable range is 1 - 255.
434+
424435
downdelay
425436

426437
Specifies the time, in milliseconds, to wait before disabling

drivers/net/bonding/bond_main.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3129,8 +3129,8 @@ static void bond_loadbalance_arp_mon(struct bonding *bond)
31293129
* when the source ip is 0, so don't take the link down
31303130
* if we don't know our ip yet
31313131
*/
3132-
if (!bond_time_in_interval(bond, trans_start, 2) ||
3133-
!bond_time_in_interval(bond, slave->last_rx, 2)) {
3132+
if (!bond_time_in_interval(bond, trans_start, bond->params.missed_max) ||
3133+
!bond_time_in_interval(bond, slave->last_rx, bond->params.missed_max)) {
31343134

31353135
bond_propose_link_state(slave, BOND_LINK_DOWN);
31363136
slave_state_changed = 1;
@@ -3224,7 +3224,7 @@ static int bond_ab_arp_inspect(struct bonding *bond)
32243224

32253225
/* Backup slave is down if:
32263226
* - No current_arp_slave AND
3227-
* - more than 3*delta since last receive AND
3227+
* - more than (missed_max+1)*delta since last receive AND
32283228
* - the bond has an IP address
32293229
*
32303230
* Note: a non-null current_arp_slave indicates
@@ -3236,20 +3236,20 @@ static int bond_ab_arp_inspect(struct bonding *bond)
32363236
*/
32373237
if (!bond_is_active_slave(slave) &&
32383238
!rcu_access_pointer(bond->current_arp_slave) &&
3239-
!bond_time_in_interval(bond, last_rx, 3)) {
3239+
!bond_time_in_interval(bond, last_rx, bond->params.missed_max + 1)) {
32403240
bond_propose_link_state(slave, BOND_LINK_DOWN);
32413241
commit++;
32423242
}
32433243

32443244
/* Active slave is down if:
3245-
* - more than 2*delta since transmitting OR
3246-
* - (more than 2*delta since receive AND
3245+
* - more than missed_max*delta since transmitting OR
3246+
* - (more than missed_max*delta since receive AND
32473247
* the bond has an IP address)
32483248
*/
32493249
trans_start = dev_trans_start(slave->dev);
32503250
if (bond_is_active_slave(slave) &&
3251-
(!bond_time_in_interval(bond, trans_start, 2) ||
3252-
!bond_time_in_interval(bond, last_rx, 2))) {
3251+
(!bond_time_in_interval(bond, trans_start, bond->params.missed_max) ||
3252+
!bond_time_in_interval(bond, last_rx, bond->params.missed_max))) {
32533253
bond_propose_link_state(slave, BOND_LINK_DOWN);
32543254
commit++;
32553255
}
@@ -5822,6 +5822,7 @@ static int bond_check_params(struct bond_params *params)
58225822
params->arp_interval = arp_interval;
58235823
params->arp_validate = arp_validate_value;
58245824
params->arp_all_targets = arp_all_targets_value;
5825+
params->missed_max = 2;
58255826
params->updelay = updelay;
58265827
params->downdelay = downdelay;
58275828
params->peer_notif_delay = 0;

drivers/net/bonding/bond_netlink.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ static const struct nla_policy bond_policy[IFLA_BOND_MAX + 1] = {
110110
.len = ETH_ALEN },
111111
[IFLA_BOND_TLB_DYNAMIC_LB] = { .type = NLA_U8 },
112112
[IFLA_BOND_PEER_NOTIF_DELAY] = { .type = NLA_U32 },
113+
[IFLA_BOND_MISSED_MAX] = { .type = NLA_U8 },
113114
};
114115

115116
static const struct nla_policy bond_slave_policy[IFLA_BOND_SLAVE_MAX + 1] = {
@@ -453,6 +454,15 @@ static int bond_changelink(struct net_device *bond_dev, struct nlattr *tb[],
453454
return err;
454455
}
455456

457+
if (data[IFLA_BOND_MISSED_MAX]) {
458+
int missed_max = nla_get_u8(data[IFLA_BOND_MISSED_MAX]);
459+
460+
bond_opt_initval(&newval, missed_max);
461+
err = __bond_opt_set(bond, BOND_OPT_MISSED_MAX, &newval);
462+
if (err)
463+
return err;
464+
}
465+
456466
return 0;
457467
}
458468

@@ -515,6 +525,7 @@ static size_t bond_get_size(const struct net_device *bond_dev)
515525
nla_total_size(ETH_ALEN) + /* IFLA_BOND_AD_ACTOR_SYSTEM */
516526
nla_total_size(sizeof(u8)) + /* IFLA_BOND_TLB_DYNAMIC_LB */
517527
nla_total_size(sizeof(u32)) + /* IFLA_BOND_PEER_NOTIF_DELAY */
528+
nla_total_size(sizeof(u8)) + /* IFLA_BOND_MISSED_MAX */
518529
0;
519530
}
520531

@@ -650,6 +661,10 @@ static int bond_fill_info(struct sk_buff *skb,
650661
bond->params.tlb_dynamic_lb))
651662
goto nla_put_failure;
652663

664+
if (nla_put_u8(skb, IFLA_BOND_MISSED_MAX,
665+
bond->params.missed_max))
666+
goto nla_put_failure;
667+
653668
if (BOND_MODE(bond) == BOND_MODE_8023AD) {
654669
struct ad_info info;
655670

drivers/net/bonding/bond_options.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ static int bond_option_ad_actor_system_set(struct bonding *bond,
7878
const struct bond_opt_value *newval);
7979
static int bond_option_ad_user_port_key_set(struct bonding *bond,
8080
const struct bond_opt_value *newval);
81+
static int bond_option_missed_max_set(struct bonding *bond,
82+
const struct bond_opt_value *newval);
8183

8284

8385
static const struct bond_opt_value bond_mode_tbl[] = {
@@ -213,6 +215,13 @@ static const struct bond_opt_value bond_ad_user_port_key_tbl[] = {
213215
{ NULL, -1, 0},
214216
};
215217

218+
static const struct bond_opt_value bond_missed_max_tbl[] = {
219+
{ "minval", 1, BOND_VALFLAG_MIN},
220+
{ "maxval", 255, BOND_VALFLAG_MAX},
221+
{ "default", 2, BOND_VALFLAG_DEFAULT},
222+
{ NULL, -1, 0},
223+
};
224+
216225
static const struct bond_option bond_opts[BOND_OPT_LAST] = {
217226
[BOND_OPT_MODE] = {
218227
.id = BOND_OPT_MODE,
@@ -270,6 +279,15 @@ static const struct bond_option bond_opts[BOND_OPT_LAST] = {
270279
.values = bond_intmax_tbl,
271280
.set = bond_option_arp_interval_set
272281
},
282+
[BOND_OPT_MISSED_MAX] = {
283+
.id = BOND_OPT_MISSED_MAX,
284+
.name = "arp_missed_max",
285+
.desc = "Maximum number of missed ARP interval",
286+
.unsuppmodes = BIT(BOND_MODE_8023AD) | BIT(BOND_MODE_TLB) |
287+
BIT(BOND_MODE_ALB),
288+
.values = bond_missed_max_tbl,
289+
.set = bond_option_missed_max_set
290+
},
273291
[BOND_OPT_ARP_TARGETS] = {
274292
.id = BOND_OPT_ARP_TARGETS,
275293
.name = "arp_ip_target",
@@ -1186,6 +1204,16 @@ static int bond_option_arp_all_targets_set(struct bonding *bond,
11861204
return 0;
11871205
}
11881206

1207+
static int bond_option_missed_max_set(struct bonding *bond,
1208+
const struct bond_opt_value *newval)
1209+
{
1210+
netdev_dbg(bond->dev, "Setting missed max to %s (%llu)\n",
1211+
newval->string, newval->value);
1212+
bond->params.missed_max = newval->value;
1213+
1214+
return 0;
1215+
}
1216+
11891217
static int bond_option_primary_set(struct bonding *bond,
11901218
const struct bond_opt_value *newval)
11911219
{

drivers/net/bonding/bond_procfs.c

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

116116
seq_printf(seq, "ARP Polling Interval (ms): %d\n",
117117
bond->params.arp_interval);
118+
seq_printf(seq, "ARP Missed Max: %u\n",
119+
bond->params.missed_max);
118120

119121
seq_printf(seq, "ARP IP target/s (n.n.n.n form):");
120122

drivers/net/bonding/bond_sysfs.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,18 @@ static ssize_t bonding_show_arp_targets(struct device *d,
303303
static DEVICE_ATTR(arp_ip_target, 0644,
304304
bonding_show_arp_targets, bonding_sysfs_store_option);
305305

306+
/* Show the arp missed max. */
307+
static ssize_t bonding_show_missed_max(struct device *d,
308+
struct device_attribute *attr,
309+
char *buf)
310+
{
311+
struct bonding *bond = to_bond(d);
312+
313+
return sprintf(buf, "%u\n", bond->params.missed_max);
314+
}
315+
static DEVICE_ATTR(arp_missed_max, 0644,
316+
bonding_show_missed_max, bonding_sysfs_store_option);
317+
306318
/* Show the up and down delays. */
307319
static ssize_t bonding_show_downdelay(struct device *d,
308320
struct device_attribute *attr,
@@ -779,6 +791,7 @@ static struct attribute *per_bond_attrs[] = {
779791
&dev_attr_ad_actor_sys_prio.attr,
780792
&dev_attr_ad_actor_system.attr,
781793
&dev_attr_ad_user_port_key.attr,
794+
&dev_attr_arp_missed_max.attr,
782795
NULL,
783796
};
784797

include/net/bond_options.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ enum {
6565
BOND_OPT_NUM_PEER_NOTIF_ALIAS,
6666
BOND_OPT_PEER_NOTIF_DELAY,
6767
BOND_OPT_LACP_ACTIVE,
68+
BOND_OPT_MISSED_MAX,
6869
BOND_OPT_LAST
6970
};
7071

include/net/bonding.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ struct bond_params {
121121
int xmit_policy;
122122
int miimon;
123123
u8 num_peer_notif;
124+
u8 missed_max;
124125
int arp_interval;
125126
int arp_validate;
126127
int arp_all_targets;

include/uapi/linux/if_link.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -858,6 +858,7 @@ enum {
858858
IFLA_BOND_TLB_DYNAMIC_LB,
859859
IFLA_BOND_PEER_NOTIF_DELAY,
860860
IFLA_BOND_AD_LACP_ACTIVE,
861+
IFLA_BOND_MISSED_MAX,
861862
__IFLA_BOND_MAX,
862863
};
863864

tools/include/uapi/linux/if_link.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -858,6 +858,7 @@ enum {
858858
IFLA_BOND_TLB_DYNAMIC_LB,
859859
IFLA_BOND_PEER_NOTIF_DELAY,
860860
IFLA_BOND_AD_LACP_ACTIVE,
861+
IFLA_BOND_MISSED_MAX,
861862
__IFLA_BOND_MAX,
862863
};
863864

0 commit comments

Comments
 (0)