diff options
author | Jiri Pirko <jiri@resnulli.us> | 2014-09-05 09:51:31 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-09-09 14:29:55 -0400 |
commit | e5c3ea5c668033b303e7ac835d7d91da32d97958 (patch) | |
tree | cf53b62bb7cba3ff01b19e6f58ac64f175917700 | |
parent | 3ac636b8591c37bb5028814a4ebd41d263b56181 (diff) |
bridge: implement rtnl_link_ops->get_size and rtnl_link_ops->fill_info
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/uapi/linux/if_link.h | 12 | ||||
-rw-r--r-- | net/bridge/br_netlink.c | 25 |
2 files changed, 37 insertions, 0 deletions
diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h index ff957604a721..c80f95f6ee78 100644 --- a/include/uapi/linux/if_link.h +++ b/include/uapi/linux/if_link.h | |||
@@ -215,6 +215,18 @@ enum in6_addr_gen_mode { | |||
215 | IN6_ADDR_GEN_MODE_NONE, | 215 | IN6_ADDR_GEN_MODE_NONE, |
216 | }; | 216 | }; |
217 | 217 | ||
218 | /* Bridge section */ | ||
219 | |||
220 | enum { | ||
221 | IFLA_BR_UNSPEC, | ||
222 | IFLA_BR_FORWARD_DELAY, | ||
223 | IFLA_BR_HELLO_TIME, | ||
224 | IFLA_BR_MAX_AGE, | ||
225 | __IFLA_BR_MAX, | ||
226 | }; | ||
227 | |||
228 | #define IFLA_BR_MAX (__IFLA_BR_MAX - 1) | ||
229 | |||
218 | enum { | 230 | enum { |
219 | BRIDGE_MODE_UNSPEC, | 231 | BRIDGE_MODE_UNSPEC, |
220 | BRIDGE_MODE_HAIRPIN, | 232 | BRIDGE_MODE_HAIRPIN, |
diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c index 05aeea1222a7..bcac09fe2ac8 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, | |||
484 | return br_port_info_size(); | 484 | return br_port_info_size(); |
485 | } | 485 | } |
486 | 486 | ||
487 | static size_t br_get_size(const struct net_device *brdev) | ||
488 | { | ||
489 | return nla_total_size(sizeof(u32)) + /* IFLA_BR_FORWARD_DELAY */ | ||
490 | nla_total_size(sizeof(u32)) + /* IFLA_BR_HELLO_TIME */ | ||
491 | nla_total_size(sizeof(u32)) + /* IFLA_BR_MAX_AGE */ | ||
492 | 0; | ||
493 | } | ||
494 | |||
495 | static int br_fill_info(struct sk_buff *skb, const struct net_device *brdev) | ||
496 | { | ||
497 | struct net_bridge *br = netdev_priv(brdev); | ||
498 | u32 forward_delay = jiffies_to_clock_t(br->forward_delay); | ||
499 | u32 hello_time = jiffies_to_clock_t(br->hello_time); | ||
500 | u32 age_time = jiffies_to_clock_t(br->max_age); | ||
501 | |||
502 | if (nla_put_u32(skb, IFLA_BR_FORWARD_DELAY, forward_delay) || | ||
503 | nla_put_u32(skb, IFLA_BR_HELLO_TIME, hello_time) || | ||
504 | nla_put_u32(skb, IFLA_BR_MAX_AGE, age_time)) | ||
505 | return -EMSGSIZE; | ||
506 | |||
507 | return 0; | ||
508 | } | ||
509 | |||
487 | static size_t br_get_link_af_size(const struct net_device *dev) | 510 | static size_t br_get_link_af_size(const struct net_device *dev) |
488 | { | 511 | { |
489 | struct net_port_vlans *pv; | 512 | struct net_port_vlans *pv; |
@@ -514,6 +537,8 @@ struct rtnl_link_ops br_link_ops __read_mostly = { | |||
514 | .validate = br_validate, | 537 | .validate = br_validate, |
515 | .newlink = br_dev_newlink, | 538 | .newlink = br_dev_newlink, |
516 | .dellink = br_dev_delete, | 539 | .dellink = br_dev_delete, |
540 | .get_size = br_get_size, | ||
541 | .fill_info = br_fill_info, | ||
517 | 542 | ||
518 | .slave_maxtype = IFLA_BRPORT_MAX, | 543 | .slave_maxtype = IFLA_BRPORT_MAX, |
519 | .slave_policy = br_port_policy, | 544 | .slave_policy = br_port_policy, |