From: Nikolay Aleksandrov <nikolay@redhat.com>
To: netdev@vger.kernel.org
Cc: jiri@resnulli.us, stephen@networkplumber.org,
davem@davemloft.net, Nikolay Aleksandrov <nikolay@redhat.com>
Subject: [PATCH net-next iproute2] iproute2: allow to change slave options via type_slave
Date: Wed, 3 Sep 2014 16:43:28 +0200 [thread overview]
Message-ID: <1409755408-13929-1-git-send-email-nikolay@redhat.com> (raw)
This patch adds the necessary changes to allow altering a slave device's
options via ip link set <device> type <master type>_slave specific-option.
It also adds support to set the bonding slaves' queue_id.
Example:
ip link set eth0 type bond_slave queue_id 10
Signed-off-by: Nikolay Aleksandrov <nikolay@redhat.com>
---
ip/iplink.c | 22 +++++++++++++++++++---
ip/iplink_bond_slave.c | 19 +++++++++++++++++++
2 files changed, 38 insertions(+), 3 deletions(-)
diff --git a/ip/iplink.c b/ip/iplink.c
index 1a907d998a87..5f2db92c981e 100644
--- a/ip/iplink.c
+++ b/ip/iplink.c
@@ -88,7 +88,8 @@ void iplink_usage(void)
fprintf(stderr, "\n");
fprintf(stderr, "TYPE := { vlan | veth | vcan | dummy | ifb | macvlan | macvtap |\n");
fprintf(stderr, " bridge | bond | ipoib | ip6tnl | ipip | sit | vxlan |\n");
- fprintf(stderr, " gre | gretap | ip6gre | ip6gretap | vti | nlmon }\n");
+ fprintf(stderr, " gre | gretap | ip6gre | ip6gretap | vti | nlmon |\n");
+ fprintf(stderr, " <master type>_slave }\n");
}
exit(-1);
}
@@ -697,14 +698,29 @@ static int iplink_modify(int cmd, unsigned int flags, int argc, char **argv)
if (type) {
struct rtattr *linkinfo = NLMSG_TAIL(&req.n);
+ char slavebuf[128], *ulinep = strchr(type, '_');
+ int iflatype;
+
addattr_l(&req.n, sizeof(req), IFLA_LINKINFO, NULL, 0);
addattr_l(&req.n, sizeof(req), IFLA_INFO_KIND, type,
strlen(type));
- lu = get_link_kind(type);
+ if (ulinep && !strcmp(ulinep, "_slave")) {
+ strncpy(slavebuf, type, sizeof(slavebuf));
+ slavebuf[sizeof(slavebuf) - 1] = '\0';
+ ulinep = strchr(slavebuf, '_');
+ /* check in case it was after sizeof(slavebuf) - 1*/
+ if (ulinep)
+ *ulinep = '\0';
+ lu = get_link_slave_kind(slavebuf);
+ iflatype = IFLA_INFO_SLAVE_DATA;
+ } else {
+ lu = get_link_kind(type);
+ iflatype = IFLA_INFO_DATA;
+ }
if (lu && argc) {
struct rtattr * data = NLMSG_TAIL(&req.n);
- addattr_l(&req.n, sizeof(req), IFLA_INFO_DATA, NULL, 0);
+ addattr_l(&req.n, sizeof(req), iflatype, NULL, 0);
if (lu->parse_opt &&
lu->parse_opt(lu, argc, argv, &req.n))
diff --git a/ip/iplink_bond_slave.c b/ip/iplink_bond_slave.c
index 8f3fc6cec6fa..aacba14aef9c 100644
--- a/ip/iplink_bond_slave.c
+++ b/ip/iplink_bond_slave.c
@@ -80,10 +80,29 @@ static void bond_slave_print_opt(struct link_util *lu, FILE *f, struct rtattr *t
rta_getattr_u16(tb[IFLA_BOND_SLAVE_AD_AGGREGATOR_ID]));
}
+static int bond_slave_parse_opt(struct link_util *lu, int argc, char **argv,
+ struct nlmsghdr *n)
+{
+ __u16 queue_id;
+
+ while (argc > 0) {
+ if (matches(*argv, "queue_id") == 0) {
+ NEXT_ARG();
+ if (get_u16(&queue_id, *argv, 0))
+ invarg("queue_id is invalid", *argv);
+ addattr16(n, 1024, IFLA_BOND_SLAVE_QUEUE_ID, queue_id);
+ }
+ argc--, argv++;
+ }
+
+ return 0;
+}
+
struct link_util bond_slave_link_util = {
.id = "bond",
.maxattr = IFLA_BOND_SLAVE_MAX,
.print_opt = bond_slave_print_opt,
+ .parse_opt = bond_slave_parse_opt,
.slave = true,
};
--
1.9.3
next reply other threads:[~2014-09-03 14:43 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-03 14:43 Nikolay Aleksandrov [this message]
2014-09-03 15:02 ` [PATCH net-next iproute2] iproute2: allow to change slave options via type_slave Jiri Pirko
2014-09-03 15:57 ` [PATCH net-next iproute2 v2] " Nikolay Aleksandrov
2014-09-03 16:04 ` Jiri Pirko
2014-09-05 7:45 ` [patch iproute2] bond_slave: add help and fail on unknown opt Jiri Pirko
2014-09-28 22:56 ` Stephen Hemminger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1409755408-13929-1-git-send-email-nikolay@redhat.com \
--to=nikolay@redhat.com \
--cc=davem@davemloft.net \
--cc=jiri@resnulli.us \
--cc=netdev@vger.kernel.org \
--cc=stephen@networkplumber.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).