|
|
049c96 |
From c05b809a58c55860dabb5930ba19dbf8f71f137f Mon Sep 17 00:00:00 2001
|
|
|
049c96 |
From: Phil Sutter <psutter@redhat.com>
|
|
|
049c96 |
Date: Tue, 23 Feb 2016 18:26:25 +0100
|
|
|
049c96 |
Subject: [PATCH] iproute2: allow to change slave options via type_slave
|
|
|
049c96 |
|
|
|
049c96 |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1269528
|
|
|
049c96 |
Upstream Status: iproute2.git commit 620ddedada7fd
|
|
|
049c96 |
|
|
|
049c96 |
commit 620ddedada7fddd0d1d04a3da0145535423bc237
|
|
|
049c96 |
Author: Nikolay Aleksandrov <nikolay@redhat.com>
|
|
|
049c96 |
Date: Wed Sep 3 17:57:30 2014 +0200
|
|
|
049c96 |
|
|
|
049c96 |
iproute2: allow to change slave options via type_slave
|
|
|
049c96 |
|
|
|
049c96 |
This patch adds the necessary changes to allow altering a slave device's
|
|
|
049c96 |
options via ip link set <device> type <master type>_slave specific-option.
|
|
|
049c96 |
It also adds support to set the bonding slaves' queue_id.
|
|
|
049c96 |
|
|
|
049c96 |
Example:
|
|
|
049c96 |
ip link set eth0 type bond_slave queue_id 10
|
|
|
049c96 |
|
|
|
049c96 |
Signed-off-by: Nikolay Aleksandrov <nikolay@redhat.com>
|
|
|
049c96 |
Acked-by: Jiri Pirko <jiri@resnulli.us>
|
|
|
049c96 |
---
|
|
|
049c96 |
ip/iplink.c | 22 +++++++++++++++++++---
|
|
|
049c96 |
ip/iplink_bond_slave.c | 19 +++++++++++++++++++
|
|
|
049c96 |
2 files changed, 38 insertions(+), 3 deletions(-)
|
|
|
049c96 |
|
|
|
049c96 |
diff --git a/ip/iplink.c b/ip/iplink.c
|
|
|
049c96 |
index 2f8bbf9..f444bef 100644
|
|
|
049c96 |
--- a/ip/iplink.c
|
|
|
049c96 |
+++ b/ip/iplink.c
|
|
|
049c96 |
@@ -92,7 +92,8 @@ void iplink_usage(void)
|
|
|
049c96 |
fprintf(stderr, "\n");
|
|
|
049c96 |
fprintf(stderr, "TYPE := { vlan | veth | vcan | dummy | ifb | macvlan | macvtap |\n");
|
|
|
049c96 |
fprintf(stderr, " bridge | bond | ipoib | ip6tnl | ipip | sit | vxlan |\n");
|
|
|
049c96 |
- fprintf(stderr, " gre | gretap | ip6gre | ip6gretap | vti | nlmon }\n");
|
|
|
049c96 |
+ fprintf(stderr, " gre | gretap | ip6gre | ip6gretap | vti | nlmon |\n");
|
|
|
049c96 |
+ fprintf(stderr, " bond_slave }\n");
|
|
|
049c96 |
}
|
|
|
049c96 |
exit(-1);
|
|
|
049c96 |
}
|
|
|
049c96 |
@@ -654,14 +655,29 @@ static int iplink_modify(int cmd, unsigned int flags, int argc, char **argv)
|
|
|
049c96 |
|
|
|
049c96 |
if (type) {
|
|
|
049c96 |
struct rtattr *linkinfo = NLMSG_TAIL(&req.n);
|
|
|
049c96 |
+ char slavebuf[128], *ulinep = strchr(type, '_');
|
|
|
049c96 |
+ int iflatype;
|
|
|
049c96 |
+
|
|
|
049c96 |
addattr_l(&req.n, sizeof(req), IFLA_LINKINFO, NULL, 0);
|
|
|
049c96 |
addattr_l(&req.n, sizeof(req), IFLA_INFO_KIND, type,
|
|
|
049c96 |
strlen(type));
|
|
|
049c96 |
|
|
|
049c96 |
- lu = get_link_kind(type);
|
|
|
049c96 |
+ if (ulinep && !strcmp(ulinep, "_slave")) {
|
|
|
049c96 |
+ strncpy(slavebuf, type, sizeof(slavebuf));
|
|
|
049c96 |
+ slavebuf[sizeof(slavebuf) - 1] = '\0';
|
|
|
049c96 |
+ ulinep = strchr(slavebuf, '_');
|
|
|
049c96 |
+ /* check in case it was after sizeof(slavebuf) - 1*/
|
|
|
049c96 |
+ if (ulinep)
|
|
|
049c96 |
+ *ulinep = '\0';
|
|
|
049c96 |
+ lu = get_link_slave_kind(slavebuf);
|
|
|
049c96 |
+ iflatype = IFLA_INFO_SLAVE_DATA;
|
|
|
049c96 |
+ } else {
|
|
|
049c96 |
+ lu = get_link_kind(type);
|
|
|
049c96 |
+ iflatype = IFLA_INFO_DATA;
|
|
|
049c96 |
+ }
|
|
|
049c96 |
if (lu && argc) {
|
|
|
049c96 |
struct rtattr * data = NLMSG_TAIL(&req.n);
|
|
|
049c96 |
- addattr_l(&req.n, sizeof(req), IFLA_INFO_DATA, NULL, 0);
|
|
|
049c96 |
+ addattr_l(&req.n, sizeof(req), iflatype, NULL, 0);
|
|
|
049c96 |
|
|
|
049c96 |
if (lu->parse_opt &&
|
|
|
049c96 |
lu->parse_opt(lu, argc, argv, &req.n))
|
|
|
049c96 |
diff --git a/ip/iplink_bond_slave.c b/ip/iplink_bond_slave.c
|
|
|
049c96 |
index 8f3fc6c..aacba14 100644
|
|
|
049c96 |
--- a/ip/iplink_bond_slave.c
|
|
|
049c96 |
+++ b/ip/iplink_bond_slave.c
|
|
|
049c96 |
@@ -80,10 +80,29 @@ static void bond_slave_print_opt(struct link_util *lu, FILE *f, struct rtattr *t
|
|
|
049c96 |
rta_getattr_u16(tb[IFLA_BOND_SLAVE_AD_AGGREGATOR_ID]));
|
|
|
049c96 |
}
|
|
|
049c96 |
|
|
|
049c96 |
+static int bond_slave_parse_opt(struct link_util *lu, int argc, char **argv,
|
|
|
049c96 |
+ struct nlmsghdr *n)
|
|
|
049c96 |
+{
|
|
|
049c96 |
+ __u16 queue_id;
|
|
|
049c96 |
+
|
|
|
049c96 |
+ while (argc > 0) {
|
|
|
049c96 |
+ if (matches(*argv, "queue_id") == 0) {
|
|
|
049c96 |
+ NEXT_ARG();
|
|
|
049c96 |
+ if (get_u16(&queue_id, *argv, 0))
|
|
|
049c96 |
+ invarg("queue_id is invalid", *argv);
|
|
|
049c96 |
+ addattr16(n, 1024, IFLA_BOND_SLAVE_QUEUE_ID, queue_id);
|
|
|
049c96 |
+ }
|
|
|
049c96 |
+ argc--, argv++;
|
|
|
049c96 |
+ }
|
|
|
049c96 |
+
|
|
|
049c96 |
+ return 0;
|
|
|
049c96 |
+}
|
|
|
049c96 |
+
|
|
|
049c96 |
struct link_util bond_slave_link_util = {
|
|
|
049c96 |
.id = "bond",
|
|
|
049c96 |
.maxattr = IFLA_BOND_SLAVE_MAX,
|
|
|
049c96 |
.print_opt = bond_slave_print_opt,
|
|
|
049c96 |
+ .parse_opt = bond_slave_parse_opt,
|
|
|
049c96 |
.slave = true,
|
|
|
049c96 |
};
|
|
|
049c96 |
|
|
|
049c96 |
--
|
|
|
049c96 |
1.8.3.1
|
|
|
049c96 |
|