aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/link.c
diff options
context:
space:
mode:
authorRichard Alpe <richard.alpe@ericsson.com>2014-11-20 04:29:13 -0500
committerDavid S. Miller <davem@davemloft.net>2014-11-21 15:01:30 -0500
commitf96ce7a20d6972a834202f3cdd6a53fd0ee26a8e (patch)
treee4251ee45e56e3cd36c559996474ab4928c34e6e /net/tipc/link.c
parent7be57fc6918470ecacd16b89c0d4f73d8fc265c4 (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>
Diffstat (limited to 'net/tipc/link.c')
-rw-r--r--net/tipc/link.c73
1 files changed, 73 insertions, 0 deletions
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
2444int 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
2512out:
2513 tipc_node_unlock(node);
2514
2515 return res;
2516}
2444int __tipc_nl_add_stats(struct sk_buff *skb, struct tipc_stats *s) 2517int __tipc_nl_add_stats(struct sk_buff *skb, struct tipc_stats *s)
2445{ 2518{
2446 int i; 2519 int i;