aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/bcast.c
diff options
context:
space:
mode:
authorErik Hugne <erik.hugne@ericsson.com>2012-06-29 00:50:23 -0400
committerPaul Gortmaker <paul.gortmaker@windriver.com>2012-07-13 19:33:28 -0400
commitdc1aed37d17b4fe4f28a74d804c065b877bc7bed (patch)
tree83907b44c25a9a10c84106d17eecfceff00864ce /net/tipc/bcast.c
parente2dbd601346aeb64b1b387168b217fd5c301644e (diff)
tipc: phase out most of the struct print_buf usage
The tipc_printf is renamed to tipc_snprintf, as the new name describes more what the function actually does. It is also changed to take a buffer and length parameter and return number of characters written to the buffer. All callers of this function that used to pass a print_buf are updated. Final removal of the struct print_buf itself will be done synchronously with the pending removal of the deprecated logging code that also was using it. Functions that build up a response message with a list of ports, nametable contents etc. are changed to return the number of characters written to the output buffer. This information was previously hidden in a field of the print_buf struct, and the number of chars written was fetched with a call to tipc_printbuf_validate. This function is removed since it is no longer referenced nor needed. A generic max size ULTRA_STRING_MAX_LEN is defined, named in keeping with the existing TIPC_TLV_ULTRA_STRING, and the various definitions in port, link and nametable code that largely duplicated this information are removed. This means that amount of link statistics that can be returned is now increased from 2k to 32k. The buffer overflow check is now done just before the reply message is passed over netlink or TIPC to a remote node and the message indicating a truncated buffer is changed to a less dramatic one (less CAPS), placed at the end of the message. Signed-off-by: Erik Hugne <erik.hugne@ericsson.com> Signed-off-by: Jon Maloy <jon.maloy@ericsson.com> Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Diffstat (limited to 'net/tipc/bcast.c')
-rw-r--r--net/tipc/bcast.c63
1 files changed, 29 insertions, 34 deletions
diff --git a/net/tipc/bcast.c b/net/tipc/bcast.c
index fef3689bcf23..e4e6d8cd47e6 100644
--- a/net/tipc/bcast.c
+++ b/net/tipc/bcast.c
@@ -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)