Skip to content

Commit 0f7bffd

Browse files
Nikolay Aleksandrovdavem330
authored andcommitted
bonding: add tlb_dynamic_lb netlink support
tlb_dynamic_lb could be set only via sysfs, this patch allows it to be set via netlink. Signed-off-by: Nikolay Aleksandrov <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent b7a0925 commit 0f7bffd

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

drivers/net/bonding/bond_netlink.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ static const struct nla_policy bond_policy[IFLA_BOND_MAX + 1] = {
111111
[IFLA_BOND_AD_USER_PORT_KEY] = { .type = NLA_U16 },
112112
[IFLA_BOND_AD_ACTOR_SYSTEM] = { .type = NLA_BINARY,
113113
.len = ETH_ALEN },
114+
[IFLA_BOND_TLB_DYNAMIC_LB] = { .type = NLA_U8 },
114115
};
115116

116117
static const struct nla_policy bond_slave_policy[IFLA_BOND_SLAVE_MAX + 1] = {
@@ -405,7 +406,6 @@ static int bond_changelink(struct net_device *bond_dev,
405406
if (err)
406407
return err;
407408
}
408-
409409
if (data[IFLA_BOND_AD_USER_PORT_KEY]) {
410410
int port_key =
411411
nla_get_u16(data[IFLA_BOND_AD_USER_PORT_KEY]);
@@ -415,7 +415,6 @@ static int bond_changelink(struct net_device *bond_dev,
415415
if (err)
416416
return err;
417417
}
418-
419418
if (data[IFLA_BOND_AD_ACTOR_SYSTEM]) {
420419
if (nla_len(data[IFLA_BOND_AD_ACTOR_SYSTEM]) != ETH_ALEN)
421420
return -EINVAL;
@@ -426,6 +425,15 @@ static int bond_changelink(struct net_device *bond_dev,
426425
if (err)
427426
return err;
428427
}
428+
if (data[IFLA_BOND_TLB_DYNAMIC_LB]) {
429+
int dynamic_lb = nla_get_u8(data[IFLA_BOND_TLB_DYNAMIC_LB]);
430+
431+
bond_opt_initval(&newval, dynamic_lb);
432+
err = __bond_opt_set(bond, BOND_OPT_TLB_DYNAMIC_LB, &newval);
433+
if (err)
434+
return err;
435+
}
436+
429437
return 0;
430438
}
431439

@@ -476,6 +484,7 @@ static size_t bond_get_size(const struct net_device *bond_dev)
476484
nla_total_size(sizeof(u16)) + /* IFLA_BOND_AD_ACTOR_SYS_PRIO */
477485
nla_total_size(sizeof(u16)) + /* IFLA_BOND_AD_USER_PORT_KEY */
478486
nla_total_size(ETH_ALEN) + /* IFLA_BOND_AD_ACTOR_SYSTEM */
487+
nla_total_size(sizeof(u8)) + /* IFLA_BOND_TLB_DYNAMIC_LB */
479488
0;
480489
}
481490

@@ -598,6 +607,10 @@ static int bond_fill_info(struct sk_buff *skb,
598607
bond->params.ad_select))
599608
goto nla_put_failure;
600609

610+
if (nla_put_u8(skb, IFLA_BOND_TLB_DYNAMIC_LB,
611+
bond->params.tlb_dynamic_lb))
612+
goto nla_put_failure;
613+
601614
if (BOND_MODE(bond) == BOND_MODE_8023AD) {
602615
struct ad_info info;
603616

include/uapi/linux/if_link.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,7 @@ enum {
434434
IFLA_BOND_AD_ACTOR_SYS_PRIO,
435435
IFLA_BOND_AD_USER_PORT_KEY,
436436
IFLA_BOND_AD_ACTOR_SYSTEM,
437+
IFLA_BOND_TLB_DYNAMIC_LB,
437438
__IFLA_BOND_MAX,
438439
};
439440

0 commit comments

Comments
 (0)