diff options
Diffstat (limited to 'net')
-rw-r--r-- | net/tipc/name_distr.c | 4 | ||||
-rw-r--r-- | net/tipc/net.c | 22 | ||||
-rw-r--r-- | net/tipc/net.h | 17 | ||||
-rw-r--r-- | net/tipc/node.c | 30 | ||||
-rw-r--r-- | net/tipc/node.h | 2 |
5 files changed, 33 insertions, 42 deletions
diff --git a/net/tipc/name_distr.c b/net/tipc/name_distr.c index d58dae78b551..f2086f684b34 100644 --- a/net/tipc/name_distr.c +++ b/net/tipc/name_distr.c | |||
@@ -111,8 +111,8 @@ static void named_cluster_distribute(struct sk_buff *buf) | |||
111 | struct tipc_node *n_ptr; | 111 | struct tipc_node *n_ptr; |
112 | u32 n_num; | 112 | u32 n_num; |
113 | 113 | ||
114 | for (n_num = 1; n_num <= tipc_net.highest_node; n_num++) { | 114 | for (n_num = 1; n_num <= tipc_highest_node; n_num++) { |
115 | n_ptr = tipc_net.nodes[n_num]; | 115 | n_ptr = tipc_nodes[n_num]; |
116 | if (n_ptr && tipc_node_has_active_links(n_ptr)) { | 116 | if (n_ptr && tipc_node_has_active_links(n_ptr)) { |
117 | buf_copy = skb_copy(buf, GFP_ATOMIC); | 117 | buf_copy = skb_copy(buf, GFP_ATOMIC); |
118 | if (!buf_copy) | 118 | if (!buf_copy) |
diff --git a/net/tipc/net.c b/net/tipc/net.c index dd78d869829f..f6303d79f7f5 100644 --- a/net/tipc/net.c +++ b/net/tipc/net.c | |||
@@ -108,26 +108,28 @@ | |||
108 | */ | 108 | */ |
109 | 109 | ||
110 | DEFINE_RWLOCK(tipc_net_lock); | 110 | DEFINE_RWLOCK(tipc_net_lock); |
111 | struct network tipc_net; | 111 | struct tipc_node **tipc_nodes; |
112 | u32 tipc_highest_node; | ||
113 | atomic_t tipc_num_links; | ||
112 | 114 | ||
113 | static int net_start(void) | 115 | static int net_start(void) |
114 | { | 116 | { |
115 | tipc_net.nodes = kcalloc(tipc_max_nodes + 1, | 117 | tipc_nodes = kcalloc(tipc_max_nodes + 1, |
116 | sizeof(*tipc_net.nodes), GFP_ATOMIC); | 118 | sizeof(*tipc_nodes), GFP_ATOMIC); |
117 | tipc_net.highest_node = 0; | 119 | tipc_highest_node = 0; |
118 | atomic_set(&tipc_net.links, 0); | 120 | atomic_set(&tipc_num_links, 0); |
119 | 121 | ||
120 | return tipc_net.nodes ? 0 : -ENOMEM; | 122 | return tipc_nodes ? 0 : -ENOMEM; |
121 | } | 123 | } |
122 | 124 | ||
123 | static void net_stop(void) | 125 | static void net_stop(void) |
124 | { | 126 | { |
125 | u32 n_num; | 127 | u32 n_num; |
126 | 128 | ||
127 | for (n_num = 1; n_num <= tipc_net.highest_node; n_num++) | 129 | for (n_num = 1; n_num <= tipc_highest_node; n_num++) |
128 | tipc_node_delete(tipc_net.nodes[n_num]); | 130 | tipc_node_delete(tipc_nodes[n_num]); |
129 | kfree(tipc_net.nodes); | 131 | kfree(tipc_nodes); |
130 | tipc_net.nodes = NULL; | 132 | tipc_nodes = NULL; |
131 | } | 133 | } |
132 | 134 | ||
133 | static void net_route_named_msg(struct sk_buff *buf) | 135 | static void net_route_named_msg(struct sk_buff *buf) |
diff --git a/net/tipc/net.h b/net/tipc/net.h index aa431ef8b7bf..b52b9748b5e2 100644 --- a/net/tipc/net.h +++ b/net/tipc/net.h | |||
@@ -39,21 +39,10 @@ | |||
39 | 39 | ||
40 | struct tipc_node; | 40 | struct tipc_node; |
41 | 41 | ||
42 | /** | 42 | extern struct tipc_node **tipc_nodes; |
43 | * struct network - TIPC network structure | 43 | extern u32 tipc_highest_node; |
44 | * @nodes: array of pointers to all nodes within cluster | 44 | extern atomic_t tipc_num_links; |
45 | * @highest_node: id of highest numbered node within cluster | ||
46 | * @links: number of (unicast) links to cluster | ||
47 | */ | ||
48 | |||
49 | struct network { | ||
50 | struct tipc_node **nodes; | ||
51 | u32 highest_node; | ||
52 | atomic_t links; | ||
53 | }; | ||
54 | |||
55 | 45 | ||
56 | extern struct network tipc_net; | ||
57 | extern rwlock_t tipc_net_lock; | 46 | extern rwlock_t tipc_net_lock; |
58 | 47 | ||
59 | void tipc_net_route_msg(struct sk_buff *buf); | 48 | void tipc_net_route_msg(struct sk_buff *buf); |
diff --git a/net/tipc/node.c b/net/tipc/node.c index a24fad32345e..64976f2e3c66 100644 --- a/net/tipc/node.c +++ b/net/tipc/node.c | |||
@@ -81,9 +81,9 @@ struct tipc_node *tipc_node_create(u32 addr) | |||
81 | INIT_LIST_HEAD(&n_ptr->nsub); | 81 | INIT_LIST_HEAD(&n_ptr->nsub); |
82 | 82 | ||
83 | n_num = tipc_node(addr); | 83 | n_num = tipc_node(addr); |
84 | tipc_net.nodes[n_num] = n_ptr; | 84 | tipc_nodes[n_num] = n_ptr; |
85 | if (n_num > tipc_net.highest_node) | 85 | if (n_num > tipc_highest_node) |
86 | tipc_net.highest_node = n_num; | 86 | tipc_highest_node = n_num; |
87 | 87 | ||
88 | spin_unlock_bh(&node_create_lock); | 88 | spin_unlock_bh(&node_create_lock); |
89 | return n_ptr; | 89 | return n_ptr; |
@@ -97,11 +97,11 @@ void tipc_node_delete(struct tipc_node *n_ptr) | |||
97 | return; | 97 | return; |
98 | 98 | ||
99 | n_num = tipc_node(n_ptr->addr); | 99 | n_num = tipc_node(n_ptr->addr); |
100 | tipc_net.nodes[n_num] = NULL; | 100 | tipc_nodes[n_num] = NULL; |
101 | kfree(n_ptr); | 101 | kfree(n_ptr); |
102 | 102 | ||
103 | while (!tipc_net.nodes[tipc_net.highest_node]) | 103 | while (!tipc_nodes[tipc_highest_node]) |
104 | if (--tipc_net.highest_node == 0) | 104 | if (--tipc_highest_node == 0) |
105 | break; | 105 | break; |
106 | } | 106 | } |
107 | 107 | ||
@@ -233,7 +233,7 @@ struct tipc_node *tipc_node_attach_link(struct link *l_ptr) | |||
233 | 233 | ||
234 | if (!n_ptr->links[bearer_id]) { | 234 | if (!n_ptr->links[bearer_id]) { |
235 | n_ptr->links[bearer_id] = l_ptr; | 235 | n_ptr->links[bearer_id] = l_ptr; |
236 | atomic_inc(&tipc_net.links); | 236 | atomic_inc(&tipc_num_links); |
237 | n_ptr->link_cnt++; | 237 | n_ptr->link_cnt++; |
238 | return n_ptr; | 238 | return n_ptr; |
239 | } | 239 | } |
@@ -247,7 +247,7 @@ struct tipc_node *tipc_node_attach_link(struct link *l_ptr) | |||
247 | void tipc_node_detach_link(struct tipc_node *n_ptr, struct link *l_ptr) | 247 | void tipc_node_detach_link(struct tipc_node *n_ptr, struct link *l_ptr) |
248 | { | 248 | { |
249 | n_ptr->links[l_ptr->b_ptr->identity] = NULL; | 249 | n_ptr->links[l_ptr->b_ptr->identity] = NULL; |
250 | atomic_dec(&tipc_net.links); | 250 | atomic_dec(&tipc_num_links); |
251 | n_ptr->link_cnt--; | 251 | n_ptr->link_cnt--; |
252 | } | 252 | } |
253 | 253 | ||
@@ -390,7 +390,7 @@ struct sk_buff *tipc_node_get_nodes(const void *req_tlv_area, int req_tlv_space) | |||
390 | " (network address)"); | 390 | " (network address)"); |
391 | 391 | ||
392 | read_lock_bh(&tipc_net_lock); | 392 | read_lock_bh(&tipc_net_lock); |
393 | if (!tipc_net.nodes) { | 393 | if (!tipc_nodes) { |
394 | read_unlock_bh(&tipc_net_lock); | 394 | read_unlock_bh(&tipc_net_lock); |
395 | return tipc_cfg_reply_none(); | 395 | return tipc_cfg_reply_none(); |
396 | } | 396 | } |
@@ -398,7 +398,7 @@ struct sk_buff *tipc_node_get_nodes(const void *req_tlv_area, int req_tlv_space) | |||
398 | /* For now, get space for all other nodes */ | 398 | /* For now, get space for all other nodes */ |
399 | 399 | ||
400 | payload_size = TLV_SPACE(sizeof(node_info)) * | 400 | payload_size = TLV_SPACE(sizeof(node_info)) * |
401 | (tipc_net.highest_node - 1); | 401 | (tipc_highest_node - 1); |
402 | if (payload_size > 32768u) { | 402 | if (payload_size > 32768u) { |
403 | read_unlock_bh(&tipc_net_lock); | 403 | read_unlock_bh(&tipc_net_lock); |
404 | return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED | 404 | return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED |
@@ -412,8 +412,8 @@ struct sk_buff *tipc_node_get_nodes(const void *req_tlv_area, int req_tlv_space) | |||
412 | 412 | ||
413 | /* Add TLVs for all nodes in scope */ | 413 | /* Add TLVs for all nodes in scope */ |
414 | 414 | ||
415 | for (n_num = 1; n_num <= tipc_net.highest_node; n_num++) { | 415 | for (n_num = 1; n_num <= tipc_highest_node; n_num++) { |
416 | n_ptr = tipc_net.nodes[n_num]; | 416 | n_ptr = tipc_nodes[n_num]; |
417 | if (!n_ptr || !tipc_in_scope(domain, n_ptr->addr)) | 417 | if (!n_ptr || !tipc_in_scope(domain, n_ptr->addr)) |
418 | continue; | 418 | continue; |
419 | node_info.addr = htonl(n_ptr->addr); | 419 | node_info.addr = htonl(n_ptr->addr); |
@@ -451,7 +451,7 @@ struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space) | |||
451 | /* Get space for all unicast links + multicast link */ | 451 | /* Get space for all unicast links + multicast link */ |
452 | 452 | ||
453 | payload_size = TLV_SPACE(sizeof(link_info)) * | 453 | payload_size = TLV_SPACE(sizeof(link_info)) * |
454 | (atomic_read(&tipc_net.links) + 1); | 454 | (atomic_read(&tipc_num_links) + 1); |
455 | if (payload_size > 32768u) { | 455 | if (payload_size > 32768u) { |
456 | read_unlock_bh(&tipc_net_lock); | 456 | read_unlock_bh(&tipc_net_lock); |
457 | return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED | 457 | return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED |
@@ -472,10 +472,10 @@ struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space) | |||
472 | 472 | ||
473 | /* Add TLVs for any other links in scope */ | 473 | /* Add TLVs for any other links in scope */ |
474 | 474 | ||
475 | for (n_num = 1; n_num <= tipc_net.highest_node; n_num++) { | 475 | for (n_num = 1; n_num <= tipc_highest_node; n_num++) { |
476 | u32 i; | 476 | u32 i; |
477 | 477 | ||
478 | n_ptr = tipc_net.nodes[n_num]; | 478 | n_ptr = tipc_nodes[n_num]; |
479 | if (!n_ptr || !tipc_in_scope(domain, n_ptr->addr)) | 479 | if (!n_ptr || !tipc_in_scope(domain, n_ptr->addr)) |
480 | continue; | 480 | continue; |
481 | tipc_node_lock(n_ptr); | 481 | tipc_node_lock(n_ptr); |
diff --git a/net/tipc/node.h b/net/tipc/node.h index 206a8efa410e..c510a2afcc67 100644 --- a/net/tipc/node.h +++ b/net/tipc/node.h | |||
@@ -107,7 +107,7 @@ struct sk_buff *tipc_node_get_nodes(const void *req_tlv_area, int req_tlv_space) | |||
107 | static inline struct tipc_node *tipc_node_find(u32 addr) | 107 | static inline struct tipc_node *tipc_node_find(u32 addr) |
108 | { | 108 | { |
109 | if (likely(in_own_cluster(addr))) | 109 | if (likely(in_own_cluster(addr))) |
110 | return tipc_net.nodes[tipc_node(addr)]; | 110 | return tipc_nodes[tipc_node(addr)]; |
111 | return NULL; | 111 | return NULL; |
112 | } | 112 | } |
113 | 113 | ||