aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
Diffstat (limited to 'net')
-rw-r--r--net/tipc/config.c4
-rw-r--r--net/tipc/netlink_compat.c23
-rw-r--r--net/tipc/node.c73
-rw-r--r--net/tipc/node.h2
4 files changed, 23 insertions, 79 deletions
diff --git a/net/tipc/config.c b/net/tipc/config.c
index 67b76ee847f3..1b17f5846e86 100644
--- a/net/tipc/config.c
+++ b/net/tipc/config.c
@@ -209,10 +209,6 @@ struct sk_buff *tipc_cfg_do_cmd(struct net *net, u32 orig_node, u16 cmd,
209 rep_tlv_buf = tipc_node_get_nodes(net, req_tlv_area, 209 rep_tlv_buf = tipc_node_get_nodes(net, req_tlv_area,
210 req_tlv_space); 210 req_tlv_space);
211 break; 211 break;
212 case TIPC_CMD_GET_LINKS:
213 rep_tlv_buf = tipc_node_get_links(net, req_tlv_area,
214 req_tlv_space);
215 break;
216 case TIPC_CMD_RESET_LINK_STATS: 212 case TIPC_CMD_RESET_LINK_STATS:
217 rep_tlv_buf = tipc_link_cmd_reset_stats(net, req_tlv_area, 213 rep_tlv_buf = tipc_link_cmd_reset_stats(net, req_tlv_area,
218 req_tlv_space); 214 req_tlv_space);
diff --git a/net/tipc/netlink_compat.c b/net/tipc/netlink_compat.c
index 899bd94da467..bff9403899ed 100644
--- a/net/tipc/netlink_compat.c
+++ b/net/tipc/netlink_compat.c
@@ -553,6 +553,22 @@ static int tipc_nl_compat_link_stat_dump(struct tipc_nl_compat_msg *msg,
553 return 0; 553 return 0;
554} 554}
555 555
556static int tipc_nl_compat_link_dump(struct tipc_nl_compat_msg *msg,
557 struct nlattr **attrs)
558{
559 struct nlattr *link[TIPC_NLA_LINK_MAX + 1];
560 struct tipc_link_info link_info;
561
562 nla_parse_nested(link, TIPC_NLA_LINK_MAX, attrs[TIPC_NLA_LINK], NULL);
563
564 link_info.dest = nla_get_flag(link[TIPC_NLA_LINK_DEST]);
565 link_info.up = htonl(nla_get_flag(link[TIPC_NLA_LINK_UP]));
566 strcpy(link_info.str, nla_data(link[TIPC_NLA_LINK_NAME]));
567
568 return tipc_add_tlv(msg->rep, TIPC_TLV_LINK_INFO,
569 &link_info, sizeof(link_info));
570}
571
556static int tipc_nl_compat_handle(struct tipc_nl_compat_msg *msg) 572static int tipc_nl_compat_handle(struct tipc_nl_compat_msg *msg)
557{ 573{
558 struct tipc_nl_compat_cmd_dump dump; 574 struct tipc_nl_compat_cmd_dump dump;
@@ -584,6 +600,12 @@ static int tipc_nl_compat_handle(struct tipc_nl_compat_msg *msg)
584 dump.dumpit = tipc_nl_link_dump; 600 dump.dumpit = tipc_nl_link_dump;
585 dump.format = tipc_nl_compat_link_stat_dump; 601 dump.format = tipc_nl_compat_link_stat_dump;
586 return tipc_nl_compat_dumpit(&dump, msg); 602 return tipc_nl_compat_dumpit(&dump, msg);
603 case TIPC_CMD_GET_LINKS:
604 msg->req_type = TIPC_TLV_NET_ADDR;
605 msg->rep_size = ULTRA_STRING_MAX_LEN;
606 dump.dumpit = tipc_nl_link_dump;
607 dump.format = tipc_nl_compat_link_dump;
608 return tipc_nl_compat_dumpit(&dump, msg);
587 } 609 }
588 610
589 return -EOPNOTSUPP; 611 return -EOPNOTSUPP;
@@ -684,6 +706,7 @@ static int tipc_nl_compat_tmp_wrap(struct sk_buff *skb, struct genl_info *info)
684 case TIPC_CMD_ENABLE_BEARER: 706 case TIPC_CMD_ENABLE_BEARER:
685 case TIPC_CMD_DISABLE_BEARER: 707 case TIPC_CMD_DISABLE_BEARER:
686 case TIPC_CMD_SHOW_LINK_STATS: 708 case TIPC_CMD_SHOW_LINK_STATS:
709 case TIPC_CMD_GET_LINKS:
687 return tipc_nl_compat_recv(skb, info); 710 return tipc_nl_compat_recv(skb, info);
688 } 711 }
689 712
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 *
diff --git a/net/tipc/node.h b/net/tipc/node.h
index 20ec13f9bede..59dafee61aa0 100644
--- a/net/tipc/node.h
+++ b/net/tipc/node.h
@@ -142,8 +142,6 @@ void tipc_node_link_down(struct tipc_node *n_ptr, struct tipc_link *l_ptr);
142void tipc_node_link_up(struct tipc_node *n_ptr, struct tipc_link *l_ptr); 142void tipc_node_link_up(struct tipc_node *n_ptr, struct tipc_link *l_ptr);
143int tipc_node_active_links(struct tipc_node *n_ptr); 143int tipc_node_active_links(struct tipc_node *n_ptr);
144int tipc_node_is_up(struct tipc_node *n_ptr); 144int tipc_node_is_up(struct tipc_node *n_ptr);
145struct sk_buff *tipc_node_get_links(struct net *net, const void *req_tlv_area,
146 int req_tlv_space);
147struct sk_buff *tipc_node_get_nodes(struct net *net, const void *req_tlv_area, 145struct sk_buff *tipc_node_get_nodes(struct net *net, const void *req_tlv_area,
148 int req_tlv_space); 146 int req_tlv_space);
149int tipc_node_get_linkname(struct net *net, u32 bearer_id, u32 node, 147int tipc_node_get_linkname(struct net *net, u32 bearer_id, u32 node,