* [patch net-next 0/5] bridge: implement rtnl_link options for getting and setting bridge options
@ 2014-09-05 13:51 Jiri Pirko
2014-09-05 13:51 ` [patch net-next 1/5] bridge: switch order of rx_handler reg and upper dev link Jiri Pirko
` (8 more replies)
0 siblings, 9 replies; 15+ messages in thread
From: Jiri Pirko @ 2014-09-05 13:51 UTC (permalink / raw)
To: netdev; +Cc: davem, stephen, sfeldma, arvid.brodin, sucheta.chakraborty
So far, only sysfs is complete interface for getting and setting bridge
options. This patchset follows-up on the similar bonding code and
allows userspace to get/set bridge master/port options using Netlink
IFLA_INFO_DATA/IFLA_INFO_SLAVE_DATA attr.
Jiri Pirko (5):
bridge: switch order of rx_handler reg and upper dev link
bridge: implement rtnl_link_ops->get_slave_size and
rtnl_link_ops->fill_slave_info
bridge: implement rtnl_link_ops->slave_changelink
bridge: implement rtnl_link_ops->get_size and rtnl_link_ops->fill_info
bridge: implement rtnl_link_ops->changelink
include/uapi/linux/if_link.h | 12 +++++
net/bridge/br_if.c | 15 +++---
net/bridge/br_netlink.c | 109 +++++++++++++++++++++++++++++++++++++++----
3 files changed, 121 insertions(+), 15 deletions(-)
--
1.9.3
^ permalink raw reply [flat|nested] 15+ messages in thread
* [patch net-next 1/5] bridge: switch order of rx_handler reg and upper dev link
2014-09-05 13:51 [patch net-next 0/5] bridge: implement rtnl_link options for getting and setting bridge options Jiri Pirko
@ 2014-09-05 13:51 ` Jiri Pirko
2014-09-05 13:51 ` [patch net-next 2/5] bridge: implement rtnl_link_ops->get_slave_size and rtnl_link_ops->fill_slave_info Jiri Pirko
` (7 subsequent siblings)
8 siblings, 0 replies; 15+ messages in thread
From: Jiri Pirko @ 2014-09-05 13:51 UTC (permalink / raw)
To: netdev; +Cc: davem, stephen, sfeldma, arvid.brodin, sucheta.chakraborty
The thing is that netdev_master_upper_dev_link calls
call_netdevice_notifiers(NETDEV_CHANGEUPPER, dev). That generates rtnl
link message and during that, rtnl_link_ops->fill_slave_info is called.
But with current ordering, rx_handler and IFF_BRIDGE_PORT are not set
yet so there would have to be check for that in fill_slave_info callback.
Resolve this by reordering to similar what bonding and team does to
avoid the check.
Also add removal of IFF_BRIDGE_PORT flag into error path.
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
---
net/bridge/br_if.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c
index 078d336..a9f54a9 100644
--- a/net/bridge/br_if.c
+++ b/net/bridge/br_if.c
@@ -252,12 +252,12 @@ static void del_nbp(struct net_bridge_port *p)
br_fdb_delete_by_port(br, p, 1);
nbp_update_port_count(br);
+ netdev_upper_dev_unlink(dev, br->dev);
+
dev->priv_flags &= ~IFF_BRIDGE_PORT;
netdev_rx_handler_unregister(dev);
- netdev_upper_dev_unlink(dev, br->dev);
-
br_multicast_del_port(p);
kobject_uevent(&p->kobj, KOBJ_REMOVE);
@@ -476,16 +476,16 @@ int br_add_if(struct net_bridge *br, struct net_device *dev)
if (err)
goto err3;
- err = netdev_master_upper_dev_link(dev, br->dev);
+ err = netdev_rx_handler_register(dev, br_handle_frame, p);
if (err)
goto err4;
- err = netdev_rx_handler_register(dev, br_handle_frame, p);
+ dev->priv_flags |= IFF_BRIDGE_PORT;
+
+ err = netdev_master_upper_dev_link(dev, br->dev);
if (err)
goto err5;
- dev->priv_flags |= IFF_BRIDGE_PORT;
-
dev_disable_lro(dev);
list_add_rcu(&p->list, &br->port_list);
@@ -520,7 +520,8 @@ int br_add_if(struct net_bridge *br, struct net_device *dev)
return 0;
err5:
- netdev_upper_dev_unlink(dev, br->dev);
+ dev->priv_flags &= ~IFF_BRIDGE_PORT;
+ netdev_rx_handler_unregister(dev);
err4:
br_netpoll_disable(p);
err3:
--
1.9.3
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [patch net-next 2/5] bridge: implement rtnl_link_ops->get_slave_size and rtnl_link_ops->fill_slave_info
2014-09-05 13:51 [patch net-next 0/5] bridge: implement rtnl_link options for getting and setting bridge options Jiri Pirko
2014-09-05 13:51 ` [patch net-next 1/5] bridge: switch order of rx_handler reg and upper dev link Jiri Pirko
@ 2014-09-05 13:51 ` Jiri Pirko
2014-09-05 13:51 ` [patch net-next 3/5] bridge: implement rtnl_link_ops->slave_changelink Jiri Pirko
` (6 subsequent siblings)
8 siblings, 0 replies; 15+ messages in thread
From: Jiri Pirko @ 2014-09-05 13:51 UTC (permalink / raw)
To: netdev; +Cc: davem, stephen, sfeldma, arvid.brodin, sucheta.chakraborty
Allow rtnetlink users to get port info in IFLA_INFO_SLAVE_DATA attr
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
---
net/bridge/br_netlink.c | 27 +++++++++++++++++++++------
1 file changed, 21 insertions(+), 6 deletions(-)
diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c
index cb5fcf6..80d2347 100644
--- a/net/bridge/br_netlink.c
+++ b/net/bridge/br_netlink.c
@@ -461,6 +461,19 @@ static int br_dev_newlink(struct net *src_net, struct net_device *dev,
return register_netdevice(dev);
}
+static int br_port_fill_slave_info(struct sk_buff *skb,
+ const struct net_device *brdev,
+ const struct net_device *dev)
+{
+ return br_port_fill_attrs(skb, br_port_get_rtnl(dev));
+}
+
+static size_t br_port_get_slave_size(const struct net_device *brdev,
+ const struct net_device *dev)
+{
+ return br_port_info_size();
+}
+
static size_t br_get_link_af_size(const struct net_device *dev)
{
struct net_port_vlans *pv;
@@ -485,12 +498,14 @@ static struct rtnl_af_ops br_af_ops = {
};
struct rtnl_link_ops br_link_ops __read_mostly = {
- .kind = "bridge",
- .priv_size = sizeof(struct net_bridge),
- .setup = br_dev_setup,
- .validate = br_validate,
- .newlink = br_dev_newlink,
- .dellink = br_dev_delete,
+ .kind = "bridge",
+ .priv_size = sizeof(struct net_bridge),
+ .setup = br_dev_setup,
+ .validate = br_validate,
+ .newlink = br_dev_newlink,
+ .dellink = br_dev_delete,
+ .get_slave_size = br_port_get_slave_size,
+ .fill_slave_info = br_port_fill_slave_info,
};
int __init br_netlink_init(void)
--
1.9.3
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [patch net-next 3/5] bridge: implement rtnl_link_ops->slave_changelink
2014-09-05 13:51 [patch net-next 0/5] bridge: implement rtnl_link options for getting and setting bridge options Jiri Pirko
2014-09-05 13:51 ` [patch net-next 1/5] bridge: switch order of rx_handler reg and upper dev link Jiri Pirko
2014-09-05 13:51 ` [patch net-next 2/5] bridge: implement rtnl_link_ops->get_slave_size and rtnl_link_ops->fill_slave_info Jiri Pirko
@ 2014-09-05 13:51 ` Jiri Pirko
2014-09-05 13:51 ` [patch net-next 4/5] bridge: implement rtnl_link_ops->get_size and rtnl_link_ops->fill_info Jiri Pirko
` (5 subsequent siblings)
8 siblings, 0 replies; 15+ messages in thread
From: Jiri Pirko @ 2014-09-05 13:51 UTC (permalink / raw)
To: netdev; +Cc: davem, stephen, sfeldma, arvid.brodin, sucheta.chakraborty
Allow rtnetlink users to set port info via IFLA_INFO_SLAVE_DATA attr
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
---
net/bridge/br_netlink.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c
index 80d2347..05aeea1 100644
--- a/net/bridge/br_netlink.c
+++ b/net/bridge/br_netlink.c
@@ -276,7 +276,7 @@ static int br_afspec(struct net_bridge *br,
return err;
}
-static const struct nla_policy ifla_brport_policy[IFLA_BRPORT_MAX + 1] = {
+static const struct nla_policy br_port_policy[IFLA_BRPORT_MAX + 1] = {
[IFLA_BRPORT_STATE] = { .type = NLA_U8 },
[IFLA_BRPORT_COST] = { .type = NLA_U32 },
[IFLA_BRPORT_PRIORITY] = { .type = NLA_U16 },
@@ -382,7 +382,7 @@ int br_setlink(struct net_device *dev, struct nlmsghdr *nlh)
if (p && protinfo) {
if (protinfo->nla_type & NLA_F_NESTED) {
err = nla_parse_nested(tb, IFLA_BRPORT_MAX,
- protinfo, ifla_brport_policy);
+ protinfo, br_port_policy);
if (err)
return err;
@@ -461,6 +461,16 @@ static int br_dev_newlink(struct net *src_net, struct net_device *dev,
return register_netdevice(dev);
}
+static int br_port_slave_changelink(struct net_device *brdev,
+ struct net_device *dev,
+ struct nlattr *tb[],
+ struct nlattr *data[])
+{
+ if (!data)
+ return 0;
+ return br_setport(br_port_get_rtnl(dev), data);
+}
+
static int br_port_fill_slave_info(struct sk_buff *skb,
const struct net_device *brdev,
const struct net_device *dev)
@@ -504,6 +514,10 @@ struct rtnl_link_ops br_link_ops __read_mostly = {
.validate = br_validate,
.newlink = br_dev_newlink,
.dellink = br_dev_delete,
+
+ .slave_maxtype = IFLA_BRPORT_MAX,
+ .slave_policy = br_port_policy,
+ .slave_changelink = br_port_slave_changelink,
.get_slave_size = br_port_get_slave_size,
.fill_slave_info = br_port_fill_slave_info,
};
--
1.9.3
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [patch net-next 4/5] bridge: implement rtnl_link_ops->get_size and rtnl_link_ops->fill_info
2014-09-05 13:51 [patch net-next 0/5] bridge: implement rtnl_link options for getting and setting bridge options Jiri Pirko
` (2 preceding siblings ...)
2014-09-05 13:51 ` [patch net-next 3/5] bridge: implement rtnl_link_ops->slave_changelink Jiri Pirko
@ 2014-09-05 13:51 ` Jiri Pirko
2014-09-05 13:51 ` [patch net-next 5/5] bridge: implement rtnl_link_ops->changelink Jiri Pirko
` (4 subsequent siblings)
8 siblings, 0 replies; 15+ messages in thread
From: Jiri Pirko @ 2014-09-05 13:51 UTC (permalink / raw)
To: netdev; +Cc: davem, stephen, sfeldma, arvid.brodin, sucheta.chakraborty
Allow rtnetlink users to get bridge master info in IFLA_INFO_DATA attr
This initial part implements forward_delay, hello_time, max_age options.
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
---
include/uapi/linux/if_link.h | 12 ++++++++++++
net/bridge/br_netlink.c | 25 +++++++++++++++++++++++++
2 files changed, 37 insertions(+)
diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h
index ff95760..c80f95f 100644
--- a/include/uapi/linux/if_link.h
+++ b/include/uapi/linux/if_link.h
@@ -215,6 +215,18 @@ enum in6_addr_gen_mode {
IN6_ADDR_GEN_MODE_NONE,
};
+/* Bridge section */
+
+enum {
+ IFLA_BR_UNSPEC,
+ IFLA_BR_FORWARD_DELAY,
+ IFLA_BR_HELLO_TIME,
+ IFLA_BR_MAX_AGE,
+ __IFLA_BR_MAX,
+};
+
+#define IFLA_BR_MAX (__IFLA_BR_MAX - 1)
+
enum {
BRIDGE_MODE_UNSPEC,
BRIDGE_MODE_HAIRPIN,
diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c
index 05aeea1..bcac09f 100644
--- a/net/bridge/br_netlink.c
+++ b/net/bridge/br_netlink.c
@@ -484,6 +484,29 @@ static size_t br_port_get_slave_size(const struct net_device *brdev,
return br_port_info_size();
}
+static size_t br_get_size(const struct net_device *brdev)
+{
+ return nla_total_size(sizeof(u32)) + /* IFLA_BR_FORWARD_DELAY */
+ nla_total_size(sizeof(u32)) + /* IFLA_BR_HELLO_TIME */
+ nla_total_size(sizeof(u32)) + /* IFLA_BR_MAX_AGE */
+ 0;
+}
+
+static int br_fill_info(struct sk_buff *skb, const struct net_device *brdev)
+{
+ struct net_bridge *br = netdev_priv(brdev);
+ u32 forward_delay = jiffies_to_clock_t(br->forward_delay);
+ u32 hello_time = jiffies_to_clock_t(br->hello_time);
+ u32 age_time = jiffies_to_clock_t(br->max_age);
+
+ if (nla_put_u32(skb, IFLA_BR_FORWARD_DELAY, forward_delay) ||
+ nla_put_u32(skb, IFLA_BR_HELLO_TIME, hello_time) ||
+ nla_put_u32(skb, IFLA_BR_MAX_AGE, age_time))
+ return -EMSGSIZE;
+
+ return 0;
+}
+
static size_t br_get_link_af_size(const struct net_device *dev)
{
struct net_port_vlans *pv;
@@ -514,6 +537,8 @@ struct rtnl_link_ops br_link_ops __read_mostly = {
.validate = br_validate,
.newlink = br_dev_newlink,
.dellink = br_dev_delete,
+ .get_size = br_get_size,
+ .fill_info = br_fill_info,
.slave_maxtype = IFLA_BRPORT_MAX,
.slave_policy = br_port_policy,
--
1.9.3
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [patch net-next 5/5] bridge: implement rtnl_link_ops->changelink
2014-09-05 13:51 [patch net-next 0/5] bridge: implement rtnl_link options for getting and setting bridge options Jiri Pirko
` (3 preceding siblings ...)
2014-09-05 13:51 ` [patch net-next 4/5] bridge: implement rtnl_link_ops->get_size and rtnl_link_ops->fill_info Jiri Pirko
@ 2014-09-05 13:51 ` Jiri Pirko
2014-09-05 13:55 ` [patch iproute2 1/2] add bridge_slave device support Jiri Pirko
` (3 subsequent siblings)
8 siblings, 0 replies; 15+ messages in thread
From: Jiri Pirko @ 2014-09-05 13:51 UTC (permalink / raw)
To: netdev; +Cc: davem, stephen, sfeldma, arvid.brodin, sucheta.chakraborty
Allow rtnetlink users to set bridge master info via IFLA_INFO_DATA attr
This initial part implements forward_delay, hello_time, max_age options.
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
---
net/bridge/br_netlink.c | 39 +++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c
index bcac09f..7c97a26 100644
--- a/net/bridge/br_netlink.c
+++ b/net/bridge/br_netlink.c
@@ -484,6 +484,42 @@ static size_t br_port_get_slave_size(const struct net_device *brdev,
return br_port_info_size();
}
+static const struct nla_policy br_policy[IFLA_BR_MAX + 1] = {
+ [IFLA_BR_FORWARD_DELAY] = { .type = NLA_U32 },
+ [IFLA_BR_HELLO_TIME] = { .type = NLA_U32 },
+ [IFLA_BR_MAX_AGE] = { .type = NLA_U32 },
+};
+
+static int br_changelink(struct net_device *brdev, struct nlattr *tb[],
+ struct nlattr *data[])
+{
+ struct net_bridge *br = netdev_priv(brdev);
+ int err;
+
+ if (!data)
+ return 0;
+
+ if (data[IFLA_BR_FORWARD_DELAY]) {
+ err = br_set_forward_delay(br, nla_get_u32(data[IFLA_BR_FORWARD_DELAY]));
+ if (err)
+ return err;
+ }
+
+ if (data[IFLA_BR_HELLO_TIME]) {
+ err = br_set_hello_time(br, nla_get_u32(data[IFLA_BR_HELLO_TIME]));
+ if (err)
+ return err;
+ }
+
+ if (data[IFLA_BR_MAX_AGE]) {
+ err = br_set_max_age(br, nla_get_u32(data[IFLA_BR_MAX_AGE]));
+ if (err)
+ return err;
+ }
+
+ return 0;
+}
+
static size_t br_get_size(const struct net_device *brdev)
{
return nla_total_size(sizeof(u32)) + /* IFLA_BR_FORWARD_DELAY */
@@ -534,8 +570,11 @@ struct rtnl_link_ops br_link_ops __read_mostly = {
.kind = "bridge",
.priv_size = sizeof(struct net_bridge),
.setup = br_dev_setup,
+ .maxtype = IFLA_BRPORT_MAX,
+ .policy = br_policy,
.validate = br_validate,
.newlink = br_dev_newlink,
+ .changelink = br_changelink,
.dellink = br_dev_delete,
.get_size = br_get_size,
.fill_info = br_fill_info,
--
1.9.3
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [patch iproute2 1/2] add bridge_slave device support
2014-09-05 13:51 [patch net-next 0/5] bridge: implement rtnl_link options for getting and setting bridge options Jiri Pirko
` (4 preceding siblings ...)
2014-09-05 13:51 ` [patch net-next 5/5] bridge: implement rtnl_link_ops->changelink Jiri Pirko
@ 2014-09-05 13:55 ` Jiri Pirko
2014-09-05 13:55 ` [patch iproute2 2/2] add bridge master " Jiri Pirko
` (3 more replies)
2014-09-05 17:06 ` [patch net-next 0/5] bridge: implement rtnl_link options for getting and setting bridge options Stephen Hemminger
` (2 subsequent siblings)
8 siblings, 4 replies; 15+ messages in thread
From: Jiri Pirko @ 2014-09-05 13:55 UTC (permalink / raw)
To: netdev; +Cc: davem, stephen, sfeldma, arvid.brodin, sucheta.chakraborty
Note this depends on "iproute2: allow to change slave options via
type_slave"
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
---
ip/Makefile | 3 +-
ip/iplink_bridge_slave.c | 181 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 183 insertions(+), 1 deletion(-)
create mode 100644 ip/iplink_bridge_slave.c
diff --git a/ip/Makefile b/ip/Makefile
index 713adf5..0c0b831 100644
--- a/ip/Makefile
+++ b/ip/Makefile
@@ -5,7 +5,8 @@ IPOBJ=ip.o ipaddress.o ipaddrlabel.o iproute.o iprule.o ipnetns.o \
iplink_vlan.o link_veth.o link_gre.o iplink_can.o \
iplink_macvlan.o iplink_macvtap.o ipl2tp.o link_vti.o \
iplink_vxlan.o tcp_metrics.o iplink_ipoib.o ipnetconf.o link_ip6tnl.o \
- link_iptnl.o link_gre6.o iplink_bond.o iplink_bond_slave.o iplink_hsr.o
+ link_iptnl.o link_gre6.o iplink_bond.o iplink_bond_slave.o iplink_hsr.o \
+ iplink_bridge_slave.o
RTMONOBJ=rtmon.o
diff --git a/ip/iplink_bridge_slave.c b/ip/iplink_bridge_slave.c
new file mode 100644
index 0000000..a285185
--- /dev/null
+++ b/ip/iplink_bridge_slave.c
@@ -0,0 +1,181 @@
+/*
+ * iplink_bridge_slave.c Bridge slave device support
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ *
+ * Authors: Jiri Pirko <jiri@resnulli.us>
+ */
+
+#include <stdio.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <linux/if_link.h>
+#include <linux/if_bridge.h>
+
+#include "rt_names.h"
+#include "utils.h"
+#include "ip_common.h"
+
+static void explain(void)
+{
+ fprintf(stderr,
+ "Usage: ... bridge_slave [ state STATE ] [ priority PRIO ] [cost COST ]\n"
+ " [ guard {on | off} ]\n"
+ " [ hairpin {on | off} ] \n"
+ " [ fastleave {on | off} ]\n"
+ " [ root_block {on | off} ]\n"
+ " [ learning {on | off} ]\n"
+ " [ flood {on | off} ]\n"
+ );
+}
+
+static const char *port_states[] = {
+ [BR_STATE_DISABLED] = "disabled",
+ [BR_STATE_LISTENING] = "listening",
+ [BR_STATE_LEARNING] = "learning",
+ [BR_STATE_FORWARDING] = "forwarding",
+ [BR_STATE_BLOCKING] = "blocking",
+};
+
+static void print_portstate(FILE *f, __u8 state)
+{
+ if (state <= BR_STATE_BLOCKING)
+ fprintf(f, "state %s ", port_states[state]);
+ else
+ fprintf(f, "state (%d) ", state);
+}
+
+static void print_onoff(FILE *f, char *flag, __u8 val)
+{
+ fprintf(f, "%s %s ", flag, val ? "on" : "off");
+}
+
+static void bridge_slave_print_opt(struct link_util *lu, FILE *f,
+ struct rtattr *tb[])
+{
+ if (!tb)
+ return;
+
+ if (tb[IFLA_BRPORT_STATE])
+ print_portstate(f, rta_getattr_u8(tb[IFLA_BRPORT_STATE]));
+
+ if (tb[IFLA_BRPORT_PRIORITY])
+ fprintf(f, "priority %d ",
+ rta_getattr_u16(tb[IFLA_BRPORT_PRIORITY]));
+
+ if (tb[IFLA_BRPORT_COST])
+ fprintf(f, "cost %d ",
+ rta_getattr_u32(tb[IFLA_BRPORT_COST]));
+
+ if (tb[IFLA_BRPORT_MODE])
+ print_onoff(f, "hairpin",
+ rta_getattr_u8(tb[IFLA_BRPORT_MODE]));
+
+ if (tb[IFLA_BRPORT_GUARD])
+ print_onoff(f, "guard",
+ rta_getattr_u8(tb[IFLA_BRPORT_GUARD]));
+
+ if (tb[IFLA_BRPORT_PROTECT])
+ print_onoff(f, "root_block",
+ rta_getattr_u8(tb[IFLA_BRPORT_PROTECT]));
+
+ if (tb[IFLA_BRPORT_FAST_LEAVE])
+ print_onoff(f, "fastleave",
+ rta_getattr_u8(tb[IFLA_BRPORT_FAST_LEAVE]));
+
+ if (tb[IFLA_BRPORT_LEARNING])
+ print_onoff(f, "learning",
+ rta_getattr_u8(tb[IFLA_BRPORT_LEARNING]));
+
+ if (tb[IFLA_BRPORT_UNICAST_FLOOD])
+ print_onoff(f, "flood",
+ rta_getattr_u8(tb[IFLA_BRPORT_UNICAST_FLOOD]));
+}
+
+static void bridge_slave_parse_on_off(char *arg_name, char *arg_val,
+ struct nlmsghdr *n, int type)
+{
+ __u8 val;
+
+ if (strcmp(arg_val, "on") == 0)
+ val = 1;
+ else if (strcmp(arg_val, "off") == 0)
+ val = 0;
+ else
+ invarg("should be \"on\" or \"off\"", arg_name);
+
+ addattr8(n, 1024, type, val);
+}
+
+static int bridge_slave_parse_opt(struct link_util *lu, int argc, char **argv,
+ struct nlmsghdr *n)
+{
+ __u8 state;
+ __u16 priority;
+ __u32 cost;
+
+ while (argc > 0) {
+ if (matches(*argv, "state") == 0) {
+ NEXT_ARG();
+ if (get_u8(&state, *argv, 0))
+ invarg("state is invalid", *argv);
+ addattr8(n, 1024, IFLA_BRPORT_STATE, state);
+ } else if (matches(*argv, "priority") == 0) {
+ NEXT_ARG();
+ if (get_u16(&priority, *argv, 0))
+ invarg("priority is invalid", *argv);
+ addattr16(n, 1024, IFLA_BRPORT_PRIORITY, priority);
+ } else if (matches(*argv, "cost") == 0) {
+ NEXT_ARG();
+ if (get_u32(&cost, *argv, 0))
+ invarg("cost is invalid", *argv);
+ addattr32(n, 1024, IFLA_BRPORT_COST, cost);
+ } else if (matches(*argv, "hairpin") == 0) {
+ NEXT_ARG();
+ bridge_slave_parse_on_off("hairpin", *argv, n,
+ IFLA_BRPORT_MODE);
+ } else if (matches(*argv, "guard") == 0) {
+ NEXT_ARG();
+ bridge_slave_parse_on_off("guard", *argv, n,
+ IFLA_BRPORT_GUARD);
+ } else if (matches(*argv, "root_block") == 0) {
+ NEXT_ARG();
+ bridge_slave_parse_on_off("root_block", *argv, n,
+ IFLA_BRPORT_PROTECT);
+ } else if (matches(*argv, "fastleave") == 0) {
+ NEXT_ARG();
+ bridge_slave_parse_on_off("fastleave", *argv, n,
+ IFLA_BRPORT_FAST_LEAVE);
+ } else if (matches(*argv, "learning") == 0) {
+ NEXT_ARG();
+ bridge_slave_parse_on_off("learning", *argv, n,
+ IFLA_BRPORT_LEARNING);
+ } else if (matches(*argv, "flood") == 0) {
+ NEXT_ARG();
+ bridge_slave_parse_on_off("flood", *argv, n,
+ IFLA_BRPORT_UNICAST_FLOOD);
+ } else if (matches(*argv, "help") == 0) {
+ explain();
+ return -1;
+ } else {
+ fprintf(stderr, "bridge_slave: unknown option \"%s\"?\n",
+ *argv);
+ explain();
+ return -1;
+ }
+ argc--, argv++;
+ }
+
+ return 0;
+}
+
+struct link_util bridge_slave_link_util = {
+ .id = "bridge",
+ .maxattr = IFLA_BRPORT_MAX,
+ .print_opt = bridge_slave_print_opt,
+ .parse_opt = bridge_slave_parse_opt,
+ .slave = true,
+};
--
1.9.3
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [patch iproute2 2/2] add bridge master device support
2014-09-05 13:55 ` [patch iproute2 1/2] add bridge_slave device support Jiri Pirko
@ 2014-09-05 13:55 ` Jiri Pirko
2014-09-28 23:09 ` [patch iproute2 1/2] add bridge_slave " Stephen Hemminger
` (2 subsequent siblings)
3 siblings, 0 replies; 15+ messages in thread
From: Jiri Pirko @ 2014-09-05 13:55 UTC (permalink / raw)
To: netdev; +Cc: davem, stephen, sfeldma, arvid.brodin, sucheta.chakraborty
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
---
include/linux/if_link.h | 12 +++++++
ip/Makefile | 2 +-
ip/iplink_bridge.c | 93 +++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 106 insertions(+), 1 deletion(-)
create mode 100644 ip/iplink_bridge.c
diff --git a/include/linux/if_link.h b/include/linux/if_link.h
index 39cb62c..e9e6f03 100644
--- a/include/linux/if_link.h
+++ b/include/linux/if_link.h
@@ -213,6 +213,18 @@ enum in6_addr_gen_mode {
IN6_ADDR_GEN_MODE_NONE,
};
+/* Bridge section */
+
+enum {
+ IFLA_BR_UNSPEC,
+ IFLA_BR_FORWARD_DELAY,
+ IFLA_BR_HELLO_TIME,
+ IFLA_BR_MAX_AGE,
+ __IFLA_BR_MAX,
+};
+
+#define IFLA_BR_MAX (__IFLA_BR_MAX - 1)
+
enum {
BRIDGE_MODE_UNSPEC,
BRIDGE_MODE_HAIRPIN,
diff --git a/ip/Makefile b/ip/Makefile
index 0c0b831..381f971 100644
--- a/ip/Makefile
+++ b/ip/Makefile
@@ -6,7 +6,7 @@ IPOBJ=ip.o ipaddress.o ipaddrlabel.o iproute.o iprule.o ipnetns.o \
iplink_macvlan.o iplink_macvtap.o ipl2tp.o link_vti.o \
iplink_vxlan.o tcp_metrics.o iplink_ipoib.o ipnetconf.o link_ip6tnl.o \
link_iptnl.o link_gre6.o iplink_bond.o iplink_bond_slave.o iplink_hsr.o \
- iplink_bridge_slave.o
+ iplink_bridge.o iplink_bridge_slave.o
RTMONOBJ=rtmon.o
diff --git a/ip/iplink_bridge.c b/ip/iplink_bridge.c
new file mode 100644
index 0000000..0cea7d1
--- /dev/null
+++ b/ip/iplink_bridge.c
@@ -0,0 +1,93 @@
+/*
+ * iplink_bridge.c Bridge device support
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ *
+ * Authors: Jiri Pirko <jiri@resnulli.us>
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <linux/if_link.h>
+
+#include "utils.h"
+#include "ip_common.h"
+
+static void explain(void)
+{
+ fprintf(stderr,
+ "Usage: ... bridge [ forward_delay FORWARD_DELAY ]\n"
+ " [ hello_time HELLO_TIME ]\n"
+ " [ max_age MAX_AGE ]\n"
+ );
+}
+
+static int bridge_parse_opt(struct link_util *lu, int argc, char **argv,
+ struct nlmsghdr *n)
+{
+ __u32 val;
+
+ while (argc > 0) {
+ if (matches(*argv, "forward_delay") == 0) {
+ NEXT_ARG();
+ if (get_u32(&val, *argv, 0)) {
+ invarg("invalid forward_delay", *argv);
+ return -1;
+ }
+ addattr32(n, 1024, IFLA_BR_FORWARD_DELAY, val);
+ } else if (matches(*argv, "hello_time") == 0) {
+ NEXT_ARG();
+ if (get_u32(&val, *argv, 0)) {
+ invarg("invalid hello_time", *argv);
+ return -1;
+ }
+ addattr32(n, 1024, IFLA_BR_HELLO_TIME, val);
+ } else if (matches(*argv, "max_age") == 0) {
+ NEXT_ARG();
+ if (get_u32(&val, *argv, 0)) {
+ invarg("invalid max_age", *argv);
+ return -1;
+ }
+ addattr32(n, 1024, IFLA_BR_MAX_AGE, val);
+ } else if (matches(*argv, "help") == 0) {
+ explain();
+ return -1;
+ } else {
+ fprintf(stderr, "bridge: unknown command \"%s\"?\n", *argv);
+ explain();
+ return -1;
+ }
+ argc--, argv++;
+ }
+
+ return 0;
+}
+
+static void bridge_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
+{
+ if (!tb)
+ return;
+
+ if (tb[IFLA_BR_FORWARD_DELAY])
+ fprintf(f, "forward_delay %u ",
+ rta_getattr_u32(tb[IFLA_BR_FORWARD_DELAY]));
+
+ if (tb[IFLA_BR_HELLO_TIME])
+ fprintf(f, "hello_time %u ",
+ rta_getattr_u32(tb[IFLA_BR_HELLO_TIME]));
+
+ if (tb[IFLA_BR_MAX_AGE])
+ fprintf(f, "max_age %u ",
+ rta_getattr_u32(tb[IFLA_BR_MAX_AGE]));
+}
+
+struct link_util bridge_link_util = {
+ .id = "bridge",
+ .maxattr = IFLA_BR_MAX,
+ .parse_opt = bridge_parse_opt,
+ .print_opt = bridge_print_opt,
+};
--
1.9.3
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [patch net-next 0/5] bridge: implement rtnl_link options for getting and setting bridge options
2014-09-05 13:51 [patch net-next 0/5] bridge: implement rtnl_link options for getting and setting bridge options Jiri Pirko
` (5 preceding siblings ...)
2014-09-05 13:55 ` [patch iproute2 1/2] add bridge_slave device support Jiri Pirko
@ 2014-09-05 17:06 ` Stephen Hemminger
2014-09-07 23:06 ` David Miller
2014-09-09 18:30 ` David Miller
8 siblings, 0 replies; 15+ messages in thread
From: Stephen Hemminger @ 2014-09-05 17:06 UTC (permalink / raw)
To: Jiri Pirko; +Cc: netdev, davem, sfeldma, arvid.brodin, sucheta.chakraborty
On Fri, 5 Sep 2014 15:51:27 +0200
Jiri Pirko <jiri@resnulli.us> wrote:
> So far, only sysfs is complete interface for getting and setting bridge
> options. This patchset follows-up on the similar bonding code and
> allows userspace to get/set bridge master/port options using Netlink
> IFLA_INFO_DATA/IFLA_INFO_SLAVE_DATA attr.
>
> Jiri Pirko (5):
> bridge: switch order of rx_handler reg and upper dev link
> bridge: implement rtnl_link_ops->get_slave_size and
> rtnl_link_ops->fill_slave_info
> bridge: implement rtnl_link_ops->slave_changelink
> bridge: implement rtnl_link_ops->get_size and rtnl_link_ops->fill_info
> bridge: implement rtnl_link_ops->changelink
>
> include/uapi/linux/if_link.h | 12 +++++
> net/bridge/br_if.c | 15 +++---
> net/bridge/br_netlink.c | 109 +++++++++++++++++++++++++++++++++++++++----
> 3 files changed, 121 insertions(+), 15 deletions(-)
>
Looks good, I will try and go over in more detail and look for
any specific issues.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [patch net-next 0/5] bridge: implement rtnl_link options for getting and setting bridge options
2014-09-05 13:51 [patch net-next 0/5] bridge: implement rtnl_link options for getting and setting bridge options Jiri Pirko
` (6 preceding siblings ...)
2014-09-05 17:06 ` [patch net-next 0/5] bridge: implement rtnl_link options for getting and setting bridge options Stephen Hemminger
@ 2014-09-07 23:06 ` David Miller
2014-09-09 18:30 ` David Miller
8 siblings, 0 replies; 15+ messages in thread
From: David Miller @ 2014-09-07 23:06 UTC (permalink / raw)
To: jiri; +Cc: netdev, stephen, sfeldma, arvid.brodin, sucheta.chakraborty
From: Jiri Pirko <jiri@resnulli.us>
Date: Fri, 5 Sep 2014 15:51:27 +0200
> So far, only sysfs is complete interface for getting and setting bridge
> options. This patchset follows-up on the similar bonding code and
> allows userspace to get/set bridge master/port options using Netlink
> IFLA_INFO_DATA/IFLA_INFO_SLAVE_DATA attr.
Stephen, please review this series, thanks.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [patch net-next 0/5] bridge: implement rtnl_link options for getting and setting bridge options
2014-09-05 13:51 [patch net-next 0/5] bridge: implement rtnl_link options for getting and setting bridge options Jiri Pirko
` (7 preceding siblings ...)
2014-09-07 23:06 ` David Miller
@ 2014-09-09 18:30 ` David Miller
8 siblings, 0 replies; 15+ messages in thread
From: David Miller @ 2014-09-09 18:30 UTC (permalink / raw)
To: jiri; +Cc: netdev, stephen, sfeldma, arvid.brodin, sucheta.chakraborty
From: Jiri Pirko <jiri@resnulli.us>
Date: Fri, 5 Sep 2014 15:51:27 +0200
> So far, only sysfs is complete interface for getting and setting bridge
> options. This patchset follows-up on the similar bonding code and
> allows userspace to get/set bridge master/port options using Netlink
> IFLA_INFO_DATA/IFLA_INFO_SLAVE_DATA attr.
Series applied, thanks Jiri.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [patch iproute2 1/2] add bridge_slave device support
2014-09-05 13:55 ` [patch iproute2 1/2] add bridge_slave device support Jiri Pirko
2014-09-05 13:55 ` [patch iproute2 2/2] add bridge master " Jiri Pirko
@ 2014-09-28 23:09 ` Stephen Hemminger
2014-09-28 23:33 ` Stephen Hemminger
2014-09-29 18:20 ` Or Gerlitz
3 siblings, 0 replies; 15+ messages in thread
From: Stephen Hemminger @ 2014-09-28 23:09 UTC (permalink / raw)
To: Jiri Pirko; +Cc: netdev, davem, sfeldma, arvid.brodin, sucheta.chakraborty
On Fri, 5 Sep 2014 15:55:08 +0200
Jiri Pirko <jiri@resnulli.us> wrote:
> Note this depends on "iproute2: allow to change slave options via
> type_slave"
>
> Signed-off-by: Jiri Pirko <jiri@resnulli.us>
> ---
> ip/Makefile | 3 +-
> ip/iplink_bridge_slave.c | 181 +++++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 183 insertions(+), 1 deletion(-)
> create mode 100644 ip/iplink_bridge_slave.c
Both applied
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [patch iproute2 1/2] add bridge_slave device support
2014-09-05 13:55 ` [patch iproute2 1/2] add bridge_slave device support Jiri Pirko
2014-09-05 13:55 ` [patch iproute2 2/2] add bridge master " Jiri Pirko
2014-09-28 23:09 ` [patch iproute2 1/2] add bridge_slave " Stephen Hemminger
@ 2014-09-28 23:33 ` Stephen Hemminger
2014-09-29 18:20 ` Or Gerlitz
3 siblings, 0 replies; 15+ messages in thread
From: Stephen Hemminger @ 2014-09-28 23:33 UTC (permalink / raw)
To: Jiri Pirko; +Cc: netdev, davem, sfeldma, arvid.brodin, sucheta.chakraborty
On Fri, 5 Sep 2014 15:55:08 +0200
Jiri Pirko <jiri@resnulli.us> wrote:
> Note this depends on "iproute2: allow to change slave options via
> type_slave"
>
> Signed-off-by: Jiri Pirko <jiri@resnulli.us>
The iproute portion has to go in net-next not master branch of iproute2
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [patch iproute2 1/2] add bridge_slave device support
2014-09-05 13:55 ` [patch iproute2 1/2] add bridge_slave device support Jiri Pirko
` (2 preceding siblings ...)
2014-09-28 23:33 ` Stephen Hemminger
@ 2014-09-29 18:20 ` Or Gerlitz
2014-09-30 8:05 ` Jiri Pirko
3 siblings, 1 reply; 15+ messages in thread
From: Or Gerlitz @ 2014-09-29 18:20 UTC (permalink / raw)
To: Jiri Pirko
Cc: Linux Netdev List, David Miller, Stephen Hemminger,
Scott Feldman, arvid.brodin, sucheta.chakraborty
On Fri, Sep 5, 2014 at 4:55 PM, Jiri Pirko <jiri@resnulli.us> wrote:
> Note this depends on "iproute2: allow to change slave options via
> type_slave"
OK, but how about sparing few words what this patch does?
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [patch iproute2 1/2] add bridge_slave device support
2014-09-29 18:20 ` Or Gerlitz
@ 2014-09-30 8:05 ` Jiri Pirko
0 siblings, 0 replies; 15+ messages in thread
From: Jiri Pirko @ 2014-09-30 8:05 UTC (permalink / raw)
To: Or Gerlitz
Cc: Linux Netdev List, David Miller, Stephen Hemminger,
Scott Feldman, arvid.brodin, sucheta.chakraborty
Mon, Sep 29, 2014 at 08:20:00PM CEST, gerlitz.or@gmail.com wrote:
>On Fri, Sep 5, 2014 at 4:55 PM, Jiri Pirko <jiri@resnulli.us> wrote:
>> Note this depends on "iproute2: allow to change slave options via
>> type_slave"
>
>OK, but how about sparing few words what this patch does?
Sorry, I thought it is obvious. It allows to use IFLA_INFO_SLAVE_DATA to
get/set bridge port options.
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2014-09-30 8:05 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-05 13:51 [patch net-next 0/5] bridge: implement rtnl_link options for getting and setting bridge options Jiri Pirko
2014-09-05 13:51 ` [patch net-next 1/5] bridge: switch order of rx_handler reg and upper dev link Jiri Pirko
2014-09-05 13:51 ` [patch net-next 2/5] bridge: implement rtnl_link_ops->get_slave_size and rtnl_link_ops->fill_slave_info Jiri Pirko
2014-09-05 13:51 ` [patch net-next 3/5] bridge: implement rtnl_link_ops->slave_changelink Jiri Pirko
2014-09-05 13:51 ` [patch net-next 4/5] bridge: implement rtnl_link_ops->get_size and rtnl_link_ops->fill_info Jiri Pirko
2014-09-05 13:51 ` [patch net-next 5/5] bridge: implement rtnl_link_ops->changelink Jiri Pirko
2014-09-05 13:55 ` [patch iproute2 1/2] add bridge_slave device support Jiri Pirko
2014-09-05 13:55 ` [patch iproute2 2/2] add bridge master " Jiri Pirko
2014-09-28 23:09 ` [patch iproute2 1/2] add bridge_slave " Stephen Hemminger
2014-09-28 23:33 ` Stephen Hemminger
2014-09-29 18:20 ` Or Gerlitz
2014-09-30 8:05 ` Jiri Pirko
2014-09-05 17:06 ` [patch net-next 0/5] bridge: implement rtnl_link options for getting and setting bridge options Stephen Hemminger
2014-09-07 23:06 ` David Miller
2014-09-09 18:30 ` David Miller
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.