diff options
Diffstat (limited to 'net/tipc/node.c')
| -rw-r--r-- | net/tipc/node.c | 181 |
1 files changed, 96 insertions, 85 deletions
diff --git a/net/tipc/node.c b/net/tipc/node.c index 8d353ec77a66..ee5d33cfcf80 100644 --- a/net/tipc/node.c +++ b/net/tipc/node.c | |||
| @@ -40,17 +40,9 @@ | |||
| 40 | #include "name_distr.h" | 40 | #include "name_distr.h" |
| 41 | #include "socket.h" | 41 | #include "socket.h" |
| 42 | 42 | ||
| 43 | #define NODE_HTABLE_SIZE 512 | ||
| 44 | |||
| 45 | static void node_lost_contact(struct tipc_node *n_ptr); | 43 | static void node_lost_contact(struct tipc_node *n_ptr); |
| 46 | static void node_established_contact(struct tipc_node *n_ptr); | 44 | static void node_established_contact(struct tipc_node *n_ptr); |
| 47 | 45 | ||
| 48 | static struct hlist_head node_htable[NODE_HTABLE_SIZE]; | ||
| 49 | LIST_HEAD(tipc_node_list); | ||
| 50 | static u32 tipc_num_nodes; | ||
| 51 | static u32 tipc_num_links; | ||
| 52 | static DEFINE_SPINLOCK(node_list_lock); | ||
| 53 | |||
| 54 | struct tipc_sock_conn { | 46 | struct tipc_sock_conn { |
| 55 | u32 port; | 47 | u32 port; |
| 56 | u32 peer_port; | 48 | u32 peer_port; |
| @@ -78,15 +70,17 @@ static unsigned int tipc_hashfn(u32 addr) | |||
| 78 | /* | 70 | /* |
| 79 | * tipc_node_find - locate specified node object, if it exists | 71 | * tipc_node_find - locate specified node object, if it exists |
| 80 | */ | 72 | */ |
| 81 | struct tipc_node *tipc_node_find(u32 addr) | 73 | struct tipc_node *tipc_node_find(struct net *net, u32 addr) |
| 82 | { | 74 | { |
| 75 | struct tipc_net *tn = net_generic(net, tipc_net_id); | ||
| 83 | struct tipc_node *node; | 76 | struct tipc_node *node; |
| 84 | 77 | ||
| 85 | if (unlikely(!in_own_cluster_exact(addr))) | 78 | if (unlikely(!in_own_cluster_exact(net, addr))) |
| 86 | return NULL; | 79 | return NULL; |
| 87 | 80 | ||
| 88 | rcu_read_lock(); | 81 | rcu_read_lock(); |
| 89 | hlist_for_each_entry_rcu(node, &node_htable[tipc_hashfn(addr)], hash) { | 82 | hlist_for_each_entry_rcu(node, &tn->node_htable[tipc_hashfn(addr)], |
| 83 | hash) { | ||
| 90 | if (node->addr == addr) { | 84 | if (node->addr == addr) { |
| 91 | rcu_read_unlock(); | 85 | rcu_read_unlock(); |
| 92 | return node; | 86 | return node; |
| @@ -96,20 +90,22 @@ struct tipc_node *tipc_node_find(u32 addr) | |||
| 96 | return NULL; | 90 | return NULL; |
| 97 | } | 91 | } |
| 98 | 92 | ||
| 99 | struct tipc_node *tipc_node_create(u32 addr) | 93 | struct tipc_node *tipc_node_create(struct net *net, u32 addr) |
| 100 | { | 94 | { |
| 95 | struct tipc_net *tn = net_generic(net, tipc_net_id); | ||
| 101 | struct tipc_node *n_ptr, *temp_node; | 96 | struct tipc_node *n_ptr, *temp_node; |
| 102 | 97 | ||
| 103 | spin_lock_bh(&node_list_lock); | 98 | spin_lock_bh(&tn->node_list_lock); |
| 104 | 99 | ||
| 105 | n_ptr = kzalloc(sizeof(*n_ptr), GFP_ATOMIC); | 100 | n_ptr = kzalloc(sizeof(*n_ptr), GFP_ATOMIC); |
| 106 | if (!n_ptr) { | 101 | if (!n_ptr) { |
| 107 | spin_unlock_bh(&node_list_lock); | 102 | spin_unlock_bh(&tn->node_list_lock); |
| 108 | pr_warn("Node creation failed, no memory\n"); | 103 | pr_warn("Node creation failed, no memory\n"); |
| 109 | return NULL; | 104 | return NULL; |
| 110 | } | 105 | } |
| 111 | 106 | ||
| 112 | n_ptr->addr = addr; | 107 | n_ptr->addr = addr; |
| 108 | n_ptr->net = net; | ||
| 113 | spin_lock_init(&n_ptr->lock); | 109 | spin_lock_init(&n_ptr->lock); |
| 114 | INIT_HLIST_NODE(&n_ptr->hash); | 110 | INIT_HLIST_NODE(&n_ptr->hash); |
| 115 | INIT_LIST_HEAD(&n_ptr->list); | 111 | INIT_LIST_HEAD(&n_ptr->list); |
| @@ -118,9 +114,9 @@ struct tipc_node *tipc_node_create(u32 addr) | |||
| 118 | skb_queue_head_init(&n_ptr->waiting_sks); | 114 | skb_queue_head_init(&n_ptr->waiting_sks); |
| 119 | __skb_queue_head_init(&n_ptr->bclink.deferred_queue); | 115 | __skb_queue_head_init(&n_ptr->bclink.deferred_queue); |
| 120 | 116 | ||
| 121 | hlist_add_head_rcu(&n_ptr->hash, &node_htable[tipc_hashfn(addr)]); | 117 | hlist_add_head_rcu(&n_ptr->hash, &tn->node_htable[tipc_hashfn(addr)]); |
| 122 | 118 | ||
| 123 | list_for_each_entry_rcu(temp_node, &tipc_node_list, list) { | 119 | list_for_each_entry_rcu(temp_node, &tn->node_list, list) { |
| 124 | if (n_ptr->addr < temp_node->addr) | 120 | if (n_ptr->addr < temp_node->addr) |
| 125 | break; | 121 | break; |
| 126 | } | 122 | } |
| @@ -128,40 +124,41 @@ struct tipc_node *tipc_node_create(u32 addr) | |||
| 128 | n_ptr->action_flags = TIPC_WAIT_PEER_LINKS_DOWN; | 124 | n_ptr->action_flags = TIPC_WAIT_PEER_LINKS_DOWN; |
| 129 | n_ptr->signature = INVALID_NODE_SIG; | 125 | n_ptr->signature = INVALID_NODE_SIG; |
| 130 | 126 | ||
| 131 | tipc_num_nodes++; | 127 | tn->num_nodes++; |
| 132 | 128 | ||
| 133 | spin_unlock_bh(&node_list_lock); | 129 | spin_unlock_bh(&tn->node_list_lock); |
| 134 | return n_ptr; | 130 | return n_ptr; |
| 135 | } | 131 | } |
| 136 | 132 | ||
| 137 | static void tipc_node_delete(struct tipc_node *n_ptr) | 133 | static void tipc_node_delete(struct tipc_net *tn, struct tipc_node *n_ptr) |
| 138 | { | 134 | { |
| 139 | list_del_rcu(&n_ptr->list); | 135 | list_del_rcu(&n_ptr->list); |
| 140 | hlist_del_rcu(&n_ptr->hash); | 136 | hlist_del_rcu(&n_ptr->hash); |
| 141 | kfree_rcu(n_ptr, rcu); | 137 | kfree_rcu(n_ptr, rcu); |
| 142 | 138 | ||
| 143 | tipc_num_nodes--; | 139 | tn->num_nodes--; |
| 144 | } | 140 | } |
| 145 | 141 | ||
| 146 | void tipc_node_stop(void) | 142 | void tipc_node_stop(struct net *net) |
| 147 | { | 143 | { |
| 144 | struct tipc_net *tn = net_generic(net, tipc_net_id); | ||
| 148 | struct tipc_node *node, *t_node; | 145 | struct tipc_node *node, *t_node; |
| 149 | 146 | ||
| 150 | spin_lock_bh(&node_list_lock); | 147 | spin_lock_bh(&tn->node_list_lock); |
| 151 | list_for_each_entry_safe(node, t_node, &tipc_node_list, list) | 148 | list_for_each_entry_safe(node, t_node, &tn->node_list, list) |
| 152 | tipc_node_delete(node); | 149 | tipc_node_delete(tn, node); |
| 153 | spin_unlock_bh(&node_list_lock); | 150 | spin_unlock_bh(&tn->node_list_lock); |
| 154 | } | 151 | } |
| 155 | 152 | ||
| 156 | int tipc_node_add_conn(u32 dnode, u32 port, u32 peer_port) | 153 | int tipc_node_add_conn(struct net *net, u32 dnode, u32 port, u32 peer_port) |
| 157 | { | 154 | { |
| 158 | struct tipc_node *node; | 155 | struct tipc_node *node; |
| 159 | struct tipc_sock_conn *conn; | 156 | struct tipc_sock_conn *conn; |
| 160 | 157 | ||
| 161 | if (in_own_node(dnode)) | 158 | if (in_own_node(net, dnode)) |
| 162 | return 0; | 159 | return 0; |
| 163 | 160 | ||
| 164 | node = tipc_node_find(dnode); | 161 | node = tipc_node_find(net, dnode); |
| 165 | if (!node) { | 162 | if (!node) { |
| 166 | pr_warn("Connecting sock to node 0x%x failed\n", dnode); | 163 | pr_warn("Connecting sock to node 0x%x failed\n", dnode); |
| 167 | return -EHOSTUNREACH; | 164 | return -EHOSTUNREACH; |
| @@ -179,15 +176,15 @@ int tipc_node_add_conn(u32 dnode, u32 port, u32 peer_port) | |||
| 179 | return 0; | 176 | return 0; |
| 180 | } | 177 | } |
| 181 | 178 | ||
| 182 | void tipc_node_remove_conn(u32 dnode, u32 port) | 179 | void tipc_node_remove_conn(struct net *net, u32 dnode, u32 port) |
| 183 | { | 180 | { |
| 184 | struct tipc_node *node; | 181 | struct tipc_node *node; |
| 185 | struct tipc_sock_conn *conn, *safe; | 182 | struct tipc_sock_conn *conn, *safe; |
| 186 | 183 | ||
| 187 | if (in_own_node(dnode)) | 184 | if (in_own_node(net, dnode)) |
| 188 | return; | 185 | return; |
| 189 | 186 | ||
| 190 | node = tipc_node_find(dnode); | 187 | node = tipc_node_find(net, dnode); |
| 191 | if (!node) | 188 | if (!node) |
| 192 | return; | 189 | return; |
| 193 | 190 | ||
| @@ -201,18 +198,20 @@ void tipc_node_remove_conn(u32 dnode, u32 port) | |||
| 201 | tipc_node_unlock(node); | 198 | tipc_node_unlock(node); |
| 202 | } | 199 | } |
| 203 | 200 | ||
| 204 | void tipc_node_abort_sock_conns(struct list_head *conns) | 201 | void tipc_node_abort_sock_conns(struct net *net, struct list_head *conns) |
| 205 | { | 202 | { |
| 203 | struct tipc_net *tn = net_generic(net, tipc_net_id); | ||
| 206 | struct tipc_sock_conn *conn, *safe; | 204 | struct tipc_sock_conn *conn, *safe; |
| 207 | struct sk_buff *buf; | 205 | struct sk_buff *buf; |
| 208 | 206 | ||
| 209 | list_for_each_entry_safe(conn, safe, conns, list) { | 207 | list_for_each_entry_safe(conn, safe, conns, list) { |
| 210 | buf = tipc_msg_create(TIPC_CRITICAL_IMPORTANCE, TIPC_CONN_MSG, | 208 | buf = tipc_msg_create(net, TIPC_CRITICAL_IMPORTANCE, |
| 211 | SHORT_H_SIZE, 0, tipc_own_addr, | 209 | TIPC_CONN_MSG, SHORT_H_SIZE, 0, |
| 212 | conn->peer_node, conn->port, | 210 | tn->own_addr, conn->peer_node, |
| 213 | conn->peer_port, TIPC_ERR_NO_NODE); | 211 | conn->port, conn->peer_port, |
| 212 | TIPC_ERR_NO_NODE); | ||
| 214 | if (likely(buf)) | 213 | if (likely(buf)) |
| 215 | tipc_sk_rcv(buf); | 214 | tipc_sk_rcv(net, buf); |
| 216 | list_del(&conn->list); | 215 | list_del(&conn->list); |
| 217 | kfree(conn); | 216 | kfree(conn); |
| 218 | } | 217 | } |
| @@ -231,8 +230,8 @@ void tipc_node_link_up(struct tipc_node *n_ptr, struct tipc_link *l_ptr) | |||
| 231 | n_ptr->action_flags |= TIPC_NOTIFY_LINK_UP; | 230 | n_ptr->action_flags |= TIPC_NOTIFY_LINK_UP; |
| 232 | n_ptr->link_id = l_ptr->peer_bearer_id << 16 | l_ptr->bearer_id; | 231 | n_ptr->link_id = l_ptr->peer_bearer_id << 16 | l_ptr->bearer_id; |
| 233 | 232 | ||
| 234 | pr_info("Established link <%s> on network plane %c\n", | 233 | pr_debug("Established link <%s> on network plane %c\n", |
| 235 | l_ptr->name, l_ptr->net_plane); | 234 | l_ptr->name, l_ptr->net_plane); |
| 236 | 235 | ||
| 237 | if (!active[0]) { | 236 | if (!active[0]) { |
| 238 | active[0] = active[1] = l_ptr; | 237 | active[0] = active[1] = l_ptr; |
| @@ -240,7 +239,7 @@ void tipc_node_link_up(struct tipc_node *n_ptr, struct tipc_link *l_ptr) | |||
| 240 | goto exit; | 239 | goto exit; |
| 241 | } | 240 | } |
| 242 | if (l_ptr->priority < active[0]->priority) { | 241 | if (l_ptr->priority < active[0]->priority) { |
| 243 | pr_info("New link <%s> becomes standby\n", l_ptr->name); | 242 | pr_debug("New link <%s> becomes standby\n", l_ptr->name); |
| 244 | goto exit; | 243 | goto exit; |
| 245 | } | 244 | } |
| 246 | tipc_link_dup_queue_xmit(active[0], l_ptr); | 245 | tipc_link_dup_queue_xmit(active[0], l_ptr); |
| @@ -248,9 +247,9 @@ void tipc_node_link_up(struct tipc_node *n_ptr, struct tipc_link *l_ptr) | |||
| 248 | active[0] = l_ptr; | 247 | active[0] = l_ptr; |
| 249 | goto exit; | 248 | goto exit; |
| 250 | } | 249 | } |
| 251 | pr_info("Old link <%s> becomes standby\n", active[0]->name); | 250 | pr_debug("Old link <%s> becomes standby\n", active[0]->name); |
| 252 | if (active[1] != active[0]) | 251 | if (active[1] != active[0]) |
| 253 | pr_info("Old link <%s> becomes standby\n", active[1]->name); | 252 | pr_debug("Old link <%s> becomes standby\n", active[1]->name); |
| 254 | active[0] = active[1] = l_ptr; | 253 | active[0] = active[1] = l_ptr; |
| 255 | exit: | 254 | exit: |
| 256 | /* Leave room for changeover header when returning 'mtu' to users: */ | 255 | /* Leave room for changeover header when returning 'mtu' to users: */ |
| @@ -290,6 +289,7 @@ static void node_select_active_links(struct tipc_node *n_ptr) | |||
| 290 | */ | 289 | */ |
| 291 | void tipc_node_link_down(struct tipc_node *n_ptr, struct tipc_link *l_ptr) | 290 | void tipc_node_link_down(struct tipc_node *n_ptr, struct tipc_link *l_ptr) |
| 292 | { | 291 | { |
| 292 | struct tipc_net *tn = net_generic(n_ptr->net, tipc_net_id); | ||
| 293 | struct tipc_link **active; | 293 | struct tipc_link **active; |
| 294 | 294 | ||
| 295 | n_ptr->working_links--; | 295 | n_ptr->working_links--; |
| @@ -297,12 +297,12 @@ void tipc_node_link_down(struct tipc_node *n_ptr, struct tipc_link *l_ptr) | |||
| 297 | n_ptr->link_id = l_ptr->peer_bearer_id << 16 | l_ptr->bearer_id; | 297 | n_ptr->link_id = l_ptr->peer_bearer_id << 16 | l_ptr->bearer_id; |
| 298 | 298 | ||
| 299 | if (!tipc_link_is_active(l_ptr)) { | 299 | if (!tipc_link_is_active(l_ptr)) { |
| 300 | pr_info("Lost standby link <%s> on network plane %c\n", | 300 | pr_debug("Lost standby link <%s> on network plane %c\n", |
| 301 | l_ptr->name, l_ptr->net_plane); | 301 | l_ptr->name, l_ptr->net_plane); |
| 302 | return; | 302 | return; |
| 303 | } | 303 | } |
| 304 | pr_info("Lost link <%s> on network plane %c\n", | 304 | pr_debug("Lost link <%s> on network plane %c\n", |
| 305 | l_ptr->name, l_ptr->net_plane); | 305 | l_ptr->name, l_ptr->net_plane); |
| 306 | 306 | ||
| 307 | active = &n_ptr->active_links[0]; | 307 | active = &n_ptr->active_links[0]; |
| 308 | if (active[0] == l_ptr) | 308 | if (active[0] == l_ptr) |
| @@ -324,7 +324,7 @@ void tipc_node_link_down(struct tipc_node *n_ptr, struct tipc_link *l_ptr) | |||
| 324 | } | 324 | } |
| 325 | 325 | ||
| 326 | /* Loopback link went down? No fragmentation needed from now on. */ | 326 | /* Loopback link went down? No fragmentation needed from now on. */ |
| 327 | if (n_ptr->addr == tipc_own_addr) { | 327 | if (n_ptr->addr == tn->own_addr) { |
| 328 | n_ptr->act_mtus[0] = MAX_MSG_SIZE; | 328 | n_ptr->act_mtus[0] = MAX_MSG_SIZE; |
| 329 | n_ptr->act_mtus[1] = MAX_MSG_SIZE; | 329 | n_ptr->act_mtus[1] = MAX_MSG_SIZE; |
| 330 | } | 330 | } |
| @@ -342,24 +342,27 @@ int tipc_node_is_up(struct tipc_node *n_ptr) | |||
| 342 | 342 | ||
| 343 | void tipc_node_attach_link(struct tipc_node *n_ptr, struct tipc_link *l_ptr) | 343 | void tipc_node_attach_link(struct tipc_node *n_ptr, struct tipc_link *l_ptr) |
| 344 | { | 344 | { |
| 345 | struct tipc_net *tn = net_generic(n_ptr->net, tipc_net_id); | ||
| 346 | |||
| 345 | n_ptr->links[l_ptr->bearer_id] = l_ptr; | 347 | n_ptr->links[l_ptr->bearer_id] = l_ptr; |
| 346 | spin_lock_bh(&node_list_lock); | 348 | spin_lock_bh(&tn->node_list_lock); |
| 347 | tipc_num_links++; | 349 | tn->num_links++; |
| 348 | spin_unlock_bh(&node_list_lock); | 350 | spin_unlock_bh(&tn->node_list_lock); |
| 349 | n_ptr->link_cnt++; | 351 | n_ptr->link_cnt++; |
| 350 | } | 352 | } |
| 351 | 353 | ||
| 352 | void tipc_node_detach_link(struct tipc_node *n_ptr, struct tipc_link *l_ptr) | 354 | void tipc_node_detach_link(struct tipc_node *n_ptr, struct tipc_link *l_ptr) |
| 353 | { | 355 | { |
| 356 | struct tipc_net *tn = net_generic(n_ptr->net, tipc_net_id); | ||
| 354 | int i; | 357 | int i; |
| 355 | 358 | ||
| 356 | for (i = 0; i < MAX_BEARERS; i++) { | 359 | for (i = 0; i < MAX_BEARERS; i++) { |
| 357 | if (l_ptr != n_ptr->links[i]) | 360 | if (l_ptr != n_ptr->links[i]) |
| 358 | continue; | 361 | continue; |
| 359 | n_ptr->links[i] = NULL; | 362 | n_ptr->links[i] = NULL; |
| 360 | spin_lock_bh(&node_list_lock); | 363 | spin_lock_bh(&tn->node_list_lock); |
| 361 | tipc_num_links--; | 364 | tn->num_links--; |
| 362 | spin_unlock_bh(&node_list_lock); | 365 | spin_unlock_bh(&tn->node_list_lock); |
| 363 | n_ptr->link_cnt--; | 366 | n_ptr->link_cnt--; |
| 364 | } | 367 | } |
| 365 | } | 368 | } |
| @@ -368,8 +371,8 @@ static void node_established_contact(struct tipc_node *n_ptr) | |||
| 368 | { | 371 | { |
| 369 | n_ptr->action_flags |= TIPC_NOTIFY_NODE_UP; | 372 | n_ptr->action_flags |= TIPC_NOTIFY_NODE_UP; |
| 370 | n_ptr->bclink.oos_state = 0; | 373 | n_ptr->bclink.oos_state = 0; |
| 371 | n_ptr->bclink.acked = tipc_bclink_get_last_sent(); | 374 | n_ptr->bclink.acked = tipc_bclink_get_last_sent(n_ptr->net); |
| 372 | tipc_bclink_add_node(n_ptr->addr); | 375 | tipc_bclink_add_node(n_ptr->net, n_ptr->addr); |
| 373 | } | 376 | } |
| 374 | 377 | ||
| 375 | static void node_lost_contact(struct tipc_node *n_ptr) | 378 | static void node_lost_contact(struct tipc_node *n_ptr) |
| @@ -377,8 +380,8 @@ static void node_lost_contact(struct tipc_node *n_ptr) | |||
| 377 | char addr_string[16]; | 380 | char addr_string[16]; |
| 378 | u32 i; | 381 | u32 i; |
| 379 | 382 | ||
| 380 | pr_info("Lost contact with %s\n", | 383 | pr_debug("Lost contact with %s\n", |
| 381 | tipc_addr_string_fill(addr_string, n_ptr->addr)); | 384 | tipc_addr_string_fill(addr_string, n_ptr->addr)); |
| 382 | 385 | ||
| 383 | /* Flush broadcast link info associated with lost node */ | 386 | /* Flush broadcast link info associated with lost node */ |
| 384 | if (n_ptr->bclink.recv_permitted) { | 387 | if (n_ptr->bclink.recv_permitted) { |
| @@ -389,7 +392,7 @@ static void node_lost_contact(struct tipc_node *n_ptr) | |||
| 389 | n_ptr->bclink.reasm_buf = NULL; | 392 | n_ptr->bclink.reasm_buf = NULL; |
| 390 | } | 393 | } |
| 391 | 394 | ||
| 392 | tipc_bclink_remove_node(n_ptr->addr); | 395 | tipc_bclink_remove_node(n_ptr->net, n_ptr->addr); |
| 393 | tipc_bclink_acknowledge(n_ptr, INVALID_LINK_SEQ); | 396 | tipc_bclink_acknowledge(n_ptr, INVALID_LINK_SEQ); |
| 394 | 397 | ||
| 395 | n_ptr->bclink.recv_permitted = false; | 398 | n_ptr->bclink.recv_permitted = false; |
| @@ -414,8 +417,10 @@ static void node_lost_contact(struct tipc_node *n_ptr) | |||
| 414 | TIPC_NOTIFY_NODE_DOWN; | 417 | TIPC_NOTIFY_NODE_DOWN; |
| 415 | } | 418 | } |
| 416 | 419 | ||
| 417 | struct sk_buff *tipc_node_get_nodes(const void *req_tlv_area, int req_tlv_space) | 420 | struct sk_buff *tipc_node_get_nodes(struct net *net, const void *req_tlv_area, |
| 421 | int req_tlv_space) | ||
| 418 | { | 422 | { |
| 423 | struct tipc_net *tn = net_generic(net, tipc_net_id); | ||
| 419 | u32 domain; | 424 | u32 domain; |
| 420 | struct sk_buff *buf; | 425 | struct sk_buff *buf; |
| 421 | struct tipc_node *n_ptr; | 426 | struct tipc_node *n_ptr; |
| @@ -430,20 +435,20 @@ struct sk_buff *tipc_node_get_nodes(const void *req_tlv_area, int req_tlv_space) | |||
| 430 | return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE | 435 | return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE |
| 431 | " (network address)"); | 436 | " (network address)"); |
| 432 | 437 | ||
| 433 | spin_lock_bh(&node_list_lock); | 438 | spin_lock_bh(&tn->node_list_lock); |
| 434 | if (!tipc_num_nodes) { | 439 | if (!tn->num_nodes) { |
| 435 | spin_unlock_bh(&node_list_lock); | 440 | spin_unlock_bh(&tn->node_list_lock); |
| 436 | return tipc_cfg_reply_none(); | 441 | return tipc_cfg_reply_none(); |
| 437 | } | 442 | } |
| 438 | 443 | ||
| 439 | /* For now, get space for all other nodes */ | 444 | /* For now, get space for all other nodes */ |
| 440 | payload_size = TLV_SPACE(sizeof(node_info)) * tipc_num_nodes; | 445 | payload_size = TLV_SPACE(sizeof(node_info)) * tn->num_nodes; |
| 441 | if (payload_size > 32768u) { | 446 | if (payload_size > 32768u) { |
| 442 | spin_unlock_bh(&node_list_lock); | 447 | spin_unlock_bh(&tn->node_list_lock); |
| 443 | return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED | 448 | return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED |
| 444 | " (too many nodes)"); | 449 | " (too many nodes)"); |
| 445 | } | 450 | } |
| 446 | spin_unlock_bh(&node_list_lock); | 451 | spin_unlock_bh(&tn->node_list_lock); |
| 447 | 452 | ||
| 448 | buf = tipc_cfg_reply_alloc(payload_size); | 453 | buf = tipc_cfg_reply_alloc(payload_size); |
| 449 | if (!buf) | 454 | if (!buf) |
| @@ -451,7 +456,7 @@ struct sk_buff *tipc_node_get_nodes(const void *req_tlv_area, int req_tlv_space) | |||
| 451 | 456 | ||
| 452 | /* Add TLVs for all nodes in scope */ | 457 | /* Add TLVs for all nodes in scope */ |
| 453 | rcu_read_lock(); | 458 | rcu_read_lock(); |
| 454 | list_for_each_entry_rcu(n_ptr, &tipc_node_list, list) { | 459 | list_for_each_entry_rcu(n_ptr, &tn->node_list, list) { |
| 455 | if (!tipc_in_scope(domain, n_ptr->addr)) | 460 | if (!tipc_in_scope(domain, n_ptr->addr)) |
| 456 | continue; | 461 | continue; |
| 457 | node_info.addr = htonl(n_ptr->addr); | 462 | node_info.addr = htonl(n_ptr->addr); |
| @@ -463,8 +468,10 @@ struct sk_buff *tipc_node_get_nodes(const void *req_tlv_area, int req_tlv_space) | |||
| 463 | return buf; | 468 | return buf; |
| 464 | } | 469 | } |
| 465 | 470 | ||
| 466 | struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space) | 471 | struct sk_buff *tipc_node_get_links(struct net *net, const void *req_tlv_area, |
| 472 | int req_tlv_space) | ||
| 467 | { | 473 | { |
| 474 | struct tipc_net *tn = net_generic(net, tipc_net_id); | ||
| 468 | u32 domain; | 475 | u32 domain; |
| 469 | struct sk_buff *buf; | 476 | struct sk_buff *buf; |
| 470 | struct tipc_node *n_ptr; | 477 | struct tipc_node *n_ptr; |
| @@ -479,32 +486,32 @@ struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space) | |||
| 479 | return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE | 486 | return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE |
| 480 | " (network address)"); | 487 | " (network address)"); |
| 481 | 488 | ||
| 482 | if (!tipc_own_addr) | 489 | if (!tn->own_addr) |
| 483 | return tipc_cfg_reply_none(); | 490 | return tipc_cfg_reply_none(); |
| 484 | 491 | ||
| 485 | spin_lock_bh(&node_list_lock); | 492 | spin_lock_bh(&tn->node_list_lock); |
| 486 | /* Get space for all unicast links + broadcast link */ | 493 | /* Get space for all unicast links + broadcast link */ |
| 487 | payload_size = TLV_SPACE((sizeof(link_info)) * (tipc_num_links + 1)); | 494 | payload_size = TLV_SPACE((sizeof(link_info)) * (tn->num_links + 1)); |
| 488 | if (payload_size > 32768u) { | 495 | if (payload_size > 32768u) { |
| 489 | spin_unlock_bh(&node_list_lock); | 496 | spin_unlock_bh(&tn->node_list_lock); |
| 490 | return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED | 497 | return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED |
| 491 | " (too many links)"); | 498 | " (too many links)"); |
| 492 | } | 499 | } |
| 493 | spin_unlock_bh(&node_list_lock); | 500 | spin_unlock_bh(&tn->node_list_lock); |
| 494 | 501 | ||
| 495 | buf = tipc_cfg_reply_alloc(payload_size); | 502 | buf = tipc_cfg_reply_alloc(payload_size); |
| 496 | if (!buf) | 503 | if (!buf) |
| 497 | return NULL; | 504 | return NULL; |
| 498 | 505 | ||
| 499 | /* Add TLV for broadcast link */ | 506 | /* Add TLV for broadcast link */ |
| 500 | link_info.dest = htonl(tipc_cluster_mask(tipc_own_addr)); | 507 | link_info.dest = htonl(tipc_cluster_mask(tn->own_addr)); |
| 501 | link_info.up = htonl(1); | 508 | link_info.up = htonl(1); |
| 502 | strlcpy(link_info.str, tipc_bclink_name, TIPC_MAX_LINK_NAME); | 509 | strlcpy(link_info.str, tipc_bclink_name, TIPC_MAX_LINK_NAME); |
| 503 | tipc_cfg_append_tlv(buf, TIPC_TLV_LINK_INFO, &link_info, sizeof(link_info)); | 510 | tipc_cfg_append_tlv(buf, TIPC_TLV_LINK_INFO, &link_info, sizeof(link_info)); |
| 504 | 511 | ||
| 505 | /* Add TLVs for any other links in scope */ | 512 | /* Add TLVs for any other links in scope */ |
| 506 | rcu_read_lock(); | 513 | rcu_read_lock(); |
| 507 | list_for_each_entry_rcu(n_ptr, &tipc_node_list, list) { | 514 | list_for_each_entry_rcu(n_ptr, &tn->node_list, list) { |
| 508 | u32 i; | 515 | u32 i; |
| 509 | 516 | ||
| 510 | if (!tipc_in_scope(domain, n_ptr->addr)) | 517 | if (!tipc_in_scope(domain, n_ptr->addr)) |
| @@ -534,10 +541,11 @@ struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space) | |||
| 534 | * | 541 | * |
| 535 | * Returns 0 on success | 542 | * Returns 0 on success |
| 536 | */ | 543 | */ |
| 537 | int tipc_node_get_linkname(u32 bearer_id, u32 addr, char *linkname, size_t len) | 544 | int tipc_node_get_linkname(struct net *net, u32 bearer_id, u32 addr, |
| 545 | char *linkname, size_t len) | ||
| 538 | { | 546 | { |
| 539 | struct tipc_link *link; | 547 | struct tipc_link *link; |
| 540 | struct tipc_node *node = tipc_node_find(addr); | 548 | struct tipc_node *node = tipc_node_find(net, addr); |
| 541 | 549 | ||
| 542 | if ((bearer_id >= MAX_BEARERS) || !node) | 550 | if ((bearer_id >= MAX_BEARERS) || !node) |
| 543 | return -EINVAL; | 551 | return -EINVAL; |
| @@ -554,6 +562,7 @@ int tipc_node_get_linkname(u32 bearer_id, u32 addr, char *linkname, size_t len) | |||
| 554 | 562 | ||
| 555 | void tipc_node_unlock(struct tipc_node *node) | 563 | void tipc_node_unlock(struct tipc_node *node) |
| 556 | { | 564 | { |
| 565 | struct net *net = node->net; | ||
| 557 | LIST_HEAD(nsub_list); | 566 | LIST_HEAD(nsub_list); |
| 558 | LIST_HEAD(conn_sks); | 567 | LIST_HEAD(conn_sks); |
| 559 | struct sk_buff_head waiting_sks; | 568 | struct sk_buff_head waiting_sks; |
| @@ -585,26 +594,26 @@ void tipc_node_unlock(struct tipc_node *node) | |||
| 585 | spin_unlock_bh(&node->lock); | 594 | spin_unlock_bh(&node->lock); |
| 586 | 595 | ||
| 587 | while (!skb_queue_empty(&waiting_sks)) | 596 | while (!skb_queue_empty(&waiting_sks)) |
| 588 | tipc_sk_rcv(__skb_dequeue(&waiting_sks)); | 597 | tipc_sk_rcv(net, __skb_dequeue(&waiting_sks)); |
| 589 | 598 | ||
| 590 | if (!list_empty(&conn_sks)) | 599 | if (!list_empty(&conn_sks)) |
| 591 | tipc_node_abort_sock_conns(&conn_sks); | 600 | tipc_node_abort_sock_conns(net, &conn_sks); |
| 592 | 601 | ||
| 593 | if (!list_empty(&nsub_list)) | 602 | if (!list_empty(&nsub_list)) |
| 594 | tipc_publ_notify(&nsub_list, addr); | 603 | tipc_publ_notify(net, &nsub_list, addr); |
| 595 | 604 | ||
| 596 | if (flags & TIPC_WAKEUP_BCAST_USERS) | 605 | if (flags & TIPC_WAKEUP_BCAST_USERS) |
| 597 | tipc_bclink_wakeup_users(); | 606 | tipc_bclink_wakeup_users(net); |
| 598 | 607 | ||
| 599 | if (flags & TIPC_NOTIFY_NODE_UP) | 608 | if (flags & TIPC_NOTIFY_NODE_UP) |
| 600 | tipc_named_node_up(addr); | 609 | tipc_named_node_up(net, addr); |
| 601 | 610 | ||
| 602 | if (flags & TIPC_NOTIFY_LINK_UP) | 611 | if (flags & TIPC_NOTIFY_LINK_UP) |
| 603 | tipc_nametbl_publish(TIPC_LINK_STATE, addr, addr, | 612 | tipc_nametbl_publish(net, TIPC_LINK_STATE, addr, addr, |
| 604 | TIPC_NODE_SCOPE, link_id, addr); | 613 | TIPC_NODE_SCOPE, link_id, addr); |
| 605 | 614 | ||
| 606 | if (flags & TIPC_NOTIFY_LINK_DOWN) | 615 | if (flags & TIPC_NOTIFY_LINK_DOWN) |
| 607 | tipc_nametbl_withdraw(TIPC_LINK_STATE, addr, | 616 | tipc_nametbl_withdraw(net, TIPC_LINK_STATE, addr, |
| 608 | link_id, addr); | 617 | link_id, addr); |
| 609 | } | 618 | } |
| 610 | 619 | ||
| @@ -645,6 +654,8 @@ msg_full: | |||
| 645 | int tipc_nl_node_dump(struct sk_buff *skb, struct netlink_callback *cb) | 654 | int tipc_nl_node_dump(struct sk_buff *skb, struct netlink_callback *cb) |
| 646 | { | 655 | { |
| 647 | int err; | 656 | int err; |
| 657 | struct net *net = sock_net(skb->sk); | ||
| 658 | struct tipc_net *tn = net_generic(net, tipc_net_id); | ||
| 648 | int done = cb->args[0]; | 659 | int done = cb->args[0]; |
| 649 | int last_addr = cb->args[1]; | 660 | int last_addr = cb->args[1]; |
| 650 | struct tipc_node *node; | 661 | struct tipc_node *node; |
| @@ -659,7 +670,7 @@ int tipc_nl_node_dump(struct sk_buff *skb, struct netlink_callback *cb) | |||
| 659 | 670 | ||
| 660 | rcu_read_lock(); | 671 | rcu_read_lock(); |
| 661 | 672 | ||
| 662 | if (last_addr && !tipc_node_find(last_addr)) { | 673 | if (last_addr && !tipc_node_find(net, last_addr)) { |
| 663 | rcu_read_unlock(); | 674 | rcu_read_unlock(); |
| 664 | /* We never set seq or call nl_dump_check_consistent() this | 675 | /* We never set seq or call nl_dump_check_consistent() this |
| 665 | * means that setting prev_seq here will cause the consistence | 676 | * means that setting prev_seq here will cause the consistence |
| @@ -671,7 +682,7 @@ int tipc_nl_node_dump(struct sk_buff *skb, struct netlink_callback *cb) | |||
| 671 | return -EPIPE; | 682 | return -EPIPE; |
| 672 | } | 683 | } |
| 673 | 684 | ||
| 674 | list_for_each_entry_rcu(node, &tipc_node_list, list) { | 685 | list_for_each_entry_rcu(node, &tn->node_list, list) { |
| 675 | if (last_addr) { | 686 | if (last_addr) { |
| 676 | if (node->addr == last_addr) | 687 | if (node->addr == last_addr) |
| 677 | last_addr = 0; | 688 | last_addr = 0; |
