diff options
author | Richard Alpe <richard.alpe@ericsson.com> | 2014-11-20 04:29:13 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-11-21 15:01:30 -0500 |
commit | f96ce7a20d6972a834202f3cdd6a53fd0ee26a8e (patch) | |
tree | e4251ee45e56e3cd36c559996474ab4928c34e6e | |
parent | 7be57fc6918470ecacd16b89c0d4f73d8fc265c4 (diff) |
tipc: add link set to new netlink api
Add TIPC_NL_LINK_SET to the new tipc netlink API.
This command can set one or more link properties for a particular
link.
Netlink logical layout of link set message:
-> link
-> name
-> properties
[ -> tolerance ]
[ -> priority ]
[ -> window ]
Signed-off-by: Richard Alpe <richard.alpe@ericsson.com>
Reviewed-by: Erik Hugne <erik.hugne@ericsson.com>
Reviewed-by: Jon Maloy <jon.maloy@ericsson.com>
Acked-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/uapi/linux/tipc_netlink.h | 1 | ||||
-rw-r--r-- | net/tipc/link.c | 73 | ||||
-rw-r--r-- | net/tipc/link.h | 1 | ||||
-rw-r--r-- | net/tipc/netlink.c | 5 |
4 files changed, 80 insertions, 0 deletions
diff --git a/include/uapi/linux/tipc_netlink.h b/include/uapi/linux/tipc_netlink.h index 1034fb43d32e..2deb7fd8d85d 100644 --- a/include/uapi/linux/tipc_netlink.h +++ b/include/uapi/linux/tipc_netlink.h | |||
@@ -48,6 +48,7 @@ enum { | |||
48 | TIPC_NL_SOCK_GET, | 48 | TIPC_NL_SOCK_GET, |
49 | TIPC_NL_PUBL_GET, | 49 | TIPC_NL_PUBL_GET, |
50 | TIPC_NL_LINK_GET, | 50 | TIPC_NL_LINK_GET, |
51 | TIPC_NL_LINK_SET, | ||
51 | 52 | ||
52 | __TIPC_NL_CMD_MAX, | 53 | __TIPC_NL_CMD_MAX, |
53 | TIPC_NL_CMD_MAX = __TIPC_NL_CMD_MAX - 1 | 54 | TIPC_NL_CMD_MAX = __TIPC_NL_CMD_MAX - 1 |
diff --git a/net/tipc/link.c b/net/tipc/link.c index bdc4b5e5bf56..6785dcfd2d23 100644 --- a/net/tipc/link.c +++ b/net/tipc/link.c | |||
@@ -2441,6 +2441,79 @@ int tipc_nl_parse_link_prop(struct nlattr *prop, struct nlattr *props[]) | |||
2441 | return 0; | 2441 | return 0; |
2442 | } | 2442 | } |
2443 | 2443 | ||
2444 | int tipc_nl_link_set(struct sk_buff *skb, struct genl_info *info) | ||
2445 | { | ||
2446 | int err; | ||
2447 | int res = 0; | ||
2448 | int bearer_id; | ||
2449 | char *name; | ||
2450 | struct tipc_link *link; | ||
2451 | struct tipc_node *node; | ||
2452 | struct nlattr *attrs[TIPC_NLA_LINK_MAX + 1]; | ||
2453 | |||
2454 | if (!info->attrs[TIPC_NLA_LINK]) | ||
2455 | return -EINVAL; | ||
2456 | |||
2457 | err = nla_parse_nested(attrs, TIPC_NLA_LINK_MAX, | ||
2458 | info->attrs[TIPC_NLA_LINK], | ||
2459 | tipc_nl_link_policy); | ||
2460 | if (err) | ||
2461 | return err; | ||
2462 | |||
2463 | if (!attrs[TIPC_NLA_LINK_NAME]) | ||
2464 | return -EINVAL; | ||
2465 | |||
2466 | name = nla_data(attrs[TIPC_NLA_LINK_NAME]); | ||
2467 | |||
2468 | node = tipc_link_find_owner(name, &bearer_id); | ||
2469 | if (!node) | ||
2470 | return -EINVAL; | ||
2471 | |||
2472 | tipc_node_lock(node); | ||
2473 | |||
2474 | link = node->links[bearer_id]; | ||
2475 | if (!link) { | ||
2476 | res = -EINVAL; | ||
2477 | goto out; | ||
2478 | } | ||
2479 | |||
2480 | if (attrs[TIPC_NLA_LINK_PROP]) { | ||
2481 | struct nlattr *props[TIPC_NLA_PROP_MAX + 1]; | ||
2482 | |||
2483 | err = tipc_nl_parse_link_prop(attrs[TIPC_NLA_LINK_PROP], | ||
2484 | props); | ||
2485 | if (err) { | ||
2486 | res = err; | ||
2487 | goto out; | ||
2488 | } | ||
2489 | |||
2490 | if (props[TIPC_NLA_PROP_TOL]) { | ||
2491 | u32 tol; | ||
2492 | |||
2493 | tol = nla_get_u32(props[TIPC_NLA_PROP_TOL]); | ||
2494 | link_set_supervision_props(link, tol); | ||
2495 | tipc_link_proto_xmit(link, STATE_MSG, 0, 0, tol, 0, 0); | ||
2496 | } | ||
2497 | if (props[TIPC_NLA_PROP_PRIO]) { | ||
2498 | u32 prio; | ||
2499 | |||
2500 | prio = nla_get_u32(props[TIPC_NLA_PROP_PRIO]); | ||
2501 | link->priority = prio; | ||
2502 | tipc_link_proto_xmit(link, STATE_MSG, 0, 0, 0, prio, 0); | ||
2503 | } | ||
2504 | if (props[TIPC_NLA_PROP_WIN]) { | ||
2505 | u32 win; | ||
2506 | |||
2507 | win = nla_get_u32(props[TIPC_NLA_PROP_WIN]); | ||
2508 | tipc_link_set_queue_limits(link, win); | ||
2509 | } | ||
2510 | } | ||
2511 | |||
2512 | out: | ||
2513 | tipc_node_unlock(node); | ||
2514 | |||
2515 | return res; | ||
2516 | } | ||
2444 | int __tipc_nl_add_stats(struct sk_buff *skb, struct tipc_stats *s) | 2517 | int __tipc_nl_add_stats(struct sk_buff *skb, struct tipc_stats *s) |
2445 | { | 2518 | { |
2446 | int i; | 2519 | int i; |
diff --git a/net/tipc/link.h b/net/tipc/link.h index 8e3542a4a037..3738ba11ce00 100644 --- a/net/tipc/link.h +++ b/net/tipc/link.h | |||
@@ -242,6 +242,7 @@ void tipc_link_retransmit(struct tipc_link *l_ptr, | |||
242 | 242 | ||
243 | int tipc_nl_link_dump(struct sk_buff *skb, struct netlink_callback *cb); | 243 | int tipc_nl_link_dump(struct sk_buff *skb, struct netlink_callback *cb); |
244 | int tipc_nl_link_get(struct sk_buff *skb, struct genl_info *info); | 244 | int tipc_nl_link_get(struct sk_buff *skb, struct genl_info *info); |
245 | int tipc_nl_link_set(struct sk_buff *skb, struct genl_info *info); | ||
245 | int tipc_nl_parse_link_prop(struct nlattr *prop, struct nlattr *props[]); | 246 | int tipc_nl_parse_link_prop(struct nlattr *prop, struct nlattr *props[]); |
246 | 247 | ||
247 | /* | 248 | /* |
diff --git a/net/tipc/netlink.c b/net/tipc/netlink.c index ea168b889caa..d4444e59bf98 100644 --- a/net/tipc/netlink.c +++ b/net/tipc/netlink.c | |||
@@ -144,6 +144,11 @@ static const struct genl_ops tipc_genl_v2_ops[] = { | |||
144 | .doit = tipc_nl_link_get, | 144 | .doit = tipc_nl_link_get, |
145 | .dumpit = tipc_nl_link_dump, | 145 | .dumpit = tipc_nl_link_dump, |
146 | .policy = tipc_nl_policy, | 146 | .policy = tipc_nl_policy, |
147 | }, | ||
148 | { | ||
149 | .cmd = TIPC_NL_LINK_SET, | ||
150 | .doit = tipc_nl_link_set, | ||
151 | .policy = tipc_nl_policy, | ||
147 | } | 152 | } |
148 | }; | 153 | }; |
149 | 154 | ||