diff options
Diffstat (limited to 'net/tipc/config.c')
| -rw-r--r-- | net/tipc/config.c | 90 | 
1 files changed, 40 insertions, 50 deletions
| diff --git a/net/tipc/config.c b/net/tipc/config.c index 876f4c6a2631..6873360cda53 100644 --- a/net/tipc/config.c +++ b/net/tipc/config.c | |||
| @@ -134,7 +134,7 @@ static struct sk_buff *tipc_show_stats(void) | |||
| 134 | return buf; | 134 | return buf; | 
| 135 | } | 135 | } | 
| 136 | 136 | ||
| 137 | static struct sk_buff *cfg_enable_bearer(void) | 137 | static struct sk_buff *cfg_enable_bearer(struct net *net) | 
| 138 | { | 138 | { | 
| 139 | struct tipc_bearer_config *args; | 139 | struct tipc_bearer_config *args; | 
| 140 | 140 | ||
| @@ -142,7 +142,7 @@ static struct sk_buff *cfg_enable_bearer(void) | |||
| 142 | return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR); | 142 | return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR); | 
| 143 | 143 | ||
| 144 | args = (struct tipc_bearer_config *)TLV_DATA(req_tlv_area); | 144 | args = (struct tipc_bearer_config *)TLV_DATA(req_tlv_area); | 
| 145 | if (tipc_enable_bearer(args->name, | 145 | if (tipc_enable_bearer(net, args->name, | 
| 146 | ntohl(args->disc_domain), | 146 | ntohl(args->disc_domain), | 
| 147 | ntohl(args->priority))) | 147 | ntohl(args->priority))) | 
| 148 | return tipc_cfg_reply_error_string("unable to enable bearer"); | 148 | return tipc_cfg_reply_error_string("unable to enable bearer"); | 
| @@ -150,78 +150,66 @@ static struct sk_buff *cfg_enable_bearer(void) | |||
| 150 | return tipc_cfg_reply_none(); | 150 | return tipc_cfg_reply_none(); | 
| 151 | } | 151 | } | 
| 152 | 152 | ||
| 153 | static struct sk_buff *cfg_disable_bearer(void) | 153 | static struct sk_buff *cfg_disable_bearer(struct net *net) | 
| 154 | { | 154 | { | 
| 155 | if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_BEARER_NAME)) | 155 | if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_BEARER_NAME)) | 
| 156 | return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR); | 156 | return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR); | 
| 157 | 157 | ||
| 158 | if (tipc_disable_bearer((char *)TLV_DATA(req_tlv_area))) | 158 | if (tipc_disable_bearer(net, (char *)TLV_DATA(req_tlv_area))) | 
| 159 | return tipc_cfg_reply_error_string("unable to disable bearer"); | 159 | return tipc_cfg_reply_error_string("unable to disable bearer"); | 
| 160 | 160 | ||
| 161 | return tipc_cfg_reply_none(); | 161 | return tipc_cfg_reply_none(); | 
| 162 | } | 162 | } | 
| 163 | 163 | ||
| 164 | static struct sk_buff *cfg_set_own_addr(void) | 164 | static struct sk_buff *cfg_set_own_addr(struct net *net) | 
| 165 | { | 165 | { | 
| 166 | struct tipc_net *tn = net_generic(net, tipc_net_id); | ||
| 166 | u32 addr; | 167 | u32 addr; | 
| 167 | 168 | ||
| 168 | if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_NET_ADDR)) | 169 | if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_NET_ADDR)) | 
| 169 | return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR); | 170 | return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR); | 
| 170 | 171 | ||
| 171 | addr = ntohl(*(__be32 *)TLV_DATA(req_tlv_area)); | 172 | addr = ntohl(*(__be32 *)TLV_DATA(req_tlv_area)); | 
| 172 | if (addr == tipc_own_addr) | 173 | if (addr == tn->own_addr) | 
| 173 | return tipc_cfg_reply_none(); | 174 | return tipc_cfg_reply_none(); | 
| 174 | if (!tipc_addr_node_valid(addr)) | 175 | if (!tipc_addr_node_valid(addr)) | 
| 175 | return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE | 176 | return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE | 
| 176 | " (node address)"); | 177 | " (node address)"); | 
| 177 | if (tipc_own_addr) | 178 | if (tn->own_addr) | 
| 178 | return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED | 179 | return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED | 
| 179 | " (cannot change node address once assigned)"); | 180 | " (cannot change node address once assigned)"); | 
| 180 | if (!tipc_net_start(addr)) | 181 | if (!tipc_net_start(net, addr)) | 
| 181 | return tipc_cfg_reply_none(); | 182 | return tipc_cfg_reply_none(); | 
| 182 | 183 | ||
| 183 | return tipc_cfg_reply_error_string("cannot change to network mode"); | 184 | return tipc_cfg_reply_error_string("cannot change to network mode"); | 
| 184 | } | 185 | } | 
| 185 | 186 | ||
| 186 | static struct sk_buff *cfg_set_max_ports(void) | 187 | static struct sk_buff *cfg_set_netid(struct net *net) | 
| 187 | { | 188 | { | 
| 189 | struct tipc_net *tn = net_generic(net, tipc_net_id); | ||
| 188 | u32 value; | 190 | u32 value; | 
| 189 | 191 | ||
| 190 | if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_UNSIGNED)) | 192 | if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_UNSIGNED)) | 
| 191 | return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR); | 193 | return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR); | 
| 192 | value = ntohl(*(__be32 *)TLV_DATA(req_tlv_area)); | 194 | value = ntohl(*(__be32 *)TLV_DATA(req_tlv_area)); | 
| 193 | if (value == tipc_max_ports) | 195 | if (value == tn->net_id) | 
| 194 | return tipc_cfg_reply_none(); | ||
| 195 | if (value < 127 || value > 65535) | ||
| 196 | return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE | ||
| 197 | " (max ports must be 127-65535)"); | ||
| 198 | return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED | ||
| 199 | " (cannot change max ports while TIPC is active)"); | ||
| 200 | } | ||
| 201 | |||
| 202 | static struct sk_buff *cfg_set_netid(void) | ||
| 203 | { | ||
| 204 | u32 value; | ||
| 205 | |||
| 206 | if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_UNSIGNED)) | ||
| 207 | return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR); | ||
| 208 | value = ntohl(*(__be32 *)TLV_DATA(req_tlv_area)); | ||
| 209 | if (value == tipc_net_id) | ||
| 210 | return tipc_cfg_reply_none(); | 196 | return tipc_cfg_reply_none(); | 
| 211 | if (value < 1 || value > 9999) | 197 | if (value < 1 || value > 9999) | 
| 212 | return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE | 198 | return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE | 
| 213 | " (network id must be 1-9999)"); | 199 | " (network id must be 1-9999)"); | 
| 214 | if (tipc_own_addr) | 200 | if (tn->own_addr) | 
| 215 | return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED | 201 | return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED | 
| 216 | " (cannot change network id once TIPC has joined a network)"); | 202 | " (cannot change network id once TIPC has joined a network)"); | 
| 217 | tipc_net_id = value; | 203 | tn->net_id = value; | 
| 218 | return tipc_cfg_reply_none(); | 204 | return tipc_cfg_reply_none(); | 
| 219 | } | 205 | } | 
| 220 | 206 | ||
| 221 | struct sk_buff *tipc_cfg_do_cmd(u32 orig_node, u16 cmd, const void *request_area, | 207 | struct sk_buff *tipc_cfg_do_cmd(struct net *net, u32 orig_node, u16 cmd, | 
| 222 | int request_space, int reply_headroom) | 208 | const void *request_area, int request_space, | 
| 209 | int reply_headroom) | ||
| 223 | { | 210 | { | 
| 224 | struct sk_buff *rep_tlv_buf; | 211 | struct sk_buff *rep_tlv_buf; | 
| 212 | struct tipc_net *tn = net_generic(net, tipc_net_id); | ||
| 225 | 213 | ||
| 226 | rtnl_lock(); | 214 | rtnl_lock(); | 
| 227 | 215 | ||
| @@ -231,7 +219,7 @@ struct sk_buff *tipc_cfg_do_cmd(u32 orig_node, u16 cmd, const void *request_area | |||
| 231 | rep_headroom = reply_headroom; | 219 | rep_headroom = reply_headroom; | 
| 232 | 220 | ||
| 233 | /* Check command authorization */ | 221 | /* Check command authorization */ | 
| 234 | if (likely(in_own_node(orig_node))) { | 222 | if (likely(in_own_node(net, orig_node))) { | 
| 235 | /* command is permitted */ | 223 | /* command is permitted */ | 
| 236 | } else { | 224 | } else { | 
| 237 | rep_tlv_buf = tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED | 225 | rep_tlv_buf = tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED | 
| @@ -245,28 +233,33 @@ struct sk_buff *tipc_cfg_do_cmd(u32 orig_node, u16 cmd, const void *request_area | |||
| 245 | rep_tlv_buf = tipc_cfg_reply_none(); | 233 | rep_tlv_buf = tipc_cfg_reply_none(); | 
| 246 | break; | 234 | break; | 
| 247 | case TIPC_CMD_GET_NODES: | 235 | case TIPC_CMD_GET_NODES: | 
| 248 | rep_tlv_buf = tipc_node_get_nodes(req_tlv_area, req_tlv_space); | 236 | rep_tlv_buf = tipc_node_get_nodes(net, req_tlv_area, | 
| 237 | req_tlv_space); | ||
| 249 | break; | 238 | break; | 
| 250 | case TIPC_CMD_GET_LINKS: | 239 | case TIPC_CMD_GET_LINKS: | 
| 251 | rep_tlv_buf = tipc_node_get_links(req_tlv_area, req_tlv_space); | 240 | rep_tlv_buf = tipc_node_get_links(net, req_tlv_area, | 
| 241 | req_tlv_space); | ||
| 252 | break; | 242 | break; | 
| 253 | case TIPC_CMD_SHOW_LINK_STATS: | 243 | case TIPC_CMD_SHOW_LINK_STATS: | 
| 254 | rep_tlv_buf = tipc_link_cmd_show_stats(req_tlv_area, req_tlv_space); | 244 | rep_tlv_buf = tipc_link_cmd_show_stats(net, req_tlv_area, | 
| 245 | req_tlv_space); | ||
| 255 | break; | 246 | break; | 
| 256 | case TIPC_CMD_RESET_LINK_STATS: | 247 | case TIPC_CMD_RESET_LINK_STATS: | 
| 257 | rep_tlv_buf = tipc_link_cmd_reset_stats(req_tlv_area, req_tlv_space); | 248 | rep_tlv_buf = tipc_link_cmd_reset_stats(net, req_tlv_area, | 
| 249 | req_tlv_space); | ||
| 258 | break; | 250 | break; | 
| 259 | case TIPC_CMD_SHOW_NAME_TABLE: | 251 | case TIPC_CMD_SHOW_NAME_TABLE: | 
| 260 | rep_tlv_buf = tipc_nametbl_get(req_tlv_area, req_tlv_space); | 252 | rep_tlv_buf = tipc_nametbl_get(net, req_tlv_area, | 
| 253 | req_tlv_space); | ||
| 261 | break; | 254 | break; | 
| 262 | case TIPC_CMD_GET_BEARER_NAMES: | 255 | case TIPC_CMD_GET_BEARER_NAMES: | 
| 263 | rep_tlv_buf = tipc_bearer_get_names(); | 256 | rep_tlv_buf = tipc_bearer_get_names(net); | 
| 264 | break; | 257 | break; | 
| 265 | case TIPC_CMD_GET_MEDIA_NAMES: | 258 | case TIPC_CMD_GET_MEDIA_NAMES: | 
| 266 | rep_tlv_buf = tipc_media_get_names(); | 259 | rep_tlv_buf = tipc_media_get_names(); | 
| 267 | break; | 260 | break; | 
| 268 | case TIPC_CMD_SHOW_PORTS: | 261 | case TIPC_CMD_SHOW_PORTS: | 
| 269 | rep_tlv_buf = tipc_sk_socks_show(); | 262 | rep_tlv_buf = tipc_sk_socks_show(net); | 
| 270 | break; | 263 | break; | 
| 271 | case TIPC_CMD_SHOW_STATS: | 264 | case TIPC_CMD_SHOW_STATS: | 
| 272 | rep_tlv_buf = tipc_show_stats(); | 265 | rep_tlv_buf = tipc_show_stats(); | 
| @@ -274,28 +267,23 @@ struct sk_buff *tipc_cfg_do_cmd(u32 orig_node, u16 cmd, const void *request_area | |||
| 274 | case TIPC_CMD_SET_LINK_TOL: | 267 | case TIPC_CMD_SET_LINK_TOL: | 
| 275 | case TIPC_CMD_SET_LINK_PRI: | 268 | case TIPC_CMD_SET_LINK_PRI: | 
| 276 | case TIPC_CMD_SET_LINK_WINDOW: | 269 | case TIPC_CMD_SET_LINK_WINDOW: | 
| 277 | rep_tlv_buf = tipc_link_cmd_config(req_tlv_area, req_tlv_space, cmd); | 270 | rep_tlv_buf = tipc_link_cmd_config(net, req_tlv_area, | 
| 271 | req_tlv_space, cmd); | ||
| 278 | break; | 272 | break; | 
| 279 | case TIPC_CMD_ENABLE_BEARER: | 273 | case TIPC_CMD_ENABLE_BEARER: | 
| 280 | rep_tlv_buf = cfg_enable_bearer(); | 274 | rep_tlv_buf = cfg_enable_bearer(net); | 
| 281 | break; | 275 | break; | 
| 282 | case TIPC_CMD_DISABLE_BEARER: | 276 | case TIPC_CMD_DISABLE_BEARER: | 
| 283 | rep_tlv_buf = cfg_disable_bearer(); | 277 | rep_tlv_buf = cfg_disable_bearer(net); | 
| 284 | break; | 278 | break; | 
| 285 | case TIPC_CMD_SET_NODE_ADDR: | 279 | case TIPC_CMD_SET_NODE_ADDR: | 
| 286 | rep_tlv_buf = cfg_set_own_addr(); | 280 | rep_tlv_buf = cfg_set_own_addr(net); | 
| 287 | break; | ||
| 288 | case TIPC_CMD_SET_MAX_PORTS: | ||
| 289 | rep_tlv_buf = cfg_set_max_ports(); | ||
| 290 | break; | 281 | break; | 
| 291 | case TIPC_CMD_SET_NETID: | 282 | case TIPC_CMD_SET_NETID: | 
| 292 | rep_tlv_buf = cfg_set_netid(); | 283 | rep_tlv_buf = cfg_set_netid(net); | 
| 293 | break; | ||
| 294 | case TIPC_CMD_GET_MAX_PORTS: | ||
| 295 | rep_tlv_buf = tipc_cfg_reply_unsigned(tipc_max_ports); | ||
| 296 | break; | 284 | break; | 
| 297 | case TIPC_CMD_GET_NETID: | 285 | case TIPC_CMD_GET_NETID: | 
| 298 | rep_tlv_buf = tipc_cfg_reply_unsigned(tipc_net_id); | 286 | rep_tlv_buf = tipc_cfg_reply_unsigned(tn->net_id); | 
| 299 | break; | 287 | break; | 
| 300 | case TIPC_CMD_NOT_NET_ADMIN: | 288 | case TIPC_CMD_NOT_NET_ADMIN: | 
| 301 | rep_tlv_buf = | 289 | rep_tlv_buf = | 
| @@ -317,6 +305,8 @@ struct sk_buff *tipc_cfg_do_cmd(u32 orig_node, u16 cmd, const void *request_area | |||
| 317 | case TIPC_CMD_SET_REMOTE_MNG: | 305 | case TIPC_CMD_SET_REMOTE_MNG: | 
| 318 | case TIPC_CMD_GET_REMOTE_MNG: | 306 | case TIPC_CMD_GET_REMOTE_MNG: | 
| 319 | case TIPC_CMD_DUMP_LOG: | 307 | case TIPC_CMD_DUMP_LOG: | 
| 308 | case TIPC_CMD_SET_MAX_PORTS: | ||
| 309 | case TIPC_CMD_GET_MAX_PORTS: | ||
| 320 | rep_tlv_buf = tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED | 310 | rep_tlv_buf = tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED | 
| 321 | " (obsolete command)"); | 311 | " (obsolete command)"); | 
| 322 | break; | 312 | break; | 
