* [PATCH net-next iproute2] iproute2: allow to change slave options via type_slave
@ 2014-09-03 14:43 Nikolay Aleksandrov
2014-09-03 15:02 ` Jiri Pirko
0 siblings, 1 reply; 6+ messages in thread
From: Nikolay Aleksandrov @ 2014-09-03 14:43 UTC (permalink / raw)
To: netdev; +Cc: jiri, stephen, davem, Nikolay Aleksandrov
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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH net-next iproute2] iproute2: allow to change slave options via type_slave
2014-09-03 14:43 [PATCH net-next iproute2] iproute2: allow to change slave options via type_slave Nikolay Aleksandrov
@ 2014-09-03 15:02 ` Jiri Pirko
2014-09-03 15:57 ` [PATCH net-next iproute2 v2] " Nikolay Aleksandrov
0 siblings, 1 reply; 6+ messages in thread
From: Jiri Pirko @ 2014-09-03 15:02 UTC (permalink / raw)
To: Nikolay Aleksandrov; +Cc: netdev, stephen, davem
Wed, Sep 03, 2014 at 04:43:28PM CEST, nikolay@redhat.com wrote:
>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");
I think you can put "bond_slave" here. Once any other slave type
implements parse_opt, it would be added here as well.
> }
> 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
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH net-next iproute2 v2] iproute2: allow to change slave options via type_slave
2014-09-03 15:02 ` Jiri Pirko
@ 2014-09-03 15:57 ` 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
0 siblings, 2 replies; 6+ messages in thread
From: Nikolay Aleksandrov @ 2014-09-03 15:57 UTC (permalink / raw)
To: netdev; +Cc: jiri, stephen, davem, Nikolay Aleksandrov
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>
---
v2: change the usage from <master type>_slave to bond_slave as Jiri suggested
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..0992923c83bc 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, " bond_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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH net-next iproute2 v2] iproute2: allow to change slave options via type_slave
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
1 sibling, 0 replies; 6+ messages in thread
From: Jiri Pirko @ 2014-09-03 16:04 UTC (permalink / raw)
To: Nikolay Aleksandrov; +Cc: netdev, stephen, davem
Wed, Sep 03, 2014 at 05:57:30PM CEST, nikolay@redhat.com wrote:
>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>
Acked-by: Jiri Pirko <jiri@resnulli.us>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [patch iproute2] bond_slave: add help and fail on unknown opt
2014-09-03 15:57 ` [PATCH net-next iproute2 v2] " Nikolay Aleksandrov
2014-09-03 16:04 ` Jiri Pirko
@ 2014-09-05 7:45 ` Jiri Pirko
2014-09-28 22:56 ` Stephen Hemminger
1 sibling, 1 reply; 6+ messages in thread
From: Jiri Pirko @ 2014-09-05 7:45 UTC (permalink / raw)
To: netdev; +Cc: davem, stephen, nikolay
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
---
ip/iplink_bond_slave.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/ip/iplink_bond_slave.c b/ip/iplink_bond_slave.c
index aacba14..3c26f08 100644
--- a/ip/iplink_bond_slave.c
+++ b/ip/iplink_bond_slave.c
@@ -17,6 +17,13 @@
#include "utils.h"
#include "ip_common.h"
+static void explain(void)
+{
+ fprintf(stderr,
+ "Usage: ... bond_slave [ queue_id QUEUE_ID ]\n"
+ );
+}
+
static const char *slave_states[] = {
[BOND_STATE_ACTIVE] = "ACTIVE",
[BOND_STATE_BACKUP] = "BACKUP",
@@ -91,6 +98,14 @@ static int bond_slave_parse_opt(struct link_util *lu, int argc, char **argv,
if (get_u16(&queue_id, *argv, 0))
invarg("queue_id is invalid", *argv);
addattr16(n, 1024, IFLA_BOND_SLAVE_QUEUE_ID, queue_id);
+ } else if (matches(*argv, "help") == 0) {
+ explain();
+ return -1;
+ } else {
+ fprintf(stderr, "bond_slave: unknown option \"%s\"?\n",
+ *argv);
+ explain();
+ return -1;
}
argc--, argv++;
}
--
1.9.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [patch iproute2] bond_slave: add help and fail on unknown opt
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
0 siblings, 0 replies; 6+ messages in thread
From: Stephen Hemminger @ 2014-09-28 22:56 UTC (permalink / raw)
To: Jiri Pirko; +Cc: netdev, davem, nikolay
On Fri, 5 Sep 2014 09:45:25 +0200
Jiri Pirko <jiri@resnulli.us> wrote:
> Signed-off-by: Jiri Pirko <jiri@resnulli.us>
> ---
> ip/iplink_bond_slave.c | 15 +++++++++++++++
> 1 file changed, 15 insertions(+)
>
> diff --git a/ip/iplink_bond_slave.c b/ip/iplink_bond_slave.c
> index aacba14..3c26f08 100644
> --- a/ip/iplink_bond_slave.c
> +++ b/ip/iplink_bond_slave.c
> @@ -17,6 +17,13 @@
> #include "utils.h"
> #include "ip_common.h"
>
> +static void explain(void)
> +{
> + fprintf(stderr,
> + "Usage: ... bond_slave [ queue_id QUEUE_ID ]\n"
> + );
> +}
> +
> static const char *slave_states[] = {
> [BOND_STATE_ACTIVE] = "ACTIVE",
> [BOND_STATE_BACKUP] = "BACKUP",
> @@ -91,6 +98,14 @@ static int bond_slave_parse_opt(struct link_util *lu, int argc, char **argv,
> if (get_u16(&queue_id, *argv, 0))
> invarg("queue_id is invalid", *argv);
> addattr16(n, 1024, IFLA_BOND_SLAVE_QUEUE_ID, queue_id);
> + } else if (matches(*argv, "help") == 0) {
> + explain();
> + return -1;
> + } else {
> + fprintf(stderr, "bond_slave: unknown option \"%s\"?\n",
> + *argv);
> + explain();
> + return -1;
> }
> argc--, argv++;
> }
This patch does not apply. there is probably some earlier patch you forgot to send about
BOND_SLAVE_QUEUE_ID.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-09-28 22:56 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-03 14:43 [PATCH net-next iproute2] iproute2: allow to change slave options via type_slave Nikolay Aleksandrov
2014-09-03 15:02 ` 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
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.