42 #define REPLY_TRUNCATED "<truncated>\n"
44 static u32 config_port_ref;
48 static const void *req_tlv_area;
49 static int req_tlv_space;
50 static int rep_headroom;
57 buf = alloc_skb(rep_headroom + payload_size,
GFP_ATOMIC);
59 skb_reserve(buf, rep_headroom);
64 void *tlv_data,
int tlv_data_size)
67 int new_tlv_space =
TLV_SPACE(tlv_data_size);
69 if (skb_tailroom(buf) < new_tlv_space)
74 if (tlv_data_size && tlv_data)
86 value_net =
htonl(value);
93 static struct sk_buff *tipc_cfg_reply_unsigned(
u32 value)
101 int string_len =
strlen(
string) + 1;
109 static struct sk_buff *tipc_show_stats(
void)
123 return tipc_cfg_reply_error_string(
"unsupported argument");
141 static struct sk_buff *cfg_enable_bearer(
void)
152 return tipc_cfg_reply_error_string(
"unable to enable bearer");
154 return tipc_cfg_reply_none();
157 static struct sk_buff *cfg_disable_bearer(
void)
163 return tipc_cfg_reply_error_string(
"unable to disable bearer");
165 return tipc_cfg_reply_none();
168 static struct sk_buff *cfg_set_own_addr(
void)
176 if (addr == tipc_own_addr)
177 return tipc_cfg_reply_none();
183 " (cannot change node address once assigned)");
193 spin_unlock_bh(&config_lock);
195 spin_lock_bh(&config_lock);
196 return tipc_cfg_reply_none();
199 static struct sk_buff *cfg_set_remote_mng(
void)
207 tipc_remote_management = (value != 0);
208 return tipc_cfg_reply_none();
211 static struct sk_buff *cfg_set_max_ports(
void)
218 if (value == tipc_max_ports)
219 return tipc_cfg_reply_none();
220 if (value < 127 || value > 65535)
222 " (max ports must be 127-65535)");
224 " (cannot change max ports while TIPC is active)");
227 static struct sk_buff *cfg_set_netid(
void)
234 if (value == tipc_net_id)
235 return tipc_cfg_reply_none();
236 if (value < 1 || value > 9999)
238 " (network id must be 1-9999)");
241 " (cannot change network id once TIPC has joined a network)");
243 return tipc_cfg_reply_none();
247 int request_space,
int reply_headroom)
251 spin_lock_bh(&config_lock);
254 req_tlv_area = request_area;
255 req_tlv_space = request_space;
256 rep_headroom = reply_headroom;
259 if (
likely(in_own_node(orig_node))) {
261 }
else if (cmd >= 0x8000) {
263 " (cannot be done remotely)");
265 }
else if (!tipc_remote_management) {
268 }
else if (cmd >= 0x4000) {
272 (domain != orig_node)) {
281 rep_tlv_buf = tipc_cfg_reply_none();
308 rep_tlv_buf = tipc_show_stats();
316 rep_tlv_buf = cfg_enable_bearer();
319 rep_tlv_buf = cfg_disable_bearer();
322 rep_tlv_buf = cfg_set_own_addr();
325 rep_tlv_buf = cfg_set_remote_mng();
328 rep_tlv_buf = cfg_set_max_ports();
331 rep_tlv_buf = cfg_set_netid();
334 rep_tlv_buf = tipc_cfg_reply_unsigned(tipc_remote_management);
337 rep_tlv_buf = tipc_cfg_reply_unsigned(tipc_max_ports);
340 rep_tlv_buf = tipc_cfg_reply_unsigned(tipc_net_id);
361 " (obsolete command)");
365 " (unknown command)");
380 spin_unlock_bh(&config_lock);
384 static void cfg_named_msg_event(
void *userdata,
399 if ((size <
sizeof(*req_hdr)) ||
402 pr_warn(
"Invalid configuration message discarded\n");
409 msg +
sizeof(*req_hdr),
410 size -
sizeof(*req_hdr),
413 skb_push(rep_buf,
sizeof(*rep_hdr));
415 memcpy(rep_hdr, req_hdr,
sizeof(*rep_hdr));
435 NULL, &config_port_ref);
448 pr_err(
"Unable to create configuration service\n");
464 pr_err(
"Unable to reinitialize configuration service\n");