aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/link.c
diff options
context:
space:
mode:
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;