aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/node.c
diff options
context:
space:
mode:
authorRichard Alpe <richard.alpe@ericsson.com>2015-02-09 03:50:07 -0500
committerDavid S. Miller <davem@davemloft.net>2015-02-09 16:20:48 -0500
commit357ebdbfca0baa9a8d8d85307393e9ec3406affc (patch)
treee12b5c96459aad150b2e66a417634d39be0a14cd /net/tipc/node.c
parentf2b3b2d4ccbf9666f5f42a21347cd1aaa532b2fa (diff)
tipc: convert legacy nl link dump to nl compat
Convert TIPC_CMD_GET_LINKS to compat dumpit and remove global link counter solely used by the legacy API. Signed-off-by: Richard Alpe <richard.alpe@ericsson.com> Reviewed-by: Erik Hugne <erik.hugne@ericsson.com> Reviewed-by: Ying Xue <ying.xue@windriver.com> Reviewed-by: Jon Maloy <jon.maloy@ericsson.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc/node.c')
-rw-r--r--net/tipc/node.c73
1 files changed, 0 insertions, 73 deletions
diff --git a/net/tipc/node.c b/net/tipc/node.c
index 995618d6da9d..46b87f77d342 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -319,27 +319,18 @@ int tipc_node_is_up(struct tipc_node *n_ptr)
319 319
320void tipc_node_attach_link(struct tipc_node *n_ptr, struct tipc_link *l_ptr) 320void tipc_node_attach_link(struct tipc_node *n_ptr, struct tipc_link *l_ptr)
321{ 321{
322 struct tipc_net *tn = net_generic(n_ptr->net, tipc_net_id);
323
324 n_ptr->links[l_ptr->bearer_id] = l_ptr; 322 n_ptr->links[l_ptr->bearer_id] = l_ptr;
325 spin_lock_bh(&tn->node_list_lock);
326 tn->num_links++;
327 spin_unlock_bh(&tn->node_list_lock);
328 n_ptr->link_cnt++; 323 n_ptr->link_cnt++;
329} 324}
330 325
331void tipc_node_detach_link(struct tipc_node *n_ptr, struct tipc_link *l_ptr) 326void tipc_node_detach_link(struct tipc_node *n_ptr, struct tipc_link *l_ptr)
332{ 327{
333 struct tipc_net *tn = net_generic(n_ptr->net, tipc_net_id);
334 int i; 328 int i;
335 329
336 for (i = 0; i < MAX_BEARERS; i++) { 330 for (i = 0; i < MAX_BEARERS; i++) {
337 if (l_ptr != n_ptr->links[i]) 331 if (l_ptr != n_ptr->links[i])
338 continue; 332 continue;
339 n_ptr->links[i] = NULL; 333 n_ptr->links[i] = NULL;
340 spin_lock_bh(&tn->node_list_lock);
341 tn->num_links--;
342 spin_unlock_bh(&tn->node_list_lock);
343 n_ptr->link_cnt--; 334 n_ptr->link_cnt--;
344 } 335 }
345} 336}
@@ -467,70 +458,6 @@ struct sk_buff *tipc_node_get_nodes(struct net *net, const void *req_tlv_area,
467 return buf; 458 return buf;
468} 459}
469 460
470struct sk_buff *tipc_node_get_links(struct net *net, const void *req_tlv_area,
471 int req_tlv_space)
472{
473 struct tipc_net *tn = net_generic(net, tipc_net_id);
474 u32 domain;
475 struct sk_buff *buf;
476 struct tipc_node *n_ptr;
477 struct tipc_link_info link_info;
478 u32 payload_size;
479
480 if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_NET_ADDR))
481 return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR);
482
483 domain = ntohl(*(__be32 *)TLV_DATA(req_tlv_area));
484 if (!tipc_addr_domain_valid(domain))
485 return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE
486 " (network address)");
487
488 if (!tn->own_addr)
489 return tipc_cfg_reply_none();
490
491 spin_lock_bh(&tn->node_list_lock);
492 /* Get space for all unicast links + broadcast link */
493 payload_size = TLV_SPACE((sizeof(link_info)) * (tn->num_links + 1));
494 if (payload_size > 32768u) {
495 spin_unlock_bh(&tn->node_list_lock);
496 return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED
497 " (too many links)");
498 }
499 spin_unlock_bh(&tn->node_list_lock);
500
501 buf = tipc_cfg_reply_alloc(payload_size);
502 if (!buf)
503 return NULL;
504
505 /* Add TLV for broadcast link */
506 link_info.dest = htonl(tipc_cluster_mask(tn->own_addr));
507 link_info.up = htonl(1);
508 strlcpy(link_info.str, tipc_bclink_name, TIPC_MAX_LINK_NAME);
509 tipc_cfg_append_tlv(buf, TIPC_TLV_LINK_INFO, &link_info, sizeof(link_info));
510
511 /* Add TLVs for any other links in scope */
512 rcu_read_lock();
513 list_for_each_entry_rcu(n_ptr, &tn->node_list, list) {
514 u32 i;
515
516 if (!tipc_in_scope(domain, n_ptr->addr))
517 continue;
518 tipc_node_lock(n_ptr);
519 for (i = 0; i < MAX_BEARERS; i++) {
520 if (!n_ptr->links[i])
521 continue;
522 link_info.dest = htonl(n_ptr->addr);
523 link_info.up = htonl(tipc_link_is_up(n_ptr->links[i]));
524 strcpy(link_info.str, n_ptr->links[i]->name);
525 tipc_cfg_append_tlv(buf, TIPC_TLV_LINK_INFO,
526 &link_info, sizeof(link_info));
527 }
528 tipc_node_unlock(n_ptr);
529 }
530 rcu_read_unlock();
531 return buf;
532}
533
534/** 461/**
535 * tipc_node_get_linkname - get the name of a link 462 * tipc_node_get_linkname - get the name of a link
536 * 463 *