aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/config.c
diff options
context:
space:
mode:
authorRichard Alpe <richard.alpe@ericsson.com>2015-02-09 03:50:18 -0500
committerDavid S. Miller <davem@davemloft.net>2015-02-09 16:20:49 -0500
commit22ae7cff509f3bb22caaa0003f67eeb93d338fed (patch)
tree2d3ee4ec9044797f4520e14c5b34e3605c5ce9fa /net/tipc/config.c
parent5a81a6377b6083fccffdfb7a21ec080b8d58475b (diff)
tipc: nl compat add noop and remove legacy nl framework
Add TIPC_CMD_NOOP to compat layer and remove the old framework. All legacy nl commands are now converted to the compat layer in netlink_compat.c. Signed-off-by: Richard Alpe <richard.alpe@ericsson.com> Reviewed-by: Erik Hugne <erik.hugne@ericsson.com> Reviewed-by: Ying Xue <ying.xue@windriver.com> Reviewed-by: Jon Maloy <jon.maloy@ericsson.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc/config.c')
-rw-r--r--net/tipc/config.c157
1 files changed, 0 insertions, 157 deletions
diff --git a/net/tipc/config.c b/net/tipc/config.c
deleted file mode 100644
index c2ad2ff32a15..000000000000
--- a/net/tipc/config.c
+++ /dev/null
@@ -1,157 +0,0 @@
1/*
2 * net/tipc/config.c: TIPC configuration management code
3 *
4 * Copyright (c) 2002-2006, Ericsson AB
5 * Copyright (c) 2004-2007, 2010-2013, 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#include "core.h"
38#include "socket.h"
39#include "name_table.h"
40#include "config.h"
41#include "server.h"
42
43#define REPLY_TRUNCATED "<truncated>\n"
44
45static const void *req_tlv_area; /* request message TLV area */
46static int req_tlv_space; /* request message TLV area size */
47static int rep_headroom; /* reply message headroom to use */
48
49struct sk_buff *tipc_cfg_reply_alloc(int payload_size)
50{
51 struct sk_buff *buf;
52
53 buf = alloc_skb(rep_headroom + payload_size, GFP_ATOMIC);
54 if (buf)
55 skb_reserve(buf, rep_headroom);
56 return buf;
57}
58
59int tipc_cfg_append_tlv(struct sk_buff *buf, int tlv_type,
60 void *tlv_data, int tlv_data_size)
61{
62 struct tlv_desc *tlv = (struct tlv_desc *)skb_tail_pointer(buf);
63 int new_tlv_space = TLV_SPACE(tlv_data_size);
64
65 if (skb_tailroom(buf) < new_tlv_space)
66 return 0;
67 skb_put(buf, new_tlv_space);
68 tlv->tlv_type = htons(tlv_type);
69 tlv->tlv_len = htons(TLV_LENGTH(tlv_data_size));
70 if (tlv_data_size && tlv_data)
71 memcpy(TLV_DATA(tlv), tlv_data, tlv_data_size);
72 return 1;
73}
74
75struct sk_buff *tipc_cfg_reply_string_type(u16 tlv_type, char *string)
76{
77 struct sk_buff *buf;
78 int string_len = strlen(string) + 1;
79
80 buf = tipc_cfg_reply_alloc(TLV_SPACE(string_len));
81 if (buf)
82 tipc_cfg_append_tlv(buf, tlv_type, string, string_len);
83 return buf;
84}
85
86struct sk_buff *tipc_cfg_do_cmd(struct net *net, u32 orig_node, u16 cmd,
87 const void *request_area, int request_space,
88 int reply_headroom)
89{
90 struct sk_buff *rep_tlv_buf;
91
92 rtnl_lock();
93
94 /* Save request and reply details in a well-known location */
95 req_tlv_area = request_area;
96 req_tlv_space = request_space;
97 rep_headroom = reply_headroom;
98
99 /* Check command authorization */
100 if (likely(in_own_node(net, orig_node))) {
101 /* command is permitted */
102 } else {
103 rep_tlv_buf = tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED
104 " (cannot be done remotely)");
105 goto exit;
106 }
107
108 /* Call appropriate processing routine */
109 switch (cmd) {
110 case TIPC_CMD_NOOP:
111 rep_tlv_buf = tipc_cfg_reply_none();
112 break;
113 case TIPC_CMD_NOT_NET_ADMIN:
114 rep_tlv_buf =
115 tipc_cfg_reply_error_string(TIPC_CFG_NOT_NET_ADMIN);
116 break;
117 case TIPC_CMD_SET_MAX_ZONES:
118 case TIPC_CMD_GET_MAX_ZONES:
119 case TIPC_CMD_SET_MAX_SLAVES:
120 case TIPC_CMD_GET_MAX_SLAVES:
121 case TIPC_CMD_SET_MAX_CLUSTERS:
122 case TIPC_CMD_GET_MAX_CLUSTERS:
123 case TIPC_CMD_SET_MAX_NODES:
124 case TIPC_CMD_GET_MAX_NODES:
125 case TIPC_CMD_SET_MAX_SUBSCR:
126 case TIPC_CMD_GET_MAX_SUBSCR:
127 case TIPC_CMD_SET_MAX_PUBL:
128 case TIPC_CMD_GET_MAX_PUBL:
129 case TIPC_CMD_SET_LOG_SIZE:
130 case TIPC_CMD_SET_REMOTE_MNG:
131 case TIPC_CMD_GET_REMOTE_MNG:
132 case TIPC_CMD_DUMP_LOG:
133 case TIPC_CMD_SET_MAX_PORTS:
134 case TIPC_CMD_GET_MAX_PORTS:
135 rep_tlv_buf = tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED
136 " (obsolete command)");
137 break;
138 default:
139 rep_tlv_buf = tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED
140 " (unknown command)");
141 break;
142 }
143
144 WARN_ON(rep_tlv_buf->len > TLV_SPACE(ULTRA_STRING_MAX_LEN));
145
146 /* Append an error message if we cannot return all requested data */
147 if (rep_tlv_buf->len == TLV_SPACE(ULTRA_STRING_MAX_LEN)) {
148 if (*(rep_tlv_buf->data + ULTRA_STRING_MAX_LEN) != '\0')
149 sprintf(rep_tlv_buf->data + rep_tlv_buf->len -
150 sizeof(REPLY_TRUNCATED) - 1, REPLY_TRUNCATED);
151 }
152
153 /* Return reply buffer */
154exit:
155 rtnl_unlock();
156 return rep_tlv_buf;
157}