aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc
diff options
context:
space:
mode:
Diffstat (limited to 'net/tipc')
-rw-r--r--net/tipc/Kconfig25
-rw-r--r--net/tipc/bcast.c75
-rw-r--r--net/tipc/bearer.c69
-rw-r--r--net/tipc/bearer.h4
-rw-r--r--net/tipc/config.c41
-rw-r--r--net/tipc/core.c18
-rw-r--r--net/tipc/core.h65
-rw-r--r--net/tipc/discover.c10
-rw-r--r--net/tipc/handler.c4
-rw-r--r--net/tipc/link.c326
-rw-r--r--net/tipc/link.h63
-rw-r--r--net/tipc/log.c302
-rw-r--r--net/tipc/log.h66
-rw-r--r--net/tipc/msg.c242
-rw-r--r--net/tipc/name_distr.c25
-rw-r--r--net/tipc/name_table.c142
-rw-r--r--net/tipc/net.c8
-rw-r--r--net/tipc/netlink.c2
-rw-r--r--net/tipc/node.c22
-rw-r--r--net/tipc/node_subscr.c3
-rw-r--r--net/tipc/port.c77
-rw-r--r--net/tipc/port.h1
-rw-r--r--net/tipc/ref.c10
-rw-r--r--net/tipc/socket.c17
-rw-r--r--net/tipc/subscr.c14
25 files changed, 471 insertions, 1160 deletions
diff --git a/net/tipc/Kconfig b/net/tipc/Kconfig
index 2c5954b85933..585460180ffb 100644
--- a/net/tipc/Kconfig
+++ b/net/tipc/Kconfig
@@ -41,29 +41,4 @@ config TIPC_PORTS
41 Setting this to a smaller value saves some memory, 41 Setting this to a smaller value saves some memory,
42 setting it to higher allows for more ports. 42 setting it to higher allows for more ports.
43 43
44config TIPC_LOG
45 int "Size of log buffer"
46 depends on TIPC_ADVANCED
47 range 0 32768
48 default "0"
49 help
50 Size (in bytes) of TIPC's internal log buffer, which records the
51 occurrence of significant events. Can range from 0 to 32768 bytes;
52 default is 0.
53
54 There is no need to enable the log buffer unless the node will be
55 managed remotely via TIPC.
56
57config TIPC_DEBUG
58 bool "Enable debugging support"
59 default n
60 help
61 Saying Y here enables TIPC debugging capabilities used by developers.
62 Most users do not need to bother; if unsure, just say N.
63
64 Enabling debugging support causes TIPC to display data about its
65 internal state when certain abnormal conditions occur. It also
66 makes it easy for developers to capture additional information of
67 interest using the dbg() or msg_dbg() macros.
68
69endif # TIPC 44endif # TIPC
diff --git a/net/tipc/bcast.c b/net/tipc/bcast.c
index 2625f5ebe3e8..e4e6d8cd47e6 100644
--- a/net/tipc/bcast.c
+++ b/net/tipc/bcast.c
@@ -162,7 +162,7 @@ static void bclink_update_last_sent(struct tipc_node *node, u32 seqno)
162} 162}
163 163
164 164
165/* 165/**
166 * tipc_bclink_retransmit_to - get most recent node to request retransmission 166 * tipc_bclink_retransmit_to - get most recent node to request retransmission
167 * 167 *
168 * Called with bc_lock locked 168 * Called with bc_lock locked
@@ -270,7 +270,7 @@ exit:
270 spin_unlock_bh(&bc_lock); 270 spin_unlock_bh(&bc_lock);
271} 271}
272 272
273/* 273/**
274 * tipc_bclink_update_link_state - update broadcast link state 274 * tipc_bclink_update_link_state - update broadcast link state
275 * 275 *
276 * tipc_net_lock and node lock set 276 * tipc_net_lock and node lock set
@@ -330,7 +330,7 @@ void tipc_bclink_update_link_state(struct tipc_node *n_ptr, u32 last_sent)
330 } 330 }
331} 331}
332 332
333/* 333/**
334 * bclink_peek_nack - monitor retransmission requests sent by other nodes 334 * bclink_peek_nack - monitor retransmission requests sent by other nodes
335 * 335 *
336 * Delay any upcoming NACK by this node if another node has already 336 * Delay any upcoming NACK by this node if another node has already
@@ -381,7 +381,7 @@ exit:
381 return res; 381 return res;
382} 382}
383 383
384/* 384/**
385 * bclink_accept_pkt - accept an incoming, in-sequence broadcast packet 385 * bclink_accept_pkt - accept an incoming, in-sequence broadcast packet
386 * 386 *
387 * Called with both sending node's lock and bc_lock taken. 387 * Called with both sending node's lock and bc_lock taken.
@@ -406,7 +406,7 @@ static void bclink_accept_pkt(struct tipc_node *node, u32 seqno)
406 } 406 }
407} 407}
408 408
409/* 409/**
410 * tipc_bclink_recv_pkt - receive a broadcast packet, and deliver upwards 410 * tipc_bclink_recv_pkt - receive a broadcast packet, and deliver upwards
411 * 411 *
412 * tipc_net_lock is read_locked, no other locks set 412 * tipc_net_lock is read_locked, no other locks set
@@ -701,48 +701,43 @@ void tipc_bcbearer_sort(void)
701 701
702int tipc_bclink_stats(char *buf, const u32 buf_size) 702int tipc_bclink_stats(char *buf, const u32 buf_size)
703{ 703{
704 struct print_buf pb; 704 int ret;
705 struct tipc_stats *s;
705 706
706 if (!bcl) 707 if (!bcl)
707 return 0; 708 return 0;
708 709
709 tipc_printbuf_init(&pb, buf, buf_size);
710
711 spin_lock_bh(&bc_lock); 710 spin_lock_bh(&bc_lock);
712 711
713 tipc_printf(&pb, "Link <%s>\n" 712 s = &bcl->stats;
714 " Window:%u packets\n", 713
715 bcl->name, bcl->queue_limit[0]); 714 ret = tipc_snprintf(buf, buf_size, "Link <%s>\n"
716 tipc_printf(&pb, " RX packets:%u fragments:%u/%u bundles:%u/%u\n", 715 " Window:%u packets\n",
717 bcl->stats.recv_info, 716 bcl->name, bcl->queue_limit[0]);
718 bcl->stats.recv_fragments, 717 ret += tipc_snprintf(buf + ret, buf_size - ret,
719 bcl->stats.recv_fragmented, 718 " RX packets:%u fragments:%u/%u bundles:%u/%u\n",
720 bcl->stats.recv_bundles, 719 s->recv_info, s->recv_fragments,
721 bcl->stats.recv_bundled); 720 s->recv_fragmented, s->recv_bundles,
722 tipc_printf(&pb, " TX packets:%u fragments:%u/%u bundles:%u/%u\n", 721 s->recv_bundled);
723 bcl->stats.sent_info, 722 ret += tipc_snprintf(buf + ret, buf_size - ret,
724 bcl->stats.sent_fragments, 723 " TX packets:%u fragments:%u/%u bundles:%u/%u\n",
725 bcl->stats.sent_fragmented, 724 s->sent_info, s->sent_fragments,
726 bcl->stats.sent_bundles, 725 s->sent_fragmented, s->sent_bundles,
727 bcl->stats.sent_bundled); 726 s->sent_bundled);
728 tipc_printf(&pb, " RX naks:%u defs:%u dups:%u\n", 727 ret += tipc_snprintf(buf + ret, buf_size - ret,
729 bcl->stats.recv_nacks, 728 " RX naks:%u defs:%u dups:%u\n",
730 bcl->stats.deferred_recv, 729 s->recv_nacks, s->deferred_recv, s->duplicates);
731 bcl->stats.duplicates); 730 ret += tipc_snprintf(buf + ret, buf_size - ret,
732 tipc_printf(&pb, " TX naks:%u acks:%u dups:%u\n", 731 " TX naks:%u acks:%u dups:%u\n",
733 bcl->stats.sent_nacks, 732 s->sent_nacks, s->sent_acks, s->retransmitted);
734 bcl->stats.sent_acks, 733 ret += tipc_snprintf(buf + ret, buf_size - ret,
735 bcl->stats.retransmitted); 734 " Congestion bearer:%u link:%u Send queue max:%u avg:%u\n",
736 tipc_printf(&pb, " Congestion bearer:%u link:%u Send queue max:%u avg:%u\n", 735 s->bearer_congs, s->link_congs, s->max_queue_sz,
737 bcl->stats.bearer_congs, 736 s->queue_sz_counts ?
738 bcl->stats.link_congs, 737 (s->accu_queue_sz / s->queue_sz_counts) : 0);
739 bcl->stats.max_queue_sz,
740 bcl->stats.queue_sz_counts
741 ? (bcl->stats.accu_queue_sz / bcl->stats.queue_sz_counts)
742 : 0);
743 738
744 spin_unlock_bh(&bc_lock); 739 spin_unlock_bh(&bc_lock);
745 return tipc_printbuf_validate(&pb); 740 return ret;
746} 741}
747 742
748int tipc_bclink_reset_stats(void) 743int tipc_bclink_reset_stats(void)
@@ -880,7 +875,7 @@ void tipc_port_list_add(struct tipc_port_list *pl_ptr, u32 port)
880 if (!item->next) { 875 if (!item->next) {
881 item->next = kmalloc(sizeof(*item), GFP_ATOMIC); 876 item->next = kmalloc(sizeof(*item), GFP_ATOMIC);
882 if (!item->next) { 877 if (!item->next) {
883 warn("Incomplete multicast delivery, no memory\n"); 878 pr_warn("Incomplete multicast delivery, no memory\n");
884 return; 879 return;
885 } 880 }
886 item->next->next = NULL; 881 item->next->next = NULL;
diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c
index a297e3a2e3e7..09e71241265d 100644
--- a/net/tipc/bearer.c
+++ b/net/tipc/bearer.c
@@ -123,28 +123,30 @@ int tipc_register_media(struct tipc_media *m_ptr)
123exit: 123exit:
124 write_unlock_bh(&tipc_net_lock); 124 write_unlock_bh(&tipc_net_lock);
125 if (res) 125 if (res)
126 warn("Media <%s> registration error\n", m_ptr->name); 126 pr_warn("Media <%s> registration error\n", m_ptr->name);
127 return res; 127 return res;
128} 128}
129 129
130/** 130/**
131 * tipc_media_addr_printf - record media address in print buffer 131 * tipc_media_addr_printf - record media address in print buffer
132 */ 132 */
133void tipc_media_addr_printf(struct print_buf *pb, struct tipc_media_addr *a) 133void tipc_media_addr_printf(char *buf, int len, struct tipc_media_addr *a)
134{ 134{
135 char addr_str[MAX_ADDR_STR]; 135 char addr_str[MAX_ADDR_STR];
136 struct tipc_media *m_ptr; 136 struct tipc_media *m_ptr;
137 int ret;
137 138
138 m_ptr = media_find_id(a->media_id); 139 m_ptr = media_find_id(a->media_id);
139 140
140 if (m_ptr && !m_ptr->addr2str(a, addr_str, sizeof(addr_str))) 141 if (m_ptr && !m_ptr->addr2str(a, addr_str, sizeof(addr_str)))
141 tipc_printf(pb, "%s(%s)", m_ptr->name, addr_str); 142 ret = tipc_snprintf(buf, len, "%s(%s)", m_ptr->name, addr_str);
142 else { 143 else {
143 u32 i; 144 u32 i;
144 145
145 tipc_printf(pb, "UNKNOWN(%u)", a->media_id); 146 ret = tipc_snprintf(buf, len, "UNKNOWN(%u)", a->media_id);
146 for (i = 0; i < sizeof(a->value); i++) 147 for (i = 0; i < sizeof(a->value); i++)
147 tipc_printf(pb, "-%02x", a->value[i]); 148 ret += tipc_snprintf(buf - ret, len + ret,
149 "-%02x", a->value[i]);
148 } 150 }
149} 151}
150 152
@@ -172,8 +174,8 @@ struct sk_buff *tipc_media_get_names(void)
172 174
173/** 175/**
174 * bearer_name_validate - validate & (optionally) deconstruct bearer name 176 * bearer_name_validate - validate & (optionally) deconstruct bearer name
175 * @name - ptr to bearer name string 177 * @name: ptr to bearer name string
176 * @name_parts - ptr to area for bearer name components (or NULL if not needed) 178 * @name_parts: ptr to area for bearer name components (or NULL if not needed)
177 * 179 *
178 * Returns 1 if bearer name is valid, otherwise 0. 180 * Returns 1 if bearer name is valid, otherwise 0.
179 */ 181 */
@@ -418,12 +420,12 @@ int tipc_enable_bearer(const char *name, u32 disc_domain, u32 priority)
418 int res = -EINVAL; 420 int res = -EINVAL;
419 421
420 if (!tipc_own_addr) { 422 if (!tipc_own_addr) {
421 warn("Bearer <%s> rejected, not supported in standalone mode\n", 423 pr_warn("Bearer <%s> rejected, not supported in standalone mode\n",
422 name); 424 name);
423 return -ENOPROTOOPT; 425 return -ENOPROTOOPT;
424 } 426 }
425 if (!bearer_name_validate(name, &b_names)) { 427 if (!bearer_name_validate(name, &b_names)) {
426 warn("Bearer <%s> rejected, illegal name\n", name); 428 pr_warn("Bearer <%s> rejected, illegal name\n", name);
427 return -EINVAL; 429 return -EINVAL;
428 } 430 }
429 if (tipc_addr_domain_valid(disc_domain) && 431 if (tipc_addr_domain_valid(disc_domain) &&
@@ -435,12 +437,13 @@ int tipc_enable_bearer(const char *name, u32 disc_domain, u32 priority)
435 res = 0; /* accept specified node in own cluster */ 437 res = 0; /* accept specified node in own cluster */
436 } 438 }
437 if (res) { 439 if (res) {
438 warn("Bearer <%s> rejected, illegal discovery domain\n", name); 440 pr_warn("Bearer <%s> rejected, illegal discovery domain\n",
441 name);
439 return -EINVAL; 442 return -EINVAL;
440 } 443 }
441 if ((priority > TIPC_MAX_LINK_PRI) && 444 if ((priority > TIPC_MAX_LINK_PRI) &&
442 (priority != TIPC_MEDIA_LINK_PRI)) { 445 (priority != TIPC_MEDIA_LINK_PRI)) {
443 warn("Bearer <%s> rejected, illegal priority\n", name); 446 pr_warn("Bearer <%s> rejected, illegal priority\n", name);
444 return -EINVAL; 447 return -EINVAL;
445 } 448 }
446 449
@@ -448,8 +451,8 @@ int tipc_enable_bearer(const char *name, u32 disc_domain, u32 priority)
448 451
449 m_ptr = tipc_media_find(b_names.media_name); 452 m_ptr = tipc_media_find(b_names.media_name);
450 if (!m_ptr) { 453 if (!m_ptr) {
451 warn("Bearer <%s> rejected, media <%s> not registered\n", name, 454 pr_warn("Bearer <%s> rejected, media <%s> not registered\n",
452 b_names.media_name); 455 name, b_names.media_name);
453 goto exit; 456 goto exit;
454 } 457 }
455 458
@@ -465,24 +468,25 @@ restart:
465 continue; 468 continue;
466 } 469 }
467 if (!strcmp(name, tipc_bearers[i].name)) { 470 if (!strcmp(name, tipc_bearers[i].name)) {
468 warn("Bearer <%s> rejected, already enabled\n", name); 471 pr_warn("Bearer <%s> rejected, already enabled\n",
472 name);
469 goto exit; 473 goto exit;
470 } 474 }
471 if ((tipc_bearers[i].priority == priority) && 475 if ((tipc_bearers[i].priority == priority) &&
472 (++with_this_prio > 2)) { 476 (++with_this_prio > 2)) {
473 if (priority-- == 0) { 477 if (priority-- == 0) {
474 warn("Bearer <%s> rejected, duplicate priority\n", 478 pr_warn("Bearer <%s> rejected, duplicate priority\n",
475 name); 479 name);
476 goto exit; 480 goto exit;
477 } 481 }
478 warn("Bearer <%s> priority adjustment required %u->%u\n", 482 pr_warn("Bearer <%s> priority adjustment required %u->%u\n",
479 name, priority + 1, priority); 483 name, priority + 1, priority);
480 goto restart; 484 goto restart;
481 } 485 }
482 } 486 }
483 if (bearer_id >= MAX_BEARERS) { 487 if (bearer_id >= MAX_BEARERS) {
484 warn("Bearer <%s> rejected, bearer limit reached (%u)\n", 488 pr_warn("Bearer <%s> rejected, bearer limit reached (%u)\n",
485 name, MAX_BEARERS); 489 name, MAX_BEARERS);
486 goto exit; 490 goto exit;
487 } 491 }
488 492
@@ -490,7 +494,8 @@ restart:
490 strcpy(b_ptr->name, name); 494 strcpy(b_ptr->name, name);
491 res = m_ptr->enable_bearer(b_ptr); 495 res = m_ptr->enable_bearer(b_ptr);
492 if (res) { 496 if (res) {
493 warn("Bearer <%s> rejected, enable failure (%d)\n", name, -res); 497 pr_warn("Bearer <%s> rejected, enable failure (%d)\n",
498 name, -res);
494 goto exit; 499 goto exit;
495 } 500 }
496 501
@@ -508,20 +513,20 @@ restart:
508 res = tipc_disc_create(b_ptr, &m_ptr->bcast_addr, disc_domain); 513 res = tipc_disc_create(b_ptr, &m_ptr->bcast_addr, disc_domain);
509 if (res) { 514 if (res) {
510 bearer_disable(b_ptr); 515 bearer_disable(b_ptr);
511 warn("Bearer <%s> rejected, discovery object creation failed\n", 516 pr_warn("Bearer <%s> rejected, discovery object creation failed\n",
512 name); 517 name);
513 goto exit; 518 goto exit;
514 } 519 }
515 info("Enabled bearer <%s>, discovery domain %s, priority %u\n", 520 pr_info("Enabled bearer <%s>, discovery domain %s, priority %u\n",
516 name, tipc_addr_string_fill(addr_string, disc_domain), priority); 521 name,
522 tipc_addr_string_fill(addr_string, disc_domain), priority);
517exit: 523exit:
518 write_unlock_bh(&tipc_net_lock); 524 write_unlock_bh(&tipc_net_lock);
519 return res; 525 return res;
520} 526}
521 527
522/** 528/**
523 * tipc_block_bearer(): Block the bearer with the given name, 529 * tipc_block_bearer - Block the bearer with the given name, and reset all its links
524 * and reset all its links
525 */ 530 */
526int tipc_block_bearer(const char *name) 531int tipc_block_bearer(const char *name)
527{ 532{
@@ -532,12 +537,12 @@ int tipc_block_bearer(const char *name)
532 read_lock_bh(&tipc_net_lock); 537 read_lock_bh(&tipc_net_lock);
533 b_ptr = tipc_bearer_find(name); 538 b_ptr = tipc_bearer_find(name);
534 if (!b_ptr) { 539 if (!b_ptr) {
535 warn("Attempt to block unknown bearer <%s>\n", name); 540 pr_warn("Attempt to block unknown bearer <%s>\n", name);
536 read_unlock_bh(&tipc_net_lock); 541 read_unlock_bh(&tipc_net_lock);
537 return -EINVAL; 542 return -EINVAL;
538 } 543 }
539 544
540 info("Blocking bearer <%s>\n", name); 545 pr_info("Blocking bearer <%s>\n", name);
541 spin_lock_bh(&b_ptr->lock); 546 spin_lock_bh(&b_ptr->lock);
542 b_ptr->blocked = 1; 547 b_ptr->blocked = 1;
543 list_splice_init(&b_ptr->cong_links, &b_ptr->links); 548 list_splice_init(&b_ptr->cong_links, &b_ptr->links);
@@ -563,7 +568,7 @@ static void bearer_disable(struct tipc_bearer *b_ptr)
563 struct tipc_link *l_ptr; 568 struct tipc_link *l_ptr;
564 struct tipc_link *temp_l_ptr; 569 struct tipc_link *temp_l_ptr;
565 570
566 info("Disabling bearer <%s>\n", b_ptr->name); 571 pr_info("Disabling bearer <%s>\n", b_ptr->name);
567 spin_lock_bh(&b_ptr->lock); 572 spin_lock_bh(&b_ptr->lock);
568 b_ptr->blocked = 1; 573 b_ptr->blocked = 1;
569 b_ptr->media->disable_bearer(b_ptr); 574 b_ptr->media->disable_bearer(b_ptr);
@@ -585,7 +590,7 @@ int tipc_disable_bearer(const char *name)
585 write_lock_bh(&tipc_net_lock); 590 write_lock_bh(&tipc_net_lock);
586 b_ptr = tipc_bearer_find(name); 591 b_ptr = tipc_bearer_find(name);
587 if (b_ptr == NULL) { 592 if (b_ptr == NULL) {
588 warn("Attempt to disable unknown bearer <%s>\n", name); 593 pr_warn("Attempt to disable unknown bearer <%s>\n", name);
589 res = -EINVAL; 594 res = -EINVAL;
590 } else { 595 } else {
591 bearer_disable(b_ptr); 596 bearer_disable(b_ptr);
diff --git a/net/tipc/bearer.h b/net/tipc/bearer.h
index e3b2be37fb31..dd4c2abf08e7 100644
--- a/net/tipc/bearer.h
+++ b/net/tipc/bearer.h
@@ -57,7 +57,7 @@
57 */ 57 */
58#define TIPC_MEDIA_TYPE_ETH 1 58#define TIPC_MEDIA_TYPE_ETH 1
59 59
60/* 60/**
61 * struct tipc_media_addr - destination address used by TIPC bearers 61 * struct tipc_media_addr - destination address used by TIPC bearers
62 * @value: address info (format defined by media) 62 * @value: address info (format defined by media)
63 * @media_id: TIPC media type identifier 63 * @media_id: TIPC media type identifier
@@ -179,7 +179,7 @@ void tipc_eth_media_stop(void);
179 179
180int tipc_media_set_priority(const char *name, u32 new_value); 180int tipc_media_set_priority(const char *name, u32 new_value);
181int tipc_media_set_window(const char *name, u32 new_value); 181int tipc_media_set_window(const char *name, u32 new_value);
182void tipc_media_addr_printf(struct print_buf *pb, struct tipc_media_addr *a); 182void tipc_media_addr_printf(char *buf, int len, struct tipc_media_addr *a);
183struct sk_buff *tipc_media_get_names(void); 183struct sk_buff *tipc_media_get_names(void);
184 184
185struct sk_buff *tipc_bearer_get_names(void); 185struct sk_buff *tipc_bearer_get_names(void);
diff --git a/net/tipc/config.c b/net/tipc/config.c
index c5712a343810..a056a3852f71 100644
--- a/net/tipc/config.c
+++ b/net/tipc/config.c
@@ -39,6 +39,8 @@
39#include "name_table.h" 39#include "name_table.h"
40#include "config.h" 40#include "config.h"
41 41
42#define REPLY_TRUNCATED "<truncated>\n"
43
42static u32 config_port_ref; 44static u32 config_port_ref;
43 45
44static DEFINE_SPINLOCK(config_lock); 46static DEFINE_SPINLOCK(config_lock);
@@ -104,13 +106,12 @@ struct sk_buff *tipc_cfg_reply_string_type(u16 tlv_type, char *string)
104 return buf; 106 return buf;
105} 107}
106 108
107#define MAX_STATS_INFO 2000
108
109static struct sk_buff *tipc_show_stats(void) 109static struct sk_buff *tipc_show_stats(void)
110{ 110{
111 struct sk_buff *buf; 111 struct sk_buff *buf;
112 struct tlv_desc *rep_tlv; 112 struct tlv_desc *rep_tlv;
113 struct print_buf pb; 113 char *pb;
114 int pb_len;
114 int str_len; 115 int str_len;
115 u32 value; 116 u32 value;
116 117
@@ -121,17 +122,16 @@ static struct sk_buff *tipc_show_stats(void)
121 if (value != 0) 122 if (value != 0)
122 return tipc_cfg_reply_error_string("unsupported argument"); 123 return tipc_cfg_reply_error_string("unsupported argument");
123 124
124 buf = tipc_cfg_reply_alloc(TLV_SPACE(MAX_STATS_INFO)); 125 buf = tipc_cfg_reply_alloc(TLV_SPACE(ULTRA_STRING_MAX_LEN));
125 if (buf == NULL) 126 if (buf == NULL)
126 return NULL; 127 return NULL;
127 128
128 rep_tlv = (struct tlv_desc *)buf->data; 129 rep_tlv = (struct tlv_desc *)buf->data;
129 tipc_printbuf_init(&pb, (char *)TLV_DATA(rep_tlv), MAX_STATS_INFO); 130 pb = TLV_DATA(rep_tlv);
130 131 pb_len = ULTRA_STRING_MAX_LEN;
131 tipc_printf(&pb, "TIPC version " TIPC_MOD_VER "\n");
132 132
133 /* Use additional tipc_printf()'s to return more info ... */ 133 str_len = tipc_snprintf(pb, pb_len, "TIPC version " TIPC_MOD_VER "\n");
134 str_len = tipc_printbuf_validate(&pb); 134 str_len += 1; /* for "\0" */
135 skb_put(buf, TLV_SPACE(str_len)); 135 skb_put(buf, TLV_SPACE(str_len));
136 TLV_SET(rep_tlv, TIPC_TLV_ULTRA_STRING, NULL, str_len); 136 TLV_SET(rep_tlv, TIPC_TLV_ULTRA_STRING, NULL, str_len);
137 137
@@ -334,12 +334,6 @@ struct sk_buff *tipc_cfg_do_cmd(u32 orig_node, u16 cmd, const void *request_area
334 case TIPC_CMD_SHOW_PORTS: 334 case TIPC_CMD_SHOW_PORTS:
335 rep_tlv_buf = tipc_port_get_ports(); 335 rep_tlv_buf = tipc_port_get_ports();
336 break; 336 break;
337 case TIPC_CMD_SET_LOG_SIZE:
338 rep_tlv_buf = tipc_log_resize_cmd(req_tlv_area, req_tlv_space);
339 break;
340 case TIPC_CMD_DUMP_LOG:
341 rep_tlv_buf = tipc_log_dump();
342 break;
343 case TIPC_CMD_SHOW_STATS: 337 case TIPC_CMD_SHOW_STATS:
344 rep_tlv_buf = tipc_show_stats(); 338 rep_tlv_buf = tipc_show_stats();
345 break; 339 break;
@@ -399,6 +393,8 @@ struct sk_buff *tipc_cfg_do_cmd(u32 orig_node, u16 cmd, const void *request_area
399 case TIPC_CMD_GET_MAX_CLUSTERS: 393 case TIPC_CMD_GET_MAX_CLUSTERS:
400 case TIPC_CMD_SET_MAX_NODES: 394 case TIPC_CMD_SET_MAX_NODES:
401 case TIPC_CMD_GET_MAX_NODES: 395 case TIPC_CMD_GET_MAX_NODES:
396 case TIPC_CMD_SET_LOG_SIZE:
397 case TIPC_CMD_DUMP_LOG:
402 rep_tlv_buf = tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED 398 rep_tlv_buf = tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED
403 " (obsolete command)"); 399 " (obsolete command)");
404 break; 400 break;
@@ -408,6 +404,15 @@ struct sk_buff *tipc_cfg_do_cmd(u32 orig_node, u16 cmd, const void *request_area
408 break; 404 break;
409 } 405 }
410 406
407 WARN_ON(rep_tlv_buf->len > TLV_SPACE(ULTRA_STRING_MAX_LEN));
408
409 /* Append an error message if we cannot return all requested data */
410 if (rep_tlv_buf->len == TLV_SPACE(ULTRA_STRING_MAX_LEN)) {
411 if (*(rep_tlv_buf->data + ULTRA_STRING_MAX_LEN) != '\0')
412 sprintf(rep_tlv_buf->data + rep_tlv_buf->len -
413 sizeof(REPLY_TRUNCATED) - 1, REPLY_TRUNCATED);
414 }
415
411 /* Return reply buffer */ 416 /* Return reply buffer */
412exit: 417exit:
413 spin_unlock_bh(&config_lock); 418 spin_unlock_bh(&config_lock);
@@ -432,7 +437,7 @@ static void cfg_named_msg_event(void *userdata,
432 if ((size < sizeof(*req_hdr)) || 437 if ((size < sizeof(*req_hdr)) ||
433 (size != TCM_ALIGN(ntohl(req_hdr->tcm_len))) || 438 (size != TCM_ALIGN(ntohl(req_hdr->tcm_len))) ||
434 (ntohs(req_hdr->tcm_flags) != TCM_F_REQUEST)) { 439 (ntohs(req_hdr->tcm_flags) != TCM_F_REQUEST)) {
435 warn("Invalid configuration message discarded\n"); 440 pr_warn("Invalid configuration message discarded\n");
436 return; 441 return;
437 } 442 }
438 443
@@ -478,7 +483,7 @@ int tipc_cfg_init(void)
478 return 0; 483 return 0;
479 484
480failed: 485failed:
481 err("Unable to create configuration service\n"); 486 pr_err("Unable to create configuration service\n");
482 return res; 487 return res;
483} 488}
484 489
@@ -494,7 +499,7 @@ void tipc_cfg_reinit(void)
494 seq.lower = seq.upper = tipc_own_addr; 499 seq.lower = seq.upper = tipc_own_addr;
495 res = tipc_publish(config_port_ref, TIPC_ZONE_SCOPE, &seq); 500 res = tipc_publish(config_port_ref, TIPC_ZONE_SCOPE, &seq);
496 if (res) 501 if (res)
497 err("Unable to reinitialize configuration service\n"); 502 pr_err("Unable to reinitialize configuration service\n");
498} 503}
499 504
500void tipc_cfg_stop(void) 505void tipc_cfg_stop(void)
diff --git a/net/tipc/core.c b/net/tipc/core.c
index f7b95239ebda..6586eac6a50e 100644
--- a/net/tipc/core.c
+++ b/net/tipc/core.c
@@ -34,22 +34,18 @@
34 * POSSIBILITY OF SUCH DAMAGE. 34 * POSSIBILITY OF SUCH DAMAGE.
35 */ 35 */
36 36
37#include <linux/module.h>
38
39#include "core.h" 37#include "core.h"
40#include "ref.h" 38#include "ref.h"
41#include "name_table.h" 39#include "name_table.h"
42#include "subscr.h" 40#include "subscr.h"
43#include "config.h" 41#include "config.h"
44 42
43#include <linux/module.h>
45 44
46#ifndef CONFIG_TIPC_PORTS 45#ifndef CONFIG_TIPC_PORTS
47#define CONFIG_TIPC_PORTS 8191 46#define CONFIG_TIPC_PORTS 8191
48#endif 47#endif
49 48
50#ifndef CONFIG_TIPC_LOG
51#define CONFIG_TIPC_LOG 0
52#endif
53 49
54/* global variables used by multiple sub-systems within TIPC */ 50/* global variables used by multiple sub-systems within TIPC */
55int tipc_random; 51int tipc_random;
@@ -125,7 +121,6 @@ static void tipc_core_stop(void)
125 tipc_nametbl_stop(); 121 tipc_nametbl_stop();
126 tipc_ref_table_stop(); 122 tipc_ref_table_stop();
127 tipc_socket_stop(); 123 tipc_socket_stop();
128 tipc_log_resize(0);
129} 124}
130 125
131/** 126/**
@@ -161,10 +156,7 @@ static int __init tipc_init(void)
161{ 156{
162 int res; 157 int res;
163 158
164 if (tipc_log_resize(CONFIG_TIPC_LOG) != 0) 159 pr_info("Activated (version " TIPC_MOD_VER ")\n");
165 warn("Unable to create log buffer\n");
166
167 info("Activated (version " TIPC_MOD_VER ")\n");
168 160
169 tipc_own_addr = 0; 161 tipc_own_addr = 0;
170 tipc_remote_management = 1; 162 tipc_remote_management = 1;
@@ -175,9 +167,9 @@ static int __init tipc_init(void)
175 167
176 res = tipc_core_start(); 168 res = tipc_core_start();
177 if (res) 169 if (res)
178 err("Unable to start in single node mode\n"); 170 pr_err("Unable to start in single node mode\n");
179 else 171 else
180 info("Started in single node mode\n"); 172 pr_info("Started in single node mode\n");
181 return res; 173 return res;
182} 174}
183 175
@@ -185,7 +177,7 @@ static void __exit tipc_exit(void)
185{ 177{
186 tipc_core_stop_net(); 178 tipc_core_stop_net();
187 tipc_core_stop(); 179 tipc_core_stop();
188 info("Deactivated\n"); 180 pr_info("Deactivated\n");
189} 181}
190 182
191module_init(tipc_init); 183module_init(tipc_init);
diff --git a/net/tipc/core.h b/net/tipc/core.h
index 2a9bb99537b3..fd42e106c185 100644
--- a/net/tipc/core.h
+++ b/net/tipc/core.h
@@ -37,6 +37,8 @@
37#ifndef _TIPC_CORE_H 37#ifndef _TIPC_CORE_H
38#define _TIPC_CORE_H 38#define _TIPC_CORE_H
39 39
40#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
41
40#include <linux/tipc.h> 42#include <linux/tipc.h>
41#include <linux/tipc_config.h> 43#include <linux/tipc_config.h>
42#include <linux/types.h> 44#include <linux/types.h>
@@ -58,68 +60,11 @@
58 60
59#define TIPC_MOD_VER "2.0.0" 61#define TIPC_MOD_VER "2.0.0"
60 62
61struct tipc_msg; /* msg.h */ 63#define ULTRA_STRING_MAX_LEN 32768
62struct print_buf; /* log.h */
63
64/*
65 * TIPC system monitoring code
66 */
67
68/*
69 * TIPC's print buffer subsystem supports the following print buffers:
70 *
71 * TIPC_NULL : null buffer (i.e. print nowhere)
72 * TIPC_CONS : system console
73 * TIPC_LOG : TIPC log buffer
74 * &buf : user-defined buffer (struct print_buf *)
75 *
76 * Note: TIPC_LOG is configured to echo its output to the system console;
77 * user-defined buffers can be configured to do the same thing.
78 */
79extern struct print_buf *const TIPC_NULL;
80extern struct print_buf *const TIPC_CONS;
81extern struct print_buf *const TIPC_LOG;
82
83void tipc_printf(struct print_buf *, const char *fmt, ...);
84
85/*
86 * TIPC_OUTPUT is the destination print buffer for system messages.
87 */
88#ifndef TIPC_OUTPUT
89#define TIPC_OUTPUT TIPC_LOG
90#endif
91 64
92#define err(fmt, arg...) tipc_printf(TIPC_OUTPUT, \ 65struct tipc_msg; /* msg.h */
93 KERN_ERR "TIPC: " fmt, ## arg)
94#define warn(fmt, arg...) tipc_printf(TIPC_OUTPUT, \
95 KERN_WARNING "TIPC: " fmt, ## arg)
96#define info(fmt, arg...) tipc_printf(TIPC_OUTPUT, \
97 KERN_NOTICE "TIPC: " fmt, ## arg)
98
99#ifdef CONFIG_TIPC_DEBUG
100
101/*
102 * DBG_OUTPUT is the destination print buffer for debug messages.
103 */
104#ifndef DBG_OUTPUT
105#define DBG_OUTPUT TIPC_LOG
106#endif
107
108#define dbg(fmt, arg...) tipc_printf(DBG_OUTPUT, KERN_DEBUG fmt, ## arg);
109
110#define msg_dbg(msg, txt) tipc_msg_dbg(DBG_OUTPUT, msg, txt);
111
112void tipc_msg_dbg(struct print_buf *, struct tipc_msg *, const char *);
113
114#else
115
116#define dbg(fmt, arg...) do {} while (0)
117#define msg_dbg(msg, txt) do {} while (0)
118
119#define tipc_msg_dbg(buf, msg, txt) do {} while (0)
120
121#endif
122 66
67int tipc_snprintf(char *buf, int len, const char *fmt, ...);
123 68
124/* 69/*
125 * TIPC-specific error codes 70 * TIPC-specific error codes
diff --git a/net/tipc/discover.c b/net/tipc/discover.c
index ae054cfe179f..50eaa403eb6e 100644
--- a/net/tipc/discover.c
+++ b/net/tipc/discover.c
@@ -100,14 +100,12 @@ static void disc_dupl_alert(struct tipc_bearer *b_ptr, u32 node_addr,
100{ 100{
101 char node_addr_str[16]; 101 char node_addr_str[16];
102 char media_addr_str[64]; 102 char media_addr_str[64];
103 struct print_buf pb;
104 103
105 tipc_addr_string_fill(node_addr_str, node_addr); 104 tipc_addr_string_fill(node_addr_str, node_addr);
106 tipc_printbuf_init(&pb, media_addr_str, sizeof(media_addr_str)); 105 tipc_media_addr_printf(media_addr_str, sizeof(media_addr_str),
107 tipc_media_addr_printf(&pb, media_addr); 106 media_addr);
108 tipc_printbuf_validate(&pb); 107 pr_warn("Duplicate %s using %s seen on <%s>\n", node_addr_str,
109 warn("Duplicate %s using %s seen on <%s>\n", 108 media_addr_str, b_ptr->name);
110 node_addr_str, media_addr_str, b_ptr->name);
111} 109}
112 110
113/** 111/**
diff --git a/net/tipc/handler.c b/net/tipc/handler.c
index 9c6f22ff1c6d..7a52d3922f3c 100644
--- a/net/tipc/handler.c
+++ b/net/tipc/handler.c
@@ -57,14 +57,14 @@ unsigned int tipc_k_signal(Handler routine, unsigned long argument)
57 struct queue_item *item; 57 struct queue_item *item;
58 58
59 if (!handler_enabled) { 59 if (!handler_enabled) {
60 err("Signal request ignored by handler\n"); 60 pr_err("Signal request ignored by handler\n");
61 return -ENOPROTOOPT; 61 return -ENOPROTOOPT;
62 } 62 }
63 63
64 spin_lock_bh(&qitem_lock); 64 spin_lock_bh(&qitem_lock);
65 item = kmem_cache_alloc(tipc_queue_item_cache, GFP_ATOMIC); 65 item = kmem_cache_alloc(tipc_queue_item_cache, GFP_ATOMIC);
66 if (!item) { 66 if (!item) {
67 err("Signal queue out of memory\n"); 67 pr_err("Signal queue out of memory\n");
68 spin_unlock_bh(&qitem_lock); 68 spin_unlock_bh(&qitem_lock);
69 return -ENOMEM; 69 return -ENOMEM;
70 } 70 }
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}
diff --git a/net/tipc/link.h b/net/tipc/link.h
index d6a60a963ce6..6e921121be06 100644
--- a/net/tipc/link.h
+++ b/net/tipc/link.h
@@ -37,7 +37,6 @@
37#ifndef _TIPC_LINK_H 37#ifndef _TIPC_LINK_H
38#define _TIPC_LINK_H 38#define _TIPC_LINK_H
39 39
40#include "log.h"
41#include "msg.h" 40#include "msg.h"
42#include "node.h" 41#include "node.h"
43 42
@@ -63,6 +62,37 @@
63 */ 62 */
64#define MAX_PKT_DEFAULT 1500 63#define MAX_PKT_DEFAULT 1500
65 64
65struct tipc_stats {
66 u32 sent_info; /* used in counting # sent packets */
67 u32 recv_info; /* used in counting # recv'd packets */
68 u32 sent_states;
69 u32 recv_states;
70 u32 sent_probes;
71 u32 recv_probes;
72 u32 sent_nacks;
73 u32 recv_nacks;
74 u32 sent_acks;
75 u32 sent_bundled;
76 u32 sent_bundles;
77 u32 recv_bundled;
78 u32 recv_bundles;
79 u32 retransmitted;
80 u32 sent_fragmented;
81 u32 sent_fragments;
82 u32 recv_fragmented;
83 u32 recv_fragments;
84 u32 link_congs; /* # port sends blocked by congestion */
85 u32 bearer_congs;
86 u32 deferred_recv;
87 u32 duplicates;
88 u32 max_queue_sz; /* send queue size high water mark */
89 u32 accu_queue_sz; /* used for send queue size profiling */
90 u32 queue_sz_counts; /* used for send queue size profiling */
91 u32 msg_length_counts; /* used for message length profiling */
92 u32 msg_lengths_total; /* used for message length profiling */
93 u32 msg_length_profile[7]; /* used for msg. length profiling */
94};
95
66/** 96/**
67 * struct tipc_link - TIPC link data structure 97 * struct tipc_link - TIPC link data structure
68 * @addr: network address of link's peer node 98 * @addr: network address of link's peer node
@@ -175,36 +205,7 @@ struct tipc_link {
175 struct sk_buff *defragm_buf; 205 struct sk_buff *defragm_buf;
176 206
177 /* Statistics */ 207 /* Statistics */
178 struct { 208 struct tipc_stats stats;
179 u32 sent_info; /* used in counting # sent packets */
180 u32 recv_info; /* used in counting # recv'd packets */
181 u32 sent_states;
182 u32 recv_states;
183 u32 sent_probes;
184 u32 recv_probes;
185 u32 sent_nacks;
186 u32 recv_nacks;
187 u32 sent_acks;
188 u32 sent_bundled;
189 u32 sent_bundles;
190 u32 recv_bundled;
191 u32 recv_bundles;
192 u32 retransmitted;
193 u32 sent_fragmented;
194 u32 sent_fragments;
195 u32 recv_fragmented;
196 u32 recv_fragments;
197 u32 link_congs; /* # port sends blocked by congestion */
198 u32 bearer_congs;
199 u32 deferred_recv;
200 u32 duplicates;
201 u32 max_queue_sz; /* send queue size high water mark */
202 u32 accu_queue_sz; /* used for send queue size profiling */
203 u32 queue_sz_counts; /* used for send queue size profiling */
204 u32 msg_length_counts; /* used for message length profiling */
205 u32 msg_lengths_total; /* used for message length profiling */
206 u32 msg_length_profile[7]; /* used for msg. length profiling */
207 } stats;
208}; 209};
209 210
210struct tipc_port; 211struct tipc_port;
diff --git a/net/tipc/log.c b/net/tipc/log.c
index 026733f24919..abef644f27d8 100644
--- a/net/tipc/log.c
+++ b/net/tipc/log.c
@@ -36,302 +36,20 @@
36 36
37#include "core.h" 37#include "core.h"
38#include "config.h" 38#include "config.h"
39#include "log.h"
40
41/*
42 * TIPC pre-defines the following print buffers:
43 *
44 * TIPC_NULL : null buffer (i.e. print nowhere)
45 * TIPC_CONS : system console
46 * TIPC_LOG : TIPC log buffer
47 *
48 * Additional user-defined print buffers are also permitted.
49 */
50static struct print_buf null_buf = { NULL, 0, NULL, 0 };
51struct print_buf *const TIPC_NULL = &null_buf;
52
53static struct print_buf cons_buf = { NULL, 0, NULL, 1 };
54struct print_buf *const TIPC_CONS = &cons_buf;
55
56static struct print_buf log_buf = { NULL, 0, NULL, 1 };
57struct print_buf *const TIPC_LOG = &log_buf;
58
59/*
60 * Locking policy when using print buffers.
61 *
62 * 1) tipc_printf() uses 'print_lock' to protect against concurrent access to
63 * 'print_string' when writing to a print buffer. This also protects against
64 * concurrent writes to the print buffer being written to.
65 *
66 * 2) tipc_log_XXX() leverages the aforementioned use of 'print_lock' to
67 * protect against all types of concurrent operations on their associated
68 * print buffer (not just write operations).
69 *
70 * Note: All routines of the form tipc_printbuf_XXX() are lock-free, and rely
71 * on the caller to prevent simultaneous use of the print buffer(s) being
72 * manipulated.
73 */
74static char print_string[TIPC_PB_MAX_STR];
75static DEFINE_SPINLOCK(print_lock);
76
77static void tipc_printbuf_move(struct print_buf *pb_to,
78 struct print_buf *pb_from);
79
80#define FORMAT(PTR, LEN, FMT) \
81{\
82 va_list args;\
83 va_start(args, FMT);\
84 LEN = vsprintf(PTR, FMT, args);\
85 va_end(args);\
86 *(PTR + LEN) = '\0';\
87}
88
89/**
90 * tipc_printbuf_init - initialize print buffer to empty
91 * @pb: pointer to print buffer structure
92 * @raw: pointer to character array used by print buffer
93 * @size: size of character array
94 *
95 * Note: If the character array is too small (or absent), the print buffer
96 * becomes a null device that discards anything written to it.
97 */
98void tipc_printbuf_init(struct print_buf *pb, char *raw, u32 size)
99{
100 pb->buf = raw;
101 pb->crs = raw;
102 pb->size = size;
103 pb->echo = 0;
104
105 if (size < TIPC_PB_MIN_SIZE) {
106 pb->buf = NULL;
107 } else if (raw) {
108 pb->buf[0] = 0;
109 pb->buf[size - 1] = ~0;
110 }
111}
112
113/**
114 * tipc_printbuf_reset - reinitialize print buffer to empty state
115 * @pb: pointer to print buffer structure
116 */
117static void tipc_printbuf_reset(struct print_buf *pb)
118{
119 if (pb->buf) {
120 pb->crs = pb->buf;
121 pb->buf[0] = 0;
122 pb->buf[pb->size - 1] = ~0;
123 }
124}
125
126/**
127 * tipc_printbuf_empty - test if print buffer is in empty state
128 * @pb: pointer to print buffer structure
129 *
130 * Returns non-zero if print buffer is empty.
131 */
132static int tipc_printbuf_empty(struct print_buf *pb)
133{
134 return !pb->buf || (pb->crs == pb->buf);
135}
136
137/**
138 * tipc_printbuf_validate - check for print buffer overflow
139 * @pb: pointer to print buffer structure
140 *
141 * Verifies that a print buffer has captured all data written to it.
142 * If data has been lost, linearize buffer and prepend an error message
143 *
144 * Returns length of print buffer data string (including trailing NUL)
145 */
146int tipc_printbuf_validate(struct print_buf *pb)
147{
148 char *err = "\n\n*** PRINT BUFFER OVERFLOW ***\n\n";
149 char *cp_buf;
150 struct print_buf cb;
151
152 if (!pb->buf)
153 return 0;
154
155 if (pb->buf[pb->size - 1] == 0) {
156 cp_buf = kmalloc(pb->size, GFP_ATOMIC);
157 if (cp_buf) {
158 tipc_printbuf_init(&cb, cp_buf, pb->size);
159 tipc_printbuf_move(&cb, pb);
160 tipc_printbuf_move(pb, &cb);
161 kfree(cp_buf);
162 memcpy(pb->buf, err, strlen(err));
163 } else {
164 tipc_printbuf_reset(pb);
165 tipc_printf(pb, err);
166 }
167 }
168 return pb->crs - pb->buf + 1;
169}
170
171/**
172 * tipc_printbuf_move - move print buffer contents to another print buffer
173 * @pb_to: pointer to destination print buffer structure
174 * @pb_from: pointer to source print buffer structure
175 *
176 * Current contents of destination print buffer (if any) are discarded.
177 * Source print buffer becomes empty if a successful move occurs.
178 */
179static void tipc_printbuf_move(struct print_buf *pb_to,
180 struct print_buf *pb_from)
181{
182 int len;
183
184 /* Handle the cases where contents can't be moved */
185 if (!pb_to->buf)
186 return;
187
188 if (!pb_from->buf) {
189 tipc_printbuf_reset(pb_to);
190 return;
191 }
192
193 if (pb_to->size < pb_from->size) {
194 strcpy(pb_to->buf, "*** PRINT BUFFER MOVE ERROR ***");
195 pb_to->buf[pb_to->size - 1] = ~0;
196 pb_to->crs = strchr(pb_to->buf, 0);
197 return;
198 }
199
200 /* Copy data from char after cursor to end (if used) */
201 len = pb_from->buf + pb_from->size - pb_from->crs - 2;
202 if ((pb_from->buf[pb_from->size - 1] == 0) && (len > 0)) {
203 strcpy(pb_to->buf, pb_from->crs + 1);
204 pb_to->crs = pb_to->buf + len;
205 } else
206 pb_to->crs = pb_to->buf;
207
208 /* Copy data from start to cursor (always) */
209 len = pb_from->crs - pb_from->buf;
210 strcpy(pb_to->crs, pb_from->buf);
211 pb_to->crs += len;
212
213 tipc_printbuf_reset(pb_from);
214}
215 39
216/** 40/**
217 * tipc_printf - append formatted output to print buffer 41 * tipc_snprintf - append formatted output to print buffer
218 * @pb: pointer to print buffer 42 * @buf: pointer to print buffer
43 * @len: buffer length
219 * @fmt: formatted info to be printed 44 * @fmt: formatted info to be printed
220 */ 45 */
221void tipc_printf(struct print_buf *pb, const char *fmt, ...) 46int tipc_snprintf(char *buf, int len, const char *fmt, ...)
222{
223 int chars_to_add;
224 int chars_left;
225 char save_char;
226
227 spin_lock_bh(&print_lock);
228
229 FORMAT(print_string, chars_to_add, fmt);
230 if (chars_to_add >= TIPC_PB_MAX_STR)
231 strcpy(print_string, "*** PRINT BUFFER STRING TOO LONG ***");
232
233 if (pb->buf) {
234 chars_left = pb->buf + pb->size - pb->crs - 1;
235 if (chars_to_add <= chars_left) {
236 strcpy(pb->crs, print_string);
237 pb->crs += chars_to_add;
238 } else if (chars_to_add >= (pb->size - 1)) {
239 strcpy(pb->buf, print_string + chars_to_add + 1
240 - pb->size);
241 pb->crs = pb->buf + pb->size - 1;
242 } else {
243 strcpy(pb->buf, print_string + chars_left);
244 save_char = print_string[chars_left];
245 print_string[chars_left] = 0;
246 strcpy(pb->crs, print_string);
247 print_string[chars_left] = save_char;
248 pb->crs = pb->buf + chars_to_add - chars_left;
249 }
250 }
251
252 if (pb->echo)
253 printk("%s", print_string);
254
255 spin_unlock_bh(&print_lock);
256}
257
258/**
259 * tipc_log_resize - change the size of the TIPC log buffer
260 * @log_size: print buffer size to use
261 */
262int tipc_log_resize(int log_size)
263{
264 int res = 0;
265
266 spin_lock_bh(&print_lock);
267 kfree(TIPC_LOG->buf);
268 TIPC_LOG->buf = NULL;
269 if (log_size) {
270 if (log_size < TIPC_PB_MIN_SIZE)
271 log_size = TIPC_PB_MIN_SIZE;
272 res = TIPC_LOG->echo;
273 tipc_printbuf_init(TIPC_LOG, kmalloc(log_size, GFP_ATOMIC),
274 log_size);
275 TIPC_LOG->echo = res;
276 res = !TIPC_LOG->buf;
277 }
278 spin_unlock_bh(&print_lock);
279
280 return res;
281}
282
283/**
284 * tipc_log_resize_cmd - reconfigure size of TIPC log buffer
285 */
286struct sk_buff *tipc_log_resize_cmd(const void *req_tlv_area, int req_tlv_space)
287{
288 u32 value;
289
290 if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_UNSIGNED))
291 return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR);
292
293 value = ntohl(*(__be32 *)TLV_DATA(req_tlv_area));
294 if (value > 32768)
295 return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE
296 " (log size must be 0-32768)");
297 if (tipc_log_resize(value))
298 return tipc_cfg_reply_error_string(
299 "unable to create specified log (log size is now 0)");
300 return tipc_cfg_reply_none();
301}
302
303/**
304 * tipc_log_dump - capture TIPC log buffer contents in configuration message
305 */
306struct sk_buff *tipc_log_dump(void)
307{ 47{
308 struct sk_buff *reply; 48 int i;
309 49 va_list args;
310 spin_lock_bh(&print_lock);
311 if (!TIPC_LOG->buf) {
312 spin_unlock_bh(&print_lock);
313 reply = tipc_cfg_reply_ultra_string("log not activated\n");
314 } else if (tipc_printbuf_empty(TIPC_LOG)) {
315 spin_unlock_bh(&print_lock);
316 reply = tipc_cfg_reply_ultra_string("log is empty\n");
317 } else {
318 struct tlv_desc *rep_tlv;
319 struct print_buf pb;
320 int str_len;
321 50
322 str_len = min(TIPC_LOG->size, 32768u); 51 va_start(args, fmt);
323 spin_unlock_bh(&print_lock); 52 i = vscnprintf(buf, len, fmt, args);
324 reply = tipc_cfg_reply_alloc(TLV_SPACE(str_len)); 53 va_end(args);
325 if (reply) { 54 return i;
326 rep_tlv = (struct tlv_desc *)reply->data;
327 tipc_printbuf_init(&pb, TLV_DATA(rep_tlv), str_len);
328 spin_lock_bh(&print_lock);
329 tipc_printbuf_move(&pb, TIPC_LOG);
330 spin_unlock_bh(&print_lock);
331 str_len = strlen(TLV_DATA(rep_tlv)) + 1;
332 skb_put(reply, TLV_SPACE(str_len));
333 TLV_SET(rep_tlv, TIPC_TLV_ULTRA_STRING, NULL, str_len);
334 }
335 }
336 return reply;
337} 55}
diff --git a/net/tipc/log.h b/net/tipc/log.h
deleted file mode 100644
index d1f5eb967fd8..000000000000
--- a/net/tipc/log.h
+++ /dev/null
@@ -1,66 +0,0 @@
1/*
2 * net/tipc/log.h: Include file for TIPC print buffer routines
3 *
4 * Copyright (c) 1997-2006, Ericsson AB
5 * Copyright (c) 2005-2007, Wind River Systems
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are met:
10 *
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. Neither the names of the copyright holders nor the names of its
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
19 *
20 * Alternatively, this software may be distributed under the terms of the
21 * GNU General Public License ("GPL") version 2 as published by the Free
22 * Software Foundation.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
28 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 * POSSIBILITY OF SUCH DAMAGE.
35 */
36
37#ifndef _TIPC_LOG_H
38#define _TIPC_LOG_H
39
40/**
41 * struct print_buf - TIPC print buffer structure
42 * @buf: pointer to character array containing print buffer contents
43 * @size: size of character array
44 * @crs: pointer to first unused space in character array (i.e. final NUL)
45 * @echo: echo output to system console if non-zero
46 */
47struct print_buf {
48 char *buf;
49 u32 size;
50 char *crs;
51 int echo;
52};
53
54#define TIPC_PB_MIN_SIZE 64 /* minimum size for a print buffer's array */
55#define TIPC_PB_MAX_STR 512 /* max printable string (with trailing NUL) */
56
57void tipc_printbuf_init(struct print_buf *pb, char *buf, u32 size);
58int tipc_printbuf_validate(struct print_buf *pb);
59
60int tipc_log_resize(int log_size);
61
62struct sk_buff *tipc_log_resize_cmd(const void *req_tlv_area,
63 int req_tlv_space);
64struct sk_buff *tipc_log_dump(void);
65
66#endif
diff --git a/net/tipc/msg.c b/net/tipc/msg.c
index deea0d232dca..f2db8a87d9c5 100644
--- a/net/tipc/msg.c
+++ b/net/tipc/msg.c
@@ -109,245 +109,3 @@ int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect,
109 *buf = NULL; 109 *buf = NULL;
110 return -EFAULT; 110 return -EFAULT;
111} 111}
112
113#ifdef CONFIG_TIPC_DEBUG
114void tipc_msg_dbg(struct print_buf *buf, struct tipc_msg *msg, const char *str)
115{
116 u32 usr = msg_user(msg);
117 tipc_printf(buf, KERN_DEBUG);
118 tipc_printf(buf, str);
119
120 switch (usr) {
121 case MSG_BUNDLER:
122 tipc_printf(buf, "BNDL::");
123 tipc_printf(buf, "MSGS(%u):", msg_msgcnt(msg));
124 break;
125 case BCAST_PROTOCOL:
126 tipc_printf(buf, "BCASTP::");
127 break;
128 case MSG_FRAGMENTER:
129 tipc_printf(buf, "FRAGM::");
130 switch (msg_type(msg)) {
131 case FIRST_FRAGMENT:
132 tipc_printf(buf, "FIRST:");
133 break;
134 case FRAGMENT:
135 tipc_printf(buf, "BODY:");
136 break;
137 case LAST_FRAGMENT:
138 tipc_printf(buf, "LAST:");
139 break;
140 default:
141 tipc_printf(buf, "UNKNOWN:%x", msg_type(msg));
142
143 }
144 tipc_printf(buf, "NO(%u/%u):", msg_long_msgno(msg),
145 msg_fragm_no(msg));
146 break;
147 case TIPC_LOW_IMPORTANCE:
148 case TIPC_MEDIUM_IMPORTANCE:
149 case TIPC_HIGH_IMPORTANCE:
150 case TIPC_CRITICAL_IMPORTANCE:
151 tipc_printf(buf, "DAT%u:", msg_user(msg));
152 if (msg_short(msg)) {
153 tipc_printf(buf, "CON:");
154 break;
155 }
156 switch (msg_type(msg)) {
157 case TIPC_CONN_MSG:
158 tipc_printf(buf, "CON:");
159 break;
160 case TIPC_MCAST_MSG:
161 tipc_printf(buf, "MCST:");
162 break;
163 case TIPC_NAMED_MSG:
164 tipc_printf(buf, "NAM:");
165 break;
166 case TIPC_DIRECT_MSG:
167 tipc_printf(buf, "DIR:");
168 break;
169 default:
170 tipc_printf(buf, "UNKNOWN TYPE %u", msg_type(msg));
171 }
172 if (msg_reroute_cnt(msg))
173 tipc_printf(buf, "REROUTED(%u):",
174 msg_reroute_cnt(msg));
175 break;
176 case NAME_DISTRIBUTOR:
177 tipc_printf(buf, "NMD::");
178 switch (msg_type(msg)) {
179 case PUBLICATION:
180 tipc_printf(buf, "PUBL(%u):", (msg_size(msg) - msg_hdr_sz(msg)) / 20); /* Items */
181 break;
182 case WITHDRAWAL:
183 tipc_printf(buf, "WDRW:");
184 break;
185 default:
186 tipc_printf(buf, "UNKNOWN:%x", msg_type(msg));
187 }
188 if (msg_reroute_cnt(msg))
189 tipc_printf(buf, "REROUTED(%u):",
190 msg_reroute_cnt(msg));
191 break;
192 case CONN_MANAGER:
193 tipc_printf(buf, "CONN_MNG:");
194 switch (msg_type(msg)) {
195 case CONN_PROBE:
196 tipc_printf(buf, "PROBE:");
197 break;
198 case CONN_PROBE_REPLY:
199 tipc_printf(buf, "PROBE_REPLY:");
200 break;
201 case CONN_ACK:
202 tipc_printf(buf, "CONN_ACK:");
203 tipc_printf(buf, "ACK(%u):", msg_msgcnt(msg));
204 break;
205 default:
206 tipc_printf(buf, "UNKNOWN TYPE:%x", msg_type(msg));
207 }
208 if (msg_reroute_cnt(msg))
209 tipc_printf(buf, "REROUTED(%u):", msg_reroute_cnt(msg));
210 break;
211 case LINK_PROTOCOL:
212 switch (msg_type(msg)) {
213 case STATE_MSG:
214 tipc_printf(buf, "STATE:");
215 tipc_printf(buf, "%s:", msg_probe(msg) ? "PRB" : "");
216 tipc_printf(buf, "NXS(%u):", msg_next_sent(msg));
217 tipc_printf(buf, "GAP(%u):", msg_seq_gap(msg));
218 tipc_printf(buf, "LSTBC(%u):", msg_last_bcast(msg));
219 break;
220 case RESET_MSG:
221 tipc_printf(buf, "RESET:");
222 if (msg_size(msg) != msg_hdr_sz(msg))
223 tipc_printf(buf, "BEAR:%s:", msg_data(msg));
224 break;
225 case ACTIVATE_MSG:
226 tipc_printf(buf, "ACTIVATE:");
227 break;
228 default:
229 tipc_printf(buf, "UNKNOWN TYPE:%x", msg_type(msg));
230 }
231 tipc_printf(buf, "PLANE(%c):", msg_net_plane(msg));
232 tipc_printf(buf, "SESS(%u):", msg_session(msg));
233 break;
234 case CHANGEOVER_PROTOCOL:
235 tipc_printf(buf, "TUNL:");
236 switch (msg_type(msg)) {
237 case DUPLICATE_MSG:
238 tipc_printf(buf, "DUPL:");
239 break;
240 case ORIGINAL_MSG:
241 tipc_printf(buf, "ORIG:");
242 tipc_printf(buf, "EXP(%u)", msg_msgcnt(msg));
243 break;
244 default:
245 tipc_printf(buf, "UNKNOWN TYPE:%x", msg_type(msg));
246 }
247 break;
248 case LINK_CONFIG:
249 tipc_printf(buf, "CFG:");
250 switch (msg_type(msg)) {
251 case DSC_REQ_MSG:
252 tipc_printf(buf, "DSC_REQ:");
253 break;
254 case DSC_RESP_MSG:
255 tipc_printf(buf, "DSC_RESP:");
256 break;
257 default:
258 tipc_printf(buf, "UNKNOWN TYPE:%x:", msg_type(msg));
259 break;
260 }
261 break;
262 default:
263 tipc_printf(buf, "UNKNOWN USER:");
264 }
265
266 switch (usr) {
267 case CONN_MANAGER:
268 case TIPC_LOW_IMPORTANCE:
269 case TIPC_MEDIUM_IMPORTANCE:
270 case TIPC_HIGH_IMPORTANCE:
271 case TIPC_CRITICAL_IMPORTANCE:
272 switch (msg_errcode(msg)) {
273 case TIPC_OK:
274 break;
275 case TIPC_ERR_NO_NAME:
276 tipc_printf(buf, "NO_NAME:");
277 break;
278 case TIPC_ERR_NO_PORT:
279 tipc_printf(buf, "NO_PORT:");
280 break;
281 case TIPC_ERR_NO_NODE:
282 tipc_printf(buf, "NO_PROC:");
283 break;
284 case TIPC_ERR_OVERLOAD:
285 tipc_printf(buf, "OVERLOAD:");
286 break;
287 case TIPC_CONN_SHUTDOWN:
288 tipc_printf(buf, "SHUTDOWN:");
289 break;
290 default:
291 tipc_printf(buf, "UNKNOWN ERROR(%x):",
292 msg_errcode(msg));
293 }
294 default:
295 break;
296 }
297
298 tipc_printf(buf, "HZ(%u):", msg_hdr_sz(msg));
299 tipc_printf(buf, "SZ(%u):", msg_size(msg));
300 tipc_printf(buf, "SQNO(%u):", msg_seqno(msg));
301
302 if (msg_non_seq(msg))
303 tipc_printf(buf, "NOSEQ:");
304 else
305 tipc_printf(buf, "ACK(%u):", msg_ack(msg));
306 tipc_printf(buf, "BACK(%u):", msg_bcast_ack(msg));
307 tipc_printf(buf, "PRND(%x)", msg_prevnode(msg));
308
309 if (msg_isdata(msg)) {
310 if (msg_named(msg)) {
311 tipc_printf(buf, "NTYP(%u):", msg_nametype(msg));
312 tipc_printf(buf, "NINST(%u)", msg_nameinst(msg));
313 }
314 }
315
316 if ((usr != LINK_PROTOCOL) && (usr != LINK_CONFIG) &&
317 (usr != MSG_BUNDLER)) {
318 if (!msg_short(msg)) {
319 tipc_printf(buf, ":ORIG(%x:%u):",
320 msg_orignode(msg), msg_origport(msg));
321 tipc_printf(buf, ":DEST(%x:%u):",
322 msg_destnode(msg), msg_destport(msg));
323 } else {
324 tipc_printf(buf, ":OPRT(%u):", msg_origport(msg));
325 tipc_printf(buf, ":DPRT(%u):", msg_destport(msg));
326 }
327 }
328 if (msg_user(msg) == NAME_DISTRIBUTOR) {
329 tipc_printf(buf, ":ONOD(%x):", msg_orignode(msg));
330 tipc_printf(buf, ":DNOD(%x):", msg_destnode(msg));
331 }
332
333 if (msg_user(msg) == LINK_CONFIG) {
334 struct tipc_media_addr orig;
335
336 tipc_printf(buf, ":DDOM(%x):", msg_dest_domain(msg));
337 tipc_printf(buf, ":NETID(%u):", msg_bc_netid(msg));
338 memcpy(orig.value, msg_media_addr(msg), sizeof(orig.value));
339 orig.media_id = 0;
340 orig.broadcast = 0;
341 tipc_media_addr_printf(buf, &orig);
342 }
343 if (msg_user(msg) == BCAST_PROTOCOL) {
344 tipc_printf(buf, "BCNACK:AFTER(%u):", msg_bcgap_after(msg));
345 tipc_printf(buf, "TO(%u):", msg_bcgap_to(msg));
346 }
347 tipc_printf(buf, "\n");
348 if ((usr == CHANGEOVER_PROTOCOL) && (msg_msgcnt(msg)))
349 tipc_msg_dbg(buf, msg_get_wrapped(msg), " /");
350 if ((usr == MSG_FRAGMENTER) && (msg_type(msg) == FIRST_FRAGMENT))
351 tipc_msg_dbg(buf, msg_get_wrapped(msg), " /");
352}
353#endif
diff --git a/net/tipc/name_distr.c b/net/tipc/name_distr.c
index 158318e67b08..55d3928dfd67 100644
--- a/net/tipc/name_distr.c
+++ b/net/tipc/name_distr.c
@@ -161,7 +161,7 @@ void tipc_named_publish(struct publication *publ)
161 161
162 buf = named_prepare_buf(PUBLICATION, ITEM_SIZE, 0); 162 buf = named_prepare_buf(PUBLICATION, ITEM_SIZE, 0);
163 if (!buf) { 163 if (!buf) {
164 warn("Publication distribution failure\n"); 164 pr_warn("Publication distribution failure\n");
165 return; 165 return;
166 } 166 }
167 167
@@ -186,7 +186,7 @@ void tipc_named_withdraw(struct publication *publ)
186 186
187 buf = named_prepare_buf(WITHDRAWAL, ITEM_SIZE, 0); 187 buf = named_prepare_buf(WITHDRAWAL, ITEM_SIZE, 0);
188 if (!buf) { 188 if (!buf) {
189 warn("Withdrawal distribution failure\n"); 189 pr_warn("Withdrawal distribution failure\n");
190 return; 190 return;
191 } 191 }
192 192
@@ -213,7 +213,7 @@ static void named_distribute(struct list_head *message_list, u32 node,
213 rest -= left; 213 rest -= left;
214 buf = named_prepare_buf(PUBLICATION, left, node); 214 buf = named_prepare_buf(PUBLICATION, left, node);
215 if (!buf) { 215 if (!buf) {
216 warn("Bulk publication failure\n"); 216 pr_warn("Bulk publication failure\n");
217 return; 217 return;
218 } 218 }
219 item = (struct distr_item *)msg_data(buf_msg(buf)); 219 item = (struct distr_item *)msg_data(buf_msg(buf));
@@ -283,9 +283,10 @@ static void named_purge_publ(struct publication *publ)
283 write_unlock_bh(&tipc_nametbl_lock); 283 write_unlock_bh(&tipc_nametbl_lock);
284 284
285 if (p != publ) { 285 if (p != publ) {
286 err("Unable to remove publication from failed node\n" 286 pr_err("Unable to remove publication from failed node\n"
287 "(type=%u, lower=%u, node=0x%x, ref=%u, key=%u)\n", 287 " (type=%u, lower=%u, node=0x%x, ref=%u, key=%u)\n",
288 publ->type, publ->lower, publ->node, publ->ref, publ->key); 288 publ->type, publ->lower, publ->node, publ->ref,
289 publ->key);
289 } 290 }
290 291
291 kfree(p); 292 kfree(p);
@@ -329,14 +330,14 @@ void tipc_named_recv(struct sk_buff *buf)
329 tipc_nodesub_unsubscribe(&publ->subscr); 330 tipc_nodesub_unsubscribe(&publ->subscr);
330 kfree(publ); 331 kfree(publ);
331 } else { 332 } else {
332 err("Unable to remove publication by node 0x%x\n" 333 pr_err("Unable to remove publication by node 0x%x\n"
333 "(type=%u, lower=%u, ref=%u, key=%u)\n", 334 " (type=%u, lower=%u, ref=%u, key=%u)\n",
334 msg_orignode(msg), 335 msg_orignode(msg), ntohl(item->type),
335 ntohl(item->type), ntohl(item->lower), 336 ntohl(item->lower), ntohl(item->ref),
336 ntohl(item->ref), ntohl(item->key)); 337 ntohl(item->key));
337 } 338 }
338 } else { 339 } else {
339 warn("Unrecognized name table message received\n"); 340 pr_warn("Unrecognized name table message received\n");
340 } 341 }
341 item++; 342 item++;
342 } 343 }
diff --git a/net/tipc/name_table.c b/net/tipc/name_table.c
index 010f24a59da2..360c478b0b53 100644
--- a/net/tipc/name_table.c
+++ b/net/tipc/name_table.c
@@ -126,7 +126,7 @@ static struct publication *publ_create(u32 type, u32 lower, u32 upper,
126{ 126{
127 struct publication *publ = kzalloc(sizeof(*publ), GFP_ATOMIC); 127 struct publication *publ = kzalloc(sizeof(*publ), GFP_ATOMIC);
128 if (publ == NULL) { 128 if (publ == NULL) {
129 warn("Publication creation failure, no memory\n"); 129 pr_warn("Publication creation failure, no memory\n");
130 return NULL; 130 return NULL;
131 } 131 }
132 132
@@ -163,7 +163,7 @@ static struct name_seq *tipc_nameseq_create(u32 type, struct hlist_head *seq_hea
163 struct sub_seq *sseq = tipc_subseq_alloc(1); 163 struct sub_seq *sseq = tipc_subseq_alloc(1);
164 164
165 if (!nseq || !sseq) { 165 if (!nseq || !sseq) {
166 warn("Name sequence creation failed, no memory\n"); 166 pr_warn("Name sequence creation failed, no memory\n");
167 kfree(nseq); 167 kfree(nseq);
168 kfree(sseq); 168 kfree(sseq);
169 return NULL; 169 return NULL;
@@ -191,7 +191,7 @@ static void nameseq_delete_empty(struct name_seq *seq)
191 } 191 }
192} 192}
193 193
194/* 194/**
195 * nameseq_find_subseq - find sub-sequence (if any) matching a name instance 195 * nameseq_find_subseq - find sub-sequence (if any) matching a name instance
196 * 196 *
197 * Very time-critical, so binary searches through sub-sequence array. 197 * Very time-critical, so binary searches through sub-sequence array.
@@ -263,8 +263,8 @@ static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq,
263 263
264 /* Lower end overlaps existing entry => need an exact match */ 264 /* Lower end overlaps existing entry => need an exact match */
265 if ((sseq->lower != lower) || (sseq->upper != upper)) { 265 if ((sseq->lower != lower) || (sseq->upper != upper)) {
266 warn("Cannot publish {%u,%u,%u}, overlap error\n", 266 pr_warn("Cannot publish {%u,%u,%u}, overlap error\n",
267 type, lower, upper); 267 type, lower, upper);
268 return NULL; 268 return NULL;
269 } 269 }
270 270
@@ -286,8 +286,8 @@ static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq,
286 /* Fail if upper end overlaps into an existing entry */ 286 /* Fail if upper end overlaps into an existing entry */
287 if ((inspos < nseq->first_free) && 287 if ((inspos < nseq->first_free) &&
288 (upper >= nseq->sseqs[inspos].lower)) { 288 (upper >= nseq->sseqs[inspos].lower)) {
289 warn("Cannot publish {%u,%u,%u}, overlap error\n", 289 pr_warn("Cannot publish {%u,%u,%u}, overlap error\n",
290 type, lower, upper); 290 type, lower, upper);
291 return NULL; 291 return NULL;
292 } 292 }
293 293
@@ -296,8 +296,8 @@ static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq,
296 struct sub_seq *sseqs = tipc_subseq_alloc(nseq->alloc * 2); 296 struct sub_seq *sseqs = tipc_subseq_alloc(nseq->alloc * 2);
297 297
298 if (!sseqs) { 298 if (!sseqs) {
299 warn("Cannot publish {%u,%u,%u}, no memory\n", 299 pr_warn("Cannot publish {%u,%u,%u}, no memory\n",
300 type, lower, upper); 300 type, lower, upper);
301 return NULL; 301 return NULL;
302 } 302 }
303 memcpy(sseqs, nseq->sseqs, 303 memcpy(sseqs, nseq->sseqs,
@@ -309,8 +309,8 @@ static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq,
309 309
310 info = kzalloc(sizeof(*info), GFP_ATOMIC); 310 info = kzalloc(sizeof(*info), GFP_ATOMIC);
311 if (!info) { 311 if (!info) {
312 warn("Cannot publish {%u,%u,%u}, no memory\n", 312 pr_warn("Cannot publish {%u,%u,%u}, no memory\n",
313 type, lower, upper); 313 type, lower, upper);
314 return NULL; 314 return NULL;
315 } 315 }
316 316
@@ -435,7 +435,7 @@ found:
435} 435}
436 436
437/** 437/**
438 * tipc_nameseq_subscribe: attach a subscription, and issue 438 * tipc_nameseq_subscribe - attach a subscription, and issue
439 * the prescribed number of events if there is any sub- 439 * the prescribed number of events if there is any sub-
440 * sequence overlapping with the requested sequence 440 * sequence overlapping with the requested sequence
441 */ 441 */
@@ -492,8 +492,8 @@ struct publication *tipc_nametbl_insert_publ(u32 type, u32 lower, u32 upper,
492 492
493 if ((scope < TIPC_ZONE_SCOPE) || (scope > TIPC_NODE_SCOPE) || 493 if ((scope < TIPC_ZONE_SCOPE) || (scope > TIPC_NODE_SCOPE) ||
494 (lower > upper)) { 494 (lower > upper)) {
495 dbg("Failed to publish illegal {%u,%u,%u} with scope %u\n", 495 pr_debug("Failed to publish illegal {%u,%u,%u} with scope %u\n",
496 type, lower, upper, scope); 496 type, lower, upper, scope);
497 return NULL; 497 return NULL;
498 } 498 }
499 499
@@ -520,7 +520,7 @@ struct publication *tipc_nametbl_remove_publ(u32 type, u32 lower,
520 return publ; 520 return publ;
521} 521}
522 522
523/* 523/**
524 * tipc_nametbl_translate - perform name translation 524 * tipc_nametbl_translate - perform name translation
525 * 525 *
526 * On entry, 'destnode' is the search domain used during translation. 526 * On entry, 'destnode' is the search domain used during translation.
@@ -668,8 +668,8 @@ struct publication *tipc_nametbl_publish(u32 type, u32 lower, u32 upper,
668 struct publication *publ; 668 struct publication *publ;
669 669
670 if (table.local_publ_count >= tipc_max_publications) { 670 if (table.local_publ_count >= tipc_max_publications) {
671 warn("Publication failed, local publication limit reached (%u)\n", 671 pr_warn("Publication failed, local publication limit reached (%u)\n",
672 tipc_max_publications); 672 tipc_max_publications);
673 return NULL; 673 return NULL;
674 } 674 }
675 675
@@ -702,9 +702,9 @@ int tipc_nametbl_withdraw(u32 type, u32 lower, u32 ref, u32 key)
702 return 1; 702 return 1;
703 } 703 }
704 write_unlock_bh(&tipc_nametbl_lock); 704 write_unlock_bh(&tipc_nametbl_lock);
705 err("Unable to remove local publication\n" 705 pr_err("Unable to remove local publication\n"
706 "(type=%u, lower=%u, ref=%u, key=%u)\n", 706 "(type=%u, lower=%u, ref=%u, key=%u)\n",
707 type, lower, ref, key); 707 type, lower, ref, key);
708 return 0; 708 return 0;
709} 709}
710 710
@@ -725,8 +725,8 @@ void tipc_nametbl_subscribe(struct tipc_subscription *s)
725 tipc_nameseq_subscribe(seq, s); 725 tipc_nameseq_subscribe(seq, s);
726 spin_unlock_bh(&seq->lock); 726 spin_unlock_bh(&seq->lock);
727 } else { 727 } else {
728 warn("Failed to create subscription for {%u,%u,%u}\n", 728 pr_warn("Failed to create subscription for {%u,%u,%u}\n",
729 s->seq.type, s->seq.lower, s->seq.upper); 729 s->seq.type, s->seq.lower, s->seq.upper);
730 } 730 }
731 write_unlock_bh(&tipc_nametbl_lock); 731 write_unlock_bh(&tipc_nametbl_lock);
732} 732}
@@ -751,21 +751,22 @@ void tipc_nametbl_unsubscribe(struct tipc_subscription *s)
751 751
752 752
753/** 753/**
754 * subseq_list: print specified sub-sequence contents into the given buffer 754 * subseq_list - print specified sub-sequence contents into the given buffer
755 */ 755 */
756static void subseq_list(struct sub_seq *sseq, struct print_buf *buf, u32 depth, 756static int subseq_list(struct sub_seq *sseq, char *buf, int len, u32 depth,
757 u32 index) 757 u32 index)
758{ 758{
759 char portIdStr[27]; 759 char portIdStr[27];
760 const char *scope_str[] = {"", " zone", " cluster", " node"}; 760 const char *scope_str[] = {"", " zone", " cluster", " node"};
761 struct publication *publ; 761 struct publication *publ;
762 struct name_info *info; 762 struct name_info *info;
763 int ret;
763 764
764 tipc_printf(buf, "%-10u %-10u ", sseq->lower, sseq->upper); 765 ret = tipc_snprintf(buf, len, "%-10u %-10u ", sseq->lower, sseq->upper);
765 766
766 if (depth == 2) { 767 if (depth == 2) {
767 tipc_printf(buf, "\n"); 768 ret += tipc_snprintf(buf - ret, len + ret, "\n");
768 return; 769 return ret;
769 } 770 }
770 771
771 info = sseq->info; 772 info = sseq->info;
@@ -774,52 +775,58 @@ static void subseq_list(struct sub_seq *sseq, struct print_buf *buf, u32 depth,
774 sprintf(portIdStr, "<%u.%u.%u:%u>", 775 sprintf(portIdStr, "<%u.%u.%u:%u>",
775 tipc_zone(publ->node), tipc_cluster(publ->node), 776 tipc_zone(publ->node), tipc_cluster(publ->node),
776 tipc_node(publ->node), publ->ref); 777 tipc_node(publ->node), publ->ref);
777 tipc_printf(buf, "%-26s ", portIdStr); 778 ret += tipc_snprintf(buf + ret, len - ret, "%-26s ", portIdStr);
778 if (depth > 3) { 779 if (depth > 3) {
779 tipc_printf(buf, "%-10u %s", publ->key, 780 ret += tipc_snprintf(buf + ret, len - ret, "%-10u %s",
780 scope_str[publ->scope]); 781 publ->key, scope_str[publ->scope]);
781 } 782 }
782 if (!list_is_last(&publ->zone_list, &info->zone_list)) 783 if (!list_is_last(&publ->zone_list, &info->zone_list))
783 tipc_printf(buf, "\n%33s", " "); 784 ret += tipc_snprintf(buf + ret, len - ret,
785 "\n%33s", " ");
784 }; 786 };
785 787
786 tipc_printf(buf, "\n"); 788 ret += tipc_snprintf(buf + ret, len - ret, "\n");
789 return ret;
787} 790}
788 791
789/** 792/**
790 * nameseq_list: print specified name sequence contents into the given buffer 793 * nameseq_list - print specified name sequence contents into the given buffer
791 */ 794 */
792static void nameseq_list(struct name_seq *seq, struct print_buf *buf, u32 depth, 795static int nameseq_list(struct name_seq *seq, char *buf, int len, u32 depth,
793 u32 type, u32 lowbound, u32 upbound, u32 index) 796 u32 type, u32 lowbound, u32 upbound, u32 index)
794{ 797{
795 struct sub_seq *sseq; 798 struct sub_seq *sseq;
796 char typearea[11]; 799 char typearea[11];
800 int ret = 0;
797 801
798 if (seq->first_free == 0) 802 if (seq->first_free == 0)
799 return; 803 return 0;
800 804
801 sprintf(typearea, "%-10u", seq->type); 805 sprintf(typearea, "%-10u", seq->type);
802 806
803 if (depth == 1) { 807 if (depth == 1) {
804 tipc_printf(buf, "%s\n", typearea); 808 ret += tipc_snprintf(buf, len, "%s\n", typearea);
805 return; 809 return ret;
806 } 810 }
807 811
808 for (sseq = seq->sseqs; sseq != &seq->sseqs[seq->first_free]; sseq++) { 812 for (sseq = seq->sseqs; sseq != &seq->sseqs[seq->first_free]; sseq++) {
809 if ((lowbound <= sseq->upper) && (upbound >= sseq->lower)) { 813 if ((lowbound <= sseq->upper) && (upbound >= sseq->lower)) {
810 tipc_printf(buf, "%s ", typearea); 814 ret += tipc_snprintf(buf + ret, len - ret, "%s ",
815 typearea);
811 spin_lock_bh(&seq->lock); 816 spin_lock_bh(&seq->lock);
812 subseq_list(sseq, buf, depth, index); 817 ret += subseq_list(sseq, buf + ret, len - ret,
818 depth, index);
813 spin_unlock_bh(&seq->lock); 819 spin_unlock_bh(&seq->lock);
814 sprintf(typearea, "%10s", " "); 820 sprintf(typearea, "%10s", " ");
815 } 821 }
816 } 822 }
823 return ret;
817} 824}
818 825
819/** 826/**
820 * nametbl_header - print name table header into the given buffer 827 * nametbl_header - print name table header into the given buffer
821 */ 828 */
822static void nametbl_header(struct print_buf *buf, u32 depth) 829static int nametbl_header(char *buf, int len, u32 depth)
823{ 830{
824 const char *header[] = { 831 const char *header[] = {
825 "Type ", 832 "Type ",
@@ -829,24 +836,27 @@ static void nametbl_header(struct print_buf *buf, u32 depth)
829 }; 836 };
830 837
831 int i; 838 int i;
839 int ret = 0;
832 840
833 if (depth > 4) 841 if (depth > 4)
834 depth = 4; 842 depth = 4;
835 for (i = 0; i < depth; i++) 843 for (i = 0; i < depth; i++)
836 tipc_printf(buf, header[i]); 844 ret += tipc_snprintf(buf + ret, len - ret, header[i]);
837 tipc_printf(buf, "\n"); 845 ret += tipc_snprintf(buf + ret, len - ret, "\n");
846 return ret;
838} 847}
839 848
840/** 849/**
841 * nametbl_list - print specified name table contents into the given buffer 850 * nametbl_list - print specified name table contents into the given buffer
842 */ 851 */
843static void nametbl_list(struct print_buf *buf, u32 depth_info, 852static int nametbl_list(char *buf, int len, u32 depth_info,
844 u32 type, u32 lowbound, u32 upbound) 853 u32 type, u32 lowbound, u32 upbound)
845{ 854{
846 struct hlist_head *seq_head; 855 struct hlist_head *seq_head;
847 struct hlist_node *seq_node; 856 struct hlist_node *seq_node;
848 struct name_seq *seq; 857 struct name_seq *seq;
849 int all_types; 858 int all_types;
859 int ret = 0;
850 u32 depth; 860 u32 depth;
851 u32 i; 861 u32 i;
852 862
@@ -854,65 +864,69 @@ static void nametbl_list(struct print_buf *buf, u32 depth_info,
854 depth = (depth_info & ~TIPC_NTQ_ALLTYPES); 864 depth = (depth_info & ~TIPC_NTQ_ALLTYPES);
855 865
856 if (depth == 0) 866 if (depth == 0)
857 return; 867 return 0;
858 868
859 if (all_types) { 869 if (all_types) {
860 /* display all entries in name table to specified depth */ 870 /* display all entries in name table to specified depth */
861 nametbl_header(buf, depth); 871 ret += nametbl_header(buf, len, depth);
862 lowbound = 0; 872 lowbound = 0;
863 upbound = ~0; 873 upbound = ~0;
864 for (i = 0; i < tipc_nametbl_size; i++) { 874 for (i = 0; i < tipc_nametbl_size; i++) {
865 seq_head = &table.types[i]; 875 seq_head = &table.types[i];
866 hlist_for_each_entry(seq, seq_node, seq_head, ns_list) { 876 hlist_for_each_entry(seq, seq_node, seq_head, ns_list) {
867 nameseq_list(seq, buf, depth, seq->type, 877 ret += nameseq_list(seq, buf + ret, len - ret,
868 lowbound, upbound, i); 878 depth, seq->type,
879 lowbound, upbound, i);
869 } 880 }
870 } 881 }
871 } else { 882 } else {
872 /* display only the sequence that matches the specified type */ 883 /* display only the sequence that matches the specified type */
873 if (upbound < lowbound) { 884 if (upbound < lowbound) {
874 tipc_printf(buf, "invalid name sequence specified\n"); 885 ret += tipc_snprintf(buf + ret, len - ret,
875 return; 886 "invalid name sequence specified\n");
887 return ret;
876 } 888 }
877 nametbl_header(buf, depth); 889 ret += nametbl_header(buf + ret, len - ret, depth);
878 i = hash(type); 890 i = hash(type);
879 seq_head = &table.types[i]; 891 seq_head = &table.types[i];
880 hlist_for_each_entry(seq, seq_node, seq_head, ns_list) { 892 hlist_for_each_entry(seq, seq_node, seq_head, ns_list) {
881 if (seq->type == type) { 893 if (seq->type == type) {
882 nameseq_list(seq, buf, depth, type, 894 ret += nameseq_list(seq, buf + ret, len - ret,
883 lowbound, upbound, i); 895 depth, type,
896 lowbound, upbound, i);
884 break; 897 break;
885 } 898 }
886 } 899 }
887 } 900 }
901 return ret;
888} 902}
889 903
890#define MAX_NAME_TBL_QUERY 32768
891
892struct sk_buff *tipc_nametbl_get(const void *req_tlv_area, int req_tlv_space) 904struct sk_buff *tipc_nametbl_get(const void *req_tlv_area, int req_tlv_space)
893{ 905{
894 struct sk_buff *buf; 906 struct sk_buff *buf;
895 struct tipc_name_table_query *argv; 907 struct tipc_name_table_query *argv;
896 struct tlv_desc *rep_tlv; 908 struct tlv_desc *rep_tlv;
897 struct print_buf b; 909 char *pb;
910 int pb_len;
898 int str_len; 911 int str_len;
899 912
900 if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_NAME_TBL_QUERY)) 913 if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_NAME_TBL_QUERY))
901 return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR); 914 return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR);
902 915
903 buf = tipc_cfg_reply_alloc(TLV_SPACE(MAX_NAME_TBL_QUERY)); 916 buf = tipc_cfg_reply_alloc(TLV_SPACE(ULTRA_STRING_MAX_LEN));
904 if (!buf) 917 if (!buf)
905 return NULL; 918 return NULL;
906 919
907 rep_tlv = (struct tlv_desc *)buf->data; 920 rep_tlv = (struct tlv_desc *)buf->data;
908 tipc_printbuf_init(&b, TLV_DATA(rep_tlv), MAX_NAME_TBL_QUERY); 921 pb = TLV_DATA(rep_tlv);
922 pb_len = ULTRA_STRING_MAX_LEN;
909 argv = (struct tipc_name_table_query *)TLV_DATA(req_tlv_area); 923 argv = (struct tipc_name_table_query *)TLV_DATA(req_tlv_area);
910 read_lock_bh(&tipc_nametbl_lock); 924 read_lock_bh(&tipc_nametbl_lock);
911 nametbl_list(&b, ntohl(argv->depth), ntohl(argv->type), 925 str_len = nametbl_list(pb, pb_len, ntohl(argv->depth),
912 ntohl(argv->lowbound), ntohl(argv->upbound)); 926 ntohl(argv->type),
927 ntohl(argv->lowbound), ntohl(argv->upbound));
913 read_unlock_bh(&tipc_nametbl_lock); 928 read_unlock_bh(&tipc_nametbl_lock);
914 str_len = tipc_printbuf_validate(&b); 929 str_len += 1; /* for "\0" */
915
916 skb_put(buf, TLV_SPACE(str_len)); 930 skb_put(buf, TLV_SPACE(str_len));
917 TLV_SET(rep_tlv, TIPC_TLV_ULTRA_STRING, NULL, str_len); 931 TLV_SET(rep_tlv, TIPC_TLV_ULTRA_STRING, NULL, str_len);
918 932
@@ -940,8 +954,10 @@ void tipc_nametbl_stop(void)
940 /* Verify name table is empty, then release it */ 954 /* Verify name table is empty, then release it */
941 write_lock_bh(&tipc_nametbl_lock); 955 write_lock_bh(&tipc_nametbl_lock);
942 for (i = 0; i < tipc_nametbl_size; i++) { 956 for (i = 0; i < tipc_nametbl_size; i++) {
943 if (!hlist_empty(&table.types[i])) 957 if (hlist_empty(&table.types[i]))
944 err("tipc_nametbl_stop(): hash chain %u is non-null\n", i); 958 continue;
959 pr_err("nametbl_stop(): orphaned hash chain detected\n");
960 break;
945 } 961 }
946 kfree(table.types); 962 kfree(table.types);
947 table.types = NULL; 963 table.types = NULL;
diff --git a/net/tipc/net.c b/net/tipc/net.c
index 7c236c89cf5e..5b5cea259caf 100644
--- a/net/tipc/net.c
+++ b/net/tipc/net.c
@@ -184,9 +184,9 @@ int tipc_net_start(u32 addr)
184 184
185 tipc_cfg_reinit(); 185 tipc_cfg_reinit();
186 186
187 info("Started in network mode\n"); 187 pr_info("Started in network mode\n");
188 info("Own node address %s, network identity %u\n", 188 pr_info("Own node address %s, network identity %u\n",
189 tipc_addr_string_fill(addr_string, tipc_own_addr), tipc_net_id); 189 tipc_addr_string_fill(addr_string, tipc_own_addr), tipc_net_id);
190 return 0; 190 return 0;
191} 191}
192 192
@@ -202,5 +202,5 @@ void tipc_net_stop(void)
202 list_for_each_entry_safe(node, t_node, &tipc_node_list, list) 202 list_for_each_entry_safe(node, t_node, &tipc_node_list, list)
203 tipc_node_delete(node); 203 tipc_node_delete(node);
204 write_unlock_bh(&tipc_net_lock); 204 write_unlock_bh(&tipc_net_lock);
205 info("Left network mode\n"); 205 pr_info("Left network mode\n");
206} 206}
diff --git a/net/tipc/netlink.c b/net/tipc/netlink.c
index 7bda8e3d1398..47a839df27dc 100644
--- a/net/tipc/netlink.c
+++ b/net/tipc/netlink.c
@@ -90,7 +90,7 @@ int tipc_netlink_start(void)
90 res = genl_register_family_with_ops(&tipc_genl_family, 90 res = genl_register_family_with_ops(&tipc_genl_family,
91 &tipc_genl_ops, 1); 91 &tipc_genl_ops, 1);
92 if (res) { 92 if (res) {
93 err("Failed to register netlink interface\n"); 93 pr_err("Failed to register netlink interface\n");
94 return res; 94 return res;
95 } 95 }
96 96
diff --git a/net/tipc/node.c b/net/tipc/node.c
index d4fd341e6e0d..d21db204e25a 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -105,7 +105,7 @@ struct tipc_node *tipc_node_create(u32 addr)
105 n_ptr = kzalloc(sizeof(*n_ptr), GFP_ATOMIC); 105 n_ptr = kzalloc(sizeof(*n_ptr), GFP_ATOMIC);
106 if (!n_ptr) { 106 if (!n_ptr) {
107 spin_unlock_bh(&node_create_lock); 107 spin_unlock_bh(&node_create_lock);
108 warn("Node creation failed, no memory\n"); 108 pr_warn("Node creation failed, no memory\n");
109 return NULL; 109 return NULL;
110 } 110 }
111 111
@@ -151,8 +151,8 @@ void tipc_node_link_up(struct tipc_node *n_ptr, struct tipc_link *l_ptr)
151 151
152 n_ptr->working_links++; 152 n_ptr->working_links++;
153 153
154 info("Established link <%s> on network plane %c\n", 154 pr_info("Established link <%s> on network plane %c\n",
155 l_ptr->name, l_ptr->b_ptr->net_plane); 155 l_ptr->name, l_ptr->b_ptr->net_plane);
156 156
157 if (!active[0]) { 157 if (!active[0]) {
158 active[0] = active[1] = l_ptr; 158 active[0] = active[1] = l_ptr;
@@ -160,7 +160,7 @@ void tipc_node_link_up(struct tipc_node *n_ptr, struct tipc_link *l_ptr)
160 return; 160 return;
161 } 161 }
162 if (l_ptr->priority < active[0]->priority) { 162 if (l_ptr->priority < active[0]->priority) {
163 info("New link <%s> becomes standby\n", l_ptr->name); 163 pr_info("New link <%s> becomes standby\n", l_ptr->name);
164 return; 164 return;
165 } 165 }
166 tipc_link_send_duplicate(active[0], l_ptr); 166 tipc_link_send_duplicate(active[0], l_ptr);
@@ -168,9 +168,9 @@ void tipc_node_link_up(struct tipc_node *n_ptr, struct tipc_link *l_ptr)
168 active[0] = l_ptr; 168 active[0] = l_ptr;
169 return; 169 return;
170 } 170 }
171 info("Old link <%s> becomes standby\n", active[0]->name); 171 pr_info("Old link <%s> becomes standby\n", active[0]->name);
172 if (active[1] != active[0]) 172 if (active[1] != active[0])
173 info("Old link <%s> becomes standby\n", active[1]->name); 173 pr_info("Old link <%s> becomes standby\n", active[1]->name);
174 active[0] = active[1] = l_ptr; 174 active[0] = active[1] = l_ptr;
175} 175}
176 176
@@ -211,11 +211,11 @@ void tipc_node_link_down(struct tipc_node *n_ptr, struct tipc_link *l_ptr)
211 n_ptr->working_links--; 211 n_ptr->working_links--;
212 212
213 if (!tipc_link_is_active(l_ptr)) { 213 if (!tipc_link_is_active(l_ptr)) {
214 info("Lost standby link <%s> on network plane %c\n", 214 pr_info("Lost standby link <%s> on network plane %c\n",
215 l_ptr->name, l_ptr->b_ptr->net_plane); 215 l_ptr->name, l_ptr->b_ptr->net_plane);
216 return; 216 return;
217 } 217 }
218 info("Lost link <%s> on network plane %c\n", 218 pr_info("Lost link <%s> on network plane %c\n",
219 l_ptr->name, l_ptr->b_ptr->net_plane); 219 l_ptr->name, l_ptr->b_ptr->net_plane);
220 220
221 active = &n_ptr->active_links[0]; 221 active = &n_ptr->active_links[0];
@@ -290,8 +290,8 @@ static void node_lost_contact(struct tipc_node *n_ptr)
290 char addr_string[16]; 290 char addr_string[16];
291 u32 i; 291 u32 i;
292 292
293 info("Lost contact with %s\n", 293 pr_info("Lost contact with %s\n",
294 tipc_addr_string_fill(addr_string, n_ptr->addr)); 294 tipc_addr_string_fill(addr_string, n_ptr->addr));
295 295
296 /* Flush broadcast link info associated with lost node */ 296 /* Flush broadcast link info associated with lost node */
297 if (n_ptr->bclink.supported) { 297 if (n_ptr->bclink.supported) {
diff --git a/net/tipc/node_subscr.c b/net/tipc/node_subscr.c
index 7a27344108fe..5e34b015da45 100644
--- a/net/tipc/node_subscr.c
+++ b/net/tipc/node_subscr.c
@@ -51,7 +51,8 @@ void tipc_nodesub_subscribe(struct tipc_node_subscr *node_sub, u32 addr,
51 51
52 node_sub->node = tipc_node_find(addr); 52 node_sub->node = tipc_node_find(addr);
53 if (!node_sub->node) { 53 if (!node_sub->node) {
54 warn("Node subscription rejected, unknown node 0x%x\n", addr); 54 pr_warn("Node subscription rejected, unknown node 0x%x\n",
55 addr);
55 return; 56 return;
56 } 57 }
57 node_sub->handle_node_down = handle_down; 58 node_sub->handle_node_down = handle_down;
diff --git a/net/tipc/port.c b/net/tipc/port.c
index 2ad37a4db376..07c42fba672b 100644
--- a/net/tipc/port.c
+++ b/net/tipc/port.c
@@ -69,7 +69,7 @@ static u32 port_peerport(struct tipc_port *p_ptr)
69 return msg_destport(&p_ptr->phdr); 69 return msg_destport(&p_ptr->phdr);
70} 70}
71 71
72/* 72/**
73 * tipc_port_peer_msg - verify message was sent by connected port's peer 73 * tipc_port_peer_msg - verify message was sent by connected port's peer
74 * 74 *
75 * Handles cases where the node's network address has changed from 75 * Handles cases where the node's network address has changed from
@@ -191,7 +191,7 @@ void tipc_port_recv_mcast(struct sk_buff *buf, struct tipc_port_list *dp)
191 struct sk_buff *b = skb_clone(buf, GFP_ATOMIC); 191 struct sk_buff *b = skb_clone(buf, GFP_ATOMIC);
192 192
193 if (b == NULL) { 193 if (b == NULL) {
194 warn("Unable to deliver multicast message(s)\n"); 194 pr_warn("Unable to deliver multicast message(s)\n");
195 goto exit; 195 goto exit;
196 } 196 }
197 if ((index == 0) && (cnt != 0)) 197 if ((index == 0) && (cnt != 0))
@@ -221,12 +221,12 @@ struct tipc_port *tipc_createport_raw(void *usr_handle,
221 221
222 p_ptr = kzalloc(sizeof(*p_ptr), GFP_ATOMIC); 222 p_ptr = kzalloc(sizeof(*p_ptr), GFP_ATOMIC);
223 if (!p_ptr) { 223 if (!p_ptr) {
224 warn("Port creation failed, no memory\n"); 224 pr_warn("Port creation failed, no memory\n");
225 return NULL; 225 return NULL;
226 } 226 }
227 ref = tipc_ref_acquire(p_ptr, &p_ptr->lock); 227 ref = tipc_ref_acquire(p_ptr, &p_ptr->lock);
228 if (!ref) { 228 if (!ref) {
229 warn("Port creation failed, reference table exhausted\n"); 229 pr_warn("Port creation failed, ref. table exhausted\n");
230 kfree(p_ptr); 230 kfree(p_ptr);
231 return NULL; 231 return NULL;
232 } 232 }
@@ -581,67 +581,73 @@ exit:
581 kfree_skb(buf); 581 kfree_skb(buf);
582} 582}
583 583
584static void port_print(struct tipc_port *p_ptr, struct print_buf *buf, int full_id) 584static int port_print(struct tipc_port *p_ptr, char *buf, int len, int full_id)
585{ 585{
586 struct publication *publ; 586 struct publication *publ;
587 int ret;
587 588
588 if (full_id) 589 if (full_id)
589 tipc_printf(buf, "<%u.%u.%u:%u>:", 590 ret = tipc_snprintf(buf, len, "<%u.%u.%u:%u>:",
590 tipc_zone(tipc_own_addr), tipc_cluster(tipc_own_addr), 591 tipc_zone(tipc_own_addr),
591 tipc_node(tipc_own_addr), p_ptr->ref); 592 tipc_cluster(tipc_own_addr),
593 tipc_node(tipc_own_addr), p_ptr->ref);
592 else 594 else
593 tipc_printf(buf, "%-10u:", p_ptr->ref); 595 ret = tipc_snprintf(buf, len, "%-10u:", p_ptr->ref);
594 596
595 if (p_ptr->connected) { 597 if (p_ptr->connected) {
596 u32 dport = port_peerport(p_ptr); 598 u32 dport = port_peerport(p_ptr);
597 u32 destnode = port_peernode(p_ptr); 599 u32 destnode = port_peernode(p_ptr);
598 600
599 tipc_printf(buf, " connected to <%u.%u.%u:%u>", 601 ret += tipc_snprintf(buf + ret, len - ret,
600 tipc_zone(destnode), tipc_cluster(destnode), 602 " connected to <%u.%u.%u:%u>",
601 tipc_node(destnode), dport); 603 tipc_zone(destnode),
604 tipc_cluster(destnode),
605 tipc_node(destnode), dport);
602 if (p_ptr->conn_type != 0) 606 if (p_ptr->conn_type != 0)
603 tipc_printf(buf, " via {%u,%u}", 607 ret += tipc_snprintf(buf + ret, len - ret,
604 p_ptr->conn_type, 608 " via {%u,%u}", p_ptr->conn_type,
605 p_ptr->conn_instance); 609 p_ptr->conn_instance);
606 } else if (p_ptr->published) { 610 } else if (p_ptr->published) {
607 tipc_printf(buf, " bound to"); 611 ret += tipc_snprintf(buf + ret, len - ret, " bound to");
608 list_for_each_entry(publ, &p_ptr->publications, pport_list) { 612 list_for_each_entry(publ, &p_ptr->publications, pport_list) {
609 if (publ->lower == publ->upper) 613 if (publ->lower == publ->upper)
610 tipc_printf(buf, " {%u,%u}", publ->type, 614 ret += tipc_snprintf(buf + ret, len - ret,
611 publ->lower); 615 " {%u,%u}", publ->type,
616 publ->lower);
612 else 617 else
613 tipc_printf(buf, " {%u,%u,%u}", publ->type, 618 ret += tipc_snprintf(buf + ret, len - ret,
614 publ->lower, publ->upper); 619 " {%u,%u,%u}", publ->type,
620 publ->lower, publ->upper);
615 } 621 }
616 } 622 }
617 tipc_printf(buf, "\n"); 623 ret += tipc_snprintf(buf + ret, len - ret, "\n");
624 return ret;
618} 625}
619 626
620#define MAX_PORT_QUERY 32768
621
622struct sk_buff *tipc_port_get_ports(void) 627struct sk_buff *tipc_port_get_ports(void)
623{ 628{
624 struct sk_buff *buf; 629 struct sk_buff *buf;
625 struct tlv_desc *rep_tlv; 630 struct tlv_desc *rep_tlv;
626 struct print_buf pb; 631 char *pb;
632 int pb_len;
627 struct tipc_port *p_ptr; 633 struct tipc_port *p_ptr;
628 int str_len; 634 int str_len = 0;
629 635
630 buf = tipc_cfg_reply_alloc(TLV_SPACE(MAX_PORT_QUERY)); 636 buf = tipc_cfg_reply_alloc(TLV_SPACE(ULTRA_STRING_MAX_LEN));
631 if (!buf) 637 if (!buf)
632 return NULL; 638 return NULL;
633 rep_tlv = (struct tlv_desc *)buf->data; 639 rep_tlv = (struct tlv_desc *)buf->data;
640 pb = TLV_DATA(rep_tlv);
641 pb_len = ULTRA_STRING_MAX_LEN;
634 642
635 tipc_printbuf_init(&pb, TLV_DATA(rep_tlv), MAX_PORT_QUERY);
636 spin_lock_bh(&tipc_port_list_lock); 643 spin_lock_bh(&tipc_port_list_lock);
637 list_for_each_entry(p_ptr, &ports, port_list) { 644 list_for_each_entry(p_ptr, &ports, port_list) {
638 spin_lock_bh(p_ptr->lock); 645 spin_lock_bh(p_ptr->lock);
639 port_print(p_ptr, &pb, 0); 646 str_len += port_print(p_ptr, pb, pb_len, 0);
640 spin_unlock_bh(p_ptr->lock); 647 spin_unlock_bh(p_ptr->lock);
641 } 648 }
642 spin_unlock_bh(&tipc_port_list_lock); 649 spin_unlock_bh(&tipc_port_list_lock);
643 str_len = tipc_printbuf_validate(&pb); 650 str_len += 1; /* for "\0" */
644
645 skb_put(buf, TLV_SPACE(str_len)); 651 skb_put(buf, TLV_SPACE(str_len));
646 TLV_SET(rep_tlv, TIPC_TLV_ULTRA_STRING, NULL, str_len); 652 TLV_SET(rep_tlv, TIPC_TLV_ULTRA_STRING, NULL, str_len);
647 653
@@ -906,11 +912,11 @@ int tipc_createport(void *usr_handle,
906 912
907 up_ptr = kmalloc(sizeof(*up_ptr), GFP_ATOMIC); 913 up_ptr = kmalloc(sizeof(*up_ptr), GFP_ATOMIC);
908 if (!up_ptr) { 914 if (!up_ptr) {
909 warn("Port creation failed, no memory\n"); 915 pr_warn("Port creation failed, no memory\n");
910 return -ENOMEM; 916 return -ENOMEM;
911 } 917 }
912 p_ptr = (struct tipc_port *)tipc_createport_raw(NULL, port_dispatcher, 918 p_ptr = tipc_createport_raw(NULL, port_dispatcher, port_wakeup,
913 port_wakeup, importance); 919 importance);
914 if (!p_ptr) { 920 if (!p_ptr) {
915 kfree(up_ptr); 921 kfree(up_ptr);
916 return -ENOMEM; 922 return -ENOMEM;
@@ -1078,8 +1084,7 @@ int tipc_disconnect_port(struct tipc_port *tp_ptr)
1078 if (tp_ptr->connected) { 1084 if (tp_ptr->connected) {
1079 tp_ptr->connected = 0; 1085 tp_ptr->connected = 0;
1080 /* let timer expire on it's own to avoid deadlock! */ 1086 /* let timer expire on it's own to avoid deadlock! */
1081 tipc_nodesub_unsubscribe( 1087 tipc_nodesub_unsubscribe(&tp_ptr->subscription);
1082 &((struct tipc_port *)tp_ptr)->subscription);
1083 res = 0; 1088 res = 0;
1084 } else { 1089 } else {
1085 res = -ENOTCONN; 1090 res = -ENOTCONN;
@@ -1099,7 +1104,7 @@ int tipc_disconnect(u32 ref)
1099 p_ptr = tipc_port_lock(ref); 1104 p_ptr = tipc_port_lock(ref);
1100 if (!p_ptr) 1105 if (!p_ptr)
1101 return -EINVAL; 1106 return -EINVAL;
1102 res = tipc_disconnect_port((struct tipc_port *)p_ptr); 1107 res = tipc_disconnect_port(p_ptr);
1103 tipc_port_unlock(p_ptr); 1108 tipc_port_unlock(p_ptr);
1104 return res; 1109 return res;
1105} 1110}
diff --git a/net/tipc/port.h b/net/tipc/port.h
index 98cbec9c4532..4660e3065790 100644
--- a/net/tipc/port.h
+++ b/net/tipc/port.h
@@ -79,6 +79,7 @@ typedef void (*tipc_continue_event) (void *usr_handle, u32 portref);
79 * struct user_port - TIPC user port (used with native API) 79 * struct user_port - TIPC user port (used with native API)
80 * @usr_handle: user-specified field 80 * @usr_handle: user-specified field
81 * @ref: object reference to associated TIPC port 81 * @ref: object reference to associated TIPC port
82 *
82 * <various callback routines> 83 * <various callback routines>
83 */ 84 */
84struct user_port { 85struct user_port {
diff --git a/net/tipc/ref.c b/net/tipc/ref.c
index 5cada0e38e03..2a2a938dc22c 100644
--- a/net/tipc/ref.c
+++ b/net/tipc/ref.c
@@ -153,11 +153,11 @@ u32 tipc_ref_acquire(void *object, spinlock_t **lock)
153 struct reference *entry = NULL; 153 struct reference *entry = NULL;
154 154
155 if (!object) { 155 if (!object) {
156 err("Attempt to acquire reference to non-existent object\n"); 156 pr_err("Attempt to acquire ref. to non-existent obj\n");
157 return 0; 157 return 0;
158 } 158 }
159 if (!tipc_ref_table.entries) { 159 if (!tipc_ref_table.entries) {
160 err("Reference table not found during acquisition attempt\n"); 160 pr_err("Ref. table not found in acquisition attempt\n");
161 return 0; 161 return 0;
162 } 162 }
163 163
@@ -211,7 +211,7 @@ void tipc_ref_discard(u32 ref)
211 u32 index_mask; 211 u32 index_mask;
212 212
213 if (!tipc_ref_table.entries) { 213 if (!tipc_ref_table.entries) {
214 err("Reference table not found during discard attempt\n"); 214 pr_err("Ref. table not found during discard attempt\n");
215 return; 215 return;
216 } 216 }
217 217
@@ -222,11 +222,11 @@ void tipc_ref_discard(u32 ref)
222 write_lock_bh(&ref_table_lock); 222 write_lock_bh(&ref_table_lock);
223 223
224 if (!entry->object) { 224 if (!entry->object) {
225 err("Attempt to discard reference to non-existent object\n"); 225 pr_err("Attempt to discard ref. to non-existent obj\n");
226 goto exit; 226 goto exit;
227 } 227 }
228 if (entry->ref != ref) { 228 if (entry->ref != ref) {
229 err("Attempt to discard non-existent reference\n"); 229 pr_err("Attempt to discard non-existent reference\n");
230 goto exit; 230 goto exit;
231 } 231 }
232 232
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index 5577a447f531..09dc5b97e079 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -34,12 +34,12 @@
34 * POSSIBILITY OF SUCH DAMAGE. 34 * POSSIBILITY OF SUCH DAMAGE.
35 */ 35 */
36 36
37#include <linux/export.h>
38#include <net/sock.h>
39
40#include "core.h" 37#include "core.h"
41#include "port.h" 38#include "port.h"
42 39
40#include <linux/export.h>
41#include <net/sock.h>
42
43#define SS_LISTENING -1 /* socket is listening */ 43#define SS_LISTENING -1 /* socket is listening */
44#define SS_READY -2 /* socket is connectionless */ 44#define SS_READY -2 /* socket is connectionless */
45 45
@@ -54,7 +54,7 @@ struct tipc_sock {
54}; 54};
55 55
56#define tipc_sk(sk) ((struct tipc_sock *)(sk)) 56#define tipc_sk(sk) ((struct tipc_sock *)(sk))
57#define tipc_sk_port(sk) ((struct tipc_port *)(tipc_sk(sk)->p)) 57#define tipc_sk_port(sk) (tipc_sk(sk)->p)
58 58
59#define tipc_rx_ready(sock) (!skb_queue_empty(&sock->sk->sk_receive_queue) || \ 59#define tipc_rx_ready(sock) (!skb_queue_empty(&sock->sk->sk_receive_queue) || \
60 (sock->state == SS_DISCONNECTING)) 60 (sock->state == SS_DISCONNECTING))
@@ -1699,9 +1699,8 @@ static int getsockopt(struct socket *sock,
1699 return put_user(sizeof(value), ol); 1699 return put_user(sizeof(value), ol);
1700} 1700}
1701 1701
1702/** 1702/* Protocol switches for the various types of TIPC sockets */
1703 * Protocol switches for the various types of TIPC sockets 1703
1704 */
1705static const struct proto_ops msg_ops = { 1704static const struct proto_ops msg_ops = {
1706 .owner = THIS_MODULE, 1705 .owner = THIS_MODULE,
1707 .family = AF_TIPC, 1706 .family = AF_TIPC,
@@ -1788,13 +1787,13 @@ int tipc_socket_init(void)
1788 1787
1789 res = proto_register(&tipc_proto, 1); 1788 res = proto_register(&tipc_proto, 1);
1790 if (res) { 1789 if (res) {
1791 err("Failed to register TIPC protocol type\n"); 1790 pr_err("Failed to register TIPC protocol type\n");
1792 goto out; 1791 goto out;
1793 } 1792 }
1794 1793
1795 res = sock_register(&tipc_family_ops); 1794 res = sock_register(&tipc_family_ops);
1796 if (res) { 1795 if (res) {
1797 err("Failed to register TIPC socket type\n"); 1796 pr_err("Failed to register TIPC socket type\n");
1798 proto_unregister(&tipc_proto); 1797 proto_unregister(&tipc_proto);
1799 goto out; 1798 goto out;
1800 } 1799 }
diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
index f976e9cd6a72..5ed5965eb0be 100644
--- a/net/tipc/subscr.c
+++ b/net/tipc/subscr.c
@@ -305,8 +305,8 @@ static struct tipc_subscription *subscr_subscribe(struct tipc_subscr *s,
305 305
306 /* Refuse subscription if global limit exceeded */ 306 /* Refuse subscription if global limit exceeded */
307 if (atomic_read(&topsrv.subscription_count) >= tipc_max_subscriptions) { 307 if (atomic_read(&topsrv.subscription_count) >= tipc_max_subscriptions) {
308 warn("Subscription rejected, subscription limit reached (%u)\n", 308 pr_warn("Subscription rejected, limit reached (%u)\n",
309 tipc_max_subscriptions); 309 tipc_max_subscriptions);
310 subscr_terminate(subscriber); 310 subscr_terminate(subscriber);
311 return NULL; 311 return NULL;
312 } 312 }
@@ -314,7 +314,7 @@ static struct tipc_subscription *subscr_subscribe(struct tipc_subscr *s,
314 /* Allocate subscription object */ 314 /* Allocate subscription object */
315 sub = kmalloc(sizeof(*sub), GFP_ATOMIC); 315 sub = kmalloc(sizeof(*sub), GFP_ATOMIC);
316 if (!sub) { 316 if (!sub) {
317 warn("Subscription rejected, no memory\n"); 317 pr_warn("Subscription rejected, no memory\n");
318 subscr_terminate(subscriber); 318 subscr_terminate(subscriber);
319 return NULL; 319 return NULL;
320 } 320 }
@@ -328,7 +328,7 @@ static struct tipc_subscription *subscr_subscribe(struct tipc_subscr *s,
328 if ((!(sub->filter & TIPC_SUB_PORTS) == 328 if ((!(sub->filter & TIPC_SUB_PORTS) ==
329 !(sub->filter & TIPC_SUB_SERVICE)) || 329 !(sub->filter & TIPC_SUB_SERVICE)) ||
330 (sub->seq.lower > sub->seq.upper)) { 330 (sub->seq.lower > sub->seq.upper)) {
331 warn("Subscription rejected, illegal request\n"); 331 pr_warn("Subscription rejected, illegal request\n");
332 kfree(sub); 332 kfree(sub);
333 subscr_terminate(subscriber); 333 subscr_terminate(subscriber);
334 return NULL; 334 return NULL;
@@ -440,7 +440,7 @@ static void subscr_named_msg_event(void *usr_handle,
440 /* Create subscriber object */ 440 /* Create subscriber object */
441 subscriber = kzalloc(sizeof(struct tipc_subscriber), GFP_ATOMIC); 441 subscriber = kzalloc(sizeof(struct tipc_subscriber), GFP_ATOMIC);
442 if (subscriber == NULL) { 442 if (subscriber == NULL) {
443 warn("Subscriber rejected, no memory\n"); 443 pr_warn("Subscriber rejected, no memory\n");
444 return; 444 return;
445 } 445 }
446 INIT_LIST_HEAD(&subscriber->subscription_list); 446 INIT_LIST_HEAD(&subscriber->subscription_list);
@@ -458,7 +458,7 @@ static void subscr_named_msg_event(void *usr_handle,
458 NULL, 458 NULL,
459 &subscriber->port_ref); 459 &subscriber->port_ref);
460 if (subscriber->port_ref == 0) { 460 if (subscriber->port_ref == 0) {
461 warn("Subscriber rejected, unable to create port\n"); 461 pr_warn("Subscriber rejected, unable to create port\n");
462 kfree(subscriber); 462 kfree(subscriber);
463 return; 463 return;
464 } 464 }
@@ -517,7 +517,7 @@ int tipc_subscr_start(void)
517 return 0; 517 return 0;
518 518
519failed: 519failed:
520 err("Failed to create subscription service\n"); 520 pr_err("Failed to create subscription service\n");
521 return res; 521 return res;
522} 522}
523 523