Blame view
net/tipc/node.c
13.8 KB
b97bf3fd8 [TIPC] Initial merge |
1 2 |
/* * net/tipc/node.c: TIPC node management routines |
c43072852 [NET] TIPC: Fix w... |
3 |
* |
593a5f22d [TIPC] More updat... |
4 |
* Copyright (c) 2000-2006, Ericsson AB |
2d627b92f tipc: Combine bea... |
5 |
* Copyright (c) 2005-2006, 2010-2011, Wind River Systems |
b97bf3fd8 [TIPC] Initial merge |
6 7 |
* All rights reserved. * |
9ea1fd3c1 [TIPC] License he... |
8 |
* Redistribution and use in source and binary forms, with or without |
b97bf3fd8 [TIPC] Initial merge |
9 10 |
* modification, are permitted provided that the following conditions are met: * |
9ea1fd3c1 [TIPC] License he... |
11 12 13 14 15 16 17 18 |
* 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the names of the copyright holders nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. |
b97bf3fd8 [TIPC] Initial merge |
19 |
* |
9ea1fd3c1 [TIPC] License he... |
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
* Alternatively, this software may be distributed under the terms of the * GNU General Public License ("GPL") version 2 as published by the Free * Software Foundation. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
b97bf3fd8 [TIPC] Initial merge |
34 35 36 37 38 39 |
* POSSIBILITY OF SUCH DAMAGE. */ #include "core.h" #include "config.h" #include "node.h" |
b97bf3fd8 [TIPC] Initial merge |
40 |
#include "name_distr.h" |
b97bf3fd8 [TIPC] Initial merge |
41 |
|
6c00055a8 tipc: Don't use s... |
42 43 |
static void node_lost_contact(struct tipc_node *n_ptr); static void node_established_contact(struct tipc_node *n_ptr); |
b97bf3fd8 [TIPC] Initial merge |
44 |
|
2ecb0924d tipc: Prevent nod... |
45 |
static DEFINE_SPINLOCK(node_create_lock); |
672d99e19 tipc: Convert nod... |
46 47 48 |
static struct hlist_head node_htable[NODE_HTABLE_SIZE]; LIST_HEAD(tipc_node_list); static u32 tipc_num_nodes; |
34e46258c tipc: manually in... |
49 50 |
static atomic_t tipc_num_links = ATOMIC_INIT(0); |
e3ec9c7d5 tipc: remove zero... |
51 |
u32 tipc_own_tag; |
b97bf3fd8 [TIPC] Initial merge |
52 |
|
2ecb0924d tipc: Prevent nod... |
53 |
/** |
672d99e19 tipc: Convert nod... |
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
* tipc_node_find - locate specified node object, if it exists */ struct tipc_node *tipc_node_find(u32 addr) { struct tipc_node *node; struct hlist_node *pos; if (unlikely(!in_own_cluster(addr))) return NULL; hlist_for_each_entry(node, pos, &node_htable[tipc_hashfn(addr)], hash) { if (node->addr == addr) return node; } return NULL; } /** |
2ecb0924d tipc: Prevent nod... |
73 74 75 76 77 78 79 80 |
* tipc_node_create - create neighboring node * * Currently, this routine is called by neighbor discovery code, which holds * net_lock for reading only. We must take node_create_lock to ensure a node * isn't created twice if two different bearers discover the node at the same * time. (It would be preferable to switch to holding net_lock in write mode, * but this is a non-trivial change.) */ |
6c00055a8 tipc: Don't use s... |
81 |
struct tipc_node *tipc_node_create(u32 addr) |
b97bf3fd8 [TIPC] Initial merge |
82 |
{ |
672d99e19 tipc: Convert nod... |
83 |
struct tipc_node *n_ptr, *temp_node; |
b97bf3fd8 [TIPC] Initial merge |
84 |
|
2ecb0924d tipc: Prevent nod... |
85 |
spin_lock_bh(&node_create_lock); |
5af547929 tipc: Remove inte... |
86 87 88 89 |
n_ptr = tipc_node_find(addr); if (n_ptr) { spin_unlock_bh(&node_create_lock); return n_ptr; |
2ecb0924d tipc: Prevent nod... |
90 |
} |
5af547929 tipc: Remove inte... |
91 |
n_ptr = kzalloc(sizeof(*n_ptr), GFP_ATOMIC); |
a10bd924a [TIPC]: Enhanced ... |
92 |
if (!n_ptr) { |
2ecb0924d tipc: Prevent nod... |
93 |
spin_unlock_bh(&node_create_lock); |
a10bd924a [TIPC]: Enhanced ... |
94 95 96 97 |
warn("Node creation failed, no memory "); return NULL; } |
a10bd924a [TIPC]: Enhanced ... |
98 |
n_ptr->addr = addr; |
51a8e4dee tipc: Remove prot... |
99 |
spin_lock_init(&n_ptr->lock); |
672d99e19 tipc: Convert nod... |
100 101 |
INIT_HLIST_NODE(&n_ptr->hash); INIT_LIST_HEAD(&n_ptr->list); |
a10bd924a [TIPC]: Enhanced ... |
102 |
INIT_LIST_HEAD(&n_ptr->nsub); |
8f92df6ad tipc: Remove prot... |
103 |
|
672d99e19 tipc: Convert nod... |
104 105 106 107 108 109 110 |
hlist_add_head(&n_ptr->hash, &node_htable[tipc_hashfn(addr)]); list_for_each_entry(temp_node, &tipc_node_list, list) { if (n_ptr->addr < temp_node->addr) break; } list_add_tail(&n_ptr->list, &temp_node->list); |
b4b561022 tipc: Ensure both... |
111 |
n_ptr->block_setup = WAIT_PEER_DOWN; |
672d99e19 tipc: Convert nod... |
112 113 |
tipc_num_nodes++; |
a10bd924a [TIPC]: Enhanced ... |
114 |
|
2ecb0924d tipc: Prevent nod... |
115 |
spin_unlock_bh(&node_create_lock); |
b97bf3fd8 [TIPC] Initial merge |
116 117 |
return n_ptr; } |
6c00055a8 tipc: Don't use s... |
118 |
void tipc_node_delete(struct tipc_node *n_ptr) |
b97bf3fd8 [TIPC] Initial merge |
119 |
{ |
672d99e19 tipc: Convert nod... |
120 121 |
list_del(&n_ptr->list); hlist_del(&n_ptr->hash); |
b97bf3fd8 [TIPC] Initial merge |
122 |
kfree(n_ptr); |
8f92df6ad tipc: Remove prot... |
123 |
|
672d99e19 tipc: Convert nod... |
124 |
tipc_num_nodes--; |
b97bf3fd8 [TIPC] Initial merge |
125 126 127 128 |
} /** |
4323add67 [TIPC] Avoid poll... |
129 |
* tipc_node_link_up - handle addition of link |
c43072852 [NET] TIPC: Fix w... |
130 |
* |
b97bf3fd8 [TIPC] Initial merge |
131 132 |
* Link becomes active (alone or shared) or standby, depending on its priority. */ |
6c00055a8 tipc: Don't use s... |
133 |
void tipc_node_link_up(struct tipc_node *n_ptr, struct link *l_ptr) |
b97bf3fd8 [TIPC] Initial merge |
134 135 |
{ struct link **active = &n_ptr->active_links[0]; |
5392d6468 [TIPC]: Fixed lin... |
136 |
n_ptr->working_links++; |
b97bf3fd8 [TIPC] Initial merge |
137 138 139 |
info("Established link <%s> on network plane %c ", l_ptr->name, l_ptr->b_ptr->net_plane); |
c43072852 [NET] TIPC: Fix w... |
140 |
|
b97bf3fd8 [TIPC] Initial merge |
141 |
if (!active[0]) { |
b97bf3fd8 [TIPC] Initial merge |
142 143 144 145 |
active[0] = active[1] = l_ptr; node_established_contact(n_ptr); return; } |
c43072852 [NET] TIPC: Fix w... |
146 |
if (l_ptr->priority < active[0]->priority) { |
a10bd924a [TIPC]: Enhanced ... |
147 148 |
info("New link <%s> becomes standby ", l_ptr->name); |
b97bf3fd8 [TIPC] Initial merge |
149 150 |
return; } |
4323add67 [TIPC] Avoid poll... |
151 |
tipc_link_send_duplicate(active[0], l_ptr); |
c43072852 [NET] TIPC: Fix w... |
152 |
if (l_ptr->priority == active[0]->priority) { |
b97bf3fd8 [TIPC] Initial merge |
153 154 155 |
active[0] = l_ptr; return; } |
a10bd924a [TIPC]: Enhanced ... |
156 157 158 159 160 |
info("Old link <%s> becomes standby ", active[0]->name); if (active[1] != active[0]) info("Old link <%s> becomes standby ", active[1]->name); |
b97bf3fd8 [TIPC] Initial merge |
161 162 163 164 165 166 |
active[0] = active[1] = l_ptr; } /** * node_select_active_links - select active link */ |
6c00055a8 tipc: Don't use s... |
167 |
static void node_select_active_links(struct tipc_node *n_ptr) |
b97bf3fd8 [TIPC] Initial merge |
168 169 170 171 |
{ struct link **active = &n_ptr->active_links[0]; u32 i; u32 highest_prio = 0; |
c43072852 [NET] TIPC: Fix w... |
172 |
active[0] = active[1] = NULL; |
b97bf3fd8 [TIPC] Initial merge |
173 174 |
for (i = 0; i < MAX_BEARERS; i++) { |
c43072852 [NET] TIPC: Fix w... |
175 |
struct link *l_ptr = n_ptr->links[i]; |
b97bf3fd8 [TIPC] Initial merge |
176 |
|
4323add67 [TIPC] Avoid poll... |
177 |
if (!l_ptr || !tipc_link_is_up(l_ptr) || |
b97bf3fd8 [TIPC] Initial merge |
178 179 180 181 |
(l_ptr->priority < highest_prio)) continue; if (l_ptr->priority > highest_prio) { |
c43072852 [NET] TIPC: Fix w... |
182 |
highest_prio = l_ptr->priority; |
b97bf3fd8 [TIPC] Initial merge |
183 184 185 186 187 188 189 190 |
active[0] = active[1] = l_ptr; } else { active[1] = l_ptr; } } } /** |
4323add67 [TIPC] Avoid poll... |
191 |
* tipc_node_link_down - handle loss of link |
b97bf3fd8 [TIPC] Initial merge |
192 |
*/ |
6c00055a8 tipc: Don't use s... |
193 |
void tipc_node_link_down(struct tipc_node *n_ptr, struct link *l_ptr) |
b97bf3fd8 [TIPC] Initial merge |
194 195 |
{ struct link **active; |
5392d6468 [TIPC]: Fixed lin... |
196 |
n_ptr->working_links--; |
4323add67 [TIPC] Avoid poll... |
197 |
if (!tipc_link_is_active(l_ptr)) { |
b97bf3fd8 [TIPC] Initial merge |
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 |
info("Lost standby link <%s> on network plane %c ", l_ptr->name, l_ptr->b_ptr->net_plane); return; } info("Lost link <%s> on network plane %c ", l_ptr->name, l_ptr->b_ptr->net_plane); active = &n_ptr->active_links[0]; if (active[0] == l_ptr) active[0] = active[1]; if (active[1] == l_ptr) active[1] = active[0]; if (active[0] == l_ptr) node_select_active_links(n_ptr); |
c43072852 [NET] TIPC: Fix w... |
214 |
if (tipc_node_is_up(n_ptr)) |
4323add67 [TIPC] Avoid poll... |
215 |
tipc_link_changeover(l_ptr); |
c43072852 [NET] TIPC: Fix w... |
216 |
else |
b97bf3fd8 [TIPC] Initial merge |
217 218 |
node_lost_contact(n_ptr); } |
8f19afb2d tipc: cosmetic - ... |
219 |
int tipc_node_active_links(struct tipc_node *n_ptr) |
b97bf3fd8 [TIPC] Initial merge |
220 |
{ |
76ae0d71d tipc: Optimize ti... |
221 |
return n_ptr->active_links[0] != NULL; |
b97bf3fd8 [TIPC] Initial merge |
222 |
} |
8f19afb2d tipc: cosmetic - ... |
223 |
int tipc_node_redundant_links(struct tipc_node *n_ptr) |
b97bf3fd8 [TIPC] Initial merge |
224 |
{ |
a02cec215 net: return opera... |
225 |
return n_ptr->working_links > 1; |
b97bf3fd8 [TIPC] Initial merge |
226 |
} |
6c00055a8 tipc: Don't use s... |
227 |
int tipc_node_is_up(struct tipc_node *n_ptr) |
b97bf3fd8 [TIPC] Initial merge |
228 |
{ |
8f19afb2d tipc: cosmetic - ... |
229 |
return tipc_node_active_links(n_ptr); |
b97bf3fd8 [TIPC] Initial merge |
230 |
} |
37b9c08a8 tipc: Optimizatio... |
231 |
void tipc_node_attach_link(struct tipc_node *n_ptr, struct link *l_ptr) |
b97bf3fd8 [TIPC] Initial merge |
232 |
{ |
37b9c08a8 tipc: Optimizatio... |
233 234 235 |
n_ptr->links[l_ptr->b_ptr->identity] = l_ptr; atomic_inc(&tipc_num_links); n_ptr->link_cnt++; |
b97bf3fd8 [TIPC] Initial merge |
236 |
} |
6c00055a8 tipc: Don't use s... |
237 |
void tipc_node_detach_link(struct tipc_node *n_ptr, struct link *l_ptr) |
b97bf3fd8 [TIPC] Initial merge |
238 |
{ |
1fc54d8f4 [TIPC]: Fix simpl... |
239 |
n_ptr->links[l_ptr->b_ptr->identity] = NULL; |
d1bcb1154 tipc: Split up un... |
240 |
atomic_dec(&tipc_num_links); |
b97bf3fd8 [TIPC] Initial merge |
241 242 243 244 245 246 247 |
n_ptr->link_cnt--; } /* * Routing table management - five cases to handle: * * 1: A link towards a zone/cluster external node comes up. |
c43072852 [NET] TIPC: Fix w... |
248 249 250 |
* => Send a multicast message updating routing tables of all * system nodes within own cluster that the new destination * can be reached via this node. |
b97bf3fd8 [TIPC] Initial merge |
251 252 253 |
* (node.establishedContact()=>cluster.multicastNewRoute()) * * 2: A link towards a slave node comes up. |
c43072852 [NET] TIPC: Fix w... |
254 255 256 |
* => Send a multicast message updating routing tables of all * system nodes within own cluster that the new destination * can be reached via this node. |
b97bf3fd8 [TIPC] Initial merge |
257 |
* (node.establishedContact()=>cluster.multicastNewRoute()) |
c43072852 [NET] TIPC: Fix w... |
258 |
* => Send a message to the slave node about existence |
b97bf3fd8 [TIPC] Initial merge |
259 260 261 262 263 264 265 266 267 |
* of all system nodes within cluster: * (node.establishedContact()=>cluster.sendLocalRoutes()) * * 3: A new cluster local system node becomes available. * => Send message(s) to this particular node containing * information about all cluster external and slave * nodes which can be reached via this node. * (node.establishedContact()==>network.sendExternalRoutes()) * (node.establishedContact()==>network.sendSlaveRoutes()) |
c43072852 [NET] TIPC: Fix w... |
268 |
* => Send messages to all directly connected slave nodes |
b97bf3fd8 [TIPC] Initial merge |
269 270 |
* containing information about the existence of the new node * (node.establishedContact()=>cluster.multicastNewRoute()) |
c43072852 [NET] TIPC: Fix w... |
271 |
* |
b97bf3fd8 [TIPC] Initial merge |
272 273 |
* 4: The link towards a zone/cluster external node or slave * node goes down. |
c43072852 [NET] TIPC: Fix w... |
274 |
* => Send a multcast message updating routing tables of all |
b97bf3fd8 [TIPC] Initial merge |
275 276 277 278 279 280 281 282 283 |
* nodes within cluster that the new destination can not any * longer be reached via this node. * (node.lostAllLinks()=>cluster.bcastLostRoute()) * * 5: A cluster local system node becomes unavailable. * => Remove all references to this node from the local * routing tables. Note: This is a completely node * local operation. * (node.lostAllLinks()=>network.removeAsRouter()) |
c43072852 [NET] TIPC: Fix w... |
284 |
* => Send messages to all directly connected slave nodes |
b97bf3fd8 [TIPC] Initial merge |
285 286 287 288 |
* containing information about loss of the node * (node.establishedContact()=>cluster.multicastLostRoute()) * */ |
6c00055a8 tipc: Don't use s... |
289 |
static void node_established_contact(struct tipc_node *n_ptr) |
b97bf3fd8 [TIPC] Initial merge |
290 |
{ |
51a8e4dee tipc: Remove prot... |
291 |
tipc_k_signal((Handler)tipc_named_node_up, n_ptr->addr); |
b97bf3fd8 [TIPC] Initial merge |
292 |
|
c43072852 [NET] TIPC: Fix w... |
293 294 |
/* Syncronize broadcast acks */ n_ptr->bclink.acked = tipc_bclink_get_last_sent(); |
b97bf3fd8 [TIPC] Initial merge |
295 |
|
b97bf3fd8 [TIPC] Initial merge |
296 |
if (n_ptr->bclink.supported) { |
8f92df6ad tipc: Remove prot... |
297 |
tipc_nmap_add(&tipc_bcast_nmap, n_ptr->addr); |
b97bf3fd8 [TIPC] Initial merge |
298 299 300 |
if (n_ptr->addr < tipc_own_addr) tipc_own_tag++; } |
b97bf3fd8 [TIPC] Initial merge |
301 |
} |
b4b561022 tipc: Ensure both... |
302 |
static void node_name_purge_complete(unsigned long node_addr) |
5a68d5ee0 tipc: Prevent mis... |
303 304 305 306 307 308 309 |
{ struct tipc_node *n_ptr; read_lock_bh(&tipc_net_lock); n_ptr = tipc_node_find(node_addr); if (n_ptr) { tipc_node_lock(n_ptr); |
b4b561022 tipc: Ensure both... |
310 |
n_ptr->block_setup &= ~WAIT_NAMES_GONE; |
5a68d5ee0 tipc: Prevent mis... |
311 312 313 314 |
tipc_node_unlock(n_ptr); } read_unlock_bh(&tipc_net_lock); } |
6c00055a8 tipc: Don't use s... |
315 |
static void node_lost_contact(struct tipc_node *n_ptr) |
b97bf3fd8 [TIPC] Initial merge |
316 |
{ |
b97bf3fd8 [TIPC] Initial merge |
317 318 |
char addr_string[16]; u32 i; |
c5bd4d85d tipc: Enhance cle... |
319 320 321 322 323 |
info("Lost contact with %s ", tipc_addr_string_fill(addr_string, n_ptr->addr)); /* Flush broadcast link info associated with lost node */ |
c43072852 [NET] TIPC: Fix w... |
324 |
|
51a8e4dee tipc: Remove prot... |
325 |
if (n_ptr->bclink.supported) { |
c5bd4d85d tipc: Enhance cle... |
326 327 328 329 330 331 332 333 334 335 336 |
n_ptr->bclink.gap_after = n_ptr->bclink.gap_to = 0; while (n_ptr->bclink.deferred_head) { struct sk_buff *buf = n_ptr->bclink.deferred_head; n_ptr->bclink.deferred_head = buf->next; buf_discard(buf); } if (n_ptr->bclink.defragm) { buf_discard(n_ptr->bclink.defragm); n_ptr->bclink.defragm = NULL; } |
169073db4 tipc: Prevent bro... |
337 |
tipc_nmap_remove(&tipc_bcast_nmap, n_ptr->addr); |
8f92df6ad tipc: Remove prot... |
338 339 |
tipc_bclink_acknowledge(n_ptr, mod(n_ptr->bclink.acked + 10000)); |
51a8e4dee tipc: Remove prot... |
340 341 |
if (n_ptr->addr < tipc_own_addr) tipc_own_tag--; |
b97bf3fd8 [TIPC] Initial merge |
342 |
|
c5bd4d85d tipc: Enhance cle... |
343 344 |
n_ptr->bclink.supported = 0; } |
b97bf3fd8 [TIPC] Initial merge |
345 346 347 348 |
/* Abort link changeover */ for (i = 0; i < MAX_BEARERS; i++) { struct link *l_ptr = n_ptr->links[i]; |
c43072852 [NET] TIPC: Fix w... |
349 |
if (!l_ptr) |
b97bf3fd8 [TIPC] Initial merge |
350 351 352 |
continue; l_ptr->reset_checkpoint = l_ptr->next_in_no; l_ptr->exp_msg_count = 0; |
4323add67 [TIPC] Avoid poll... |
353 |
tipc_link_reset_fragments(l_ptr); |
b97bf3fd8 [TIPC] Initial merge |
354 355 356 |
} /* Notify subscribers */ |
f13791733 tipc: Cosmetic ch... |
357 |
tipc_nodesub_notify(n_ptr); |
5a68d5ee0 tipc: Prevent mis... |
358 |
|
b4b561022 tipc: Ensure both... |
359 |
/* Prevent re-contact with node until cleanup is done */ |
5a68d5ee0 tipc: Prevent mis... |
360 |
|
b4b561022 tipc: Ensure both... |
361 362 |
n_ptr->block_setup = WAIT_PEER_DOWN | WAIT_NAMES_GONE; tipc_k_signal((Handler)node_name_purge_complete, n_ptr->addr); |
b97bf3fd8 [TIPC] Initial merge |
363 |
} |
4323add67 [TIPC] Avoid poll... |
364 |
struct sk_buff *tipc_node_get_nodes(const void *req_tlv_area, int req_tlv_space) |
b97bf3fd8 [TIPC] Initial merge |
365 366 367 |
{ u32 domain; struct sk_buff *buf; |
6c00055a8 tipc: Don't use s... |
368 |
struct tipc_node *n_ptr; |
c43072852 [NET] TIPC: Fix w... |
369 |
struct tipc_node_info node_info; |
ea13847b2 [TIPC]: Improve r... |
370 |
u32 payload_size; |
b97bf3fd8 [TIPC] Initial merge |
371 372 |
if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_NET_ADDR)) |
4323add67 [TIPC] Avoid poll... |
373 |
return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR); |
b97bf3fd8 [TIPC] Initial merge |
374 |
|
3e6c8cd56 [TIPC]: endiannes... |
375 |
domain = ntohl(*(__be32 *)TLV_DATA(req_tlv_area)); |
4323add67 [TIPC] Avoid poll... |
376 377 378 |
if (!tipc_addr_domain_valid(domain)) return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE " (network address)"); |
b97bf3fd8 [TIPC] Initial merge |
379 |
|
1aad72d6c tipc: Add missing... |
380 |
read_lock_bh(&tipc_net_lock); |
672d99e19 tipc: Convert nod... |
381 |
if (!tipc_num_nodes) { |
1aad72d6c tipc: Add missing... |
382 |
read_unlock_bh(&tipc_net_lock); |
c43072852 [NET] TIPC: Fix w... |
383 |
return tipc_cfg_reply_none(); |
1aad72d6c tipc: Add missing... |
384 |
} |
b97bf3fd8 [TIPC] Initial merge |
385 |
|
08c80e9a0 tipc: Remove prot... |
386 |
/* For now, get space for all other nodes */ |
b97bf3fd8 [TIPC] Initial merge |
387 |
|
672d99e19 tipc: Convert nod... |
388 |
payload_size = TLV_SPACE(sizeof(node_info)) * tipc_num_nodes; |
1aad72d6c tipc: Add missing... |
389 390 |
if (payload_size > 32768u) { read_unlock_bh(&tipc_net_lock); |
ea13847b2 [TIPC]: Improve r... |
391 392 |
return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED " (too many nodes)"); |
1aad72d6c tipc: Add missing... |
393 |
} |
ea13847b2 [TIPC]: Improve r... |
394 |
buf = tipc_cfg_reply_alloc(payload_size); |
1aad72d6c tipc: Add missing... |
395 396 |
if (!buf) { read_unlock_bh(&tipc_net_lock); |
b97bf3fd8 [TIPC] Initial merge |
397 |
return NULL; |
1aad72d6c tipc: Add missing... |
398 |
} |
b97bf3fd8 [TIPC] Initial merge |
399 400 |
/* Add TLVs for all nodes in scope */ |
672d99e19 tipc: Convert nod... |
401 402 |
list_for_each_entry(n_ptr, &tipc_node_list, list) { if (!tipc_in_scope(domain, n_ptr->addr)) |
b97bf3fd8 [TIPC] Initial merge |
403 |
continue; |
c43072852 [NET] TIPC: Fix w... |
404 405 406 |
node_info.addr = htonl(n_ptr->addr); node_info.up = htonl(tipc_node_is_up(n_ptr)); tipc_cfg_append_tlv(buf, TIPC_TLV_NODE_INFO, |
4323add67 [TIPC] Avoid poll... |
407 |
&node_info, sizeof(node_info)); |
b97bf3fd8 [TIPC] Initial merge |
408 |
} |
1aad72d6c tipc: Add missing... |
409 |
read_unlock_bh(&tipc_net_lock); |
b97bf3fd8 [TIPC] Initial merge |
410 411 |
return buf; } |
4323add67 [TIPC] Avoid poll... |
412 |
struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space) |
b97bf3fd8 [TIPC] Initial merge |
413 414 415 |
{ u32 domain; struct sk_buff *buf; |
6c00055a8 tipc: Don't use s... |
416 |
struct tipc_node *n_ptr; |
c43072852 [NET] TIPC: Fix w... |
417 |
struct tipc_link_info link_info; |
ea13847b2 [TIPC]: Improve r... |
418 |
u32 payload_size; |
b97bf3fd8 [TIPC] Initial merge |
419 420 |
if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_NET_ADDR)) |
4323add67 [TIPC] Avoid poll... |
421 |
return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR); |
b97bf3fd8 [TIPC] Initial merge |
422 |
|
3e6c8cd56 [TIPC]: endiannes... |
423 |
domain = ntohl(*(__be32 *)TLV_DATA(req_tlv_area)); |
4323add67 [TIPC] Avoid poll... |
424 425 426 |
if (!tipc_addr_domain_valid(domain)) return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE " (network address)"); |
b97bf3fd8 [TIPC] Initial merge |
427 |
|
c43072852 [NET] TIPC: Fix w... |
428 429 |
if (tipc_mode != TIPC_NET_MODE) return tipc_cfg_reply_none(); |
1aad72d6c tipc: Add missing... |
430 |
read_lock_bh(&tipc_net_lock); |
ea13847b2 [TIPC]: Improve r... |
431 |
/* Get space for all unicast links + multicast link */ |
9df3b7eb6 tipc: Fix problem... |
432 |
payload_size = TLV_SPACE(sizeof(link_info)) * |
d1bcb1154 tipc: Split up un... |
433 |
(atomic_read(&tipc_num_links) + 1); |
1aad72d6c tipc: Add missing... |
434 435 |
if (payload_size > 32768u) { read_unlock_bh(&tipc_net_lock); |
ea13847b2 [TIPC]: Improve r... |
436 437 |
return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED " (too many links)"); |
1aad72d6c tipc: Add missing... |
438 |
} |
ea13847b2 [TIPC]: Improve r... |
439 |
buf = tipc_cfg_reply_alloc(payload_size); |
1aad72d6c tipc: Add missing... |
440 441 |
if (!buf) { read_unlock_bh(&tipc_net_lock); |
b97bf3fd8 [TIPC] Initial merge |
442 |
return NULL; |
1aad72d6c tipc: Add missing... |
443 |
} |
b97bf3fd8 [TIPC] Initial merge |
444 445 |
/* Add TLV for broadcast link */ |
a3796f895 tipc: Add network... |
446 |
link_info.dest = htonl(tipc_cluster_mask(tipc_own_addr)); |
c43072852 [NET] TIPC: Fix w... |
447 |
link_info.up = htonl(1); |
4b704d59d tipc: fix non-con... |
448 |
strlcpy(link_info.str, tipc_bclink_name, TIPC_MAX_LINK_NAME); |
4323add67 [TIPC] Avoid poll... |
449 |
tipc_cfg_append_tlv(buf, TIPC_TLV_LINK_INFO, &link_info, sizeof(link_info)); |
b97bf3fd8 [TIPC] Initial merge |
450 451 |
/* Add TLVs for any other links in scope */ |
672d99e19 tipc: Convert nod... |
452 |
list_for_each_entry(n_ptr, &tipc_node_list, list) { |
c43072852 [NET] TIPC: Fix w... |
453 |
u32 i; |
b97bf3fd8 [TIPC] Initial merge |
454 |
|
672d99e19 tipc: Convert nod... |
455 |
if (!tipc_in_scope(domain, n_ptr->addr)) |
b97bf3fd8 [TIPC] Initial merge |
456 |
continue; |
1aad72d6c tipc: Add missing... |
457 |
tipc_node_lock(n_ptr); |
c43072852 [NET] TIPC: Fix w... |
458 459 460 461 462 463 464 |
for (i = 0; i < MAX_BEARERS; i++) { if (!n_ptr->links[i]) continue; link_info.dest = htonl(n_ptr->addr); link_info.up = htonl(tipc_link_is_up(n_ptr->links[i])); strcpy(link_info.str, n_ptr->links[i]->name); tipc_cfg_append_tlv(buf, TIPC_TLV_LINK_INFO, |
4323add67 [TIPC] Avoid poll... |
465 |
&link_info, sizeof(link_info)); |
c43072852 [NET] TIPC: Fix w... |
466 |
} |
1aad72d6c tipc: Add missing... |
467 |
tipc_node_unlock(n_ptr); |
b97bf3fd8 [TIPC] Initial merge |
468 |
} |
1aad72d6c tipc: Add missing... |
469 |
read_unlock_bh(&tipc_net_lock); |
b97bf3fd8 [TIPC] Initial merge |
470 471 |
return buf; } |