Skip to content

Commit d5c8425

Browse files
sfeldma@cumulusnetworks.comdavem330
authored andcommitted
bonding: add arp_all_targets netlink support
Add IFLA_BOND_ARP_ALL_TARGETS to allow get/set of bonding parameter arp_all_targets via netlink. Signed-off-by: Scott Feldman <sfeldma@cumulusnetworks.com> Signed-off-by: Jiri Pirko <jiri@resnulli.us> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 29c4948 commit d5c8425

File tree

5 files changed

+37
-6
lines changed

5 files changed

+37
-6
lines changed

drivers/net/bonding/bond_netlink.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ static const struct nla_policy bond_policy[IFLA_BOND_MAX + 1] = {
3131
[IFLA_BOND_ARP_INTERVAL] = { .type = NLA_U32 },
3232
[IFLA_BOND_ARP_IP_TARGET] = { .type = NLA_NESTED },
3333
[IFLA_BOND_ARP_VALIDATE] = { .type = NLA_U32 },
34+
[IFLA_BOND_ARP_ALL_TARGETS] = { .type = NLA_U32 },
3435
};
3536

3637
static int bond_validate(struct nlattr *tb[], struct nlattr *data[])
@@ -145,6 +146,14 @@ static int bond_changelink(struct net_device *bond_dev,
145146
if (err)
146147
return err;
147148
}
149+
if (data[IFLA_BOND_ARP_ALL_TARGETS]) {
150+
int arp_all_targets =
151+
nla_get_u32(data[IFLA_BOND_ARP_ALL_TARGETS]);
152+
153+
err = bond_option_arp_all_targets_set(bond, arp_all_targets);
154+
if (err)
155+
return err;
156+
}
148157
return 0;
149158
}
150159

@@ -172,6 +181,7 @@ static size_t bond_get_size(const struct net_device *bond_dev)
172181
/* IFLA_BOND_ARP_IP_TARGET */
173182
nla_total_size(sizeof(u32)) * BOND_MAX_ARP_TARGETS +
174183
nla_total_size(sizeof(u32)) + /* IFLA_BOND_ARP_VALIDATE */
184+
nla_total_size(sizeof(u32)) + /* IFLA_BOND_ARP_ALL_TARGETS */
175185
0;
176186
}
177187

@@ -227,6 +237,10 @@ static int bond_fill_info(struct sk_buff *skb,
227237
if (nla_put_u32(skb, IFLA_BOND_ARP_VALIDATE, bond->params.arp_validate))
228238
goto nla_put_failure;
229239

240+
if (nla_put_u32(skb, IFLA_BOND_ARP_ALL_TARGETS,
241+
bond->params.arp_all_targets))
242+
goto nla_put_failure;
243+
230244
return 0;
231245

232246
nla_put_failure:

drivers/net/bonding/bond_options.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,3 +458,14 @@ int bond_option_arp_validate_set(struct bonding *bond, int arp_validate)
458458

459459
return 0;
460460
}
461+
462+
int bond_option_arp_all_targets_set(struct bonding *bond, int arp_all_targets)
463+
{
464+
pr_info("%s: setting arp_all_targets to %s (%d).\n",
465+
bond->dev->name, arp_all_targets_tbl[arp_all_targets].modename,
466+
arp_all_targets);
467+
468+
bond->params.arp_all_targets = arp_all_targets;
469+
470+
return 0;
471+
}

drivers/net/bonding/bond_sysfs.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -399,21 +399,25 @@ static ssize_t bonding_store_arp_all_targets(struct device *d,
399399
const char *buf, size_t count)
400400
{
401401
struct bonding *bond = to_bond(d);
402-
int new_value;
402+
int new_value, ret;
403403

404404
new_value = bond_parse_parm(buf, arp_all_targets_tbl);
405405
if (new_value < 0) {
406406
pr_err("%s: Ignoring invalid arp_all_targets value %s\n",
407407
bond->dev->name, buf);
408408
return -EINVAL;
409409
}
410-
pr_info("%s: setting arp_all_targets to %s (%d).\n",
411-
bond->dev->name, arp_all_targets_tbl[new_value].modename,
412-
new_value);
413410

414-
bond->params.arp_all_targets = new_value;
411+
if (!rtnl_trylock())
412+
return restart_syscall();
415413

416-
return count;
414+
ret = bond_option_arp_all_targets_set(bond, new_value);
415+
if (!ret)
416+
ret = count;
417+
418+
rtnl_unlock();
419+
420+
return ret;
417421
}
418422

419423
static DEVICE_ATTR(arp_all_targets, S_IRUGO | S_IWUSR,

drivers/net/bonding/bonding.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,7 @@ int bond_option_arp_ip_targets_set(struct bonding *bond, __be32 *targets,
449449
int bond_option_arp_ip_target_add(struct bonding *bond, __be32 target);
450450
int bond_option_arp_ip_target_rem(struct bonding *bond, __be32 target);
451451
int bond_option_arp_validate_set(struct bonding *bond, int arp_validate);
452+
int bond_option_arp_all_targets_set(struct bonding *bond, int arp_all_targets);
452453
struct net_device *bond_option_active_slave_get_rcu(struct bonding *bond);
453454
struct net_device *bond_option_active_slave_get(struct bonding *bond);
454455

include/uapi/linux/if_link.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ enum {
338338
IFLA_BOND_ARP_INTERVAL,
339339
IFLA_BOND_ARP_IP_TARGET,
340340
IFLA_BOND_ARP_VALIDATE,
341+
IFLA_BOND_ARP_ALL_TARGETS,
341342
__IFLA_BOND_MAX,
342343
};
343344

0 commit comments

Comments
 (0)