diff options
| author | Ying Xue <ying.xue@windriver.com> | 2015-01-09 02:27:05 -0500 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2015-01-12 16:24:32 -0500 |
| commit | f2f9800d4955a96d92896841d8ba9b04201deaa1 (patch) | |
| tree | 3b817800cfd8fcb2de6d5a3d7eb4fff972fba681 | |
| parent | c93d3baa24095887005647984cff5de8c63d3611 (diff) | |
tipc: make tipc node table aware of net namespace
Global variables associated with node table are below:
- node table list (node_htable)
- node hash table list (tipc_node_list)
- node table lock (node_list_lock)
- node number counter (tipc_num_nodes)
- node link number counter (tipc_num_links)
To make node table support namespace, above global variables must be
moved to tipc_net structure in order to keep secret for different
namespaces. As a consequence, these variables are allocated and
initialized when namespace is created, and deallocated when namespace
is destroyed. After the change, functions associated with these
variables have to utilize a namespace pointer to access them. So
adding namespace pointer as a parameter of these functions is the
major change made in the commit.
Signed-off-by: Ying Xue <ying.xue@windriver.com>
Tested-by: Tero Aho <Tero.Aho@coriant.com>
Reviewed-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
| -rw-r--r-- | net/tipc/addr.h | 2 | ||||
| -rw-r--r-- | net/tipc/bcast.c | 24 | ||||
| -rw-r--r-- | net/tipc/bcast.h | 4 | ||||
| -rw-r--r-- | net/tipc/bearer.c | 25 | ||||
| -rw-r--r-- | net/tipc/bearer.h | 4 | ||||
| -rw-r--r-- | net/tipc/config.c | 21 | ||||
| -rw-r--r-- | net/tipc/core.c | 4 | ||||
| -rw-r--r-- | net/tipc/core.h | 9 | ||||
| -rw-r--r-- | net/tipc/discover.c | 4 | ||||
| -rw-r--r-- | net/tipc/link.c | 107 | ||||
| -rw-r--r-- | net/tipc/link.h | 24 | ||||
| -rw-r--r-- | net/tipc/name_distr.c | 57 | ||||
| -rw-r--r-- | net/tipc/name_distr.h | 10 | ||||
| -rw-r--r-- | net/tipc/name_table.c | 16 | ||||
| -rw-r--r-- | net/tipc/name_table.h | 8 | ||||
| -rw-r--r-- | net/tipc/net.c | 11 | ||||
| -rw-r--r-- | net/tipc/net.h | 2 | ||||
| -rw-r--r-- | net/tipc/node.c | 130 | ||||
| -rw-r--r-- | net/tipc/node.h | 35 | ||||
| -rw-r--r-- | net/tipc/socket.c | 72 | ||||
| -rw-r--r-- | net/tipc/socket.h | 4 |
21 files changed, 329 insertions, 244 deletions
diff --git a/net/tipc/addr.h b/net/tipc/addr.h index 60b00ab93d74..3e1f18e29f1e 100644 --- a/net/tipc/addr.h +++ b/net/tipc/addr.h | |||
| @@ -40,6 +40,8 @@ | |||
| 40 | #define TIPC_ZONE_MASK 0xff000000u | 40 | #define TIPC_ZONE_MASK 0xff000000u |
| 41 | #define TIPC_CLUSTER_MASK 0xfffff000u | 41 | #define TIPC_CLUSTER_MASK 0xfffff000u |
| 42 | 42 | ||
| 43 | extern u32 tipc_own_addr __read_mostly; | ||
| 44 | |||
| 43 | static inline u32 tipc_zone_mask(u32 addr) | 45 | static inline u32 tipc_zone_mask(u32 addr) |
| 44 | { | 46 | { |
| 45 | return addr & TIPC_ZONE_MASK; | 47 | return addr & TIPC_ZONE_MASK; |
diff --git a/net/tipc/bcast.c b/net/tipc/bcast.c index f98231138916..816c0e49319f 100644 --- a/net/tipc/bcast.c +++ b/net/tipc/bcast.c | |||
| @@ -232,13 +232,12 @@ static void bclink_retransmit_pkt(u32 after, u32 to) | |||
| 232 | * | 232 | * |
| 233 | * Called with no locks taken | 233 | * Called with no locks taken |
| 234 | */ | 234 | */ |
| 235 | void tipc_bclink_wakeup_users(void) | 235 | void tipc_bclink_wakeup_users(struct net *net) |
| 236 | { | 236 | { |
| 237 | struct sk_buff *skb; | 237 | struct sk_buff *skb; |
| 238 | 238 | ||
| 239 | while ((skb = skb_dequeue(&bclink->link.waiting_sks))) | 239 | while ((skb = skb_dequeue(&bclink->link.waiting_sks))) |
| 240 | tipc_sk_rcv(skb); | 240 | tipc_sk_rcv(net, skb); |
| 241 | |||
| 242 | } | 241 | } |
| 243 | 242 | ||
| 244 | /** | 243 | /** |
| @@ -385,9 +384,9 @@ void tipc_bclink_update_link_state(struct net *net, struct tipc_node *n_ptr, | |||
| 385 | * Delay any upcoming NACK by this node if another node has already | 384 | * Delay any upcoming NACK by this node if another node has already |
| 386 | * requested the first message this node is going to ask for. | 385 | * requested the first message this node is going to ask for. |
| 387 | */ | 386 | */ |
| 388 | static void bclink_peek_nack(struct tipc_msg *msg) | 387 | static void bclink_peek_nack(struct net *net, struct tipc_msg *msg) |
| 389 | { | 388 | { |
| 390 | struct tipc_node *n_ptr = tipc_node_find(msg_destnode(msg)); | 389 | struct tipc_node *n_ptr = tipc_node_find(net, msg_destnode(msg)); |
| 391 | 390 | ||
| 392 | if (unlikely(!n_ptr)) | 391 | if (unlikely(!n_ptr)) |
| 393 | return; | 392 | return; |
| @@ -404,11 +403,12 @@ static void bclink_peek_nack(struct tipc_msg *msg) | |||
| 404 | 403 | ||
| 405 | /* tipc_bclink_xmit - broadcast buffer chain to all nodes in cluster | 404 | /* tipc_bclink_xmit - broadcast buffer chain to all nodes in cluster |
| 406 | * and to identified node local sockets | 405 | * and to identified node local sockets |
| 406 | * @net: the applicable net namespace | ||
| 407 | * @list: chain of buffers containing message | 407 | * @list: chain of buffers containing message |
| 408 | * Consumes the buffer chain, except when returning -ELINKCONG | 408 | * Consumes the buffer chain, except when returning -ELINKCONG |
| 409 | * Returns 0 if success, otherwise errno: -ELINKCONG,-EHOSTUNREACH,-EMSGSIZE | 409 | * Returns 0 if success, otherwise errno: -ELINKCONG,-EHOSTUNREACH,-EMSGSIZE |
| 410 | */ | 410 | */ |
| 411 | int tipc_bclink_xmit(struct sk_buff_head *list) | 411 | int tipc_bclink_xmit(struct net *net, struct sk_buff_head *list) |
| 412 | { | 412 | { |
| 413 | int rc = 0; | 413 | int rc = 0; |
| 414 | int bc = 0; | 414 | int bc = 0; |
| @@ -443,7 +443,7 @@ int tipc_bclink_xmit(struct sk_buff_head *list) | |||
| 443 | 443 | ||
| 444 | /* Deliver message clone */ | 444 | /* Deliver message clone */ |
| 445 | if (likely(!rc)) | 445 | if (likely(!rc)) |
| 446 | tipc_sk_mcast_rcv(skb); | 446 | tipc_sk_mcast_rcv(net, skb); |
| 447 | else | 447 | else |
| 448 | kfree_skb(skb); | 448 | kfree_skb(skb); |
| 449 | 449 | ||
| @@ -491,7 +491,7 @@ void tipc_bclink_rcv(struct net *net, struct sk_buff *buf) | |||
| 491 | if (msg_mc_netid(msg) != tn->net_id) | 491 | if (msg_mc_netid(msg) != tn->net_id) |
| 492 | goto exit; | 492 | goto exit; |
| 493 | 493 | ||
| 494 | node = tipc_node_find(msg_prevnode(msg)); | 494 | node = tipc_node_find(net, msg_prevnode(msg)); |
| 495 | if (unlikely(!node)) | 495 | if (unlikely(!node)) |
| 496 | goto exit; | 496 | goto exit; |
| 497 | 497 | ||
| @@ -514,7 +514,7 @@ void tipc_bclink_rcv(struct net *net, struct sk_buff *buf) | |||
| 514 | tipc_bclink_unlock(); | 514 | tipc_bclink_unlock(); |
| 515 | } else { | 515 | } else { |
| 516 | tipc_node_unlock(node); | 516 | tipc_node_unlock(node); |
| 517 | bclink_peek_nack(msg); | 517 | bclink_peek_nack(net, msg); |
| 518 | } | 518 | } |
| 519 | goto exit; | 519 | goto exit; |
| 520 | } | 520 | } |
| @@ -532,7 +532,7 @@ receive: | |||
| 532 | tipc_bclink_unlock(); | 532 | tipc_bclink_unlock(); |
| 533 | tipc_node_unlock(node); | 533 | tipc_node_unlock(node); |
| 534 | if (likely(msg_mcast(msg))) | 534 | if (likely(msg_mcast(msg))) |
| 535 | tipc_sk_mcast_rcv(buf); | 535 | tipc_sk_mcast_rcv(net, buf); |
| 536 | else | 536 | else |
| 537 | kfree_skb(buf); | 537 | kfree_skb(buf); |
| 538 | } else if (msg_user(msg) == MSG_BUNDLER) { | 538 | } else if (msg_user(msg) == MSG_BUNDLER) { |
| @@ -542,7 +542,7 @@ receive: | |||
| 542 | bcl->stats.recv_bundled += msg_msgcnt(msg); | 542 | bcl->stats.recv_bundled += msg_msgcnt(msg); |
| 543 | tipc_bclink_unlock(); | 543 | tipc_bclink_unlock(); |
| 544 | tipc_node_unlock(node); | 544 | tipc_node_unlock(node); |
| 545 | tipc_link_bundle_rcv(buf); | 545 | tipc_link_bundle_rcv(net, buf); |
| 546 | } else if (msg_user(msg) == MSG_FRAGMENTER) { | 546 | } else if (msg_user(msg) == MSG_FRAGMENTER) { |
| 547 | tipc_buf_append(&node->bclink.reasm_buf, &buf); | 547 | tipc_buf_append(&node->bclink.reasm_buf, &buf); |
| 548 | if (unlikely(!buf && !node->bclink.reasm_buf)) | 548 | if (unlikely(!buf && !node->bclink.reasm_buf)) |
| @@ -563,7 +563,7 @@ receive: | |||
| 563 | bclink_accept_pkt(node, seqno); | 563 | bclink_accept_pkt(node, seqno); |
| 564 | tipc_bclink_unlock(); | 564 | tipc_bclink_unlock(); |
| 565 | tipc_node_unlock(node); | 565 | tipc_node_unlock(node); |
| 566 | tipc_named_rcv(buf); | 566 | tipc_named_rcv(net, buf); |
| 567 | } else { | 567 | } else { |
| 568 | tipc_bclink_lock(); | 568 | tipc_bclink_lock(); |
| 569 | bclink_accept_pkt(node, seqno); | 569 | bclink_accept_pkt(node, seqno); |
diff --git a/net/tipc/bcast.h b/net/tipc/bcast.h index a5fd22438aed..fd0d17a76493 100644 --- a/net/tipc/bcast.h +++ b/net/tipc/bcast.h | |||
| @@ -101,8 +101,8 @@ int tipc_bclink_reset_stats(void); | |||
| 101 | int tipc_bclink_set_queue_limits(u32 limit); | 101 | int tipc_bclink_set_queue_limits(u32 limit); |
| 102 | void tipc_bcbearer_sort(struct tipc_node_map *nm_ptr, u32 node, bool action); | 102 | void tipc_bcbearer_sort(struct tipc_node_map *nm_ptr, u32 node, bool action); |
| 103 | uint tipc_bclink_get_mtu(void); | 103 | uint tipc_bclink_get_mtu(void); |
| 104 | int tipc_bclink_xmit(struct sk_buff_head *list); | 104 | int tipc_bclink_xmit(struct net *net, struct sk_buff_head *list); |
| 105 | void tipc_bclink_wakeup_users(void); | 105 | void tipc_bclink_wakeup_users(struct net *net); |
| 106 | int tipc_nl_add_bc_link(struct tipc_nl_msg *msg); | 106 | int tipc_nl_add_bc_link(struct tipc_nl_msg *msg); |
| 107 | 107 | ||
| 108 | #endif | 108 | #endif |
diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c index cdd30337dc5e..a735c08e9d90 100644 --- a/net/tipc/bearer.c +++ b/net/tipc/bearer.c | |||
| @@ -69,7 +69,8 @@ static const struct nla_policy tipc_nl_media_policy[TIPC_NLA_MEDIA_MAX + 1] = { | |||
| 69 | 69 | ||
| 70 | struct tipc_bearer __rcu *bearer_list[MAX_BEARERS + 1]; | 70 | struct tipc_bearer __rcu *bearer_list[MAX_BEARERS + 1]; |
| 71 | 71 | ||
| 72 | static void bearer_disable(struct tipc_bearer *b_ptr, bool shutting_down); | 72 | static void bearer_disable(struct net *net, struct tipc_bearer *b_ptr, |
| 73 | bool shutting_down); | ||
| 73 | 74 | ||
| 74 | /** | 75 | /** |
| 75 | * tipc_media_find - locates specified media object by name | 76 | * tipc_media_find - locates specified media object by name |
| @@ -364,7 +365,7 @@ restart: | |||
| 364 | 365 | ||
| 365 | res = tipc_disc_create(net, b_ptr, &b_ptr->bcast_addr); | 366 | res = tipc_disc_create(net, b_ptr, &b_ptr->bcast_addr); |
| 366 | if (res) { | 367 | if (res) { |
| 367 | bearer_disable(b_ptr, false); | 368 | bearer_disable(net, b_ptr, false); |
| 368 | pr_warn("Bearer <%s> rejected, discovery object creation failed\n", | 369 | pr_warn("Bearer <%s> rejected, discovery object creation failed\n", |
| 369 | name); | 370 | name); |
| 370 | return -EINVAL; | 371 | return -EINVAL; |
| @@ -384,7 +385,7 @@ restart: | |||
| 384 | static int tipc_reset_bearer(struct net *net, struct tipc_bearer *b_ptr) | 385 | static int tipc_reset_bearer(struct net *net, struct tipc_bearer *b_ptr) |
| 385 | { | 386 | { |
| 386 | pr_info("Resetting bearer <%s>\n", b_ptr->name); | 387 | pr_info("Resetting bearer <%s>\n", b_ptr->name); |
| 387 | tipc_link_reset_list(b_ptr->identity); | 388 | tipc_link_reset_list(net, b_ptr->identity); |
| 388 | tipc_disc_reset(net, b_ptr); | 389 | tipc_disc_reset(net, b_ptr); |
| 389 | return 0; | 390 | return 0; |
| 390 | } | 391 | } |
| @@ -394,14 +395,15 @@ static int tipc_reset_bearer(struct net *net, struct tipc_bearer *b_ptr) | |||
| 394 | * | 395 | * |
| 395 | * Note: This routine assumes caller holds RTNL lock. | 396 | * Note: This routine assumes caller holds RTNL lock. |
| 396 | */ | 397 | */ |
| 397 | static void bearer_disable(struct tipc_bearer *b_ptr, bool shutting_down) | 398 | static void bearer_disable(struct net *net, struct tipc_bearer *b_ptr, |
| 399 | bool shutting_down) | ||
| 398 | { | 400 | { |
| 399 | u32 i; | 401 | u32 i; |
| 400 | 402 | ||
| 401 | pr_info("Disabling bearer <%s>\n", b_ptr->name); | 403 | pr_info("Disabling bearer <%s>\n", b_ptr->name); |
| 402 | b_ptr->media->disable_media(b_ptr); | 404 | b_ptr->media->disable_media(b_ptr); |
| 403 | 405 | ||
| 404 | tipc_link_delete_list(b_ptr->identity, shutting_down); | 406 | tipc_link_delete_list(net, b_ptr->identity, shutting_down); |
| 405 | if (b_ptr->link_req) | 407 | if (b_ptr->link_req) |
| 406 | tipc_disc_delete(b_ptr->link_req); | 408 | tipc_disc_delete(b_ptr->link_req); |
| 407 | 409 | ||
| @@ -414,7 +416,7 @@ static void bearer_disable(struct tipc_bearer *b_ptr, bool shutting_down) | |||
| 414 | kfree_rcu(b_ptr, rcu); | 416 | kfree_rcu(b_ptr, rcu); |
| 415 | } | 417 | } |
| 416 | 418 | ||
| 417 | int tipc_disable_bearer(const char *name) | 419 | int tipc_disable_bearer(struct net *net, const char *name) |
| 418 | { | 420 | { |
| 419 | struct tipc_bearer *b_ptr; | 421 | struct tipc_bearer *b_ptr; |
| 420 | int res; | 422 | int res; |
| @@ -424,7 +426,7 @@ int tipc_disable_bearer(const char *name) | |||
| 424 | pr_warn("Attempt to disable unknown bearer <%s>\n", name); | 426 | pr_warn("Attempt to disable unknown bearer <%s>\n", name); |
| 425 | res = -EINVAL; | 427 | res = -EINVAL; |
| 426 | } else { | 428 | } else { |
| 427 | bearer_disable(b_ptr, false); | 429 | bearer_disable(net, b_ptr, false); |
| 428 | res = 0; | 430 | res = 0; |
| 429 | } | 431 | } |
| 430 | return res; | 432 | return res; |
| @@ -593,7 +595,7 @@ static int tipc_l2_device_event(struct notifier_block *nb, unsigned long evt, | |||
| 593 | break; | 595 | break; |
| 594 | case NETDEV_UNREGISTER: | 596 | case NETDEV_UNREGISTER: |
| 595 | case NETDEV_CHANGENAME: | 597 | case NETDEV_CHANGENAME: |
| 596 | bearer_disable(b_ptr, false); | 598 | bearer_disable(dev_net(dev), b_ptr, false); |
| 597 | break; | 599 | break; |
| 598 | } | 600 | } |
| 599 | return NOTIFY_OK; | 601 | return NOTIFY_OK; |
| @@ -626,7 +628,7 @@ void tipc_bearer_cleanup(void) | |||
| 626 | dev_remove_pack(&tipc_packet_type); | 628 | dev_remove_pack(&tipc_packet_type); |
| 627 | } | 629 | } |
| 628 | 630 | ||
| 629 | void tipc_bearer_stop(void) | 631 | void tipc_bearer_stop(struct net *net) |
| 630 | { | 632 | { |
| 631 | struct tipc_bearer *b_ptr; | 633 | struct tipc_bearer *b_ptr; |
| 632 | u32 i; | 634 | u32 i; |
| @@ -634,7 +636,7 @@ void tipc_bearer_stop(void) | |||
| 634 | for (i = 0; i < MAX_BEARERS; i++) { | 636 | for (i = 0; i < MAX_BEARERS; i++) { |
| 635 | b_ptr = rtnl_dereference(bearer_list[i]); | 637 | b_ptr = rtnl_dereference(bearer_list[i]); |
| 636 | if (b_ptr) { | 638 | if (b_ptr) { |
| 637 | bearer_disable(b_ptr, true); | 639 | bearer_disable(net, b_ptr, true); |
| 638 | bearer_list[i] = NULL; | 640 | bearer_list[i] = NULL; |
| 639 | } | 641 | } |
| 640 | } | 642 | } |
| @@ -772,6 +774,7 @@ int tipc_nl_bearer_disable(struct sk_buff *skb, struct genl_info *info) | |||
| 772 | char *name; | 774 | char *name; |
| 773 | struct tipc_bearer *bearer; | 775 | struct tipc_bearer *bearer; |
| 774 | struct nlattr *attrs[TIPC_NLA_BEARER_MAX + 1]; | 776 | struct nlattr *attrs[TIPC_NLA_BEARER_MAX + 1]; |
| 777 | struct net *net = genl_info_net(info); | ||
| 775 | 778 | ||
| 776 | if (!info->attrs[TIPC_NLA_BEARER]) | 779 | if (!info->attrs[TIPC_NLA_BEARER]) |
| 777 | return -EINVAL; | 780 | return -EINVAL; |
| @@ -794,7 +797,7 @@ int tipc_nl_bearer_disable(struct sk_buff *skb, struct genl_info *info) | |||
| 794 | return -EINVAL; | 797 | return -EINVAL; |
| 795 | } | 798 | } |
| 796 | 799 | ||
| 797 | bearer_disable(bearer, false); | 800 | bearer_disable(net, bearer, false); |
| 798 | rtnl_unlock(); | 801 | rtnl_unlock(); |
| 799 | 802 | ||
| 800 | return 0; | 803 | return 0; |
diff --git a/net/tipc/bearer.h b/net/tipc/bearer.h index 43f683aebbbe..91a8eeea309c 100644 --- a/net/tipc/bearer.h +++ b/net/tipc/bearer.h | |||
| @@ -168,7 +168,7 @@ extern struct tipc_bearer __rcu *bearer_list[]; | |||
| 168 | void tipc_rcv(struct net *net, struct sk_buff *skb, struct tipc_bearer *b_ptr); | 168 | void tipc_rcv(struct net *net, struct sk_buff *skb, struct tipc_bearer *b_ptr); |
| 169 | int tipc_enable_bearer(struct net *net, const char *bearer_name, | 169 | int tipc_enable_bearer(struct net *net, const char *bearer_name, |
| 170 | u32 disc_domain, u32 priority); | 170 | u32 disc_domain, u32 priority); |
| 171 | int tipc_disable_bearer(const char *name); | 171 | int tipc_disable_bearer(struct net *net, const char *name); |
| 172 | 172 | ||
| 173 | /* | 173 | /* |
| 174 | * Routines made available to TIPC by supported media types | 174 | * Routines made available to TIPC by supported media types |
| @@ -205,7 +205,7 @@ struct tipc_bearer *tipc_bearer_find(const char *name); | |||
| 205 | struct tipc_media *tipc_media_find(const char *name); | 205 | struct tipc_media *tipc_media_find(const char *name); |
| 206 | int tipc_bearer_setup(void); | 206 | int tipc_bearer_setup(void); |
| 207 | void tipc_bearer_cleanup(void); | 207 | void tipc_bearer_cleanup(void); |
| 208 | void tipc_bearer_stop(void); | 208 | void tipc_bearer_stop(struct net *net); |
| 209 | void tipc_bearer_send(u32 bearer_id, struct sk_buff *buf, | 209 | void tipc_bearer_send(u32 bearer_id, struct sk_buff *buf, |
| 210 | struct tipc_media_addr *dest); | 210 | struct tipc_media_addr *dest); |
| 211 | 211 | ||
diff --git a/net/tipc/config.c b/net/tipc/config.c index 28d4272803c4..cf2d417ad488 100644 --- a/net/tipc/config.c +++ b/net/tipc/config.c | |||
| @@ -150,12 +150,12 @@ static struct sk_buff *cfg_enable_bearer(struct net *net) | |||
| 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(); |
| @@ -232,16 +232,20 @@ struct sk_buff *tipc_cfg_do_cmd(struct net *net, u32 orig_node, u16 cmd, | |||
| 232 | rep_tlv_buf = tipc_cfg_reply_none(); | 232 | rep_tlv_buf = tipc_cfg_reply_none(); |
| 233 | break; | 233 | break; |
| 234 | case TIPC_CMD_GET_NODES: | 234 | case TIPC_CMD_GET_NODES: |
| 235 | rep_tlv_buf = tipc_node_get_nodes(req_tlv_area, req_tlv_space); | 235 | rep_tlv_buf = tipc_node_get_nodes(net, req_tlv_area, |
| 236 | req_tlv_space); | ||
| 236 | break; | 237 | break; |
| 237 | case TIPC_CMD_GET_LINKS: | 238 | case TIPC_CMD_GET_LINKS: |
| 238 | rep_tlv_buf = tipc_node_get_links(req_tlv_area, req_tlv_space); | 239 | rep_tlv_buf = tipc_node_get_links(net, req_tlv_area, |
| 240 | req_tlv_space); | ||
| 239 | break; | 241 | break; |
| 240 | case TIPC_CMD_SHOW_LINK_STATS: | 242 | case TIPC_CMD_SHOW_LINK_STATS: |
| 241 | rep_tlv_buf = tipc_link_cmd_show_stats(req_tlv_area, req_tlv_space); | 243 | rep_tlv_buf = tipc_link_cmd_show_stats(net, req_tlv_area, |
| 244 | req_tlv_space); | ||
| 242 | break; | 245 | break; |
| 243 | case TIPC_CMD_RESET_LINK_STATS: | 246 | case TIPC_CMD_RESET_LINK_STATS: |
| 244 | rep_tlv_buf = tipc_link_cmd_reset_stats(req_tlv_area, req_tlv_space); | 247 | rep_tlv_buf = tipc_link_cmd_reset_stats(net, req_tlv_area, |
| 248 | req_tlv_space); | ||
| 245 | break; | 249 | break; |
| 246 | case TIPC_CMD_SHOW_NAME_TABLE: | 250 | case TIPC_CMD_SHOW_NAME_TABLE: |
| 247 | rep_tlv_buf = tipc_nametbl_get(req_tlv_area, req_tlv_space); | 251 | rep_tlv_buf = tipc_nametbl_get(req_tlv_area, req_tlv_space); |
| @@ -261,13 +265,14 @@ struct sk_buff *tipc_cfg_do_cmd(struct net *net, u32 orig_node, u16 cmd, | |||
| 261 | case TIPC_CMD_SET_LINK_TOL: | 265 | case TIPC_CMD_SET_LINK_TOL: |
| 262 | case TIPC_CMD_SET_LINK_PRI: | 266 | case TIPC_CMD_SET_LINK_PRI: |
| 263 | case TIPC_CMD_SET_LINK_WINDOW: | 267 | case TIPC_CMD_SET_LINK_WINDOW: |
| 264 | rep_tlv_buf = tipc_link_cmd_config(req_tlv_area, req_tlv_space, cmd); | 268 | rep_tlv_buf = tipc_link_cmd_config(net, req_tlv_area, |
| 269 | req_tlv_space, cmd); | ||
| 265 | break; | 270 | break; |
| 266 | case TIPC_CMD_ENABLE_BEARER: | 271 | case TIPC_CMD_ENABLE_BEARER: |
| 267 | rep_tlv_buf = cfg_enable_bearer(net); | 272 | rep_tlv_buf = cfg_enable_bearer(net); |
| 268 | break; | 273 | break; |
| 269 | case TIPC_CMD_DISABLE_BEARER: | 274 | case TIPC_CMD_DISABLE_BEARER: |
| 270 | rep_tlv_buf = cfg_disable_bearer(); | 275 | rep_tlv_buf = cfg_disable_bearer(net); |
| 271 | break; | 276 | break; |
| 272 | case TIPC_CMD_SET_NODE_ADDR: | 277 | case TIPC_CMD_SET_NODE_ADDR: |
| 273 | rep_tlv_buf = cfg_set_own_addr(net); | 278 | rep_tlv_buf = cfg_set_own_addr(net); |
diff --git a/net/tipc/core.c b/net/tipc/core.c index a2302480d8cf..7b8443938caf 100644 --- a/net/tipc/core.c +++ b/net/tipc/core.c | |||
| @@ -57,12 +57,15 @@ static int __net_init tipc_init_net(struct net *net) | |||
| 57 | struct tipc_net *tn = net_generic(net, tipc_net_id); | 57 | struct tipc_net *tn = net_generic(net, tipc_net_id); |
| 58 | 58 | ||
| 59 | tn->net_id = 4711; | 59 | tn->net_id = 4711; |
| 60 | INIT_LIST_HEAD(&tn->node_list); | ||
| 61 | spin_lock_init(&tn->node_list_lock); | ||
| 60 | 62 | ||
| 61 | return 0; | 63 | return 0; |
| 62 | } | 64 | } |
| 63 | 65 | ||
| 64 | static void __net_exit tipc_exit_net(struct net *net) | 66 | static void __net_exit tipc_exit_net(struct net *net) |
| 65 | { | 67 | { |
| 68 | tipc_net_stop(net); | ||
| 66 | } | 69 | } |
| 67 | 70 | ||
| 68 | static struct pernet_operations tipc_net_ops = { | 71 | static struct pernet_operations tipc_net_ops = { |
| @@ -144,7 +147,6 @@ out_pernet: | |||
| 144 | static void __exit tipc_exit(void) | 147 | static void __exit tipc_exit(void) |
| 145 | { | 148 | { |
| 146 | unregister_pernet_subsys(&tipc_net_ops); | 149 | unregister_pernet_subsys(&tipc_net_ops); |
| 147 | tipc_net_stop(); | ||
| 148 | tipc_bearer_cleanup(); | 150 | tipc_bearer_cleanup(); |
| 149 | tipc_netlink_stop(); | 151 | tipc_netlink_stop(); |
| 150 | tipc_subscr_stop(); | 152 | tipc_subscr_stop(); |
diff --git a/net/tipc/core.h b/net/tipc/core.h index 106e8150c3a6..4fb113397e7b 100644 --- a/net/tipc/core.h +++ b/net/tipc/core.h | |||
| @@ -59,6 +59,8 @@ | |||
| 59 | #include <linux/etherdevice.h> | 59 | #include <linux/etherdevice.h> |
| 60 | #include <net/netns/generic.h> | 60 | #include <net/netns/generic.h> |
| 61 | 61 | ||
| 62 | #include "node.h" | ||
| 63 | |||
| 62 | #define TIPC_MOD_VER "2.0.0" | 64 | #define TIPC_MOD_VER "2.0.0" |
| 63 | 65 | ||
| 64 | int tipc_snprintf(char *buf, int len, const char *fmt, ...); | 66 | int tipc_snprintf(char *buf, int len, const char *fmt, ...); |
| @@ -78,6 +80,13 @@ extern int tipc_random __read_mostly; | |||
| 78 | 80 | ||
| 79 | struct tipc_net { | 81 | struct tipc_net { |
| 80 | int net_id; | 82 | int net_id; |
| 83 | |||
| 84 | /* Node table and node list */ | ||
| 85 | spinlock_t node_list_lock; | ||
| 86 | struct hlist_head node_htable[NODE_HTABLE_SIZE]; | ||
| 87 | struct list_head node_list; | ||
| 88 | u32 num_nodes; | ||
| 89 | u32 num_links; | ||
| 81 | }; | 90 | }; |
| 82 | 91 | ||
| 83 | #ifdef CONFIG_SYSCTL | 92 | #ifdef CONFIG_SYSCTL |
diff --git a/net/tipc/discover.c b/net/tipc/discover.c index 246a23788ded..f0fd8b449aef 100644 --- a/net/tipc/discover.c +++ b/net/tipc/discover.c | |||
| @@ -162,9 +162,9 @@ void tipc_disc_rcv(struct net *net, struct sk_buff *buf, | |||
| 162 | return; | 162 | return; |
| 163 | 163 | ||
| 164 | /* Locate, or if necessary, create, node: */ | 164 | /* Locate, or if necessary, create, node: */ |
| 165 | node = tipc_node_find(onode); | 165 | node = tipc_node_find(net, onode); |
| 166 | if (!node) | 166 | if (!node) |
| 167 | node = tipc_node_create(onode); | 167 | node = tipc_node_create(net, onode); |
| 168 | if (!node) | 168 | if (!node) |
| 169 | return; | 169 | return; |
| 170 | 170 | ||
diff --git a/net/tipc/link.c b/net/tipc/link.c index 248813cb6d68..f6505652742e 100644 --- a/net/tipc/link.c +++ b/net/tipc/link.c | |||
| @@ -114,7 +114,8 @@ static void link_reset_statistics(struct tipc_link *l_ptr); | |||
| 114 | static void link_print(struct tipc_link *l_ptr, const char *str); | 114 | static void link_print(struct tipc_link *l_ptr, const char *str); |
| 115 | static void tipc_link_sync_xmit(struct tipc_link *l); | 115 | static void tipc_link_sync_xmit(struct tipc_link *l); |
| 116 | static void tipc_link_sync_rcv(struct tipc_node *n, struct sk_buff *buf); | 116 | static void tipc_link_sync_rcv(struct tipc_node *n, struct sk_buff *buf); |
| 117 | static int tipc_link_input(struct tipc_link *l, struct sk_buff *buf); | 117 | static int tipc_link_input(struct net *net, struct tipc_link *l, |
| 118 | struct sk_buff *buf); | ||
| 118 | static int tipc_link_prepare_input(struct net *net, struct tipc_link *l, | 119 | static int tipc_link_prepare_input(struct net *net, struct tipc_link *l, |
| 119 | struct sk_buff **buf); | 120 | struct sk_buff **buf); |
| 120 | 121 | ||
| @@ -310,13 +311,15 @@ struct tipc_link *tipc_link_create(struct tipc_node *n_ptr, | |||
| 310 | return l_ptr; | 311 | return l_ptr; |
| 311 | } | 312 | } |
| 312 | 313 | ||
| 313 | void tipc_link_delete_list(unsigned int bearer_id, bool shutting_down) | 314 | void tipc_link_delete_list(struct net *net, unsigned int bearer_id, |
| 315 | bool shutting_down) | ||
| 314 | { | 316 | { |
| 317 | struct tipc_net *tn = net_generic(net, tipc_net_id); | ||
| 315 | struct tipc_link *l_ptr; | 318 | struct tipc_link *l_ptr; |
| 316 | struct tipc_node *n_ptr; | 319 | struct tipc_node *n_ptr; |
| 317 | 320 | ||
| 318 | rcu_read_lock(); | 321 | rcu_read_lock(); |
| 319 | list_for_each_entry_rcu(n_ptr, &tipc_node_list, list) { | 322 | list_for_each_entry_rcu(n_ptr, &tn->node_list, list) { |
| 320 | tipc_node_lock(n_ptr); | 323 | tipc_node_lock(n_ptr); |
| 321 | l_ptr = n_ptr->links[bearer_id]; | 324 | l_ptr = n_ptr->links[bearer_id]; |
| 322 | if (l_ptr) { | 325 | if (l_ptr) { |
| @@ -451,13 +454,14 @@ void tipc_link_reset(struct tipc_link *l_ptr) | |||
| 451 | link_reset_statistics(l_ptr); | 454 | link_reset_statistics(l_ptr); |
| 452 | } | 455 | } |
| 453 | 456 | ||
| 454 | void tipc_link_reset_list(unsigned int bearer_id) | 457 | void tipc_link_reset_list(struct net *net, unsigned int bearer_id) |
| 455 | { | 458 | { |
| 459 | struct tipc_net *tn = net_generic(net, tipc_net_id); | ||
| 456 | struct tipc_link *l_ptr; | 460 | struct tipc_link *l_ptr; |
| 457 | struct tipc_node *n_ptr; | 461 | struct tipc_node *n_ptr; |
| 458 | 462 | ||
| 459 | rcu_read_lock(); | 463 | rcu_read_lock(); |
| 460 | list_for_each_entry_rcu(n_ptr, &tipc_node_list, list) { | 464 | list_for_each_entry_rcu(n_ptr, &tn->node_list, list) { |
| 461 | tipc_node_lock(n_ptr); | 465 | tipc_node_lock(n_ptr); |
| 462 | l_ptr = n_ptr->links[bearer_id]; | 466 | l_ptr = n_ptr->links[bearer_id]; |
| 463 | if (l_ptr) | 467 | if (l_ptr) |
| @@ -773,16 +777,18 @@ static int __tipc_link_xmit_skb(struct tipc_link *link, struct sk_buff *skb) | |||
| 773 | return __tipc_link_xmit(link, &head); | 777 | return __tipc_link_xmit(link, &head); |
| 774 | } | 778 | } |
| 775 | 779 | ||
| 776 | int tipc_link_xmit_skb(struct sk_buff *skb, u32 dnode, u32 selector) | 780 | int tipc_link_xmit_skb(struct net *net, struct sk_buff *skb, u32 dnode, |
| 781 | u32 selector) | ||
| 777 | { | 782 | { |
| 778 | struct sk_buff_head head; | 783 | struct sk_buff_head head; |
| 779 | 784 | ||
| 780 | skb2list(skb, &head); | 785 | skb2list(skb, &head); |
| 781 | return tipc_link_xmit(&head, dnode, selector); | 786 | return tipc_link_xmit(net, &head, dnode, selector); |
| 782 | } | 787 | } |
| 783 | 788 | ||
| 784 | /** | 789 | /** |
| 785 | * tipc_link_xmit() is the general link level function for message sending | 790 | * tipc_link_xmit() is the general link level function for message sending |
| 791 | * @net: the applicable net namespace | ||
| 786 | * @list: chain of buffers containing message | 792 | * @list: chain of buffers containing message |
| 787 | * @dsz: amount of user data to be sent | 793 | * @dsz: amount of user data to be sent |
| 788 | * @dnode: address of destination node | 794 | * @dnode: address of destination node |
| @@ -790,13 +796,14 @@ int tipc_link_xmit_skb(struct sk_buff *skb, u32 dnode, u32 selector) | |||
| 790 | * Consumes the buffer chain, except when returning -ELINKCONG | 796 | * Consumes the buffer chain, except when returning -ELINKCONG |
| 791 | * Returns 0 if success, otherwise errno: -ELINKCONG,-EHOSTUNREACH,-EMSGSIZE | 797 | * Returns 0 if success, otherwise errno: -ELINKCONG,-EHOSTUNREACH,-EMSGSIZE |
| 792 | */ | 798 | */ |
| 793 | int tipc_link_xmit(struct sk_buff_head *list, u32 dnode, u32 selector) | 799 | int tipc_link_xmit(struct net *net, struct sk_buff_head *list, u32 dnode, |
| 800 | u32 selector) | ||
| 794 | { | 801 | { |
| 795 | struct tipc_link *link = NULL; | 802 | struct tipc_link *link = NULL; |
| 796 | struct tipc_node *node; | 803 | struct tipc_node *node; |
| 797 | int rc = -EHOSTUNREACH; | 804 | int rc = -EHOSTUNREACH; |
| 798 | 805 | ||
| 799 | node = tipc_node_find(dnode); | 806 | node = tipc_node_find(net, dnode); |
| 800 | if (node) { | 807 | if (node) { |
| 801 | tipc_node_lock(node); | 808 | tipc_node_lock(node); |
| 802 | link = node->active_links[selector & 1]; | 809 | link = node->active_links[selector & 1]; |
| @@ -813,7 +820,7 @@ int tipc_link_xmit(struct sk_buff_head *list, u32 dnode, u32 selector) | |||
| 813 | * buffer, we just need to dequeue one SKB buffer from the | 820 | * buffer, we just need to dequeue one SKB buffer from the |
| 814 | * head list. | 821 | * head list. |
| 815 | */ | 822 | */ |
| 816 | return tipc_sk_rcv(__skb_dequeue(list)); | 823 | return tipc_sk_rcv(net, __skb_dequeue(list)); |
| 817 | } | 824 | } |
| 818 | __skb_queue_purge(list); | 825 | __skb_queue_purge(list); |
| 819 | 826 | ||
| @@ -1066,7 +1073,7 @@ static int link_recv_buf_validate(struct sk_buff *buf) | |||
| 1066 | 1073 | ||
| 1067 | /** | 1074 | /** |
| 1068 | * tipc_rcv - process TIPC packets/messages arriving from off-node | 1075 | * tipc_rcv - process TIPC packets/messages arriving from off-node |
| 1069 | * @net: net namespace handler | 1076 | * @net: the applicable net namespace |
| 1070 | * @skb: TIPC packet | 1077 | * @skb: TIPC packet |
| 1071 | * @b_ptr: pointer to bearer message arrived on | 1078 | * @b_ptr: pointer to bearer message arrived on |
| 1072 | * | 1079 | * |
| @@ -1112,7 +1119,7 @@ void tipc_rcv(struct net *net, struct sk_buff *skb, struct tipc_bearer *b_ptr) | |||
| 1112 | goto discard; | 1119 | goto discard; |
| 1113 | 1120 | ||
| 1114 | /* Locate neighboring node that sent message */ | 1121 | /* Locate neighboring node that sent message */ |
| 1115 | n_ptr = tipc_node_find(msg_prevnode(msg)); | 1122 | n_ptr = tipc_node_find(net, msg_prevnode(msg)); |
| 1116 | if (unlikely(!n_ptr)) | 1123 | if (unlikely(!n_ptr)) |
| 1117 | goto discard; | 1124 | goto discard; |
| 1118 | tipc_node_lock(n_ptr); | 1125 | tipc_node_lock(n_ptr); |
| @@ -1203,7 +1210,7 @@ void tipc_rcv(struct net *net, struct sk_buff *skb, struct tipc_bearer *b_ptr) | |||
| 1203 | } | 1210 | } |
| 1204 | tipc_node_unlock(n_ptr); | 1211 | tipc_node_unlock(n_ptr); |
| 1205 | 1212 | ||
| 1206 | if (tipc_link_input(l_ptr, skb) != 0) | 1213 | if (tipc_link_input(net, l_ptr, skb) != 0) |
| 1207 | goto discard; | 1214 | goto discard; |
| 1208 | continue; | 1215 | continue; |
| 1209 | unlock_discard: | 1216 | unlock_discard: |
| @@ -1263,7 +1270,8 @@ static int tipc_link_prepare_input(struct net *net, struct tipc_link *l, | |||
| 1263 | /** | 1270 | /** |
| 1264 | * tipc_link_input - Deliver message too higher layers | 1271 | * tipc_link_input - Deliver message too higher layers |
| 1265 | */ | 1272 | */ |
| 1266 | static int tipc_link_input(struct tipc_link *l, struct sk_buff *buf) | 1273 | static int tipc_link_input(struct net *net, struct tipc_link *l, |
| 1274 | struct sk_buff *buf) | ||
| 1267 | { | 1275 | { |
| 1268 | struct tipc_msg *msg = buf_msg(buf); | 1276 | struct tipc_msg *msg = buf_msg(buf); |
| 1269 | int res = 0; | 1277 | int res = 0; |
| @@ -1274,13 +1282,13 @@ static int tipc_link_input(struct tipc_link *l, struct sk_buff *buf) | |||
| 1274 | case TIPC_HIGH_IMPORTANCE: | 1282 | case TIPC_HIGH_IMPORTANCE: |
| 1275 | case TIPC_CRITICAL_IMPORTANCE: | 1283 | case TIPC_CRITICAL_IMPORTANCE: |
| 1276 | case CONN_MANAGER: | 1284 | case CONN_MANAGER: |
| 1277 | tipc_sk_rcv(buf); | 1285 | tipc_sk_rcv(net, buf); |
| 1278 | break; | 1286 | break; |
| 1279 | case NAME_DISTRIBUTOR: | 1287 | case NAME_DISTRIBUTOR: |
| 1280 | tipc_named_rcv(buf); | 1288 | tipc_named_rcv(net, buf); |
| 1281 | break; | 1289 | break; |
| 1282 | case MSG_BUNDLER: | 1290 | case MSG_BUNDLER: |
| 1283 | tipc_link_bundle_rcv(buf); | 1291 | tipc_link_bundle_rcv(net, buf); |
| 1284 | break; | 1292 | break; |
| 1285 | default: | 1293 | default: |
| 1286 | res = -EINVAL; | 1294 | res = -EINVAL; |
| @@ -1855,7 +1863,7 @@ exit: | |||
| 1855 | /* | 1863 | /* |
| 1856 | * Bundler functionality: | 1864 | * Bundler functionality: |
| 1857 | */ | 1865 | */ |
| 1858 | void tipc_link_bundle_rcv(struct sk_buff *buf) | 1866 | void tipc_link_bundle_rcv(struct net *net, struct sk_buff *buf) |
| 1859 | { | 1867 | { |
| 1860 | u32 msgcount = msg_msgcnt(buf_msg(buf)); | 1868 | u32 msgcount = msg_msgcnt(buf_msg(buf)); |
| 1861 | u32 pos = INT_H_SIZE; | 1869 | u32 pos = INT_H_SIZE; |
| @@ -1872,13 +1880,13 @@ void tipc_link_bundle_rcv(struct sk_buff *buf) | |||
| 1872 | pos += align(msg_size(omsg)); | 1880 | pos += align(msg_size(omsg)); |
| 1873 | if (msg_isdata(omsg)) { | 1881 | if (msg_isdata(omsg)) { |
| 1874 | if (unlikely(msg_type(omsg) == TIPC_MCAST_MSG)) | 1882 | if (unlikely(msg_type(omsg) == TIPC_MCAST_MSG)) |
| 1875 | tipc_sk_mcast_rcv(obuf); | 1883 | tipc_sk_mcast_rcv(net, obuf); |
| 1876 | else | 1884 | else |
| 1877 | tipc_sk_rcv(obuf); | 1885 | tipc_sk_rcv(net, obuf); |
| 1878 | } else if (msg_user(omsg) == CONN_MANAGER) { | 1886 | } else if (msg_user(omsg) == CONN_MANAGER) { |
| 1879 | tipc_sk_rcv(obuf); | 1887 | tipc_sk_rcv(net, obuf); |
| 1880 | } else if (msg_user(omsg) == NAME_DISTRIBUTOR) { | 1888 | } else if (msg_user(omsg) == NAME_DISTRIBUTOR) { |
| 1881 | tipc_named_rcv(obuf); | 1889 | tipc_named_rcv(net, obuf); |
| 1882 | } else { | 1890 | } else { |
| 1883 | pr_warn("Illegal bundled msg: %u\n", msg_user(omsg)); | 1891 | pr_warn("Illegal bundled msg: %u\n", msg_user(omsg)); |
| 1884 | kfree_skb(obuf); | 1892 | kfree_skb(obuf); |
| @@ -1919,14 +1927,17 @@ void tipc_link_set_queue_limits(struct tipc_link *l_ptr, u32 window) | |||
| 1919 | } | 1927 | } |
| 1920 | 1928 | ||
| 1921 | /* tipc_link_find_owner - locate owner node of link by link's name | 1929 | /* tipc_link_find_owner - locate owner node of link by link's name |
| 1930 | * @net: the applicable net namespace | ||
| 1922 | * @name: pointer to link name string | 1931 | * @name: pointer to link name string |
| 1923 | * @bearer_id: pointer to index in 'node->links' array where the link was found. | 1932 | * @bearer_id: pointer to index in 'node->links' array where the link was found. |
| 1924 | * | 1933 | * |
| 1925 | * Returns pointer to node owning the link, or 0 if no matching link is found. | 1934 | * Returns pointer to node owning the link, or 0 if no matching link is found. |
| 1926 | */ | 1935 | */ |
| 1927 | static struct tipc_node *tipc_link_find_owner(const char *link_name, | 1936 | static struct tipc_node *tipc_link_find_owner(struct net *net, |
| 1937 | const char *link_name, | ||
| 1928 | unsigned int *bearer_id) | 1938 | unsigned int *bearer_id) |
| 1929 | { | 1939 | { |
| 1940 | struct tipc_net *tn = net_generic(net, tipc_net_id); | ||
| 1930 | struct tipc_link *l_ptr; | 1941 | struct tipc_link *l_ptr; |
| 1931 | struct tipc_node *n_ptr; | 1942 | struct tipc_node *n_ptr; |
| 1932 | struct tipc_node *found_node = NULL; | 1943 | struct tipc_node *found_node = NULL; |
| @@ -1934,7 +1945,7 @@ static struct tipc_node *tipc_link_find_owner(const char *link_name, | |||
| 1934 | 1945 | ||
| 1935 | *bearer_id = 0; | 1946 | *bearer_id = 0; |
| 1936 | rcu_read_lock(); | 1947 | rcu_read_lock(); |
| 1937 | list_for_each_entry_rcu(n_ptr, &tipc_node_list, list) { | 1948 | list_for_each_entry_rcu(n_ptr, &tn->node_list, list) { |
| 1938 | tipc_node_lock(n_ptr); | 1949 | tipc_node_lock(n_ptr); |
| 1939 | for (i = 0; i < MAX_BEARERS; i++) { | 1950 | for (i = 0; i < MAX_BEARERS; i++) { |
| 1940 | l_ptr = n_ptr->links[i]; | 1951 | l_ptr = n_ptr->links[i]; |
| @@ -1978,6 +1989,7 @@ static int link_value_is_valid(u16 cmd, u32 new_value) | |||
| 1978 | 1989 | ||
| 1979 | /** | 1990 | /** |
| 1980 | * link_cmd_set_value - change priority/tolerance/window for link/bearer/media | 1991 | * link_cmd_set_value - change priority/tolerance/window for link/bearer/media |
| 1992 | * @net: the applicable net namespace | ||
| 1981 | * @name: ptr to link, bearer, or media name | 1993 | * @name: ptr to link, bearer, or media name |
| 1982 | * @new_value: new value of link, bearer, or media setting | 1994 | * @new_value: new value of link, bearer, or media setting |
| 1983 | * @cmd: which link, bearer, or media attribute to set (TIPC_CMD_SET_LINK_*) | 1995 | * @cmd: which link, bearer, or media attribute to set (TIPC_CMD_SET_LINK_*) |
| @@ -1986,7 +1998,8 @@ static int link_value_is_valid(u16 cmd, u32 new_value) | |||
| 1986 | * | 1998 | * |
| 1987 | * Returns 0 if value updated and negative value on error. | 1999 | * Returns 0 if value updated and negative value on error. |
| 1988 | */ | 2000 | */ |
| 1989 | static int link_cmd_set_value(const char *name, u32 new_value, u16 cmd) | 2001 | static int link_cmd_set_value(struct net *net, const char *name, u32 new_value, |
| 2002 | u16 cmd) | ||
| 1990 | { | 2003 | { |
| 1991 | struct tipc_node *node; | 2004 | struct tipc_node *node; |
| 1992 | struct tipc_link *l_ptr; | 2005 | struct tipc_link *l_ptr; |
| @@ -1995,7 +2008,7 @@ static int link_cmd_set_value(const char *name, u32 new_value, u16 cmd) | |||
| 1995 | int bearer_id; | 2008 | int bearer_id; |
| 1996 | int res = 0; | 2009 | int res = 0; |
| 1997 | 2010 | ||
| 1998 | node = tipc_link_find_owner(name, &bearer_id); | 2011 | node = tipc_link_find_owner(net, name, &bearer_id); |
| 1999 | if (node) { | 2012 | if (node) { |
| 2000 | tipc_node_lock(node); | 2013 | tipc_node_lock(node); |
| 2001 | l_ptr = node->links[bearer_id]; | 2014 | l_ptr = node->links[bearer_id]; |
| @@ -2063,8 +2076,8 @@ static int link_cmd_set_value(const char *name, u32 new_value, u16 cmd) | |||
| 2063 | return res; | 2076 | return res; |
| 2064 | } | 2077 | } |
| 2065 | 2078 | ||
| 2066 | struct sk_buff *tipc_link_cmd_config(const void *req_tlv_area, int req_tlv_space, | 2079 | struct sk_buff *tipc_link_cmd_config(struct net *net, const void *req_tlv_area, |
| 2067 | u16 cmd) | 2080 | int req_tlv_space, u16 cmd) |
| 2068 | { | 2081 | { |
| 2069 | struct tipc_link_config *args; | 2082 | struct tipc_link_config *args; |
| 2070 | u32 new_value; | 2083 | u32 new_value; |
| @@ -2088,7 +2101,7 @@ struct sk_buff *tipc_link_cmd_config(const void *req_tlv_area, int req_tlv_space | |||
| 2088 | " (cannot change setting on broadcast link)"); | 2101 | " (cannot change setting on broadcast link)"); |
| 2089 | } | 2102 | } |
| 2090 | 2103 | ||
| 2091 | res = link_cmd_set_value(args->name, new_value, cmd); | 2104 | res = link_cmd_set_value(net, args->name, new_value, cmd); |
| 2092 | if (res) | 2105 | if (res) |
| 2093 | return tipc_cfg_reply_error_string("cannot change link setting"); | 2106 | return tipc_cfg_reply_error_string("cannot change link setting"); |
| 2094 | 2107 | ||
| @@ -2106,7 +2119,9 @@ static void link_reset_statistics(struct tipc_link *l_ptr) | |||
| 2106 | l_ptr->stats.recv_info = l_ptr->next_in_no; | 2119 | l_ptr->stats.recv_info = l_ptr->next_in_no; |
| 2107 | } | 2120 | } |
| 2108 | 2121 | ||
| 2109 | struct sk_buff *tipc_link_cmd_reset_stats(const void *req_tlv_area, int req_tlv_space) | 2122 | struct sk_buff *tipc_link_cmd_reset_stats(struct net *net, |
| 2123 | const void *req_tlv_area, | ||
| 2124 | int req_tlv_space) | ||
| 2110 | { | 2125 | { |
| 2111 | char *link_name; | 2126 | char *link_name; |
| 2112 | struct tipc_link *l_ptr; | 2127 | struct tipc_link *l_ptr; |
| @@ -2122,7 +2137,7 @@ struct sk_buff *tipc_link_cmd_reset_stats(const void *req_tlv_area, int req_tlv_ | |||
| 2122 | return tipc_cfg_reply_error_string("link not found"); | 2137 | return tipc_cfg_reply_error_string("link not found"); |
| 2123 | return tipc_cfg_reply_none(); | 2138 | return tipc_cfg_reply_none(); |
| 2124 | } | 2139 | } |
| 2125 | node = tipc_link_find_owner(link_name, &bearer_id); | 2140 | node = tipc_link_find_owner(net, link_name, &bearer_id); |
| 2126 | if (!node) | 2141 | if (!node) |
| 2127 | return tipc_cfg_reply_error_string("link not found"); | 2142 | return tipc_cfg_reply_error_string("link not found"); |
| 2128 | 2143 | ||
| @@ -2147,13 +2162,15 @@ static u32 percent(u32 count, u32 total) | |||
| 2147 | 2162 | ||
| 2148 | /** | 2163 | /** |
| 2149 | * tipc_link_stats - print link statistics | 2164 | * tipc_link_stats - print link statistics |
| 2165 | * @net: the applicable net namespace | ||
| 2150 | * @name: link name | 2166 | * @name: link name |
| 2151 | * @buf: print buffer area | 2167 | * @buf: print buffer area |
| 2152 | * @buf_size: size of print buffer area | 2168 | * @buf_size: size of print buffer area |
| 2153 | * | 2169 | * |
| 2154 | * Returns length of print buffer data string (or 0 if error) | 2170 | * Returns length of print buffer data string (or 0 if error) |
| 2155 | */ | 2171 | */ |
| 2156 | static int tipc_link_stats(const char *name, char *buf, const u32 buf_size) | 2172 | static int tipc_link_stats(struct net *net, const char *name, char *buf, |
| 2173 | const u32 buf_size) | ||
| 2157 | { | 2174 | { |
| 2158 | struct tipc_link *l; | 2175 | struct tipc_link *l; |
| 2159 | struct tipc_stats *s; | 2176 | struct tipc_stats *s; |
| @@ -2166,7 +2183,7 @@ static int tipc_link_stats(const char *name, char *buf, const u32 buf_size) | |||
| 2166 | if (!strcmp(name, tipc_bclink_name)) | 2183 | if (!strcmp(name, tipc_bclink_name)) |
| 2167 | return tipc_bclink_stats(buf, buf_size); | 2184 | return tipc_bclink_stats(buf, buf_size); |
| 2168 | 2185 | ||
| 2169 | node = tipc_link_find_owner(name, &bearer_id); | 2186 | node = tipc_link_find_owner(net, name, &bearer_id); |
| 2170 | if (!node) | 2187 | if (!node) |
| 2171 | return 0; | 2188 | return 0; |
| 2172 | 2189 | ||
| @@ -2243,7 +2260,9 @@ static int tipc_link_stats(const char *name, char *buf, const u32 buf_size) | |||
| 2243 | return ret; | 2260 | return ret; |
| 2244 | } | 2261 | } |
| 2245 | 2262 | ||
| 2246 | struct sk_buff *tipc_link_cmd_show_stats(const void *req_tlv_area, int req_tlv_space) | 2263 | struct sk_buff *tipc_link_cmd_show_stats(struct net *net, |
| 2264 | const void *req_tlv_area, | ||
| 2265 | int req_tlv_space) | ||
| 2247 | { | 2266 | { |
| 2248 | struct sk_buff *buf; | 2267 | struct sk_buff *buf; |
| 2249 | struct tlv_desc *rep_tlv; | 2268 | struct tlv_desc *rep_tlv; |
| @@ -2261,7 +2280,7 @@ struct sk_buff *tipc_link_cmd_show_stats(const void *req_tlv_area, int req_tlv_s | |||
| 2261 | rep_tlv = (struct tlv_desc *)buf->data; | 2280 | rep_tlv = (struct tlv_desc *)buf->data; |
| 2262 | pb = TLV_DATA(rep_tlv); | 2281 | pb = TLV_DATA(rep_tlv); |
| 2263 | pb_len = ULTRA_STRING_MAX_LEN; | 2282 | pb_len = ULTRA_STRING_MAX_LEN; |
| 2264 | str_len = tipc_link_stats((char *)TLV_DATA(req_tlv_area), | 2283 | str_len = tipc_link_stats(net, (char *)TLV_DATA(req_tlv_area), |
| 2265 | pb, pb_len); | 2284 | pb, pb_len); |
| 2266 | if (!str_len) { | 2285 | if (!str_len) { |
| 2267 | kfree_skb(buf); | 2286 | kfree_skb(buf); |
| @@ -2343,6 +2362,7 @@ int tipc_nl_link_set(struct sk_buff *skb, struct genl_info *info) | |||
| 2343 | struct tipc_link *link; | 2362 | struct tipc_link *link; |
| 2344 | struct tipc_node *node; | 2363 | struct tipc_node *node; |
| 2345 | struct nlattr *attrs[TIPC_NLA_LINK_MAX + 1]; | 2364 | struct nlattr *attrs[TIPC_NLA_LINK_MAX + 1]; |
| 2365 | struct net *net = genl_info_net(info); | ||
| 2346 | 2366 | ||
| 2347 | if (!info->attrs[TIPC_NLA_LINK]) | 2367 | if (!info->attrs[TIPC_NLA_LINK]) |
| 2348 | return -EINVAL; | 2368 | return -EINVAL; |
| @@ -2358,7 +2378,7 @@ int tipc_nl_link_set(struct sk_buff *skb, struct genl_info *info) | |||
| 2358 | 2378 | ||
| 2359 | name = nla_data(attrs[TIPC_NLA_LINK_NAME]); | 2379 | name = nla_data(attrs[TIPC_NLA_LINK_NAME]); |
| 2360 | 2380 | ||
| 2361 | node = tipc_link_find_owner(name, &bearer_id); | 2381 | node = tipc_link_find_owner(net, name, &bearer_id); |
| 2362 | if (!node) | 2382 | if (!node) |
| 2363 | return -EINVAL; | 2383 | return -EINVAL; |
| 2364 | 2384 | ||
| @@ -2567,6 +2587,8 @@ static int __tipc_nl_add_node_links(struct tipc_nl_msg *msg, | |||
| 2567 | 2587 | ||
| 2568 | int tipc_nl_link_dump(struct sk_buff *skb, struct netlink_callback *cb) | 2588 | int tipc_nl_link_dump(struct sk_buff *skb, struct netlink_callback *cb) |
| 2569 | { | 2589 | { |
| 2590 | struct net *net = sock_net(skb->sk); | ||
| 2591 | struct tipc_net *tn = net_generic(net, tipc_net_id); | ||
| 2570 | struct tipc_node *node; | 2592 | struct tipc_node *node; |
| 2571 | struct tipc_nl_msg msg; | 2593 | struct tipc_nl_msg msg; |
| 2572 | u32 prev_node = cb->args[0]; | 2594 | u32 prev_node = cb->args[0]; |
| @@ -2584,7 +2606,7 @@ int tipc_nl_link_dump(struct sk_buff *skb, struct netlink_callback *cb) | |||
| 2584 | rcu_read_lock(); | 2606 | rcu_read_lock(); |
| 2585 | 2607 | ||
| 2586 | if (prev_node) { | 2608 | if (prev_node) { |
| 2587 | node = tipc_node_find(prev_node); | 2609 | node = tipc_node_find(net, prev_node); |
| 2588 | if (!node) { | 2610 | if (!node) { |
| 2589 | /* We never set seq or call nl_dump_check_consistent() | 2611 | /* We never set seq or call nl_dump_check_consistent() |
| 2590 | * this means that setting prev_seq here will cause the | 2612 | * this means that setting prev_seq here will cause the |
| @@ -2596,7 +2618,8 @@ int tipc_nl_link_dump(struct sk_buff *skb, struct netlink_callback *cb) | |||
| 2596 | goto out; | 2618 | goto out; |
| 2597 | } | 2619 | } |
| 2598 | 2620 | ||
| 2599 | list_for_each_entry_continue_rcu(node, &tipc_node_list, list) { | 2621 | list_for_each_entry_continue_rcu(node, &tn->node_list, |
| 2622 | list) { | ||
| 2600 | tipc_node_lock(node); | 2623 | tipc_node_lock(node); |
| 2601 | err = __tipc_nl_add_node_links(&msg, node, &prev_link); | 2624 | err = __tipc_nl_add_node_links(&msg, node, &prev_link); |
| 2602 | tipc_node_unlock(node); | 2625 | tipc_node_unlock(node); |
| @@ -2610,7 +2633,7 @@ int tipc_nl_link_dump(struct sk_buff *skb, struct netlink_callback *cb) | |||
| 2610 | if (err) | 2633 | if (err) |
| 2611 | goto out; | 2634 | goto out; |
| 2612 | 2635 | ||
| 2613 | list_for_each_entry_rcu(node, &tipc_node_list, list) { | 2636 | list_for_each_entry_rcu(node, &tn->node_list, list) { |
| 2614 | tipc_node_lock(node); | 2637 | tipc_node_lock(node); |
| 2615 | err = __tipc_nl_add_node_links(&msg, node, &prev_link); | 2638 | err = __tipc_nl_add_node_links(&msg, node, &prev_link); |
| 2616 | tipc_node_unlock(node); | 2639 | tipc_node_unlock(node); |
| @@ -2633,6 +2656,7 @@ out: | |||
| 2633 | 2656 | ||
| 2634 | int tipc_nl_link_get(struct sk_buff *skb, struct genl_info *info) | 2657 | int tipc_nl_link_get(struct sk_buff *skb, struct genl_info *info) |
| 2635 | { | 2658 | { |
| 2659 | struct net *net = genl_info_net(info); | ||
| 2636 | struct sk_buff *ans_skb; | 2660 | struct sk_buff *ans_skb; |
| 2637 | struct tipc_nl_msg msg; | 2661 | struct tipc_nl_msg msg; |
| 2638 | struct tipc_link *link; | 2662 | struct tipc_link *link; |
| @@ -2645,7 +2669,7 @@ int tipc_nl_link_get(struct sk_buff *skb, struct genl_info *info) | |||
| 2645 | return -EINVAL; | 2669 | return -EINVAL; |
| 2646 | 2670 | ||
| 2647 | name = nla_data(info->attrs[TIPC_NLA_LINK_NAME]); | 2671 | name = nla_data(info->attrs[TIPC_NLA_LINK_NAME]); |
| 2648 | node = tipc_link_find_owner(name, &bearer_id); | 2672 | node = tipc_link_find_owner(net, name, &bearer_id); |
| 2649 | if (!node) | 2673 | if (!node) |
| 2650 | return -EINVAL; | 2674 | return -EINVAL; |
| 2651 | 2675 | ||
| @@ -2687,6 +2711,7 @@ int tipc_nl_link_reset_stats(struct sk_buff *skb, struct genl_info *info) | |||
| 2687 | struct tipc_link *link; | 2711 | struct tipc_link *link; |
| 2688 | struct tipc_node *node; | 2712 | struct tipc_node *node; |
| 2689 | struct nlattr *attrs[TIPC_NLA_LINK_MAX + 1]; | 2713 | struct nlattr *attrs[TIPC_NLA_LINK_MAX + 1]; |
| 2714 | struct net *net = genl_info_net(info); | ||
| 2690 | 2715 | ||
| 2691 | if (!info->attrs[TIPC_NLA_LINK]) | 2716 | if (!info->attrs[TIPC_NLA_LINK]) |
| 2692 | return -EINVAL; | 2717 | return -EINVAL; |
| @@ -2709,7 +2734,7 @@ int tipc_nl_link_reset_stats(struct sk_buff *skb, struct genl_info *info) | |||
| 2709 | return 0; | 2734 | return 0; |
| 2710 | } | 2735 | } |
| 2711 | 2736 | ||
| 2712 | node = tipc_link_find_owner(link_name, &bearer_id); | 2737 | node = tipc_link_find_owner(net, link_name, &bearer_id); |
| 2713 | if (!node) | 2738 | if (!node) |
| 2714 | return -EINVAL; | 2739 | return -EINVAL; |
| 2715 | 2740 | ||
diff --git a/net/tipc/link.h b/net/tipc/link.h index 692268dca4b9..380e27ee0f70 100644 --- a/net/tipc/link.h +++ b/net/tipc/link.h | |||
| @@ -200,27 +200,31 @@ struct tipc_port; | |||
| 200 | struct tipc_link *tipc_link_create(struct tipc_node *n_ptr, | 200 | struct tipc_link *tipc_link_create(struct tipc_node *n_ptr, |
| 201 | struct tipc_bearer *b_ptr, | 201 | struct tipc_bearer *b_ptr, |
| 202 | const struct tipc_media_addr *media_addr); | 202 | const struct tipc_media_addr *media_addr); |
| 203 | void tipc_link_delete_list(unsigned int bearer_id, bool shutting_down); | 203 | void tipc_link_delete_list(struct net *net, unsigned int bearer_id, |
| 204 | bool shutting_down); | ||
| 204 | void tipc_link_failover_send_queue(struct tipc_link *l_ptr); | 205 | void tipc_link_failover_send_queue(struct tipc_link *l_ptr); |
| 205 | void tipc_link_dup_queue_xmit(struct tipc_link *l_ptr, struct tipc_link *dest); | 206 | void tipc_link_dup_queue_xmit(struct tipc_link *l_ptr, struct tipc_link *dest); |
| 206 | void tipc_link_reset_fragments(struct tipc_link *l_ptr); | 207 | void tipc_link_reset_fragments(struct tipc_link *l_ptr); |
| 207 | int tipc_link_is_up(struct tipc_link *l_ptr); | 208 | int tipc_link_is_up(struct tipc_link *l_ptr); |
| 208 | int tipc_link_is_active(struct tipc_link *l_ptr); | 209 | int tipc_link_is_active(struct tipc_link *l_ptr); |
| 209 | void tipc_link_purge_queues(struct tipc_link *l_ptr); | 210 | void tipc_link_purge_queues(struct tipc_link *l_ptr); |
| 210 | struct sk_buff *tipc_link_cmd_config(const void *req_tlv_area, | 211 | struct sk_buff *tipc_link_cmd_config(struct net *net, const void *req_tlv_area, |
| 211 | int req_tlv_space, | 212 | int req_tlv_space, u16 cmd); |
| 212 | u16 cmd); | 213 | struct sk_buff *tipc_link_cmd_show_stats(struct net *net, |
| 213 | struct sk_buff *tipc_link_cmd_show_stats(const void *req_tlv_area, | 214 | const void *req_tlv_area, |
| 214 | int req_tlv_space); | 215 | int req_tlv_space); |
| 215 | struct sk_buff *tipc_link_cmd_reset_stats(const void *req_tlv_area, | 216 | struct sk_buff *tipc_link_cmd_reset_stats(struct net *net, |
| 217 | const void *req_tlv_area, | ||
| 216 | int req_tlv_space); | 218 | int req_tlv_space); |
| 217 | void tipc_link_reset_all(struct tipc_node *node); | 219 | void tipc_link_reset_all(struct tipc_node *node); |
| 218 | void tipc_link_reset(struct tipc_link *l_ptr); | 220 | void tipc_link_reset(struct tipc_link *l_ptr); |
| 219 | void tipc_link_reset_list(unsigned int bearer_id); | 221 | void tipc_link_reset_list(struct net *net, unsigned int bearer_id); |
| 220 | int tipc_link_xmit_skb(struct sk_buff *skb, u32 dest, u32 selector); | 222 | int tipc_link_xmit_skb(struct net *net, struct sk_buff *skb, u32 dest, |
| 221 | int tipc_link_xmit(struct sk_buff_head *list, u32 dest, u32 selector); | 223 | u32 selector); |
| 224 | int tipc_link_xmit(struct net *net, struct sk_buff_head *list, u32 dest, | ||
| 225 | u32 selector); | ||
| 222 | int __tipc_link_xmit(struct tipc_link *link, struct sk_buff_head *list); | 226 | int __tipc_link_xmit(struct tipc_link *link, struct sk_buff_head *list); |
| 223 | void tipc_link_bundle_rcv(struct sk_buff *buf); | 227 | void tipc_link_bundle_rcv(struct net *net, struct sk_buff *buf); |
| 224 | void tipc_link_proto_xmit(struct tipc_link *l_ptr, u32 msg_typ, int prob, | 228 | void tipc_link_proto_xmit(struct tipc_link *l_ptr, u32 msg_typ, int prob, |
| 225 | u32 gap, u32 tolerance, u32 priority, u32 acked_mtu); | 229 | u32 gap, u32 tolerance, u32 priority, u32 acked_mtu); |
| 226 | void tipc_link_push_packets(struct tipc_link *l_ptr); | 230 | void tipc_link_push_packets(struct tipc_link *l_ptr); |
diff --git a/net/tipc/name_distr.c b/net/tipc/name_distr.c index ba6083dca95b..d40df588263e 100644 --- a/net/tipc/name_distr.c +++ b/net/tipc/name_distr.c | |||
| @@ -81,14 +81,15 @@ static struct sk_buff *named_prepare_buf(u32 type, u32 size, u32 dest) | |||
| 81 | return buf; | 81 | return buf; |
| 82 | } | 82 | } |
| 83 | 83 | ||
| 84 | void named_cluster_distribute(struct sk_buff *skb) | 84 | void named_cluster_distribute(struct net *net, struct sk_buff *skb) |
| 85 | { | 85 | { |
| 86 | struct tipc_net *tn = net_generic(net, tipc_net_id); | ||
| 86 | struct sk_buff *oskb; | 87 | struct sk_buff *oskb; |
| 87 | struct tipc_node *node; | 88 | struct tipc_node *node; |
| 88 | u32 dnode; | 89 | u32 dnode; |
| 89 | 90 | ||
| 90 | rcu_read_lock(); | 91 | rcu_read_lock(); |
| 91 | list_for_each_entry_rcu(node, &tipc_node_list, list) { | 92 | list_for_each_entry_rcu(node, &tn->node_list, list) { |
| 92 | dnode = node->addr; | 93 | dnode = node->addr; |
| 93 | if (in_own_node(dnode)) | 94 | if (in_own_node(dnode)) |
| 94 | continue; | 95 | continue; |
| @@ -98,7 +99,7 @@ void named_cluster_distribute(struct sk_buff *skb) | |||
| 98 | if (!oskb) | 99 | if (!oskb) |
| 99 | break; | 100 | break; |
| 100 | msg_set_destnode(buf_msg(oskb), dnode); | 101 | msg_set_destnode(buf_msg(oskb), dnode); |
| 101 | tipc_link_xmit_skb(oskb, dnode, dnode); | 102 | tipc_link_xmit_skb(net, oskb, dnode, dnode); |
| 102 | } | 103 | } |
| 103 | rcu_read_unlock(); | 104 | rcu_read_unlock(); |
| 104 | 105 | ||
| @@ -160,13 +161,14 @@ struct sk_buff *tipc_named_withdraw(struct publication *publ) | |||
| 160 | * @dnode: node to be updated | 161 | * @dnode: node to be updated |
| 161 | * @pls: linked list of publication items to be packed into buffer chain | 162 | * @pls: linked list of publication items to be packed into buffer chain |
| 162 | */ | 163 | */ |
| 163 | static void named_distribute(struct sk_buff_head *list, u32 dnode, | 164 | static void named_distribute(struct net *net, struct sk_buff_head *list, |
| 164 | struct list_head *pls) | 165 | u32 dnode, struct list_head *pls) |
| 165 | { | 166 | { |
| 166 | struct publication *publ; | 167 | struct publication *publ; |
| 167 | struct sk_buff *skb = NULL; | 168 | struct sk_buff *skb = NULL; |
| 168 | struct distr_item *item = NULL; | 169 | struct distr_item *item = NULL; |
| 169 | uint msg_dsz = (tipc_node_get_mtu(dnode, 0) / ITEM_SIZE) * ITEM_SIZE; | 170 | uint msg_dsz = (tipc_node_get_mtu(net, dnode, 0) / ITEM_SIZE) * |
| 171 | ITEM_SIZE; | ||
| 170 | uint msg_rem = msg_dsz; | 172 | uint msg_rem = msg_dsz; |
| 171 | 173 | ||
| 172 | list_for_each_entry(publ, pls, local_list) { | 174 | list_for_each_entry(publ, pls, local_list) { |
| @@ -202,30 +204,31 @@ static void named_distribute(struct sk_buff_head *list, u32 dnode, | |||
| 202 | /** | 204 | /** |
| 203 | * tipc_named_node_up - tell specified node about all publications by this node | 205 | * tipc_named_node_up - tell specified node about all publications by this node |
| 204 | */ | 206 | */ |
| 205 | void tipc_named_node_up(u32 dnode) | 207 | void tipc_named_node_up(struct net *net, u32 dnode) |
| 206 | { | 208 | { |
| 207 | struct sk_buff_head head; | 209 | struct sk_buff_head head; |
| 208 | 210 | ||
| 209 | __skb_queue_head_init(&head); | 211 | __skb_queue_head_init(&head); |
| 210 | 212 | ||
| 211 | rcu_read_lock(); | 213 | rcu_read_lock(); |
| 212 | named_distribute(&head, dnode, | 214 | named_distribute(net, &head, dnode, |
| 213 | &tipc_nametbl->publ_list[TIPC_CLUSTER_SCOPE]); | 215 | &tipc_nametbl->publ_list[TIPC_CLUSTER_SCOPE]); |
| 214 | named_distribute(&head, dnode, | 216 | named_distribute(net, &head, dnode, |
| 215 | &tipc_nametbl->publ_list[TIPC_ZONE_SCOPE]); | 217 | &tipc_nametbl->publ_list[TIPC_ZONE_SCOPE]); |
| 216 | rcu_read_unlock(); | 218 | rcu_read_unlock(); |
| 217 | 219 | ||
| 218 | tipc_link_xmit(&head, dnode, dnode); | 220 | tipc_link_xmit(net, &head, dnode, dnode); |
| 219 | } | 221 | } |
| 220 | 222 | ||
| 221 | static void tipc_publ_subscribe(struct publication *publ, u32 addr) | 223 | static void tipc_publ_subscribe(struct net *net, struct publication *publ, |
| 224 | u32 addr) | ||
| 222 | { | 225 | { |
| 223 | struct tipc_node *node; | 226 | struct tipc_node *node; |
| 224 | 227 | ||
| 225 | if (in_own_node(addr)) | 228 | if (in_own_node(addr)) |
| 226 | return; | 229 | return; |
| 227 | 230 | ||
| 228 | node = tipc_node_find(addr); | 231 | node = tipc_node_find(net, addr); |
| 229 | if (!node) { | 232 | if (!node) { |
| 230 | pr_warn("Node subscription rejected, unknown node 0x%x\n", | 233 | pr_warn("Node subscription rejected, unknown node 0x%x\n", |
| 231 | addr); | 234 | addr); |
| @@ -237,11 +240,12 @@ static void tipc_publ_subscribe(struct publication *publ, u32 addr) | |||
| 237 | tipc_node_unlock(node); | 240 | tipc_node_unlock(node); |
| 238 | } | 241 | } |
| 239 | 242 | ||
| 240 | static void tipc_publ_unsubscribe(struct publication *publ, u32 addr) | 243 | static void tipc_publ_unsubscribe(struct net *net, struct publication *publ, |
| 244 | u32 addr) | ||
| 241 | { | 245 | { |
| 242 | struct tipc_node *node; | 246 | struct tipc_node *node; |
| 243 | 247 | ||
| 244 | node = tipc_node_find(addr); | 248 | node = tipc_node_find(net, addr); |
| 245 | if (!node) | 249 | if (!node) |
| 246 | return; | 250 | return; |
| 247 | 251 | ||
| @@ -256,7 +260,7 @@ static void tipc_publ_unsubscribe(struct publication *publ, u32 addr) | |||
| 256 | * Invoked for each publication issued by a newly failed node. | 260 | * Invoked for each publication issued by a newly failed node. |
| 257 | * Removes publication structure from name table & deletes it. | 261 | * Removes publication structure from name table & deletes it. |
| 258 | */ | 262 | */ |
| 259 | static void tipc_publ_purge(struct publication *publ, u32 addr) | 263 | static void tipc_publ_purge(struct net *net, struct publication *publ, u32 addr) |
| 260 | { | 264 | { |
| 261 | struct publication *p; | 265 | struct publication *p; |
| 262 | 266 | ||
| @@ -264,7 +268,7 @@ static void tipc_publ_purge(struct publication *publ, u32 addr) | |||
| 264 | p = tipc_nametbl_remove_publ(publ->type, publ->lower, | 268 | p = tipc_nametbl_remove_publ(publ->type, publ->lower, |
| 265 | publ->node, publ->ref, publ->key); | 269 | publ->node, publ->ref, publ->key); |
| 266 | if (p) | 270 | if (p) |
| 267 | tipc_publ_unsubscribe(p, addr); | 271 | tipc_publ_unsubscribe(net, p, addr); |
| 268 | spin_unlock_bh(&tipc_nametbl_lock); | 272 | spin_unlock_bh(&tipc_nametbl_lock); |
| 269 | 273 | ||
| 270 | if (p != publ) { | 274 | if (p != publ) { |
| @@ -277,12 +281,12 @@ static void tipc_publ_purge(struct publication *publ, u32 addr) | |||
| 277 | kfree_rcu(p, rcu); | 281 | kfree_rcu(p, rcu); |
| 278 | } | 282 | } |
| 279 | 283 | ||
| 280 | void tipc_publ_notify(struct list_head *nsub_list, u32 addr) | 284 | void tipc_publ_notify(struct net *net, struct list_head *nsub_list, u32 addr) |
| 281 | { | 285 | { |
| 282 | struct publication *publ, *tmp; | 286 | struct publication *publ, *tmp; |
| 283 | 287 | ||
| 284 | list_for_each_entry_safe(publ, tmp, nsub_list, nodesub_list) | 288 | list_for_each_entry_safe(publ, tmp, nsub_list, nodesub_list) |
| 285 | tipc_publ_purge(publ, addr); | 289 | tipc_publ_purge(net, publ, addr); |
| 286 | } | 290 | } |
| 287 | 291 | ||
| 288 | /** | 292 | /** |
| @@ -292,7 +296,8 @@ void tipc_publ_notify(struct list_head *nsub_list, u32 addr) | |||
| 292 | * tipc_nametbl_lock must be held. | 296 | * tipc_nametbl_lock must be held. |
| 293 | * Returns the publication item if successful, otherwise NULL. | 297 | * Returns the publication item if successful, otherwise NULL. |
| 294 | */ | 298 | */ |
| 295 | static bool tipc_update_nametbl(struct distr_item *i, u32 node, u32 dtype) | 299 | static bool tipc_update_nametbl(struct net *net, struct distr_item *i, |
| 300 | u32 node, u32 dtype) | ||
| 296 | { | 301 | { |
| 297 | struct publication *publ = NULL; | 302 | struct publication *publ = NULL; |
| 298 | 303 | ||
| @@ -302,7 +307,7 @@ static bool tipc_update_nametbl(struct distr_item *i, u32 node, u32 dtype) | |||
| 302 | TIPC_CLUSTER_SCOPE, node, | 307 | TIPC_CLUSTER_SCOPE, node, |
| 303 | ntohl(i->ref), ntohl(i->key)); | 308 | ntohl(i->ref), ntohl(i->key)); |
| 304 | if (publ) { | 309 | if (publ) { |
| 305 | tipc_publ_subscribe(publ, node); | 310 | tipc_publ_subscribe(net, publ, node); |
| 306 | return true; | 311 | return true; |
| 307 | } | 312 | } |
| 308 | } else if (dtype == WITHDRAWAL) { | 313 | } else if (dtype == WITHDRAWAL) { |
| @@ -310,7 +315,7 @@ static bool tipc_update_nametbl(struct distr_item *i, u32 node, u32 dtype) | |||
| 310 | node, ntohl(i->ref), | 315 | node, ntohl(i->ref), |
| 311 | ntohl(i->key)); | 316 | ntohl(i->key)); |
| 312 | if (publ) { | 317 | if (publ) { |
| 313 | tipc_publ_unsubscribe(publ, node); | 318 | tipc_publ_unsubscribe(net, publ, node); |
| 314 | kfree_rcu(publ, rcu); | 319 | kfree_rcu(publ, rcu); |
| 315 | return true; | 320 | return true; |
| 316 | } | 321 | } |
| @@ -343,7 +348,7 @@ static void tipc_named_add_backlog(struct distr_item *i, u32 type, u32 node) | |||
| 343 | * tipc_named_process_backlog - try to process any pending name table updates | 348 | * tipc_named_process_backlog - try to process any pending name table updates |
| 344 | * from the network. | 349 | * from the network. |
| 345 | */ | 350 | */ |
| 346 | void tipc_named_process_backlog(void) | 351 | void tipc_named_process_backlog(struct net *net) |
| 347 | { | 352 | { |
| 348 | struct distr_queue_item *e, *tmp; | 353 | struct distr_queue_item *e, *tmp; |
| 349 | char addr[16]; | 354 | char addr[16]; |
| @@ -351,7 +356,7 @@ void tipc_named_process_backlog(void) | |||
| 351 | 356 | ||
| 352 | list_for_each_entry_safe(e, tmp, &tipc_dist_queue, next) { | 357 | list_for_each_entry_safe(e, tmp, &tipc_dist_queue, next) { |
| 353 | if (time_after(e->expires, now)) { | 358 | if (time_after(e->expires, now)) { |
| 354 | if (!tipc_update_nametbl(&e->i, e->node, e->dtype)) | 359 | if (!tipc_update_nametbl(net, &e->i, e->node, e->dtype)) |
| 355 | continue; | 360 | continue; |
| 356 | } else { | 361 | } else { |
| 357 | tipc_addr_string_fill(addr, e->node); | 362 | tipc_addr_string_fill(addr, e->node); |
| @@ -369,7 +374,7 @@ void tipc_named_process_backlog(void) | |||
| 369 | /** | 374 | /** |
| 370 | * tipc_named_rcv - process name table update message sent by another node | 375 | * tipc_named_rcv - process name table update message sent by another node |
| 371 | */ | 376 | */ |
| 372 | void tipc_named_rcv(struct sk_buff *buf) | 377 | void tipc_named_rcv(struct net *net, struct sk_buff *buf) |
| 373 | { | 378 | { |
| 374 | struct tipc_msg *msg = buf_msg(buf); | 379 | struct tipc_msg *msg = buf_msg(buf); |
| 375 | struct distr_item *item = (struct distr_item *)msg_data(msg); | 380 | struct distr_item *item = (struct distr_item *)msg_data(msg); |
| @@ -378,11 +383,11 @@ void tipc_named_rcv(struct sk_buff *buf) | |||
| 378 | 383 | ||
| 379 | spin_lock_bh(&tipc_nametbl_lock); | 384 | spin_lock_bh(&tipc_nametbl_lock); |
| 380 | while (count--) { | 385 | while (count--) { |
| 381 | if (!tipc_update_nametbl(item, node, msg_type(msg))) | 386 | if (!tipc_update_nametbl(net, item, node, msg_type(msg))) |
| 382 | tipc_named_add_backlog(item, msg_type(msg), node); | 387 | tipc_named_add_backlog(item, msg_type(msg), node); |
| 383 | item++; | 388 | item++; |
| 384 | } | 389 | } |
| 385 | tipc_named_process_backlog(); | 390 | tipc_named_process_backlog(net); |
| 386 | spin_unlock_bh(&tipc_nametbl_lock); | 391 | spin_unlock_bh(&tipc_nametbl_lock); |
| 387 | kfree_skb(buf); | 392 | kfree_skb(buf); |
| 388 | } | 393 | } |
diff --git a/net/tipc/name_distr.h b/net/tipc/name_distr.h index cef55cedcfb2..8039d84351b3 100644 --- a/net/tipc/name_distr.h +++ b/net/tipc/name_distr.h | |||
| @@ -69,11 +69,11 @@ struct distr_item { | |||
| 69 | 69 | ||
| 70 | struct sk_buff *tipc_named_publish(struct publication *publ); | 70 | struct sk_buff *tipc_named_publish(struct publication *publ); |
| 71 | struct sk_buff *tipc_named_withdraw(struct publication *publ); | 71 | struct sk_buff *tipc_named_withdraw(struct publication *publ); |
| 72 | void named_cluster_distribute(struct sk_buff *buf); | 72 | void named_cluster_distribute(struct net *net, struct sk_buff *buf); |
| 73 | void tipc_named_node_up(u32 dnode); | 73 | void tipc_named_node_up(struct net *net, u32 dnode); |
| 74 | void tipc_named_rcv(struct sk_buff *buf); | 74 | void tipc_named_rcv(struct net *net, struct sk_buff *buf); |
| 75 | void tipc_named_reinit(void); | 75 | void tipc_named_reinit(void); |
| 76 | void tipc_named_process_backlog(void); | 76 | void tipc_named_process_backlog(struct net *net); |
| 77 | void tipc_publ_notify(struct list_head *nsub_list, u32 addr); | 77 | void tipc_publ_notify(struct net *net, struct list_head *nsub_list, u32 addr); |
| 78 | 78 | ||
| 79 | #endif | 79 | #endif |
diff --git a/net/tipc/name_table.c b/net/tipc/name_table.c index c8df0223371a..cf177907bb53 100644 --- a/net/tipc/name_table.c +++ b/net/tipc/name_table.c | |||
| @@ -650,8 +650,9 @@ exit: | |||
| 650 | /* | 650 | /* |
| 651 | * tipc_nametbl_publish - add name publication to network name tables | 651 | * tipc_nametbl_publish - add name publication to network name tables |
| 652 | */ | 652 | */ |
| 653 | struct publication *tipc_nametbl_publish(u32 type, u32 lower, u32 upper, | 653 | struct publication *tipc_nametbl_publish(struct net *net, u32 type, u32 lower, |
| 654 | u32 scope, u32 port_ref, u32 key) | 654 | u32 upper, u32 scope, u32 port_ref, |
| 655 | u32 key) | ||
| 655 | { | 656 | { |
| 656 | struct publication *publ; | 657 | struct publication *publ; |
| 657 | struct sk_buff *buf = NULL; | 658 | struct sk_buff *buf = NULL; |
| @@ -670,19 +671,20 @@ struct publication *tipc_nametbl_publish(u32 type, u32 lower, u32 upper, | |||
| 670 | tipc_nametbl->local_publ_count++; | 671 | tipc_nametbl->local_publ_count++; |
| 671 | buf = tipc_named_publish(publ); | 672 | buf = tipc_named_publish(publ); |
| 672 | /* Any pending external events? */ | 673 | /* Any pending external events? */ |
| 673 | tipc_named_process_backlog(); | 674 | tipc_named_process_backlog(net); |
| 674 | } | 675 | } |
| 675 | spin_unlock_bh(&tipc_nametbl_lock); | 676 | spin_unlock_bh(&tipc_nametbl_lock); |
| 676 | 677 | ||
| 677 | if (buf) | 678 | if (buf) |
| 678 | named_cluster_distribute(buf); | 679 | named_cluster_distribute(net, buf); |
| 679 | return publ; | 680 | return publ; |
| 680 | } | 681 | } |
| 681 | 682 | ||
| 682 | /** | 683 | /** |
| 683 | * tipc_nametbl_withdraw - withdraw name publication from network name tables | 684 | * tipc_nametbl_withdraw - withdraw name publication from network name tables |
| 684 | */ | 685 | */ |
| 685 | int tipc_nametbl_withdraw(u32 type, u32 lower, u32 ref, u32 key) | 686 | int tipc_nametbl_withdraw(struct net *net, u32 type, u32 lower, u32 ref, |
| 687 | u32 key) | ||
| 686 | { | 688 | { |
| 687 | struct publication *publ; | 689 | struct publication *publ; |
| 688 | struct sk_buff *skb = NULL; | 690 | struct sk_buff *skb = NULL; |
| @@ -693,7 +695,7 @@ int tipc_nametbl_withdraw(u32 type, u32 lower, u32 ref, u32 key) | |||
| 693 | tipc_nametbl->local_publ_count--; | 695 | tipc_nametbl->local_publ_count--; |
| 694 | skb = tipc_named_withdraw(publ); | 696 | skb = tipc_named_withdraw(publ); |
| 695 | /* Any pending external events? */ | 697 | /* Any pending external events? */ |
| 696 | tipc_named_process_backlog(); | 698 | tipc_named_process_backlog(net); |
| 697 | list_del_init(&publ->pport_list); | 699 | list_del_init(&publ->pport_list); |
| 698 | kfree_rcu(publ, rcu); | 700 | kfree_rcu(publ, rcu); |
| 699 | } else { | 701 | } else { |
| @@ -704,7 +706,7 @@ int tipc_nametbl_withdraw(u32 type, u32 lower, u32 ref, u32 key) | |||
| 704 | spin_unlock_bh(&tipc_nametbl_lock); | 706 | spin_unlock_bh(&tipc_nametbl_lock); |
| 705 | 707 | ||
| 706 | if (skb) { | 708 | if (skb) { |
| 707 | named_cluster_distribute(skb); | 709 | named_cluster_distribute(net, skb); |
| 708 | return 1; | 710 | return 1; |
| 709 | } | 711 | } |
| 710 | return 0; | 712 | return 0; |
diff --git a/net/tipc/name_table.h b/net/tipc/name_table.h index 5f0dee92010d..efccaca7a5d5 100644 --- a/net/tipc/name_table.h +++ b/net/tipc/name_table.h | |||
| @@ -104,9 +104,11 @@ struct sk_buff *tipc_nametbl_get(const void *req_tlv_area, int req_tlv_space); | |||
| 104 | u32 tipc_nametbl_translate(u32 type, u32 instance, u32 *node); | 104 | u32 tipc_nametbl_translate(u32 type, u32 instance, u32 *node); |
| 105 | int tipc_nametbl_mc_translate(u32 type, u32 lower, u32 upper, u32 limit, | 105 | int tipc_nametbl_mc_translate(u32 type, u32 lower, u32 upper, u32 limit, |
| 106 | struct tipc_port_list *dports); | 106 | struct tipc_port_list *dports); |
| 107 | struct publication *tipc_nametbl_publish(u32 type, u32 lower, u32 upper, | 107 | struct publication *tipc_nametbl_publish(struct net *net, u32 type, u32 lower, |
| 108 | u32 scope, u32 port_ref, u32 key); | 108 | u32 upper, u32 scope, u32 port_ref, |
| 109 | int tipc_nametbl_withdraw(u32 type, u32 lower, u32 ref, u32 key); | 109 | u32 key); |
| 110 | int tipc_nametbl_withdraw(struct net *net, u32 type, u32 lower, u32 ref, | ||
| 111 | u32 key); | ||
| 110 | struct publication *tipc_nametbl_insert_publ(u32 type, u32 lower, u32 upper, | 112 | struct publication *tipc_nametbl_insert_publ(u32 type, u32 lower, u32 upper, |
| 111 | u32 scope, u32 node, u32 ref, | 113 | u32 scope, u32 node, u32 ref, |
| 112 | u32 key); | 114 | u32 key); |
diff --git a/net/tipc/net.c b/net/tipc/net.c index 5ce9d628f2d0..de18aacf3d64 100644 --- a/net/tipc/net.c +++ b/net/tipc/net.c | |||
| @@ -121,7 +121,7 @@ int tipc_net_start(struct net *net, u32 addr) | |||
| 121 | if (res) | 121 | if (res) |
| 122 | return res; | 122 | return res; |
| 123 | 123 | ||
| 124 | tipc_nametbl_publish(TIPC_CFG_SRV, tipc_own_addr, tipc_own_addr, | 124 | tipc_nametbl_publish(net, TIPC_CFG_SRV, tipc_own_addr, tipc_own_addr, |
| 125 | TIPC_ZONE_SCOPE, 0, tipc_own_addr); | 125 | TIPC_ZONE_SCOPE, 0, tipc_own_addr); |
| 126 | 126 | ||
| 127 | pr_info("Started in network mode\n"); | 127 | pr_info("Started in network mode\n"); |
| @@ -131,16 +131,17 @@ int tipc_net_start(struct net *net, u32 addr) | |||
| 131 | return 0; | 131 | return 0; |
| 132 | } | 132 | } |
| 133 | 133 | ||
| 134 | void tipc_net_stop(void) | 134 | void tipc_net_stop(struct net *net) |
| 135 | { | 135 | { |
| 136 | if (!tipc_own_addr) | 136 | if (!tipc_own_addr) |
| 137 | return; | 137 | return; |
| 138 | 138 | ||
| 139 | tipc_nametbl_withdraw(TIPC_CFG_SRV, tipc_own_addr, 0, tipc_own_addr); | 139 | tipc_nametbl_withdraw(net, TIPC_CFG_SRV, tipc_own_addr, 0, |
| 140 | tipc_own_addr); | ||
| 140 | rtnl_lock(); | 141 | rtnl_lock(); |
| 141 | tipc_bearer_stop(); | 142 | tipc_bearer_stop(net); |
| 142 | tipc_bclink_stop(); | 143 | tipc_bclink_stop(); |
| 143 | tipc_node_stop(); | 144 | tipc_node_stop(net); |
| 144 | rtnl_unlock(); | 145 | rtnl_unlock(); |
| 145 | 146 | ||
| 146 | pr_info("Left network mode\n"); | 147 | pr_info("Left network mode\n"); |
diff --git a/net/tipc/net.h b/net/tipc/net.h index 2c4812f8408f..77a7a118911d 100644 --- a/net/tipc/net.h +++ b/net/tipc/net.h | |||
| @@ -41,7 +41,7 @@ | |||
| 41 | 41 | ||
| 42 | int tipc_net_start(struct net *net, u32 addr); | 42 | int tipc_net_start(struct net *net, u32 addr); |
| 43 | 43 | ||
| 44 | void tipc_net_stop(void); | 44 | void tipc_net_stop(struct net *net); |
| 45 | 45 | ||
| 46 | int tipc_nl_net_dump(struct sk_buff *skb, struct netlink_callback *cb); | 46 | int tipc_nl_net_dump(struct sk_buff *skb, struct netlink_callback *cb); |
| 47 | int tipc_nl_net_set(struct sk_buff *skb, struct genl_info *info); | 47 | int tipc_nl_net_set(struct sk_buff *skb, struct genl_info *info); |
diff --git a/net/tipc/node.c b/net/tipc/node.c index 8d353ec77a66..a0ca1ac53119 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(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,32 +124,33 @@ 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; |
| @@ -161,7 +158,7 @@ int tipc_node_add_conn(u32 dnode, u32 port, u32 peer_port) | |||
| 161 | if (in_own_node(dnode)) | 158 | if (in_own_node(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,7 +176,7 @@ 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; |
| @@ -187,7 +184,7 @@ void tipc_node_remove_conn(u32 dnode, u32 port) | |||
| 187 | if (in_own_node(dnode)) | 184 | if (in_own_node(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,7 +198,7 @@ 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 | { |
| 206 | struct tipc_sock_conn *conn, *safe; | 203 | struct tipc_sock_conn *conn, *safe; |
| 207 | struct sk_buff *buf; | 204 | struct sk_buff *buf; |
| @@ -212,7 +209,7 @@ void tipc_node_abort_sock_conns(struct list_head *conns) | |||
| 212 | conn->peer_node, conn->port, | 209 | conn->peer_node, conn->port, |
| 213 | conn->peer_port, TIPC_ERR_NO_NODE); | 210 | conn->peer_port, TIPC_ERR_NO_NODE); |
| 214 | if (likely(buf)) | 211 | if (likely(buf)) |
| 215 | tipc_sk_rcv(buf); | 212 | tipc_sk_rcv(net, buf); |
| 216 | list_del(&conn->list); | 213 | list_del(&conn->list); |
| 217 | kfree(conn); | 214 | kfree(conn); |
| 218 | } | 215 | } |
| @@ -342,24 +339,27 @@ int tipc_node_is_up(struct tipc_node *n_ptr) | |||
| 342 | 339 | ||
| 343 | void tipc_node_attach_link(struct tipc_node *n_ptr, struct tipc_link *l_ptr) | 340 | void tipc_node_attach_link(struct tipc_node *n_ptr, struct tipc_link *l_ptr) |
| 344 | { | 341 | { |
| 342 | struct tipc_net *tn = net_generic(n_ptr->net, tipc_net_id); | ||
| 343 | |||
| 345 | n_ptr->links[l_ptr->bearer_id] = l_ptr; | 344 | n_ptr->links[l_ptr->bearer_id] = l_ptr; |
| 346 | spin_lock_bh(&node_list_lock); | 345 | spin_lock_bh(&tn->node_list_lock); |
| 347 | tipc_num_links++; | 346 | tn->num_links++; |
| 348 | spin_unlock_bh(&node_list_lock); | 347 | spin_unlock_bh(&tn->node_list_lock); |
| 349 | n_ptr->link_cnt++; | 348 | n_ptr->link_cnt++; |
| 350 | } | 349 | } |
| 351 | 350 | ||
| 352 | void tipc_node_detach_link(struct tipc_node *n_ptr, struct tipc_link *l_ptr) | 351 | void tipc_node_detach_link(struct tipc_node *n_ptr, struct tipc_link *l_ptr) |
| 353 | { | 352 | { |
| 353 | struct tipc_net *tn = net_generic(n_ptr->net, tipc_net_id); | ||
| 354 | int i; | 354 | int i; |
| 355 | 355 | ||
| 356 | for (i = 0; i < MAX_BEARERS; i++) { | 356 | for (i = 0; i < MAX_BEARERS; i++) { |
| 357 | if (l_ptr != n_ptr->links[i]) | 357 | if (l_ptr != n_ptr->links[i]) |
| 358 | continue; | 358 | continue; |
| 359 | n_ptr->links[i] = NULL; | 359 | n_ptr->links[i] = NULL; |
| 360 | spin_lock_bh(&node_list_lock); | 360 | spin_lock_bh(&tn->node_list_lock); |
| 361 | tipc_num_links--; | 361 | tn->num_links--; |
| 362 | spin_unlock_bh(&node_list_lock); | 362 | spin_unlock_bh(&tn->node_list_lock); |
| 363 | n_ptr->link_cnt--; | 363 | n_ptr->link_cnt--; |
| 364 | } | 364 | } |
| 365 | } | 365 | } |
| @@ -414,8 +414,10 @@ static void node_lost_contact(struct tipc_node *n_ptr) | |||
| 414 | TIPC_NOTIFY_NODE_DOWN; | 414 | TIPC_NOTIFY_NODE_DOWN; |
| 415 | } | 415 | } |
| 416 | 416 | ||
| 417 | struct sk_buff *tipc_node_get_nodes(const void *req_tlv_area, int req_tlv_space) | 417 | struct sk_buff *tipc_node_get_nodes(struct net *net, const void *req_tlv_area, |
| 418 | int req_tlv_space) | ||
| 418 | { | 419 | { |
| 420 | struct tipc_net *tn = net_generic(net, tipc_net_id); | ||
| 419 | u32 domain; | 421 | u32 domain; |
| 420 | struct sk_buff *buf; | 422 | struct sk_buff *buf; |
| 421 | struct tipc_node *n_ptr; | 423 | struct tipc_node *n_ptr; |
| @@ -430,20 +432,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 | 432 | return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE |
| 431 | " (network address)"); | 433 | " (network address)"); |
| 432 | 434 | ||
| 433 | spin_lock_bh(&node_list_lock); | 435 | spin_lock_bh(&tn->node_list_lock); |
| 434 | if (!tipc_num_nodes) { | 436 | if (!tn->num_nodes) { |
| 435 | spin_unlock_bh(&node_list_lock); | 437 | spin_unlock_bh(&tn->node_list_lock); |
| 436 | return tipc_cfg_reply_none(); | 438 | return tipc_cfg_reply_none(); |
| 437 | } | 439 | } |
| 438 | 440 | ||
| 439 | /* For now, get space for all other nodes */ | 441 | /* For now, get space for all other nodes */ |
| 440 | payload_size = TLV_SPACE(sizeof(node_info)) * tipc_num_nodes; | 442 | payload_size = TLV_SPACE(sizeof(node_info)) * tn->num_nodes; |
| 441 | if (payload_size > 32768u) { | 443 | if (payload_size > 32768u) { |
| 442 | spin_unlock_bh(&node_list_lock); | 444 | spin_unlock_bh(&tn->node_list_lock); |
| 443 | return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED | 445 | return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED |
| 444 | " (too many nodes)"); | 446 | " (too many nodes)"); |
| 445 | } | 447 | } |
| 446 | spin_unlock_bh(&node_list_lock); | 448 | spin_unlock_bh(&tn->node_list_lock); |
| 447 | 449 | ||
| 448 | buf = tipc_cfg_reply_alloc(payload_size); | 450 | buf = tipc_cfg_reply_alloc(payload_size); |
| 449 | if (!buf) | 451 | if (!buf) |
| @@ -451,7 +453,7 @@ struct sk_buff *tipc_node_get_nodes(const void *req_tlv_area, int req_tlv_space) | |||
| 451 | 453 | ||
| 452 | /* Add TLVs for all nodes in scope */ | 454 | /* Add TLVs for all nodes in scope */ |
| 453 | rcu_read_lock(); | 455 | rcu_read_lock(); |
| 454 | list_for_each_entry_rcu(n_ptr, &tipc_node_list, list) { | 456 | list_for_each_entry_rcu(n_ptr, &tn->node_list, list) { |
| 455 | if (!tipc_in_scope(domain, n_ptr->addr)) | 457 | if (!tipc_in_scope(domain, n_ptr->addr)) |
| 456 | continue; | 458 | continue; |
| 457 | node_info.addr = htonl(n_ptr->addr); | 459 | node_info.addr = htonl(n_ptr->addr); |
| @@ -463,8 +465,10 @@ struct sk_buff *tipc_node_get_nodes(const void *req_tlv_area, int req_tlv_space) | |||
| 463 | return buf; | 465 | return buf; |
| 464 | } | 466 | } |
| 465 | 467 | ||
| 466 | struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space) | 468 | struct sk_buff *tipc_node_get_links(struct net *net, const void *req_tlv_area, |
| 469 | int req_tlv_space) | ||
| 467 | { | 470 | { |
| 471 | struct tipc_net *tn = net_generic(net, tipc_net_id); | ||
| 468 | u32 domain; | 472 | u32 domain; |
| 469 | struct sk_buff *buf; | 473 | struct sk_buff *buf; |
| 470 | struct tipc_node *n_ptr; | 474 | struct tipc_node *n_ptr; |
| @@ -482,15 +486,15 @@ struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space) | |||
| 482 | if (!tipc_own_addr) | 486 | if (!tipc_own_addr) |
| 483 | return tipc_cfg_reply_none(); | 487 | return tipc_cfg_reply_none(); |
| 484 | 488 | ||
| 485 | spin_lock_bh(&node_list_lock); | 489 | spin_lock_bh(&tn->node_list_lock); |
| 486 | /* Get space for all unicast links + broadcast link */ | 490 | /* Get space for all unicast links + broadcast link */ |
| 487 | payload_size = TLV_SPACE((sizeof(link_info)) * (tipc_num_links + 1)); | 491 | payload_size = TLV_SPACE((sizeof(link_info)) * (tn->num_links + 1)); |
| 488 | if (payload_size > 32768u) { | 492 | if (payload_size > 32768u) { |
| 489 | spin_unlock_bh(&node_list_lock); | 493 | spin_unlock_bh(&tn->node_list_lock); |
| 490 | return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED | 494 | return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED |
| 491 | " (too many links)"); | 495 | " (too many links)"); |
| 492 | } | 496 | } |
| 493 | spin_unlock_bh(&node_list_lock); | 497 | spin_unlock_bh(&tn->node_list_lock); |
| 494 | 498 | ||
| 495 | buf = tipc_cfg_reply_alloc(payload_size); | 499 | buf = tipc_cfg_reply_alloc(payload_size); |
| 496 | if (!buf) | 500 | if (!buf) |
| @@ -504,7 +508,7 @@ struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space) | |||
| 504 | 508 | ||
| 505 | /* Add TLVs for any other links in scope */ | 509 | /* Add TLVs for any other links in scope */ |
| 506 | rcu_read_lock(); | 510 | rcu_read_lock(); |
| 507 | list_for_each_entry_rcu(n_ptr, &tipc_node_list, list) { | 511 | list_for_each_entry_rcu(n_ptr, &tn->node_list, list) { |
| 508 | u32 i; | 512 | u32 i; |
| 509 | 513 | ||
| 510 | if (!tipc_in_scope(domain, n_ptr->addr)) | 514 | if (!tipc_in_scope(domain, n_ptr->addr)) |
| @@ -534,10 +538,11 @@ struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space) | |||
| 534 | * | 538 | * |
| 535 | * Returns 0 on success | 539 | * Returns 0 on success |
| 536 | */ | 540 | */ |
| 537 | int tipc_node_get_linkname(u32 bearer_id, u32 addr, char *linkname, size_t len) | 541 | int tipc_node_get_linkname(struct net *net, u32 bearer_id, u32 addr, |
| 542 | char *linkname, size_t len) | ||
| 538 | { | 543 | { |
| 539 | struct tipc_link *link; | 544 | struct tipc_link *link; |
| 540 | struct tipc_node *node = tipc_node_find(addr); | 545 | struct tipc_node *node = tipc_node_find(net, addr); |
| 541 | 546 | ||
| 542 | if ((bearer_id >= MAX_BEARERS) || !node) | 547 | if ((bearer_id >= MAX_BEARERS) || !node) |
| 543 | return -EINVAL; | 548 | return -EINVAL; |
| @@ -554,6 +559,7 @@ int tipc_node_get_linkname(u32 bearer_id, u32 addr, char *linkname, size_t len) | |||
| 554 | 559 | ||
| 555 | void tipc_node_unlock(struct tipc_node *node) | 560 | void tipc_node_unlock(struct tipc_node *node) |
| 556 | { | 561 | { |
| 562 | struct net *net = node->net; | ||
| 557 | LIST_HEAD(nsub_list); | 563 | LIST_HEAD(nsub_list); |
| 558 | LIST_HEAD(conn_sks); | 564 | LIST_HEAD(conn_sks); |
| 559 | struct sk_buff_head waiting_sks; | 565 | struct sk_buff_head waiting_sks; |
| @@ -585,26 +591,26 @@ void tipc_node_unlock(struct tipc_node *node) | |||
| 585 | spin_unlock_bh(&node->lock); | 591 | spin_unlock_bh(&node->lock); |
| 586 | 592 | ||
| 587 | while (!skb_queue_empty(&waiting_sks)) | 593 | while (!skb_queue_empty(&waiting_sks)) |
| 588 | tipc_sk_rcv(__skb_dequeue(&waiting_sks)); | 594 | tipc_sk_rcv(net, __skb_dequeue(&waiting_sks)); |
| 589 | 595 | ||
| 590 | if (!list_empty(&conn_sks)) | 596 | if (!list_empty(&conn_sks)) |
| 591 | tipc_node_abort_sock_conns(&conn_sks); | 597 | tipc_node_abort_sock_conns(net, &conn_sks); |
| 592 | 598 | ||
| 593 | if (!list_empty(&nsub_list)) | 599 | if (!list_empty(&nsub_list)) |
| 594 | tipc_publ_notify(&nsub_list, addr); | 600 | tipc_publ_notify(net, &nsub_list, addr); |
| 595 | 601 | ||
| 596 | if (flags & TIPC_WAKEUP_BCAST_USERS) | 602 | if (flags & TIPC_WAKEUP_BCAST_USERS) |
| 597 | tipc_bclink_wakeup_users(); | 603 | tipc_bclink_wakeup_users(net); |
| 598 | 604 | ||
| 599 | if (flags & TIPC_NOTIFY_NODE_UP) | 605 | if (flags & TIPC_NOTIFY_NODE_UP) |
| 600 | tipc_named_node_up(addr); | 606 | tipc_named_node_up(net, addr); |
| 601 | 607 | ||
| 602 | if (flags & TIPC_NOTIFY_LINK_UP) | 608 | if (flags & TIPC_NOTIFY_LINK_UP) |
| 603 | tipc_nametbl_publish(TIPC_LINK_STATE, addr, addr, | 609 | tipc_nametbl_publish(net, TIPC_LINK_STATE, addr, addr, |
| 604 | TIPC_NODE_SCOPE, link_id, addr); | 610 | TIPC_NODE_SCOPE, link_id, addr); |
| 605 | 611 | ||
| 606 | if (flags & TIPC_NOTIFY_LINK_DOWN) | 612 | if (flags & TIPC_NOTIFY_LINK_DOWN) |
| 607 | tipc_nametbl_withdraw(TIPC_LINK_STATE, addr, | 613 | tipc_nametbl_withdraw(net, TIPC_LINK_STATE, addr, |
| 608 | link_id, addr); | 614 | link_id, addr); |
| 609 | } | 615 | } |
| 610 | 616 | ||
| @@ -645,6 +651,8 @@ msg_full: | |||
| 645 | int tipc_nl_node_dump(struct sk_buff *skb, struct netlink_callback *cb) | 651 | int tipc_nl_node_dump(struct sk_buff *skb, struct netlink_callback *cb) |
| 646 | { | 652 | { |
| 647 | int err; | 653 | int err; |
| 654 | struct net *net = sock_net(skb->sk); | ||
| 655 | struct tipc_net *tn = net_generic(net, tipc_net_id); | ||
| 648 | int done = cb->args[0]; | 656 | int done = cb->args[0]; |
| 649 | int last_addr = cb->args[1]; | 657 | int last_addr = cb->args[1]; |
| 650 | struct tipc_node *node; | 658 | struct tipc_node *node; |
| @@ -659,7 +667,7 @@ int tipc_nl_node_dump(struct sk_buff *skb, struct netlink_callback *cb) | |||
| 659 | 667 | ||
| 660 | rcu_read_lock(); | 668 | rcu_read_lock(); |
| 661 | 669 | ||
| 662 | if (last_addr && !tipc_node_find(last_addr)) { | 670 | if (last_addr && !tipc_node_find(net, last_addr)) { |
| 663 | rcu_read_unlock(); | 671 | rcu_read_unlock(); |
| 664 | /* We never set seq or call nl_dump_check_consistent() this | 672 | /* We never set seq or call nl_dump_check_consistent() this |
| 665 | * means that setting prev_seq here will cause the consistence | 673 | * means that setting prev_seq here will cause the consistence |
| @@ -671,7 +679,7 @@ int tipc_nl_node_dump(struct sk_buff *skb, struct netlink_callback *cb) | |||
| 671 | return -EPIPE; | 679 | return -EPIPE; |
| 672 | } | 680 | } |
| 673 | 681 | ||
| 674 | list_for_each_entry_rcu(node, &tipc_node_list, list) { | 682 | list_for_each_entry_rcu(node, &tn->node_list, list) { |
| 675 | if (last_addr) { | 683 | if (last_addr) { |
| 676 | if (node->addr == last_addr) | 684 | if (node->addr == last_addr) |
| 677 | last_addr = 0; | 685 | last_addr = 0; |
diff --git a/net/tipc/node.h b/net/tipc/node.h index cbe0e950f1cc..43ef88ef3035 100644 --- a/net/tipc/node.h +++ b/net/tipc/node.h | |||
| @@ -42,10 +42,10 @@ | |||
| 42 | #include "bearer.h" | 42 | #include "bearer.h" |
| 43 | #include "msg.h" | 43 | #include "msg.h" |
| 44 | 44 | ||
| 45 | /* | 45 | /* Out-of-range value for node signature */ |
| 46 | * Out-of-range value for node signature | 46 | #define INVALID_NODE_SIG 0x10000 |
| 47 | */ | 47 | |
| 48 | #define INVALID_NODE_SIG 0x10000 | 48 | #define NODE_HTABLE_SIZE 512 |
| 49 | 49 | ||
| 50 | /* Flags used to take different actions according to flag type | 50 | /* Flags used to take different actions according to flag type |
| 51 | * TIPC_WAIT_PEER_LINKS_DOWN: wait to see that peer's links are down | 51 | * TIPC_WAIT_PEER_LINKS_DOWN: wait to see that peer's links are down |
| @@ -90,6 +90,7 @@ struct tipc_node_bclink { | |||
| 90 | * struct tipc_node - TIPC node structure | 90 | * struct tipc_node - TIPC node structure |
| 91 | * @addr: network address of node | 91 | * @addr: network address of node |
| 92 | * @lock: spinlock governing access to structure | 92 | * @lock: spinlock governing access to structure |
| 93 | * @net: the applicable net namespace | ||
| 93 | * @hash: links to adjacent nodes in unsorted hash chain | 94 | * @hash: links to adjacent nodes in unsorted hash chain |
| 94 | * @active_links: pointers to active links to node | 95 | * @active_links: pointers to active links to node |
| 95 | * @links: pointers to all links to node | 96 | * @links: pointers to all links to node |
| @@ -106,6 +107,7 @@ struct tipc_node_bclink { | |||
| 106 | struct tipc_node { | 107 | struct tipc_node { |
| 107 | u32 addr; | 108 | u32 addr; |
| 108 | spinlock_t lock; | 109 | spinlock_t lock; |
| 110 | struct net *net; | ||
| 109 | struct hlist_node hash; | 111 | struct hlist_node hash; |
| 110 | struct tipc_link *active_links[2]; | 112 | struct tipc_link *active_links[2]; |
| 111 | u32 act_mtus[2]; | 113 | u32 act_mtus[2]; |
| @@ -123,23 +125,24 @@ struct tipc_node { | |||
| 123 | struct rcu_head rcu; | 125 | struct rcu_head rcu; |
| 124 | }; | 126 | }; |
| 125 | 127 | ||
| 126 | extern struct list_head tipc_node_list; | 128 | struct tipc_node *tipc_node_find(struct net *net, u32 addr); |
| 127 | 129 | struct tipc_node *tipc_node_create(struct net *net, u32 addr); | |
| 128 | struct tipc_node *tipc_node_find(u32 addr); | 130 | void tipc_node_stop(struct net *net); |
| 129 | struct tipc_node *tipc_node_create(u32 addr); | ||
| 130 | void tipc_node_stop(void); | ||
| 131 | void tipc_node_attach_link(struct tipc_node *n_ptr, struct tipc_link *l_ptr); | 131 | void tipc_node_attach_link(struct tipc_node *n_ptr, struct tipc_link *l_ptr); |
| 132 | void tipc_node_detach_link(struct tipc_node *n_ptr, struct tipc_link *l_ptr); | 132 | void tipc_node_detach_link(struct tipc_node *n_ptr, struct tipc_link *l_ptr); |
| 133 | void tipc_node_link_down(struct tipc_node *n_ptr, struct tipc_link *l_ptr); | 133 | void tipc_node_link_down(struct tipc_node *n_ptr, struct tipc_link *l_ptr); |
| 134 | void tipc_node_link_up(struct tipc_node *n_ptr, struct tipc_link *l_ptr); | 134 | void tipc_node_link_up(struct tipc_node *n_ptr, struct tipc_link *l_ptr); |
| 135 | int tipc_node_active_links(struct tipc_node *n_ptr); | 135 | int tipc_node_active_links(struct tipc_node *n_ptr); |
| 136 | int tipc_node_is_up(struct tipc_node *n_ptr); | 136 | int tipc_node_is_up(struct tipc_node *n_ptr); |
| 137 | struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space); | 137 | struct sk_buff *tipc_node_get_links(struct net *net, const void *req_tlv_area, |
| 138 | struct sk_buff *tipc_node_get_nodes(const void *req_tlv_area, int req_tlv_space); | 138 | int req_tlv_space); |
| 139 | int tipc_node_get_linkname(u32 bearer_id, u32 node, char *linkname, size_t len); | 139 | struct sk_buff *tipc_node_get_nodes(struct net *net, const void *req_tlv_area, |
| 140 | int req_tlv_space); | ||
| 141 | int tipc_node_get_linkname(struct net *net, u32 bearer_id, u32 node, | ||
| 142 | char *linkname, size_t len); | ||
| 140 | void tipc_node_unlock(struct tipc_node *node); | 143 | void tipc_node_unlock(struct tipc_node *node); |
| 141 | int tipc_node_add_conn(u32 dnode, u32 port, u32 peer_port); | 144 | int tipc_node_add_conn(struct net *net, u32 dnode, u32 port, u32 peer_port); |
| 142 | void tipc_node_remove_conn(u32 dnode, u32 port); | 145 | void tipc_node_remove_conn(struct net *net, u32 dnode, u32 port); |
| 143 | 146 | ||
| 144 | int tipc_nl_node_dump(struct sk_buff *skb, struct netlink_callback *cb); | 147 | int tipc_nl_node_dump(struct sk_buff *skb, struct netlink_callback *cb); |
| 145 | 148 | ||
| @@ -154,12 +157,12 @@ static inline bool tipc_node_blocked(struct tipc_node *node) | |||
| 154 | TIPC_NOTIFY_NODE_DOWN | TIPC_WAIT_OWN_LINKS_DOWN)); | 157 | TIPC_NOTIFY_NODE_DOWN | TIPC_WAIT_OWN_LINKS_DOWN)); |
| 155 | } | 158 | } |
| 156 | 159 | ||
| 157 | static inline uint tipc_node_get_mtu(u32 addr, u32 selector) | 160 | static inline uint tipc_node_get_mtu(struct net *net, u32 addr, u32 selector) |
| 158 | { | 161 | { |
| 159 | struct tipc_node *node; | 162 | struct tipc_node *node; |
| 160 | u32 mtu; | 163 | u32 mtu; |
| 161 | 164 | ||
| 162 | node = tipc_node_find(addr); | 165 | node = tipc_node_find(net, addr); |
| 163 | 166 | ||
| 164 | if (likely(node)) | 167 | if (likely(node)) |
| 165 | mtu = node->act_mtus[selector & 1]; | 168 | mtu = node->act_mtus[selector & 1]; |
diff --git a/net/tipc/socket.c b/net/tipc/socket.c index c58f66be7e18..68831453bc0e 100644 --- a/net/tipc/socket.c +++ b/net/tipc/socket.c | |||
| @@ -257,7 +257,7 @@ static void tsk_rej_rx_queue(struct sock *sk) | |||
| 257 | 257 | ||
| 258 | while ((skb = __skb_dequeue(&sk->sk_receive_queue))) { | 258 | while ((skb = __skb_dequeue(&sk->sk_receive_queue))) { |
| 259 | if (tipc_msg_reverse(skb, &dnode, TIPC_ERR_NO_PORT)) | 259 | if (tipc_msg_reverse(skb, &dnode, TIPC_ERR_NO_PORT)) |
| 260 | tipc_link_xmit_skb(skb, dnode, 0); | 260 | tipc_link_xmit_skb(sock_net(sk), skb, dnode, 0); |
| 261 | } | 261 | } |
| 262 | } | 262 | } |
| 263 | 263 | ||
| @@ -473,6 +473,7 @@ static void tipc_sk_callback(struct rcu_head *head) | |||
| 473 | static int tipc_release(struct socket *sock) | 473 | static int tipc_release(struct socket *sock) |
| 474 | { | 474 | { |
| 475 | struct sock *sk = sock->sk; | 475 | struct sock *sk = sock->sk; |
| 476 | struct net *net = sock_net(sk); | ||
| 476 | struct tipc_sock *tsk; | 477 | struct tipc_sock *tsk; |
| 477 | struct sk_buff *skb; | 478 | struct sk_buff *skb; |
| 478 | u32 dnode, probing_state; | 479 | u32 dnode, probing_state; |
| @@ -503,10 +504,10 @@ static int tipc_release(struct socket *sock) | |||
| 503 | (sock->state == SS_CONNECTED)) { | 504 | (sock->state == SS_CONNECTED)) { |
| 504 | sock->state = SS_DISCONNECTING; | 505 | sock->state = SS_DISCONNECTING; |
| 505 | tsk->connected = 0; | 506 | tsk->connected = 0; |
| 506 | tipc_node_remove_conn(dnode, tsk->portid); | 507 | tipc_node_remove_conn(net, dnode, tsk->portid); |
| 507 | } | 508 | } |
| 508 | if (tipc_msg_reverse(skb, &dnode, TIPC_ERR_NO_PORT)) | 509 | if (tipc_msg_reverse(skb, &dnode, TIPC_ERR_NO_PORT)) |
| 509 | tipc_link_xmit_skb(skb, dnode, 0); | 510 | tipc_link_xmit_skb(net, skb, dnode, 0); |
| 510 | } | 511 | } |
| 511 | } | 512 | } |
| 512 | 513 | ||
| @@ -521,8 +522,8 @@ static int tipc_release(struct socket *sock) | |||
| 521 | tsk_peer_port(tsk), | 522 | tsk_peer_port(tsk), |
| 522 | tsk->portid, TIPC_ERR_NO_PORT); | 523 | tsk->portid, TIPC_ERR_NO_PORT); |
| 523 | if (skb) | 524 | if (skb) |
| 524 | tipc_link_xmit_skb(skb, dnode, tsk->portid); | 525 | tipc_link_xmit_skb(net, skb, dnode, tsk->portid); |
| 525 | tipc_node_remove_conn(dnode, tsk->portid); | 526 | tipc_node_remove_conn(net, dnode, tsk->portid); |
| 526 | } | 527 | } |
| 527 | 528 | ||
| 528 | /* Discard any remaining (connection-based) messages in receive queue */ | 529 | /* Discard any remaining (connection-based) messages in receive queue */ |
| @@ -725,6 +726,7 @@ static int tipc_sendmcast(struct socket *sock, struct tipc_name_seq *seq, | |||
| 725 | struct msghdr *msg, size_t dsz, long timeo) | 726 | struct msghdr *msg, size_t dsz, long timeo) |
| 726 | { | 727 | { |
| 727 | struct sock *sk = sock->sk; | 728 | struct sock *sk = sock->sk; |
| 729 | struct net *net = sock_net(sk); | ||
| 728 | struct tipc_msg *mhdr = &tipc_sk(sk)->phdr; | 730 | struct tipc_msg *mhdr = &tipc_sk(sk)->phdr; |
| 729 | struct sk_buff_head head; | 731 | struct sk_buff_head head; |
| 730 | uint mtu; | 732 | uint mtu; |
| @@ -747,7 +749,7 @@ new_mtu: | |||
| 747 | return rc; | 749 | return rc; |
| 748 | 750 | ||
| 749 | do { | 751 | do { |
| 750 | rc = tipc_bclink_xmit(&head); | 752 | rc = tipc_bclink_xmit(net, &head); |
| 751 | if (likely(rc >= 0)) { | 753 | if (likely(rc >= 0)) { |
| 752 | rc = dsz; | 754 | rc = dsz; |
| 753 | break; | 755 | break; |
| @@ -766,7 +768,7 @@ new_mtu: | |||
| 766 | 768 | ||
| 767 | /* tipc_sk_mcast_rcv - Deliver multicast message to all destination sockets | 769 | /* tipc_sk_mcast_rcv - Deliver multicast message to all destination sockets |
| 768 | */ | 770 | */ |
| 769 | void tipc_sk_mcast_rcv(struct sk_buff *buf) | 771 | void tipc_sk_mcast_rcv(struct net *net, struct sk_buff *buf) |
| 770 | { | 772 | { |
| 771 | struct tipc_msg *msg = buf_msg(buf); | 773 | struct tipc_msg *msg = buf_msg(buf); |
| 772 | struct tipc_port_list dports = {0, NULL, }; | 774 | struct tipc_port_list dports = {0, NULL, }; |
| @@ -798,7 +800,7 @@ void tipc_sk_mcast_rcv(struct sk_buff *buf) | |||
| 798 | continue; | 800 | continue; |
| 799 | } | 801 | } |
| 800 | msg_set_destport(msg, item->ports[i]); | 802 | msg_set_destport(msg, item->ports[i]); |
| 801 | tipc_sk_rcv(b); | 803 | tipc_sk_rcv(net, b); |
| 802 | } | 804 | } |
| 803 | } | 805 | } |
| 804 | tipc_port_list_free(&dports); | 806 | tipc_port_list_free(&dports); |
| @@ -886,6 +888,7 @@ static int tipc_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
| 886 | DECLARE_SOCKADDR(struct sockaddr_tipc *, dest, m->msg_name); | 888 | DECLARE_SOCKADDR(struct sockaddr_tipc *, dest, m->msg_name); |
| 887 | struct sock *sk = sock->sk; | 889 | struct sock *sk = sock->sk; |
| 888 | struct tipc_sock *tsk = tipc_sk(sk); | 890 | struct tipc_sock *tsk = tipc_sk(sk); |
| 891 | struct net *net = sock_net(sk); | ||
| 889 | struct tipc_msg *mhdr = &tsk->phdr; | 892 | struct tipc_msg *mhdr = &tsk->phdr; |
| 890 | u32 dnode, dport; | 893 | u32 dnode, dport; |
| 891 | struct sk_buff_head head; | 894 | struct sk_buff_head head; |
| @@ -960,7 +963,7 @@ static int tipc_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
| 960 | } | 963 | } |
| 961 | 964 | ||
| 962 | new_mtu: | 965 | new_mtu: |
| 963 | mtu = tipc_node_get_mtu(dnode, tsk->portid); | 966 | mtu = tipc_node_get_mtu(net, dnode, tsk->portid); |
| 964 | __skb_queue_head_init(&head); | 967 | __skb_queue_head_init(&head); |
| 965 | rc = tipc_msg_build(mhdr, m, 0, dsz, mtu, &head); | 968 | rc = tipc_msg_build(mhdr, m, 0, dsz, mtu, &head); |
| 966 | if (rc < 0) | 969 | if (rc < 0) |
| @@ -969,7 +972,7 @@ new_mtu: | |||
| 969 | do { | 972 | do { |
| 970 | skb = skb_peek(&head); | 973 | skb = skb_peek(&head); |
| 971 | TIPC_SKB_CB(skb)->wakeup_pending = tsk->link_cong; | 974 | TIPC_SKB_CB(skb)->wakeup_pending = tsk->link_cong; |
| 972 | rc = tipc_link_xmit(&head, dnode, tsk->portid); | 975 | rc = tipc_link_xmit(net, &head, dnode, tsk->portid); |
| 973 | if (likely(rc >= 0)) { | 976 | if (likely(rc >= 0)) { |
| 974 | if (sock->state != SS_READY) | 977 | if (sock->state != SS_READY) |
| 975 | sock->state = SS_CONNECTING; | 978 | sock->state = SS_CONNECTING; |
| @@ -1038,6 +1041,7 @@ static int tipc_send_stream(struct kiocb *iocb, struct socket *sock, | |||
| 1038 | struct msghdr *m, size_t dsz) | 1041 | struct msghdr *m, size_t dsz) |
| 1039 | { | 1042 | { |
| 1040 | struct sock *sk = sock->sk; | 1043 | struct sock *sk = sock->sk; |
| 1044 | struct net *net = sock_net(sk); | ||
| 1041 | struct tipc_sock *tsk = tipc_sk(sk); | 1045 | struct tipc_sock *tsk = tipc_sk(sk); |
| 1042 | struct tipc_msg *mhdr = &tsk->phdr; | 1046 | struct tipc_msg *mhdr = &tsk->phdr; |
| 1043 | struct sk_buff_head head; | 1047 | struct sk_buff_head head; |
| @@ -1081,7 +1085,7 @@ next: | |||
| 1081 | goto exit; | 1085 | goto exit; |
| 1082 | do { | 1086 | do { |
| 1083 | if (likely(!tsk_conn_cong(tsk))) { | 1087 | if (likely(!tsk_conn_cong(tsk))) { |
| 1084 | rc = tipc_link_xmit(&head, dnode, portid); | 1088 | rc = tipc_link_xmit(net, &head, dnode, portid); |
| 1085 | if (likely(!rc)) { | 1089 | if (likely(!rc)) { |
| 1086 | tsk->sent_unacked++; | 1090 | tsk->sent_unacked++; |
| 1087 | sent += send; | 1091 | sent += send; |
| @@ -1090,7 +1094,8 @@ next: | |||
| 1090 | goto next; | 1094 | goto next; |
| 1091 | } | 1095 | } |
| 1092 | if (rc == -EMSGSIZE) { | 1096 | if (rc == -EMSGSIZE) { |
| 1093 | tsk->max_pkt = tipc_node_get_mtu(dnode, portid); | 1097 | tsk->max_pkt = tipc_node_get_mtu(net, dnode, |
| 1098 | portid); | ||
| 1094 | goto next; | 1099 | goto next; |
| 1095 | } | 1100 | } |
| 1096 | if (rc != -ELINKCONG) | 1101 | if (rc != -ELINKCONG) |
| @@ -1132,6 +1137,7 @@ static int tipc_send_packet(struct kiocb *iocb, struct socket *sock, | |||
| 1132 | static void tipc_sk_finish_conn(struct tipc_sock *tsk, u32 peer_port, | 1137 | static void tipc_sk_finish_conn(struct tipc_sock *tsk, u32 peer_port, |
| 1133 | u32 peer_node) | 1138 | u32 peer_node) |
| 1134 | { | 1139 | { |
| 1140 | struct net *net = sock_net(&tsk->sk); | ||
| 1135 | struct tipc_msg *msg = &tsk->phdr; | 1141 | struct tipc_msg *msg = &tsk->phdr; |
| 1136 | 1142 | ||
| 1137 | msg_set_destnode(msg, peer_node); | 1143 | msg_set_destnode(msg, peer_node); |
| @@ -1145,8 +1151,8 @@ static void tipc_sk_finish_conn(struct tipc_sock *tsk, u32 peer_port, | |||
| 1145 | tsk->connected = 1; | 1151 | tsk->connected = 1; |
| 1146 | if (!mod_timer(&tsk->timer, jiffies + tsk->probing_intv)) | 1152 | if (!mod_timer(&tsk->timer, jiffies + tsk->probing_intv)) |
| 1147 | sock_hold(&tsk->sk); | 1153 | sock_hold(&tsk->sk); |
| 1148 | tipc_node_add_conn(peer_node, tsk->portid, peer_port); | 1154 | tipc_node_add_conn(net, peer_node, tsk->portid, peer_port); |
| 1149 | tsk->max_pkt = tipc_node_get_mtu(peer_node, tsk->portid); | 1155 | tsk->max_pkt = tipc_node_get_mtu(net, peer_node, tsk->portid); |
| 1150 | } | 1156 | } |
| 1151 | 1157 | ||
| 1152 | /** | 1158 | /** |
| @@ -1245,6 +1251,7 @@ static int tipc_sk_anc_data_recv(struct msghdr *m, struct tipc_msg *msg, | |||
| 1245 | 1251 | ||
| 1246 | static void tipc_sk_send_ack(struct tipc_sock *tsk, uint ack) | 1252 | static void tipc_sk_send_ack(struct tipc_sock *tsk, uint ack) |
| 1247 | { | 1253 | { |
| 1254 | struct net *net = sock_net(&tsk->sk); | ||
| 1248 | struct sk_buff *skb = NULL; | 1255 | struct sk_buff *skb = NULL; |
| 1249 | struct tipc_msg *msg; | 1256 | struct tipc_msg *msg; |
| 1250 | u32 peer_port = tsk_peer_port(tsk); | 1257 | u32 peer_port = tsk_peer_port(tsk); |
| @@ -1258,7 +1265,7 @@ static void tipc_sk_send_ack(struct tipc_sock *tsk, uint ack) | |||
| 1258 | return; | 1265 | return; |
| 1259 | msg = buf_msg(skb); | 1266 | msg = buf_msg(skb); |
| 1260 | msg_set_msgcnt(msg, ack); | 1267 | msg_set_msgcnt(msg, ack); |
| 1261 | tipc_link_xmit_skb(skb, dnode, msg_link_selector(msg)); | 1268 | tipc_link_xmit_skb(net, skb, dnode, msg_link_selector(msg)); |
| 1262 | } | 1269 | } |
| 1263 | 1270 | ||
| 1264 | static int tipc_wait_for_rcvmsg(struct socket *sock, long *timeop) | 1271 | static int tipc_wait_for_rcvmsg(struct socket *sock, long *timeop) |
| @@ -1551,6 +1558,7 @@ static void tipc_data_ready(struct sock *sk) | |||
| 1551 | static int filter_connect(struct tipc_sock *tsk, struct sk_buff **buf) | 1558 | static int filter_connect(struct tipc_sock *tsk, struct sk_buff **buf) |
| 1552 | { | 1559 | { |
| 1553 | struct sock *sk = &tsk->sk; | 1560 | struct sock *sk = &tsk->sk; |
| 1561 | struct net *net = sock_net(sk); | ||
| 1554 | struct socket *sock = sk->sk_socket; | 1562 | struct socket *sock = sk->sk_socket; |
| 1555 | struct tipc_msg *msg = buf_msg(*buf); | 1563 | struct tipc_msg *msg = buf_msg(*buf); |
| 1556 | int retval = -TIPC_ERR_NO_PORT; | 1564 | int retval = -TIPC_ERR_NO_PORT; |
| @@ -1566,7 +1574,7 @@ static int filter_connect(struct tipc_sock *tsk, struct sk_buff **buf) | |||
| 1566 | sock->state = SS_DISCONNECTING; | 1574 | sock->state = SS_DISCONNECTING; |
| 1567 | tsk->connected = 0; | 1575 | tsk->connected = 0; |
| 1568 | /* let timer expire on it's own */ | 1576 | /* let timer expire on it's own */ |
| 1569 | tipc_node_remove_conn(tsk_peer_node(tsk), | 1577 | tipc_node_remove_conn(net, tsk_peer_node(tsk), |
| 1570 | tsk->portid); | 1578 | tsk->portid); |
| 1571 | } | 1579 | } |
| 1572 | retval = TIPC_OK; | 1580 | retval = TIPC_OK; |
| @@ -1737,7 +1745,7 @@ static int tipc_backlog_rcv(struct sock *sk, struct sk_buff *skb) | |||
| 1737 | if ((rc < 0) && !tipc_msg_reverse(skb, &onode, -rc)) | 1745 | if ((rc < 0) && !tipc_msg_reverse(skb, &onode, -rc)) |
| 1738 | return 0; | 1746 | return 0; |
| 1739 | 1747 | ||
| 1740 | tipc_link_xmit_skb(skb, onode, 0); | 1748 | tipc_link_xmit_skb(sock_net(sk), skb, onode, 0); |
| 1741 | 1749 | ||
| 1742 | return 0; | 1750 | return 0; |
| 1743 | } | 1751 | } |
| @@ -1748,7 +1756,7 @@ static int tipc_backlog_rcv(struct sock *sk, struct sk_buff *skb) | |||
| 1748 | * Consumes buffer | 1756 | * Consumes buffer |
| 1749 | * Returns 0 if success, or errno: -EHOSTUNREACH | 1757 | * Returns 0 if success, or errno: -EHOSTUNREACH |
| 1750 | */ | 1758 | */ |
| 1751 | int tipc_sk_rcv(struct sk_buff *skb) | 1759 | int tipc_sk_rcv(struct net *net, struct sk_buff *skb) |
| 1752 | { | 1760 | { |
| 1753 | struct tipc_sock *tsk; | 1761 | struct tipc_sock *tsk; |
| 1754 | struct sock *sk; | 1762 | struct sock *sk; |
| @@ -1785,7 +1793,7 @@ exit: | |||
| 1785 | if ((rc < 0) && !tipc_msg_reverse(skb, &dnode, -rc)) | 1793 | if ((rc < 0) && !tipc_msg_reverse(skb, &dnode, -rc)) |
| 1786 | return -EHOSTUNREACH; | 1794 | return -EHOSTUNREACH; |
| 1787 | 1795 | ||
| 1788 | tipc_link_xmit_skb(skb, dnode, 0); | 1796 | tipc_link_xmit_skb(net, skb, dnode, 0); |
| 1789 | return (rc < 0) ? -EHOSTUNREACH : 0; | 1797 | return (rc < 0) ? -EHOSTUNREACH : 0; |
| 1790 | } | 1798 | } |
| 1791 | 1799 | ||
| @@ -2042,6 +2050,7 @@ exit: | |||
| 2042 | static int tipc_shutdown(struct socket *sock, int how) | 2050 | static int tipc_shutdown(struct socket *sock, int how) |
| 2043 | { | 2051 | { |
| 2044 | struct sock *sk = sock->sk; | 2052 | struct sock *sk = sock->sk; |
| 2053 | struct net *net = sock_net(sk); | ||
| 2045 | struct tipc_sock *tsk = tipc_sk(sk); | 2054 | struct tipc_sock *tsk = tipc_sk(sk); |
| 2046 | struct sk_buff *skb; | 2055 | struct sk_buff *skb; |
| 2047 | u32 dnode; | 2056 | u32 dnode; |
| @@ -2065,8 +2074,9 @@ restart: | |||
| 2065 | goto restart; | 2074 | goto restart; |
| 2066 | } | 2075 | } |
| 2067 | if (tipc_msg_reverse(skb, &dnode, TIPC_CONN_SHUTDOWN)) | 2076 | if (tipc_msg_reverse(skb, &dnode, TIPC_CONN_SHUTDOWN)) |
| 2068 | tipc_link_xmit_skb(skb, dnode, tsk->portid); | 2077 | tipc_link_xmit_skb(net, skb, dnode, |
| 2069 | tipc_node_remove_conn(dnode, tsk->portid); | 2078 | tsk->portid); |
| 2079 | tipc_node_remove_conn(net, dnode, tsk->portid); | ||
| 2070 | } else { | 2080 | } else { |
| 2071 | dnode = tsk_peer_node(tsk); | 2081 | dnode = tsk_peer_node(tsk); |
| 2072 | skb = tipc_msg_create(TIPC_CRITICAL_IMPORTANCE, | 2082 | skb = tipc_msg_create(TIPC_CRITICAL_IMPORTANCE, |
| @@ -2074,11 +2084,11 @@ restart: | |||
| 2074 | 0, dnode, tipc_own_addr, | 2084 | 0, dnode, tipc_own_addr, |
| 2075 | tsk_peer_port(tsk), | 2085 | tsk_peer_port(tsk), |
| 2076 | tsk->portid, TIPC_CONN_SHUTDOWN); | 2086 | tsk->portid, TIPC_CONN_SHUTDOWN); |
| 2077 | tipc_link_xmit_skb(skb, dnode, tsk->portid); | 2087 | tipc_link_xmit_skb(net, skb, dnode, tsk->portid); |
| 2078 | } | 2088 | } |
| 2079 | tsk->connected = 0; | 2089 | tsk->connected = 0; |
| 2080 | sock->state = SS_DISCONNECTING; | 2090 | sock->state = SS_DISCONNECTING; |
| 2081 | tipc_node_remove_conn(dnode, tsk->portid); | 2091 | tipc_node_remove_conn(net, dnode, tsk->portid); |
| 2082 | /* fall through */ | 2092 | /* fall through */ |
| 2083 | 2093 | ||
| 2084 | case SS_DISCONNECTING: | 2094 | case SS_DISCONNECTING: |
| @@ -2130,7 +2140,7 @@ static void tipc_sk_timeout(unsigned long data) | |||
| 2130 | } | 2140 | } |
| 2131 | bh_unlock_sock(sk); | 2141 | bh_unlock_sock(sk); |
| 2132 | if (skb) | 2142 | if (skb) |
| 2133 | tipc_link_xmit_skb(skb, peer_node, tsk->portid); | 2143 | tipc_link_xmit_skb(sock_net(sk), skb, peer_node, tsk->portid); |
| 2134 | exit: | 2144 | exit: |
| 2135 | sock_put(sk); | 2145 | sock_put(sk); |
| 2136 | } | 2146 | } |
| @@ -2138,6 +2148,7 @@ exit: | |||
| 2138 | static int tipc_sk_publish(struct tipc_sock *tsk, uint scope, | 2148 | static int tipc_sk_publish(struct tipc_sock *tsk, uint scope, |
| 2139 | struct tipc_name_seq const *seq) | 2149 | struct tipc_name_seq const *seq) |
| 2140 | { | 2150 | { |
| 2151 | struct net *net = sock_net(&tsk->sk); | ||
| 2141 | struct publication *publ; | 2152 | struct publication *publ; |
| 2142 | u32 key; | 2153 | u32 key; |
| 2143 | 2154 | ||
| @@ -2147,7 +2158,7 @@ static int tipc_sk_publish(struct tipc_sock *tsk, uint scope, | |||
| 2147 | if (key == tsk->portid) | 2158 | if (key == tsk->portid) |
| 2148 | return -EADDRINUSE; | 2159 | return -EADDRINUSE; |
| 2149 | 2160 | ||
| 2150 | publ = tipc_nametbl_publish(seq->type, seq->lower, seq->upper, | 2161 | publ = tipc_nametbl_publish(net, seq->type, seq->lower, seq->upper, |
| 2151 | scope, tsk->portid, key); | 2162 | scope, tsk->portid, key); |
| 2152 | if (unlikely(!publ)) | 2163 | if (unlikely(!publ)) |
| 2153 | return -EINVAL; | 2164 | return -EINVAL; |
| @@ -2161,6 +2172,7 @@ static int tipc_sk_publish(struct tipc_sock *tsk, uint scope, | |||
| 2161 | static int tipc_sk_withdraw(struct tipc_sock *tsk, uint scope, | 2172 | static int tipc_sk_withdraw(struct tipc_sock *tsk, uint scope, |
| 2162 | struct tipc_name_seq const *seq) | 2173 | struct tipc_name_seq const *seq) |
| 2163 | { | 2174 | { |
| 2175 | struct net *net = sock_net(&tsk->sk); | ||
| 2164 | struct publication *publ; | 2176 | struct publication *publ; |
| 2165 | struct publication *safe; | 2177 | struct publication *safe; |
| 2166 | int rc = -EINVAL; | 2178 | int rc = -EINVAL; |
| @@ -2175,12 +2187,12 @@ static int tipc_sk_withdraw(struct tipc_sock *tsk, uint scope, | |||
| 2175 | continue; | 2187 | continue; |
| 2176 | if (publ->upper != seq->upper) | 2188 | if (publ->upper != seq->upper) |
| 2177 | break; | 2189 | break; |
| 2178 | tipc_nametbl_withdraw(publ->type, publ->lower, | 2190 | tipc_nametbl_withdraw(net, publ->type, publ->lower, |
| 2179 | publ->ref, publ->key); | 2191 | publ->ref, publ->key); |
| 2180 | rc = 0; | 2192 | rc = 0; |
| 2181 | break; | 2193 | break; |
| 2182 | } | 2194 | } |
| 2183 | tipc_nametbl_withdraw(publ->type, publ->lower, | 2195 | tipc_nametbl_withdraw(net, publ->type, publ->lower, |
| 2184 | publ->ref, publ->key); | 2196 | publ->ref, publ->key); |
| 2185 | rc = 0; | 2197 | rc = 0; |
| 2186 | } | 2198 | } |
| @@ -2492,8 +2504,9 @@ static int tipc_getsockopt(struct socket *sock, int lvl, int opt, | |||
| 2492 | return put_user(sizeof(value), ol); | 2504 | return put_user(sizeof(value), ol); |
| 2493 | } | 2505 | } |
| 2494 | 2506 | ||
| 2495 | static int tipc_ioctl(struct socket *sk, unsigned int cmd, unsigned long arg) | 2507 | static int tipc_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) |
| 2496 | { | 2508 | { |
| 2509 | struct sock *sk = sock->sk; | ||
| 2497 | struct tipc_sioc_ln_req lnr; | 2510 | struct tipc_sioc_ln_req lnr; |
| 2498 | void __user *argp = (void __user *)arg; | 2511 | void __user *argp = (void __user *)arg; |
| 2499 | 2512 | ||
| @@ -2501,7 +2514,8 @@ static int tipc_ioctl(struct socket *sk, unsigned int cmd, unsigned long arg) | |||
| 2501 | case SIOCGETLINKNAME: | 2514 | case SIOCGETLINKNAME: |
| 2502 | if (copy_from_user(&lnr, argp, sizeof(lnr))) | 2515 | if (copy_from_user(&lnr, argp, sizeof(lnr))) |
| 2503 | return -EFAULT; | 2516 | return -EFAULT; |
| 2504 | if (!tipc_node_get_linkname(lnr.bearer_id & 0xffff, lnr.peer, | 2517 | if (!tipc_node_get_linkname(sock_net(sk), |
| 2518 | lnr.bearer_id & 0xffff, lnr.peer, | ||
| 2505 | lnr.linkname, TIPC_MAX_LINK_NAME)) { | 2519 | lnr.linkname, TIPC_MAX_LINK_NAME)) { |
| 2506 | if (copy_to_user(argp, &lnr, sizeof(lnr))) | 2520 | if (copy_to_user(argp, &lnr, sizeof(lnr))) |
| 2507 | return -EFAULT; | 2521 | return -EFAULT; |
diff --git a/net/tipc/socket.h b/net/tipc/socket.h index 46bc370d82c7..eb15c3107920 100644 --- a/net/tipc/socket.h +++ b/net/tipc/socket.h | |||
| @@ -49,9 +49,9 @@ int tipc_sock_create_local(int type, struct socket **res); | |||
| 49 | void tipc_sock_release_local(struct socket *sock); | 49 | void tipc_sock_release_local(struct socket *sock); |
| 50 | int tipc_sock_accept_local(struct socket *sock, struct socket **newsock, | 50 | int tipc_sock_accept_local(struct socket *sock, struct socket **newsock, |
| 51 | int flags); | 51 | int flags); |
| 52 | int tipc_sk_rcv(struct sk_buff *buf); | 52 | int tipc_sk_rcv(struct net *net, struct sk_buff *buf); |
| 53 | struct sk_buff *tipc_sk_socks_show(void); | 53 | struct sk_buff *tipc_sk_socks_show(void); |
| 54 | void tipc_sk_mcast_rcv(struct sk_buff *buf); | 54 | void tipc_sk_mcast_rcv(struct net *net, struct sk_buff *buf); |
| 55 | void tipc_sk_reinit(void); | 55 | void tipc_sk_reinit(void); |
| 56 | int tipc_sk_rht_init(void); | 56 | int tipc_sk_rht_init(void); |
| 57 | void tipc_sk_rht_destroy(void); | 57 | void tipc_sk_rht_destroy(void); |
