aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc
diff options
context:
space:
mode:
authorErik Hugne <erik.hugne@ericsson.com>2012-06-29 00:50:24 -0400
committerPaul Gortmaker <paul.gortmaker@windriver.com>2012-07-13 19:34:43 -0400
commit869dd4662f90514cb92b44a389e85c737b464e25 (patch)
tree866ef81219668384e80d756732d2f2023513ef0e /net/tipc
parentdc1aed37d17b4fe4f28a74d804c065b877bc7bed (diff)
tipc: remove print_buf and deprecated log buffer code
The internal log buffer handling functions can now safely be removed since there is no code using it anymore. Requests to interact with the internal tipc log buffer over netlink (in config.c) will report 'obsolete command'. This represents the final removal of any references to a struct print_buf, and the removal of the struct itself. We also get rid of a TIPC specific Kconfig in the process. Finally, log.h is removed since it is not needed anymore. 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')
-rw-r--r--net/tipc/Kconfig13
-rw-r--r--net/tipc/config.c8
-rw-r--r--net/tipc/core.c7
-rw-r--r--net/tipc/core.h27
-rw-r--r--net/tipc/link.h1
-rw-r--r--net/tipc/log.c213
-rw-r--r--net/tipc/log.h66
7 files changed, 2 insertions, 333 deletions
diff --git a/net/tipc/Kconfig b/net/tipc/Kconfig
index e24519a54938..585460180ffb 100644
--- a/net/tipc/Kconfig
+++ b/net/tipc/Kconfig
@@ -41,17 +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
57endif # TIPC 44endif # TIPC
diff --git a/net/tipc/config.c b/net/tipc/config.c
index 96cfbf834a10..a056a3852f71 100644
--- a/net/tipc/config.c
+++ b/net/tipc/config.c
@@ -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;
diff --git a/net/tipc/core.c b/net/tipc/core.c
index 3689cb4067c8..6586eac6a50e 100644
--- a/net/tipc/core.c
+++ b/net/tipc/core.c
@@ -46,9 +46,6 @@
46#define CONFIG_TIPC_PORTS 8191 46#define CONFIG_TIPC_PORTS 8191
47#endif 47#endif
48 48
49#ifndef CONFIG_TIPC_LOG
50#define CONFIG_TIPC_LOG 0
51#endif
52 49
53/* global variables used by multiple sub-systems within TIPC */ 50/* global variables used by multiple sub-systems within TIPC */
54int tipc_random; 51int tipc_random;
@@ -124,7 +121,6 @@ static void tipc_core_stop(void)
124 tipc_nametbl_stop(); 121 tipc_nametbl_stop();
125 tipc_ref_table_stop(); 122 tipc_ref_table_stop();
126 tipc_socket_stop(); 123 tipc_socket_stop();
127 tipc_log_resize(0);
128} 124}
129 125
130/** 126/**
@@ -160,9 +156,6 @@ static int __init tipc_init(void)
160{ 156{
161 int res; 157 int res;
162 158
163 if (tipc_log_resize(CONFIG_TIPC_LOG) != 0)
164 pr_warn("Unable to create log buffer\n");
165
166 pr_info("Activated (version " TIPC_MOD_VER ")\n"); 159 pr_info("Activated (version " TIPC_MOD_VER ")\n");
167 160
168 tipc_own_addr = 0; 161 tipc_own_addr = 0;
diff --git a/net/tipc/core.h b/net/tipc/core.h
index 4dcdb4859026..fd42e106c185 100644
--- a/net/tipc/core.h
+++ b/net/tipc/core.h
@@ -63,37 +63,10 @@
63#define ULTRA_STRING_MAX_LEN 32768 63#define ULTRA_STRING_MAX_LEN 32768
64 64
65struct tipc_msg; /* msg.h */ 65struct tipc_msg; /* msg.h */
66struct print_buf; /* log.h */
67
68/*
69 * TIPC system monitoring code
70 */
71
72/*
73 * TIPC's print buffer subsystem supports the following print buffers:
74 *
75 * TIPC_NULL : null buffer (i.e. print nowhere)
76 * TIPC_CONS : system console
77 * TIPC_LOG : TIPC log buffer
78 * &buf : user-defined buffer (struct print_buf *)
79 *
80 * Note: TIPC_LOG is configured to echo its output to the system console;
81 * user-defined buffers can be configured to do the same thing.
82 */
83extern struct print_buf *const TIPC_NULL;
84extern struct print_buf *const TIPC_CONS;
85extern struct print_buf *const TIPC_LOG;
86 66
87int tipc_snprintf(char *buf, int len, const char *fmt, ...); 67int tipc_snprintf(char *buf, int len, const char *fmt, ...);
88 68
89/* 69/*
90 * TIPC_OUTPUT is the destination print buffer for system messages.
91 */
92#ifndef TIPC_OUTPUT
93#define TIPC_OUTPUT TIPC_LOG
94#endif
95
96/*
97 * TIPC-specific error codes 70 * TIPC-specific error codes
98 */ 71 */
99#define ELINKCONG EAGAIN /* link congestion <=> resource unavailable */ 72#define ELINKCONG EAGAIN /* link congestion <=> resource unavailable */
diff --git a/net/tipc/link.h b/net/tipc/link.h
index 8024a56a1ebc..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
diff --git a/net/tipc/log.c b/net/tipc/log.c
index fa7ce927fda5..abef644f27d8 100644
--- a/net/tipc/log.c
+++ b/net/tipc/log.c
@@ -36,138 +36,6 @@
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 DEFINE_SPINLOCK(print_lock);
75
76static void tipc_printbuf_move(struct print_buf *pb_to,
77 struct print_buf *pb_from);
78
79/**
80 * tipc_printbuf_init - initialize print buffer to empty
81 * @pb: pointer to print buffer structure
82 * @raw: pointer to character array used by print buffer
83 * @size: size of character array
84 *
85 * Note: If the character array is too small (or absent), the print buffer
86 * becomes a null device that discards anything written to it.
87 */
88void tipc_printbuf_init(struct print_buf *pb, char *raw, u32 size)
89{
90 pb->buf = raw;
91 pb->crs = raw;
92 pb->size = size;
93 pb->echo = 0;
94
95 if (size < TIPC_PB_MIN_SIZE) {
96 pb->buf = NULL;
97 } else if (raw) {
98 pb->buf[0] = 0;
99 pb->buf[size - 1] = ~0;
100 }
101}
102
103/**
104 * tipc_printbuf_reset - reinitialize print buffer to empty state
105 * @pb: pointer to print buffer structure
106 */
107static void tipc_printbuf_reset(struct print_buf *pb)
108{
109 if (pb->buf) {
110 pb->crs = pb->buf;
111 pb->buf[0] = 0;
112 pb->buf[pb->size - 1] = ~0;
113 }
114}
115
116/**
117 * tipc_printbuf_empty - test if print buffer is in empty state
118 * @pb: pointer to print buffer structure
119 *
120 * Returns non-zero if print buffer is empty.
121 */
122static int tipc_printbuf_empty(struct print_buf *pb)
123{
124 return !pb->buf || (pb->crs == pb->buf);
125}
126
127/**
128 * tipc_printbuf_move - move print buffer contents to another print buffer
129 * @pb_to: pointer to destination print buffer structure
130 * @pb_from: pointer to source print buffer structure
131 *
132 * Current contents of destination print buffer (if any) are discarded.
133 * Source print buffer becomes empty if a successful move occurs.
134 */
135static void tipc_printbuf_move(struct print_buf *pb_to,
136 struct print_buf *pb_from)
137{
138 int len;
139
140 /* Handle the cases where contents can't be moved */
141 if (!pb_to->buf)
142 return;
143
144 if (!pb_from->buf) {
145 tipc_printbuf_reset(pb_to);
146 return;
147 }
148
149 if (pb_to->size < pb_from->size) {
150 strcpy(pb_to->buf, "*** PRINT BUFFER MOVE ERROR ***");
151 pb_to->buf[pb_to->size - 1] = ~0;
152 pb_to->crs = strchr(pb_to->buf, 0);
153 return;
154 }
155
156 /* Copy data from char after cursor to end (if used) */
157 len = pb_from->buf + pb_from->size - pb_from->crs - 2;
158 if ((pb_from->buf[pb_from->size - 1] == 0) && (len > 0)) {
159 strcpy(pb_to->buf, pb_from->crs + 1);
160 pb_to->crs = pb_to->buf + len;
161 } else
162 pb_to->crs = pb_to->buf;
163
164 /* Copy data from start to cursor (always) */
165 len = pb_from->crs - pb_from->buf;
166 strcpy(pb_to->crs, pb_from->buf);
167 pb_to->crs += len;
168
169 tipc_printbuf_reset(pb_from);
170}
171 39
172/** 40/**
173 * tipc_snprintf - append formatted output to print buffer 41 * tipc_snprintf - append formatted output to print buffer
@@ -185,84 +53,3 @@ int tipc_snprintf(char *buf, int len, const char *fmt, ...)
185 va_end(args); 53 va_end(args);
186 return i; 54 return i;
187} 55}
188
189/**
190 * tipc_log_resize - change the size of the TIPC log buffer
191 * @log_size: print buffer size to use
192 */
193int tipc_log_resize(int log_size)
194{
195 int res = 0;
196
197 spin_lock_bh(&print_lock);
198 kfree(TIPC_LOG->buf);
199 TIPC_LOG->buf = NULL;
200 if (log_size) {
201 if (log_size < TIPC_PB_MIN_SIZE)
202 log_size = TIPC_PB_MIN_SIZE;
203 res = TIPC_LOG->echo;
204 tipc_printbuf_init(TIPC_LOG, kmalloc(log_size, GFP_ATOMIC),
205 log_size);
206 TIPC_LOG->echo = res;
207 res = !TIPC_LOG->buf;
208 }
209 spin_unlock_bh(&print_lock);
210
211 return res;
212}
213
214/**
215 * tipc_log_resize_cmd - reconfigure size of TIPC log buffer
216 */
217struct sk_buff *tipc_log_resize_cmd(const void *req_tlv_area, int req_tlv_space)
218{
219 u32 value;
220
221 if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_UNSIGNED))
222 return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR);
223
224 value = ntohl(*(__be32 *)TLV_DATA(req_tlv_area));
225 if (value > 32768)
226 return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE
227 " (log size must be 0-32768)");
228 if (tipc_log_resize(value))
229 return tipc_cfg_reply_error_string(
230 "unable to create specified log (log size is now 0)");
231 return tipc_cfg_reply_none();
232}
233
234/**
235 * tipc_log_dump - capture TIPC log buffer contents in configuration message
236 */
237struct sk_buff *tipc_log_dump(void)
238{
239 struct sk_buff *reply;
240
241 spin_lock_bh(&print_lock);
242 if (!TIPC_LOG->buf) {
243 spin_unlock_bh(&print_lock);
244 reply = tipc_cfg_reply_ultra_string("log not activated\n");
245 } else if (tipc_printbuf_empty(TIPC_LOG)) {
246 spin_unlock_bh(&print_lock);
247 reply = tipc_cfg_reply_ultra_string("log is empty\n");
248 } else {
249 struct tlv_desc *rep_tlv;
250 struct print_buf pb;
251 int str_len;
252
253 str_len = min(TIPC_LOG->size, 32768u);
254 spin_unlock_bh(&print_lock);
255 reply = tipc_cfg_reply_alloc(TLV_SPACE(str_len));
256 if (reply) {
257 rep_tlv = (struct tlv_desc *)reply->data;
258 tipc_printbuf_init(&pb, TLV_DATA(rep_tlv), str_len);
259 spin_lock_bh(&print_lock);
260 tipc_printbuf_move(&pb, TIPC_LOG);
261 spin_unlock_bh(&print_lock);
262 str_len = strlen(TLV_DATA(rep_tlv)) + 1;
263 skb_put(reply, TLV_SPACE(str_len));
264 TLV_SET(rep_tlv, TIPC_TLV_ULTRA_STRING, NULL, str_len);
265 }
266 }
267 return reply;
268}
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