diff options
author | Nikolay Aleksandrov <nikolay@redhat.com> | 2014-08-27 10:06:46 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-09-01 21:32:22 -0400 |
commit | 0f23124aaacd68e11271f72a13f3a8e8904c26d3 (patch) | |
tree | 052d8f8b3dc82b6c52c06805a71af582a9fc6ab3 | |
parent | 688d1945bc89bd585ec67b5b83121f499e6290bb (diff) |
bonding: add slave_changelink support and use it for queue_id
This patch adds support for slave_changelink to the bonding and uses it
to give the ability to change the queue_id of the enslaved devices via
netlink. It sets slave_maxtype and uses bond_changelink as a prototype for
bond_slave_changelink.
Example/test command after the iproute2 patch:
ip link set eth0 type bond_slave queue_id 10
CC: David S. Miller <davem@davemloft.net>
CC: Jay Vosburgh <j.vosburgh@gmail.com>
CC: Veaceslav Falico <vfalico@gmail.com>
CC: Andy Gospodarek <andy@greyhouse.net>
Suggested-by: Jiri Pirko <jiri@resnulli.us>
Signed-off-by: Nikolay Aleksandrov <nikolay@redhat.com>
Acked-by: Jiri Pirko <jiri@resnulli.us>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/bonding/bond_netlink.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/drivers/net/bonding/bond_netlink.c b/drivers/net/bonding/bond_netlink.c index d163e112f04c..1570deab112e 100644 --- a/drivers/net/bonding/bond_netlink.c +++ b/drivers/net/bonding/bond_netlink.c | |||
@@ -107,6 +107,33 @@ static int bond_validate(struct nlattr *tb[], struct nlattr *data[]) | |||
107 | return 0; | 107 | return 0; |
108 | } | 108 | } |
109 | 109 | ||
110 | static int bond_slave_changelink(struct net_device *bond_dev, | ||
111 | struct net_device *slave_dev, | ||
112 | struct nlattr *tb[], struct nlattr *data[]) | ||
113 | { | ||
114 | struct bonding *bond = netdev_priv(bond_dev); | ||
115 | struct bond_opt_value newval; | ||
116 | int err; | ||
117 | |||
118 | if (!data) | ||
119 | return 0; | ||
120 | |||
121 | if (data[IFLA_BOND_SLAVE_QUEUE_ID]) { | ||
122 | u16 queue_id = nla_get_u16(data[IFLA_BOND_SLAVE_QUEUE_ID]); | ||
123 | char queue_id_str[IFNAMSIZ + 7]; | ||
124 | |||
125 | /* queue_id option setting expects slave_name:queue_id */ | ||
126 | snprintf(queue_id_str, sizeof(queue_id_str), "%s:%u\n", | ||
127 | slave_dev->name, queue_id); | ||
128 | bond_opt_initstr(&newval, queue_id_str); | ||
129 | err = __bond_opt_set(bond, BOND_OPT_QUEUE_ID, &newval); | ||
130 | if (err) | ||
131 | return err; | ||
132 | } | ||
133 | |||
134 | return 0; | ||
135 | } | ||
136 | |||
110 | static int bond_changelink(struct net_device *bond_dev, | 137 | static int bond_changelink(struct net_device *bond_dev, |
111 | struct nlattr *tb[], struct nlattr *data[]) | 138 | struct nlattr *tb[], struct nlattr *data[]) |
112 | { | 139 | { |
@@ -553,10 +580,12 @@ struct rtnl_link_ops bond_link_ops __read_mostly = { | |||
553 | .priv_size = sizeof(struct bonding), | 580 | .priv_size = sizeof(struct bonding), |
554 | .setup = bond_setup, | 581 | .setup = bond_setup, |
555 | .maxtype = IFLA_BOND_MAX, | 582 | .maxtype = IFLA_BOND_MAX, |
583 | .slave_maxtype = IFLA_BOND_SLAVE_MAX, | ||
556 | .policy = bond_policy, | 584 | .policy = bond_policy, |
557 | .validate = bond_validate, | 585 | .validate = bond_validate, |
558 | .newlink = bond_newlink, | 586 | .newlink = bond_newlink, |
559 | .changelink = bond_changelink, | 587 | .changelink = bond_changelink, |
588 | .slave_changelink = bond_slave_changelink, | ||
560 | .get_size = bond_get_size, | 589 | .get_size = bond_get_size, |
561 | .fill_info = bond_fill_info, | 590 | .fill_info = bond_fill_info, |
562 | .get_num_tx_queues = bond_get_num_tx_queues, | 591 | .get_num_tx_queues = bond_get_num_tx_queues, |