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.c326
1 files changed, 144 insertions, 182 deletions
diff --git a/net/tipc/link.c b/net/tipc/link.c
index 7a614f43549d..1c1e6151875e 100644
--- a/net/tipc/link.c
+++ b/net/tipc/link.c
@@ -41,6 +41,12 @@
41#include "discover.h" 41#include "discover.h"
42#include "config.h" 42#include "config.h"
43 43
44/*
45 * Error message prefixes
46 */
47static const char *link_co_err = "Link changeover error, ";
48static const char *link_rst_msg = "Resetting link ";
49static const char *link_unk_evt = "Unknown link event ";
44 50
45/* 51/*
46 * Out-of-range value for link session numbers 52 * Out-of-range value for link session numbers
@@ -153,8 +159,8 @@ int tipc_link_is_active(struct tipc_link *l_ptr)
153 159
154/** 160/**
155 * link_name_validate - validate & (optionally) deconstruct tipc_link name 161 * link_name_validate - validate & (optionally) deconstruct tipc_link name
156 * @name - ptr to link name string 162 * @name: ptr to link name string
157 * @name_parts - ptr to area for link name components (or NULL if not needed) 163 * @name_parts: ptr to area for link name components (or NULL if not needed)
158 * 164 *
159 * Returns 1 if link name is valid, otherwise 0. 165 * Returns 1 if link name is valid, otherwise 0.
160 */ 166 */
@@ -300,20 +306,20 @@ struct tipc_link *tipc_link_create(struct tipc_node *n_ptr,
300 306
301 if (n_ptr->link_cnt >= 2) { 307 if (n_ptr->link_cnt >= 2) {
302 tipc_addr_string_fill(addr_string, n_ptr->addr); 308 tipc_addr_string_fill(addr_string, n_ptr->addr);
303 err("Attempt to establish third link to %s\n", addr_string); 309 pr_err("Attempt to establish third link to %s\n", addr_string);
304 return NULL; 310 return NULL;
305 } 311 }
306 312
307 if (n_ptr->links[b_ptr->identity]) { 313 if (n_ptr->links[b_ptr->identity]) {
308 tipc_addr_string_fill(addr_string, n_ptr->addr); 314 tipc_addr_string_fill(addr_string, n_ptr->addr);
309 err("Attempt to establish second link on <%s> to %s\n", 315 pr_err("Attempt to establish second link on <%s> to %s\n",
310 b_ptr->name, addr_string); 316 b_ptr->name, addr_string);
311 return NULL; 317 return NULL;
312 } 318 }
313 319
314 l_ptr = kzalloc(sizeof(*l_ptr), GFP_ATOMIC); 320 l_ptr = kzalloc(sizeof(*l_ptr), GFP_ATOMIC);
315 if (!l_ptr) { 321 if (!l_ptr) {
316 warn("Link creation failed, no memory\n"); 322 pr_warn("Link creation failed, no memory\n");
317 return NULL; 323 return NULL;
318 } 324 }
319 325
@@ -371,7 +377,7 @@ struct tipc_link *tipc_link_create(struct tipc_node *n_ptr,
371void tipc_link_delete(struct tipc_link *l_ptr) 377void tipc_link_delete(struct tipc_link *l_ptr)
372{ 378{
373 if (!l_ptr) { 379 if (!l_ptr) {
374 err("Attempt to delete non-existent link\n"); 380 pr_err("Attempt to delete non-existent link\n");
375 return; 381 return;
376 } 382 }
377 383
@@ -632,8 +638,8 @@ static void link_state_event(struct tipc_link *l_ptr, unsigned int event)
632 link_set_timer(l_ptr, cont_intv / 4); 638 link_set_timer(l_ptr, cont_intv / 4);
633 break; 639 break;
634 case RESET_MSG: 640 case RESET_MSG:
635 info("Resetting link <%s>, requested by peer\n", 641 pr_info("%s<%s>, requested by peer\n", link_rst_msg,
636 l_ptr->name); 642 l_ptr->name);
637 tipc_link_reset(l_ptr); 643 tipc_link_reset(l_ptr);
638 l_ptr->state = RESET_RESET; 644 l_ptr->state = RESET_RESET;
639 l_ptr->fsm_msg_cnt = 0; 645 l_ptr->fsm_msg_cnt = 0;
@@ -642,7 +648,7 @@ static void link_state_event(struct tipc_link *l_ptr, unsigned int event)
642 link_set_timer(l_ptr, cont_intv); 648 link_set_timer(l_ptr, cont_intv);
643 break; 649 break;
644 default: 650 default:
645 err("Unknown link event %u in WW state\n", event); 651 pr_err("%s%u in WW state\n", link_unk_evt, event);
646 } 652 }
647 break; 653 break;
648 case WORKING_UNKNOWN: 654 case WORKING_UNKNOWN:
@@ -654,8 +660,8 @@ static void link_state_event(struct tipc_link *l_ptr, unsigned int event)
654 link_set_timer(l_ptr, cont_intv); 660 link_set_timer(l_ptr, cont_intv);
655 break; 661 break;
656 case RESET_MSG: 662 case RESET_MSG:
657 info("Resetting link <%s>, requested by peer " 663 pr_info("%s<%s>, requested by peer while probing\n",
658 "while probing\n", l_ptr->name); 664 link_rst_msg, l_ptr->name);
659 tipc_link_reset(l_ptr); 665 tipc_link_reset(l_ptr);
660 l_ptr->state = RESET_RESET; 666 l_ptr->state = RESET_RESET;
661 l_ptr->fsm_msg_cnt = 0; 667 l_ptr->fsm_msg_cnt = 0;
@@ -680,8 +686,8 @@ static void link_state_event(struct tipc_link *l_ptr, unsigned int event)
680 l_ptr->fsm_msg_cnt++; 686 l_ptr->fsm_msg_cnt++;
681 link_set_timer(l_ptr, cont_intv / 4); 687 link_set_timer(l_ptr, cont_intv / 4);
682 } else { /* Link has failed */ 688 } else { /* Link has failed */
683 warn("Resetting link <%s>, peer not responding\n", 689 pr_warn("%s<%s>, peer not responding\n",
684 l_ptr->name); 690 link_rst_msg, l_ptr->name);
685 tipc_link_reset(l_ptr); 691 tipc_link_reset(l_ptr);
686 l_ptr->state = RESET_UNKNOWN; 692 l_ptr->state = RESET_UNKNOWN;
687 l_ptr->fsm_msg_cnt = 0; 693 l_ptr->fsm_msg_cnt = 0;
@@ -692,7 +698,7 @@ static void link_state_event(struct tipc_link *l_ptr, unsigned int event)
692 } 698 }
693 break; 699 break;
694 default: 700 default:
695 err("Unknown link event %u in WU state\n", event); 701 pr_err("%s%u in WU state\n", link_unk_evt, event);
696 } 702 }
697 break; 703 break;
698 case RESET_UNKNOWN: 704 case RESET_UNKNOWN:
@@ -726,7 +732,7 @@ static void link_state_event(struct tipc_link *l_ptr, unsigned int event)
726 link_set_timer(l_ptr, cont_intv); 732 link_set_timer(l_ptr, cont_intv);
727 break; 733 break;
728 default: 734 default:
729 err("Unknown link event %u in RU state\n", event); 735 pr_err("%s%u in RU state\n", link_unk_evt, event);
730 } 736 }
731 break; 737 break;
732 case RESET_RESET: 738 case RESET_RESET:
@@ -751,11 +757,11 @@ static void link_state_event(struct tipc_link *l_ptr, unsigned int event)
751 link_set_timer(l_ptr, cont_intv); 757 link_set_timer(l_ptr, cont_intv);
752 break; 758 break;
753 default: 759 default:
754 err("Unknown link event %u in RR state\n", event); 760 pr_err("%s%u in RR state\n", link_unk_evt, event);
755 } 761 }
756 break; 762 break;
757 default: 763 default:
758 err("Unknown link state %u/%u\n", l_ptr->state, event); 764 pr_err("Unknown link state %u/%u\n", l_ptr->state, event);
759 } 765 }
760} 766}
761 767
@@ -856,7 +862,8 @@ int tipc_link_send_buf(struct tipc_link *l_ptr, struct sk_buff *buf)
856 } 862 }
857 kfree_skb(buf); 863 kfree_skb(buf);
858 if (imp > CONN_MANAGER) { 864 if (imp > CONN_MANAGER) {
859 warn("Resetting link <%s>, send queue full", l_ptr->name); 865 pr_warn("%s<%s>, send queue full", link_rst_msg,
866 l_ptr->name);
860 tipc_link_reset(l_ptr); 867 tipc_link_reset(l_ptr);
861 } 868 }
862 return dsz; 869 return dsz;
@@ -944,7 +951,7 @@ int tipc_link_send(struct sk_buff *buf, u32 dest, u32 selector)
944 return res; 951 return res;
945} 952}
946 953
947/* 954/**
948 * tipc_link_send_names - send name table entries to new neighbor 955 * tipc_link_send_names - send name table entries to new neighbor
949 * 956 *
950 * Send routine for bulk delivery of name table messages when contact 957 * Send routine for bulk delivery of name table messages when contact
@@ -1409,8 +1416,8 @@ static void link_reset_all(unsigned long addr)
1409 1416
1410 tipc_node_lock(n_ptr); 1417 tipc_node_lock(n_ptr);
1411 1418
1412 warn("Resetting all links to %s\n", 1419 pr_warn("Resetting all links to %s\n",
1413 tipc_addr_string_fill(addr_string, n_ptr->addr)); 1420 tipc_addr_string_fill(addr_string, n_ptr->addr));
1414 1421
1415 for (i = 0; i < MAX_BEARERS; i++) { 1422 for (i = 0; i < MAX_BEARERS; i++) {
1416 if (n_ptr->links[i]) { 1423 if (n_ptr->links[i]) {
@@ -1428,7 +1435,7 @@ static void link_retransmit_failure(struct tipc_link *l_ptr,
1428{ 1435{
1429 struct tipc_msg *msg = buf_msg(buf); 1436 struct tipc_msg *msg = buf_msg(buf);
1430 1437
1431 warn("Retransmission failure on link <%s>\n", l_ptr->name); 1438 pr_warn("Retransmission failure on link <%s>\n", l_ptr->name);
1432 1439
1433 if (l_ptr->addr) { 1440 if (l_ptr->addr) {
1434 /* Handle failure on standard link */ 1441 /* Handle failure on standard link */
@@ -1440,21 +1447,23 @@ static void link_retransmit_failure(struct tipc_link *l_ptr,
1440 struct tipc_node *n_ptr; 1447 struct tipc_node *n_ptr;
1441 char addr_string[16]; 1448 char addr_string[16];
1442 1449
1443 info("Msg seq number: %u, ", msg_seqno(msg)); 1450 pr_info("Msg seq number: %u, ", msg_seqno(msg));
1444 info("Outstanding acks: %lu\n", 1451 pr_cont("Outstanding acks: %lu\n",
1445 (unsigned long) TIPC_SKB_CB(buf)->handle); 1452 (unsigned long) TIPC_SKB_CB(buf)->handle);
1446 1453
1447 n_ptr = tipc_bclink_retransmit_to(); 1454 n_ptr = tipc_bclink_retransmit_to();
1448 tipc_node_lock(n_ptr); 1455 tipc_node_lock(n_ptr);
1449 1456
1450 tipc_addr_string_fill(addr_string, n_ptr->addr); 1457 tipc_addr_string_fill(addr_string, n_ptr->addr);
1451 info("Broadcast link info for %s\n", addr_string); 1458 pr_info("Broadcast link info for %s\n", addr_string);
1452 info("Supportable: %d, ", n_ptr->bclink.supportable); 1459 pr_info("Supportable: %d, Supported: %d, Acked: %u\n",
1453 info("Supported: %d, ", n_ptr->bclink.supported); 1460 n_ptr->bclink.supportable,
1454 info("Acked: %u\n", n_ptr->bclink.acked); 1461 n_ptr->bclink.supported,
1455 info("Last in: %u, ", n_ptr->bclink.last_in); 1462 n_ptr->bclink.acked);
1456 info("Oos state: %u, ", n_ptr->bclink.oos_state); 1463 pr_info("Last in: %u, Oos state: %u, Last sent: %u\n",
1457 info("Last sent: %u\n", n_ptr->bclink.last_sent); 1464 n_ptr->bclink.last_in,
1465 n_ptr->bclink.oos_state,
1466 n_ptr->bclink.last_sent);
1458 1467
1459 tipc_k_signal((Handler)link_reset_all, (unsigned long)n_ptr->addr); 1468 tipc_k_signal((Handler)link_reset_all, (unsigned long)n_ptr->addr);
1460 1469
@@ -1479,8 +1488,8 @@ void tipc_link_retransmit(struct tipc_link *l_ptr, struct sk_buff *buf,
1479 l_ptr->retransm_queue_head = msg_seqno(msg); 1488 l_ptr->retransm_queue_head = msg_seqno(msg);
1480 l_ptr->retransm_queue_size = retransmits; 1489 l_ptr->retransm_queue_size = retransmits;
1481 } else { 1490 } else {
1482 err("Unexpected retransmit on link %s (qsize=%d)\n", 1491 pr_err("Unexpected retransmit on link %s (qsize=%d)\n",
1483 l_ptr->name, l_ptr->retransm_queue_size); 1492 l_ptr->name, l_ptr->retransm_queue_size);
1484 } 1493 }
1485 return; 1494 return;
1486 } else { 1495 } else {
@@ -1787,7 +1796,7 @@ cont:
1787 read_unlock_bh(&tipc_net_lock); 1796 read_unlock_bh(&tipc_net_lock);
1788} 1797}
1789 1798
1790/* 1799/**
1791 * tipc_link_defer_pkt - Add out-of-sequence message to deferred reception queue 1800 * tipc_link_defer_pkt - Add out-of-sequence message to deferred reception queue
1792 * 1801 *
1793 * Returns increase in queue length (i.e. 0 or 1) 1802 * Returns increase in queue length (i.e. 0 or 1)
@@ -2074,8 +2083,9 @@ static void link_recv_proto_msg(struct tipc_link *l_ptr, struct sk_buff *buf)
2074 2083
2075 if (msg_linkprio(msg) && 2084 if (msg_linkprio(msg) &&
2076 (msg_linkprio(msg) != l_ptr->priority)) { 2085 (msg_linkprio(msg) != l_ptr->priority)) {
2077 warn("Resetting link <%s>, priority change %u->%u\n", 2086 pr_warn("%s<%s>, priority change %u->%u\n",
2078 l_ptr->name, l_ptr->priority, msg_linkprio(msg)); 2087 link_rst_msg, l_ptr->name, l_ptr->priority,
2088 msg_linkprio(msg));
2079 l_ptr->priority = msg_linkprio(msg); 2089 l_ptr->priority = msg_linkprio(msg);
2080 tipc_link_reset(l_ptr); /* Enforce change to take effect */ 2090 tipc_link_reset(l_ptr); /* Enforce change to take effect */
2081 break; 2091 break;
@@ -2139,15 +2149,13 @@ static void tipc_link_tunnel(struct tipc_link *l_ptr,
2139 2149
2140 tunnel = l_ptr->owner->active_links[selector & 1]; 2150 tunnel = l_ptr->owner->active_links[selector & 1];
2141 if (!tipc_link_is_up(tunnel)) { 2151 if (!tipc_link_is_up(tunnel)) {
2142 warn("Link changeover error, " 2152 pr_warn("%stunnel link no longer available\n", link_co_err);
2143 "tunnel link no longer available\n");
2144 return; 2153 return;
2145 } 2154 }
2146 msg_set_size(tunnel_hdr, length + INT_H_SIZE); 2155 msg_set_size(tunnel_hdr, length + INT_H_SIZE);
2147 buf = tipc_buf_acquire(length + INT_H_SIZE); 2156 buf = tipc_buf_acquire(length + INT_H_SIZE);
2148 if (!buf) { 2157 if (!buf) {
2149 warn("Link changeover error, " 2158 pr_warn("%sunable to send tunnel msg\n", link_co_err);
2150 "unable to send tunnel msg\n");
2151 return; 2159 return;
2152 } 2160 }
2153 skb_copy_to_linear_data(buf, tunnel_hdr, INT_H_SIZE); 2161 skb_copy_to_linear_data(buf, tunnel_hdr, INT_H_SIZE);
@@ -2173,8 +2181,7 @@ void tipc_link_changeover(struct tipc_link *l_ptr)
2173 return; 2181 return;
2174 2182
2175 if (!l_ptr->owner->permit_changeover) { 2183 if (!l_ptr->owner->permit_changeover) {
2176 warn("Link changeover error, " 2184 pr_warn("%speer did not permit changeover\n", link_co_err);
2177 "peer did not permit changeover\n");
2178 return; 2185 return;
2179 } 2186 }
2180 2187
@@ -2192,8 +2199,8 @@ void tipc_link_changeover(struct tipc_link *l_ptr)
2192 msg_set_size(&tunnel_hdr, INT_H_SIZE); 2199 msg_set_size(&tunnel_hdr, INT_H_SIZE);
2193 tipc_link_send_buf(tunnel, buf); 2200 tipc_link_send_buf(tunnel, buf);
2194 } else { 2201 } else {
2195 warn("Link changeover error, " 2202 pr_warn("%sunable to send changeover msg\n",
2196 "unable to send changeover msg\n"); 2203 link_co_err);
2197 } 2204 }
2198 return; 2205 return;
2199 } 2206 }
@@ -2246,8 +2253,8 @@ void tipc_link_send_duplicate(struct tipc_link *l_ptr, struct tipc_link *tunnel)
2246 msg_set_size(&tunnel_hdr, length + INT_H_SIZE); 2253 msg_set_size(&tunnel_hdr, length + INT_H_SIZE);
2247 outbuf = tipc_buf_acquire(length + INT_H_SIZE); 2254 outbuf = tipc_buf_acquire(length + INT_H_SIZE);
2248 if (outbuf == NULL) { 2255 if (outbuf == NULL) {
2249 warn("Link changeover error, " 2256 pr_warn("%sunable to send duplicate msg\n",
2250 "unable to send duplicate msg\n"); 2257 link_co_err);
2251 return; 2258 return;
2252 } 2259 }
2253 skb_copy_to_linear_data(outbuf, &tunnel_hdr, INT_H_SIZE); 2260 skb_copy_to_linear_data(outbuf, &tunnel_hdr, INT_H_SIZE);
@@ -2298,8 +2305,8 @@ static int link_recv_changeover_msg(struct tipc_link **l_ptr,
2298 if (!dest_link) 2305 if (!dest_link)
2299 goto exit; 2306 goto exit;
2300 if (dest_link == *l_ptr) { 2307 if (dest_link == *l_ptr) {
2301 err("Unexpected changeover message on link <%s>\n", 2308 pr_err("Unexpected changeover message on link <%s>\n",
2302 (*l_ptr)->name); 2309 (*l_ptr)->name);
2303 goto exit; 2310 goto exit;
2304 } 2311 }
2305 *l_ptr = dest_link; 2312 *l_ptr = dest_link;
@@ -2310,7 +2317,7 @@ static int link_recv_changeover_msg(struct tipc_link **l_ptr,
2310 goto exit; 2317 goto exit;
2311 *buf = buf_extract(tunnel_buf, INT_H_SIZE); 2318 *buf = buf_extract(tunnel_buf, INT_H_SIZE);
2312 if (*buf == NULL) { 2319 if (*buf == NULL) {
2313 warn("Link changeover error, duplicate msg dropped\n"); 2320 pr_warn("%sduplicate msg dropped\n", link_co_err);
2314 goto exit; 2321 goto exit;
2315 } 2322 }
2316 kfree_skb(tunnel_buf); 2323 kfree_skb(tunnel_buf);
@@ -2319,8 +2326,8 @@ static int link_recv_changeover_msg(struct tipc_link **l_ptr,
2319 2326
2320 /* First original message ?: */ 2327 /* First original message ?: */
2321 if (tipc_link_is_up(dest_link)) { 2328 if (tipc_link_is_up(dest_link)) {
2322 info("Resetting link <%s>, changeover initiated by peer\n", 2329 pr_info("%s<%s>, changeover initiated by peer\n", link_rst_msg,
2323 dest_link->name); 2330 dest_link->name);
2324 tipc_link_reset(dest_link); 2331 tipc_link_reset(dest_link);
2325 dest_link->exp_msg_count = msg_count; 2332 dest_link->exp_msg_count = msg_count;
2326 if (!msg_count) 2333 if (!msg_count)
@@ -2333,8 +2340,7 @@ static int link_recv_changeover_msg(struct tipc_link **l_ptr,
2333 2340
2334 /* Receive original message */ 2341 /* Receive original message */
2335 if (dest_link->exp_msg_count == 0) { 2342 if (dest_link->exp_msg_count == 0) {
2336 warn("Link switchover error, " 2343 pr_warn("%sgot too many tunnelled messages\n", link_co_err);
2337 "got too many tunnelled messages\n");
2338 goto exit; 2344 goto exit;
2339 } 2345 }
2340 dest_link->exp_msg_count--; 2346 dest_link->exp_msg_count--;
@@ -2346,7 +2352,7 @@ static int link_recv_changeover_msg(struct tipc_link **l_ptr,
2346 kfree_skb(tunnel_buf); 2352 kfree_skb(tunnel_buf);
2347 return 1; 2353 return 1;
2348 } else { 2354 } else {
2349 warn("Link changeover error, original msg dropped\n"); 2355 pr_warn("%soriginal msg dropped\n", link_co_err);
2350 } 2356 }
2351 } 2357 }
2352exit: 2358exit:
@@ -2367,7 +2373,7 @@ void tipc_link_recv_bundle(struct sk_buff *buf)
2367 while (msgcount--) { 2373 while (msgcount--) {
2368 obuf = buf_extract(buf, pos); 2374 obuf = buf_extract(buf, pos);
2369 if (obuf == NULL) { 2375 if (obuf == NULL) {
2370 warn("Link unable to unbundle message(s)\n"); 2376 pr_warn("Link unable to unbundle message(s)\n");
2371 break; 2377 break;
2372 } 2378 }
2373 pos += align(msg_size(buf_msg(obuf))); 2379 pos += align(msg_size(buf_msg(obuf)));
@@ -2538,7 +2544,7 @@ int tipc_link_recv_fragment(struct sk_buff **pending, struct sk_buff **fb,
2538 set_fragm_size(pbuf, fragm_sz); 2544 set_fragm_size(pbuf, fragm_sz);
2539 set_expected_frags(pbuf, exp_fragm_cnt - 1); 2545 set_expected_frags(pbuf, exp_fragm_cnt - 1);
2540 } else { 2546 } else {
2541 dbg("Link unable to reassemble fragmented message\n"); 2547 pr_debug("Link unable to reassemble fragmented message\n");
2542 kfree_skb(fbuf); 2548 kfree_skb(fbuf);
2543 return -1; 2549 return -1;
2544 } 2550 }
@@ -2635,8 +2641,8 @@ void tipc_link_set_queue_limits(struct tipc_link *l_ptr, u32 window)
2635 2641
2636/** 2642/**
2637 * link_find_link - locate link by name 2643 * link_find_link - locate link by name
2638 * @name - ptr to link name string 2644 * @name: ptr to link name string
2639 * @node - ptr to area to be filled with ptr to associated node 2645 * @node: ptr to area to be filled with ptr to associated node
2640 * 2646 *
2641 * Caller must hold 'tipc_net_lock' to ensure node and bearer are not deleted; 2647 * Caller must hold 'tipc_net_lock' to ensure node and bearer are not deleted;
2642 * this also prevents link deletion. 2648 * this also prevents link deletion.
@@ -2671,8 +2677,8 @@ static struct tipc_link *link_find_link(const char *name,
2671/** 2677/**
2672 * link_value_is_valid -- validate proposed link tolerance/priority/window 2678 * link_value_is_valid -- validate proposed link tolerance/priority/window
2673 * 2679 *
2674 * @cmd - value type (TIPC_CMD_SET_LINK_*) 2680 * @cmd: value type (TIPC_CMD_SET_LINK_*)
2675 * @new_value - the new value 2681 * @new_value: the new value
2676 * 2682 *
2677 * Returns 1 if value is within range, 0 if not. 2683 * Returns 1 if value is within range, 0 if not.
2678 */ 2684 */
@@ -2693,9 +2699,9 @@ static int link_value_is_valid(u16 cmd, u32 new_value)
2693 2699
2694/** 2700/**
2695 * link_cmd_set_value - change priority/tolerance/window for link/bearer/media 2701 * link_cmd_set_value - change priority/tolerance/window for link/bearer/media
2696 * @name - ptr to link, bearer, or media name 2702 * @name: ptr to link, bearer, or media name
2697 * @new_value - new value of link, bearer, or media setting 2703 * @new_value: new value of link, bearer, or media setting
2698 * @cmd - which link, bearer, or media attribute to set (TIPC_CMD_SET_LINK_*) 2704 * @cmd: which link, bearer, or media attribute to set (TIPC_CMD_SET_LINK_*)
2699 * 2705 *
2700 * Caller must hold 'tipc_net_lock' to ensure link/bearer/media is not deleted. 2706 * Caller must hold 'tipc_net_lock' to ensure link/bearer/media is not deleted.
2701 * 2707 *
@@ -2860,112 +2866,114 @@ static u32 percent(u32 count, u32 total)
2860 */ 2866 */
2861static int tipc_link_stats(const char *name, char *buf, const u32 buf_size) 2867static int tipc_link_stats(const char *name, char *buf, const u32 buf_size)
2862{ 2868{
2863 struct print_buf pb; 2869 struct tipc_link *l;
2864 struct tipc_link *l_ptr; 2870 struct tipc_stats *s;
2865 struct tipc_node *node; 2871 struct tipc_node *node;
2866 char *status; 2872 char *status;
2867 u32 profile_total = 0; 2873 u32 profile_total = 0;
2874 int ret;
2868 2875
2869 if (!strcmp(name, tipc_bclink_name)) 2876 if (!strcmp(name, tipc_bclink_name))
2870 return tipc_bclink_stats(buf, buf_size); 2877 return tipc_bclink_stats(buf, buf_size);
2871 2878
2872 tipc_printbuf_init(&pb, buf, buf_size);
2873
2874 read_lock_bh(&tipc_net_lock); 2879 read_lock_bh(&tipc_net_lock);
2875 l_ptr = link_find_link(name, &node); 2880 l = link_find_link(name, &node);
2876 if (!l_ptr) { 2881 if (!l) {
2877 read_unlock_bh(&tipc_net_lock); 2882 read_unlock_bh(&tipc_net_lock);
2878 return 0; 2883 return 0;
2879 } 2884 }
2880 tipc_node_lock(node); 2885 tipc_node_lock(node);
2886 s = &l->stats;
2881 2887
2882 if (tipc_link_is_active(l_ptr)) 2888 if (tipc_link_is_active(l))
2883 status = "ACTIVE"; 2889 status = "ACTIVE";
2884 else if (tipc_link_is_up(l_ptr)) 2890 else if (tipc_link_is_up(l))
2885 status = "STANDBY"; 2891 status = "STANDBY";
2886 else 2892 else
2887 status = "DEFUNCT"; 2893 status = "DEFUNCT";
2888 tipc_printf(&pb, "Link <%s>\n" 2894
2889 " %s MTU:%u Priority:%u Tolerance:%u ms" 2895 ret = tipc_snprintf(buf, buf_size, "Link <%s>\n"
2890 " Window:%u packets\n", 2896 " %s MTU:%u Priority:%u Tolerance:%u ms"
2891 l_ptr->name, status, l_ptr->max_pkt, 2897 " Window:%u packets\n",
2892 l_ptr->priority, l_ptr->tolerance, l_ptr->queue_limit[0]); 2898 l->name, status, l->max_pkt, l->priority,
2893 tipc_printf(&pb, " RX packets:%u fragments:%u/%u bundles:%u/%u\n", 2899 l->tolerance, l->queue_limit[0]);
2894 l_ptr->next_in_no - l_ptr->stats.recv_info, 2900
2895 l_ptr->stats.recv_fragments, 2901 ret += tipc_snprintf(buf + ret, buf_size - ret,
2896 l_ptr->stats.recv_fragmented, 2902 " RX packets:%u fragments:%u/%u bundles:%u/%u\n",
2897 l_ptr->stats.recv_bundles, 2903 l->next_in_no - s->recv_info, s->recv_fragments,
2898 l_ptr->stats.recv_bundled); 2904 s->recv_fragmented, s->recv_bundles,
2899 tipc_printf(&pb, " TX packets:%u fragments:%u/%u bundles:%u/%u\n", 2905 s->recv_bundled);
2900 l_ptr->next_out_no - l_ptr->stats.sent_info, 2906
2901 l_ptr->stats.sent_fragments, 2907 ret += tipc_snprintf(buf + ret, buf_size - ret,
2902 l_ptr->stats.sent_fragmented, 2908 " TX packets:%u fragments:%u/%u bundles:%u/%u\n",
2903 l_ptr->stats.sent_bundles, 2909 l->next_out_no - s->sent_info, s->sent_fragments,
2904 l_ptr->stats.sent_bundled); 2910 s->sent_fragmented, s->sent_bundles,
2905 profile_total = l_ptr->stats.msg_length_counts; 2911 s->sent_bundled);
2912
2913 profile_total = s->msg_length_counts;
2906 if (!profile_total) 2914 if (!profile_total)
2907 profile_total = 1; 2915 profile_total = 1;
2908 tipc_printf(&pb, " TX profile sample:%u packets average:%u octets\n" 2916
2909 " 0-64:%u%% -256:%u%% -1024:%u%% -4096:%u%% " 2917 ret += tipc_snprintf(buf + ret, buf_size - ret,
2910 "-16384:%u%% -32768:%u%% -66000:%u%%\n", 2918 " TX profile sample:%u packets average:%u octets\n"
2911 l_ptr->stats.msg_length_counts, 2919 " 0-64:%u%% -256:%u%% -1024:%u%% -4096:%u%% "
2912 l_ptr->stats.msg_lengths_total / profile_total, 2920 "-16384:%u%% -32768:%u%% -66000:%u%%\n",
2913 percent(l_ptr->stats.msg_length_profile[0], profile_total), 2921 s->msg_length_counts,
2914 percent(l_ptr->stats.msg_length_profile[1], profile_total), 2922 s->msg_lengths_total / profile_total,
2915 percent(l_ptr->stats.msg_length_profile[2], profile_total), 2923 percent(s->msg_length_profile[0], profile_total),
2916 percent(l_ptr->stats.msg_length_profile[3], profile_total), 2924 percent(s->msg_length_profile[1], profile_total),
2917 percent(l_ptr->stats.msg_length_profile[4], profile_total), 2925 percent(s->msg_length_profile[2], profile_total),
2918 percent(l_ptr->stats.msg_length_profile[5], profile_total), 2926 percent(s->msg_length_profile[3], profile_total),
2919 percent(l_ptr->stats.msg_length_profile[6], profile_total)); 2927 percent(s->msg_length_profile[4], profile_total),
2920 tipc_printf(&pb, " RX states:%u probes:%u naks:%u defs:%u dups:%u\n", 2928 percent(s->msg_length_profile[5], profile_total),
2921 l_ptr->stats.recv_states, 2929 percent(s->msg_length_profile[6], profile_total));
2922 l_ptr->stats.recv_probes, 2930
2923 l_ptr->stats.recv_nacks, 2931 ret += tipc_snprintf(buf + ret, buf_size - ret,
2924 l_ptr->stats.deferred_recv, 2932 " RX states:%u probes:%u naks:%u defs:%u"
2925 l_ptr->stats.duplicates); 2933 " dups:%u\n", s->recv_states, s->recv_probes,
2926 tipc_printf(&pb, " TX states:%u probes:%u naks:%u acks:%u dups:%u\n", 2934 s->recv_nacks, s->deferred_recv, s->duplicates);
2927 l_ptr->stats.sent_states, 2935
2928 l_ptr->stats.sent_probes, 2936 ret += tipc_snprintf(buf + ret, buf_size - ret,
2929 l_ptr->stats.sent_nacks, 2937 " TX states:%u probes:%u naks:%u acks:%u"
2930 l_ptr->stats.sent_acks, 2938 " dups:%u\n", s->sent_states, s->sent_probes,
2931 l_ptr->stats.retransmitted); 2939 s->sent_nacks, s->sent_acks, s->retransmitted);
2932 tipc_printf(&pb, " Congestion bearer:%u link:%u Send queue max:%u avg:%u\n", 2940
2933 l_ptr->stats.bearer_congs, 2941 ret += tipc_snprintf(buf + ret, buf_size - ret,
2934 l_ptr->stats.link_congs, 2942 " Congestion bearer:%u link:%u Send queue"
2935 l_ptr->stats.max_queue_sz, 2943 " max:%u avg:%u\n", s->bearer_congs, s->link_congs,
2936 l_ptr->stats.queue_sz_counts 2944 s->max_queue_sz, s->queue_sz_counts ?
2937 ? (l_ptr->stats.accu_queue_sz / l_ptr->stats.queue_sz_counts) 2945 (s->accu_queue_sz / s->queue_sz_counts) : 0);
2938 : 0);
2939 2946
2940 tipc_node_unlock(node); 2947 tipc_node_unlock(node);
2941 read_unlock_bh(&tipc_net_lock); 2948 read_unlock_bh(&tipc_net_lock);
2942 return tipc_printbuf_validate(&pb); 2949 return ret;
2943} 2950}
2944 2951
2945#define MAX_LINK_STATS_INFO 2000
2946
2947struct sk_buff *tipc_link_cmd_show_stats(const void *req_tlv_area, int req_tlv_space) 2952struct sk_buff *tipc_link_cmd_show_stats(const void *req_tlv_area, int req_tlv_space)
2948{ 2953{
2949 struct sk_buff *buf; 2954 struct sk_buff *buf;
2950 struct tlv_desc *rep_tlv; 2955 struct tlv_desc *rep_tlv;
2951 int str_len; 2956 int str_len;
2957 int pb_len;
2958 char *pb;
2952 2959
2953 if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_LINK_NAME)) 2960 if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_LINK_NAME))
2954 return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR); 2961 return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR);
2955 2962
2956 buf = tipc_cfg_reply_alloc(TLV_SPACE(MAX_LINK_STATS_INFO)); 2963 buf = tipc_cfg_reply_alloc(TLV_SPACE(ULTRA_STRING_MAX_LEN));
2957 if (!buf) 2964 if (!buf)
2958 return NULL; 2965 return NULL;
2959 2966
2960 rep_tlv = (struct tlv_desc *)buf->data; 2967 rep_tlv = (struct tlv_desc *)buf->data;
2961 2968 pb = TLV_DATA(rep_tlv);
2969 pb_len = ULTRA_STRING_MAX_LEN;
2962 str_len = tipc_link_stats((char *)TLV_DATA(req_tlv_area), 2970 str_len = tipc_link_stats((char *)TLV_DATA(req_tlv_area),
2963 (char *)TLV_DATA(rep_tlv), MAX_LINK_STATS_INFO); 2971 pb, pb_len);
2964 if (!str_len) { 2972 if (!str_len) {
2965 kfree_skb(buf); 2973 kfree_skb(buf);
2966 return tipc_cfg_reply_error_string("link not found"); 2974 return tipc_cfg_reply_error_string("link not found");
2967 } 2975 }
2968 2976 str_len += 1; /* for "\0" */
2969 skb_put(buf, TLV_SPACE(str_len)); 2977 skb_put(buf, TLV_SPACE(str_len));
2970 TLV_SET(rep_tlv, TIPC_TLV_ULTRA_STRING, NULL, str_len); 2978 TLV_SET(rep_tlv, TIPC_TLV_ULTRA_STRING, NULL, str_len);
2971 2979
@@ -3003,62 +3011,16 @@ u32 tipc_link_get_max_pkt(u32 dest, u32 selector)
3003 3011
3004static void link_print(struct tipc_link *l_ptr, const char *str) 3012static void link_print(struct tipc_link *l_ptr, const char *str)
3005{ 3013{
3006 char print_area[256]; 3014 pr_info("%s Link %x<%s>:", str, l_ptr->addr, l_ptr->b_ptr->name);
3007 struct print_buf pb;
3008 struct print_buf *buf = &pb;
3009
3010 tipc_printbuf_init(buf, print_area, sizeof(print_area));
3011
3012 tipc_printf(buf, str);
3013 tipc_printf(buf, "Link %x<%s>:",
3014 l_ptr->addr, l_ptr->b_ptr->name);
3015
3016#ifdef CONFIG_TIPC_DEBUG
3017 if (link_reset_reset(l_ptr) || link_reset_unknown(l_ptr))
3018 goto print_state;
3019
3020 tipc_printf(buf, ": NXO(%u):", mod(l_ptr->next_out_no));
3021 tipc_printf(buf, "NXI(%u):", mod(l_ptr->next_in_no));
3022 tipc_printf(buf, "SQUE");
3023 if (l_ptr->first_out) {
3024 tipc_printf(buf, "[%u..", buf_seqno(l_ptr->first_out));
3025 if (l_ptr->next_out)
3026 tipc_printf(buf, "%u..", buf_seqno(l_ptr->next_out));
3027 tipc_printf(buf, "%u]", buf_seqno(l_ptr->last_out));
3028 if ((mod(buf_seqno(l_ptr->last_out) -
3029 buf_seqno(l_ptr->first_out))
3030 != (l_ptr->out_queue_size - 1)) ||
3031 (l_ptr->last_out->next != NULL)) {
3032 tipc_printf(buf, "\nSend queue inconsistency\n");
3033 tipc_printf(buf, "first_out= %p ", l_ptr->first_out);
3034 tipc_printf(buf, "next_out= %p ", l_ptr->next_out);
3035 tipc_printf(buf, "last_out= %p ", l_ptr->last_out);
3036 }
3037 } else
3038 tipc_printf(buf, "[]");
3039 tipc_printf(buf, "SQSIZ(%u)", l_ptr->out_queue_size);
3040 if (l_ptr->oldest_deferred_in) {
3041 u32 o = buf_seqno(l_ptr->oldest_deferred_in);
3042 u32 n = buf_seqno(l_ptr->newest_deferred_in);
3043 tipc_printf(buf, ":RQUE[%u..%u]", o, n);
3044 if (l_ptr->deferred_inqueue_sz != mod((n + 1) - o)) {
3045 tipc_printf(buf, ":RQSIZ(%u)",
3046 l_ptr->deferred_inqueue_sz);
3047 }
3048 }
3049print_state:
3050#endif
3051 3015
3052 if (link_working_unknown(l_ptr)) 3016 if (link_working_unknown(l_ptr))
3053 tipc_printf(buf, ":WU"); 3017 pr_cont(":WU\n");
3054 else if (link_reset_reset(l_ptr)) 3018 else if (link_reset_reset(l_ptr))
3055 tipc_printf(buf, ":RR"); 3019 pr_cont(":RR\n");
3056 else if (link_reset_unknown(l_ptr)) 3020 else if (link_reset_unknown(l_ptr))
3057 tipc_printf(buf, ":RU"); 3021 pr_cont(":RU\n");
3058 else if (link_working_working(l_ptr)) 3022 else if (link_working_working(l_ptr))
3059 tipc_printf(buf, ":WW"); 3023 pr_cont(":WW\n");
3060 tipc_printf(buf, "\n"); 3024 else
3061 3025 pr_cont("\n");
3062 tipc_printbuf_validate(buf);
3063 info("%s", print_area);
3064} 3026}