diff options
author | sfeldma@cumulusnetworks.com <sfeldma@cumulusnetworks.com> | 2013-12-17 21:30:37 -0800 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-12-19 18:32:10 -0500 |
commit | c13ab3ff176eab78b6ee93817484584af5807cf2 (patch) | |
tree | bd02fab1dc6136cfd9f3b8cf2a5ef7619dbb8a7c /drivers/net/bonding/bond_netlink.c | |
parent | 8d836d092ed7b77d13ac1108399165ee7de7463f (diff) | |
download | op-kernel-dev-c13ab3ff176eab78b6ee93817484584af5807cf2.zip op-kernel-dev-c13ab3ff176eab78b6ee93817484584af5807cf2.tar.gz |
bonding: add packets_per_slave attribute netlink support
Add IFLA_BOND_PACKETS_PER_SLAVE to allow get/set of bonding parameter
packets_per_slave 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>
Diffstat (limited to 'drivers/net/bonding/bond_netlink.c')
-rw-r--r-- | drivers/net/bonding/bond_netlink.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/drivers/net/bonding/bond_netlink.c b/drivers/net/bonding/bond_netlink.c index 6c8339b..84acd144 100644 --- a/drivers/net/bonding/bond_netlink.c +++ b/drivers/net/bonding/bond_netlink.c @@ -19,6 +19,7 @@ #include <linux/if_ether.h> #include <net/netlink.h> #include <net/rtnetlink.h> +#include <linux/reciprocal_div.h> #include "bonding.h" static const struct nla_policy bond_policy[IFLA_BOND_MAX + 1] = { @@ -41,6 +42,7 @@ static const struct nla_policy bond_policy[IFLA_BOND_MAX + 1] = { [IFLA_BOND_ALL_SLAVES_ACTIVE] = { .type = NLA_U8 }, [IFLA_BOND_MIN_LINKS] = { .type = NLA_U32 }, [IFLA_BOND_LP_INTERVAL] = { .type = NLA_U32 }, + [IFLA_BOND_PACKETS_PER_SLAVE] = { .type = NLA_U32 }, }; static int bond_validate(struct nlattr *tb[], struct nlattr *data[]) @@ -241,6 +243,15 @@ static int bond_changelink(struct net_device *bond_dev, if (err) return err; } + if (data[IFLA_BOND_PACKETS_PER_SLAVE]) { + int packets_per_slave = + nla_get_u32(data[IFLA_BOND_PACKETS_PER_SLAVE]); + + err = bond_option_packets_per_slave_set(bond, + packets_per_slave); + if (err) + return err; + } return 0; } @@ -278,6 +289,7 @@ static size_t bond_get_size(const struct net_device *bond_dev) nla_total_size(sizeof(u8)) + /* IFLA_BOND_ALL_SLAVES_ACTIVE */ nla_total_size(sizeof(u32)) + /* IFLA_BOND_MIN_LINKS */ nla_total_size(sizeof(u32)) + /* IFLA_BOND_LP_INTERVAL */ + nla_total_size(sizeof(u32)) + /* IFLA_BOND_PACKETS_PER_SLAVE */ 0; } @@ -287,6 +299,7 @@ static int bond_fill_info(struct sk_buff *skb, struct bonding *bond = netdev_priv(bond_dev); struct net_device *slave_dev = bond_option_active_slave_get(bond); struct nlattr *targets; + unsigned int packets_per_slave; int i, targets_added; if (nla_put_u8(skb, IFLA_BOND_MODE, bond->params.mode)) @@ -374,6 +387,14 @@ static int bond_fill_info(struct sk_buff *skb, bond->params.lp_interval)) goto nla_put_failure; + packets_per_slave = bond->params.packets_per_slave; + if (packets_per_slave > 1) + packets_per_slave = reciprocal_value(packets_per_slave); + + if (nla_put_u32(skb, IFLA_BOND_PACKETS_PER_SLAVE, + packets_per_slave)) + goto nla_put_failure; + return 0; nla_put_failure: |