diff options
Diffstat (limited to 'net/tipc/config.c')
| -rw-r--r-- | net/tipc/config.c | 148 |
1 files changed, 6 insertions, 142 deletions
diff --git a/net/tipc/config.c b/net/tipc/config.c index 961d1b097146..50a6133a3668 100644 --- a/net/tipc/config.c +++ b/net/tipc/config.c | |||
| @@ -95,7 +95,7 @@ int tipc_cfg_append_tlv(struct sk_buff *buf, int tlv_type, | |||
| 95 | return 1; | 95 | return 1; |
| 96 | } | 96 | } |
| 97 | 97 | ||
| 98 | struct sk_buff *tipc_cfg_reply_unsigned_type(u16 tlv_type, u32 value) | 98 | static struct sk_buff *tipc_cfg_reply_unsigned_type(u16 tlv_type, u32 value) |
| 99 | { | 99 | { |
| 100 | struct sk_buff *buf; | 100 | struct sk_buff *buf; |
| 101 | __be32 value_net; | 101 | __be32 value_net; |
| @@ -109,6 +109,11 @@ struct sk_buff *tipc_cfg_reply_unsigned_type(u16 tlv_type, u32 value) | |||
| 109 | return buf; | 109 | return buf; |
| 110 | } | 110 | } |
| 111 | 111 | ||
| 112 | static struct sk_buff *tipc_cfg_reply_unsigned(u32 value) | ||
| 113 | { | ||
| 114 | return tipc_cfg_reply_unsigned_type(TIPC_TLV_UNSIGNED, value); | ||
| 115 | } | ||
| 116 | |||
| 112 | struct sk_buff *tipc_cfg_reply_string_type(u16 tlv_type, char *string) | 117 | struct sk_buff *tipc_cfg_reply_string_type(u16 tlv_type, char *string) |
| 113 | { | 118 | { |
| 114 | struct sk_buff *buf; | 119 | struct sk_buff *buf; |
| @@ -120,139 +125,6 @@ struct sk_buff *tipc_cfg_reply_string_type(u16 tlv_type, char *string) | |||
| 120 | return buf; | 125 | return buf; |
| 121 | } | 126 | } |
| 122 | 127 | ||
| 123 | |||
| 124 | #if 0 | ||
| 125 | |||
| 126 | /* Now obsolete code for handling commands not yet implemented the new way */ | ||
| 127 | |||
| 128 | /* | ||
| 129 | * Some of this code assumed that the manager structure contains two added | ||
| 130 | * fields: | ||
| 131 | * u32 link_subscriptions; | ||
| 132 | * struct list_head link_subscribers; | ||
| 133 | * which are currently not present. These fields may need to be re-introduced | ||
| 134 | * if and when support for link subscriptions is added. | ||
| 135 | */ | ||
| 136 | |||
| 137 | void tipc_cfg_link_event(u32 addr, char *name, int up) | ||
| 138 | { | ||
| 139 | /* TIPC DOESN'T HANDLE LINK EVENT SUBSCRIPTIONS AT THE MOMENT */ | ||
| 140 | } | ||
| 141 | |||
| 142 | int tipc_cfg_cmd(const struct tipc_cmd_msg * msg, | ||
| 143 | char *data, | ||
| 144 | u32 sz, | ||
| 145 | u32 *ret_size, | ||
| 146 | struct tipc_portid *orig) | ||
| 147 | { | ||
| 148 | int rv = -EINVAL; | ||
| 149 | u32 cmd = msg->cmd; | ||
| 150 | |||
| 151 | *ret_size = 0; | ||
| 152 | switch (cmd) { | ||
| 153 | case TIPC_REMOVE_LINK: | ||
| 154 | case TIPC_CMD_BLOCK_LINK: | ||
| 155 | case TIPC_CMD_UNBLOCK_LINK: | ||
| 156 | if (!cfg_check_connection(orig)) | ||
| 157 | rv = link_control(msg->argv.link_name, msg->cmd, 0); | ||
| 158 | break; | ||
| 159 | case TIPC_ESTABLISH: | ||
| 160 | { | ||
| 161 | int connected; | ||
| 162 | |||
| 163 | tipc_isconnected(mng.conn_port_ref, &connected); | ||
| 164 | if (connected || !orig) { | ||
| 165 | rv = TIPC_FAILURE; | ||
| 166 | break; | ||
| 167 | } | ||
| 168 | rv = tipc_connect2port(mng.conn_port_ref, orig); | ||
| 169 | if (rv == TIPC_OK) | ||
| 170 | orig = 0; | ||
| 171 | break; | ||
| 172 | } | ||
| 173 | case TIPC_GET_PEER_ADDRESS: | ||
| 174 | *ret_size = link_peer_addr(msg->argv.link_name, data, sz); | ||
| 175 | break; | ||
| 176 | case TIPC_GET_ROUTES: | ||
| 177 | rv = TIPC_OK; | ||
| 178 | break; | ||
| 179 | default: {} | ||
| 180 | } | ||
| 181 | if (*ret_size) | ||
| 182 | rv = TIPC_OK; | ||
| 183 | return rv; | ||
| 184 | } | ||
| 185 | |||
| 186 | static void cfg_cmd_event(struct tipc_cmd_msg *msg, | ||
| 187 | char *data, | ||
| 188 | u32 sz, | ||
| 189 | struct tipc_portid const *orig) | ||
| 190 | { | ||
| 191 | int rv = -EINVAL; | ||
| 192 | struct tipc_cmd_result_msg rmsg; | ||
| 193 | struct iovec msg_sect[2]; | ||
| 194 | int *arg; | ||
| 195 | |||
| 196 | msg->cmd = ntohl(msg->cmd); | ||
| 197 | |||
| 198 | cfg_prepare_res_msg(msg->cmd, msg->usr_handle, rv, &rmsg, msg_sect, | ||
| 199 | data, 0); | ||
| 200 | if (ntohl(msg->magic) != TIPC_MAGIC) | ||
| 201 | goto exit; | ||
| 202 | |||
| 203 | switch (msg->cmd) { | ||
| 204 | case TIPC_CREATE_LINK: | ||
| 205 | if (!cfg_check_connection(orig)) | ||
| 206 | rv = disc_create_link(&msg->argv.create_link); | ||
| 207 | break; | ||
| 208 | case TIPC_LINK_SUBSCRIBE: | ||
| 209 | { | ||
| 210 | struct subscr_data *sub; | ||
| 211 | |||
| 212 | if (mng.link_subscriptions > 64) | ||
| 213 | break; | ||
| 214 | sub = kmalloc(sizeof(*sub), | ||
| 215 | GFP_ATOMIC); | ||
| 216 | if (sub == NULL) { | ||
| 217 | warn("Memory squeeze; dropped remote link subscription\n"); | ||
| 218 | break; | ||
| 219 | } | ||
| 220 | INIT_LIST_HEAD(&sub->subd_list); | ||
| 221 | tipc_createport(mng.user_ref, | ||
| 222 | (void *)sub, | ||
| 223 | TIPC_HIGH_IMPORTANCE, | ||
| 224 | 0, | ||
| 225 | 0, | ||
| 226 | (tipc_conn_shutdown_event)cfg_linksubscr_cancel, | ||
| 227 | 0, | ||
| 228 | 0, | ||
| 229 | (tipc_conn_msg_event)cfg_linksubscr_cancel, | ||
| 230 | 0, | ||
| 231 | &sub->port_ref); | ||
| 232 | if (!sub->port_ref) { | ||
| 233 | kfree(sub); | ||
| 234 | break; | ||
| 235 | } | ||
| 236 | memcpy(sub->usr_handle,msg->usr_handle, | ||
| 237 | sizeof(sub->usr_handle)); | ||
| 238 | sub->domain = msg->argv.domain; | ||
| 239 | list_add_tail(&sub->subd_list, &mng.link_subscribers); | ||
| 240 | tipc_connect2port(sub->port_ref, orig); | ||
| 241 | rmsg.retval = TIPC_OK; | ||
| 242 | tipc_send(sub->port_ref, 2u, msg_sect); | ||
| 243 | mng.link_subscriptions++; | ||
| 244 | return; | ||
| 245 | } | ||
| 246 | default: | ||
| 247 | rv = tipc_cfg_cmd(msg, data, sz, (u32 *)&msg_sect[1].iov_len, orig); | ||
| 248 | } | ||
| 249 | exit: | ||
| 250 | rmsg.result_len = htonl(msg_sect[1].iov_len); | ||
| 251 | rmsg.retval = htonl(rv); | ||
| 252 | tipc_cfg_respond(msg_sect, 2u, orig); | ||
| 253 | } | ||
| 254 | #endif | ||
| 255 | |||
| 256 | #define MAX_STATS_INFO 2000 | 128 | #define MAX_STATS_INFO 2000 |
| 257 | 129 | ||
| 258 | static struct sk_buff *tipc_show_stats(void) | 130 | static struct sk_buff *tipc_show_stats(void) |
| @@ -557,14 +429,6 @@ struct sk_buff *tipc_cfg_do_cmd(u32 orig_node, u16 cmd, const void *request_area | |||
| 557 | case TIPC_CMD_SHOW_PORTS: | 429 | case TIPC_CMD_SHOW_PORTS: |
| 558 | rep_tlv_buf = tipc_port_get_ports(); | 430 | rep_tlv_buf = tipc_port_get_ports(); |
| 559 | break; | 431 | break; |
| 560 | #if 0 | ||
| 561 | case TIPC_CMD_SHOW_PORT_STATS: | ||
| 562 | rep_tlv_buf = port_show_stats(req_tlv_area, req_tlv_space); | ||
| 563 | break; | ||
| 564 | case TIPC_CMD_RESET_PORT_STATS: | ||
| 565 | rep_tlv_buf = tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED); | ||
| 566 | break; | ||
| 567 | #endif | ||
| 568 | case TIPC_CMD_SET_LOG_SIZE: | 432 | case TIPC_CMD_SET_LOG_SIZE: |
| 569 | rep_tlv_buf = tipc_log_resize_cmd(req_tlv_area, req_tlv_space); | 433 | rep_tlv_buf = tipc_log_resize_cmd(req_tlv_area, req_tlv_space); |
| 570 | break; | 434 | break; |
