diff options
Diffstat (limited to 'net/tipc/cluster.c')
-rw-r--r-- | net/tipc/cluster.c | 166 |
1 files changed, 20 insertions, 146 deletions
diff --git a/net/tipc/cluster.c b/net/tipc/cluster.c index 996b2b67687e..6bc9f07be945 100644 --- a/net/tipc/cluster.c +++ b/net/tipc/cluster.c | |||
@@ -43,7 +43,6 @@ static void tipc_cltr_multicast(struct cluster *c_ptr, struct sk_buff *buf, | |||
43 | 43 | ||
44 | struct tipc_node **tipc_local_nodes = NULL; | 44 | struct tipc_node **tipc_local_nodes = NULL; |
45 | struct tipc_node_map tipc_cltr_bcast_nodes = {0,{0,}}; | 45 | struct tipc_node_map tipc_cltr_bcast_nodes = {0,{0,}}; |
46 | u32 tipc_highest_allowed_slave = 0; | ||
47 | 46 | ||
48 | struct cluster *tipc_cltr_create(u32 addr) | 47 | struct cluster *tipc_cltr_create(u32 addr) |
49 | { | 48 | { |
@@ -57,10 +56,7 @@ struct cluster *tipc_cltr_create(u32 addr) | |||
57 | } | 56 | } |
58 | 57 | ||
59 | c_ptr->addr = tipc_addr(tipc_zone(addr), tipc_cluster(addr), 0); | 58 | c_ptr->addr = tipc_addr(tipc_zone(addr), tipc_cluster(addr), 0); |
60 | if (in_own_cluster(addr)) | 59 | max_nodes = tipc_max_nodes + 1; |
61 | max_nodes = LOWEST_SLAVE + tipc_max_slaves; | ||
62 | else | ||
63 | max_nodes = tipc_max_nodes + 1; | ||
64 | 60 | ||
65 | c_ptr->nodes = kcalloc(max_nodes + 1, sizeof(void*), GFP_ATOMIC); | 61 | c_ptr->nodes = kcalloc(max_nodes + 1, sizeof(void*), GFP_ATOMIC); |
66 | if (c_ptr->nodes == NULL) { | 62 | if (c_ptr->nodes == NULL) { |
@@ -71,7 +67,6 @@ struct cluster *tipc_cltr_create(u32 addr) | |||
71 | 67 | ||
72 | if (in_own_cluster(addr)) | 68 | if (in_own_cluster(addr)) |
73 | tipc_local_nodes = c_ptr->nodes; | 69 | tipc_local_nodes = c_ptr->nodes; |
74 | c_ptr->highest_slave = LOWEST_SLAVE - 1; | ||
75 | c_ptr->highest_node = 0; | 70 | c_ptr->highest_node = 0; |
76 | 71 | ||
77 | tipc_net.clusters[1] = c_ptr; | 72 | tipc_net.clusters[1] = c_ptr; |
@@ -87,9 +82,6 @@ void tipc_cltr_delete(struct cluster *c_ptr) | |||
87 | for (n_num = 1; n_num <= c_ptr->highest_node; n_num++) { | 82 | for (n_num = 1; n_num <= c_ptr->highest_node; n_num++) { |
88 | tipc_node_delete(c_ptr->nodes[n_num]); | 83 | tipc_node_delete(c_ptr->nodes[n_num]); |
89 | } | 84 | } |
90 | for (n_num = LOWEST_SLAVE; n_num <= c_ptr->highest_slave; n_num++) { | ||
91 | tipc_node_delete(c_ptr->nodes[n_num]); | ||
92 | } | ||
93 | kfree(c_ptr->nodes); | 85 | kfree(c_ptr->nodes); |
94 | kfree(c_ptr); | 86 | kfree(c_ptr); |
95 | } | 87 | } |
@@ -100,8 +92,6 @@ void tipc_cltr_attach_node(struct cluster *c_ptr, struct tipc_node *n_ptr) | |||
100 | u32 n_num = tipc_node(n_ptr->addr); | 92 | u32 n_num = tipc_node(n_ptr->addr); |
101 | u32 max_n_num = tipc_max_nodes; | 93 | u32 max_n_num = tipc_max_nodes; |
102 | 94 | ||
103 | if (in_own_cluster(n_ptr->addr)) | ||
104 | max_n_num = tipc_highest_allowed_slave; | ||
105 | assert(n_num > 0); | 95 | assert(n_num > 0); |
106 | assert(n_num <= max_n_num); | 96 | assert(n_num <= max_n_num); |
107 | assert(c_ptr->nodes[n_num] == NULL); | 97 | assert(c_ptr->nodes[n_num] == NULL); |
@@ -237,41 +227,6 @@ void tipc_cltr_bcast_lost_route(struct cluster *c_ptr, u32 dest, | |||
237 | } | 227 | } |
238 | } | 228 | } |
239 | 229 | ||
240 | void tipc_cltr_send_slave_routes(struct cluster *c_ptr, u32 dest) | ||
241 | { | ||
242 | struct sk_buff *buf; | ||
243 | struct tipc_msg *msg; | ||
244 | u32 highest = c_ptr->highest_slave; | ||
245 | u32 n_num; | ||
246 | int send = 0; | ||
247 | |||
248 | assert(!is_slave(dest)); | ||
249 | assert(in_own_cluster(dest)); | ||
250 | assert(in_own_cluster(c_ptr->addr)); | ||
251 | if (highest <= LOWEST_SLAVE) | ||
252 | return; | ||
253 | buf = tipc_cltr_prepare_routing_msg(highest - LOWEST_SLAVE + 1, | ||
254 | c_ptr->addr); | ||
255 | if (buf) { | ||
256 | msg = buf_msg(buf); | ||
257 | msg_set_remote_node(msg, c_ptr->addr); | ||
258 | msg_set_type(msg, SLAVE_ROUTING_TABLE); | ||
259 | for (n_num = LOWEST_SLAVE; n_num <= highest; n_num++) { | ||
260 | if (c_ptr->nodes[n_num] && | ||
261 | tipc_node_has_active_links(c_ptr->nodes[n_num])) { | ||
262 | send = 1; | ||
263 | msg_set_dataoctet(msg, n_num); | ||
264 | } | ||
265 | } | ||
266 | if (send) | ||
267 | tipc_link_send(buf, dest, dest); | ||
268 | else | ||
269 | buf_discard(buf); | ||
270 | } else { | ||
271 | warn("Memory squeeze: broadcast of lost route failed\n"); | ||
272 | } | ||
273 | } | ||
274 | |||
275 | void tipc_cltr_send_ext_routes(struct cluster *c_ptr, u32 dest) | 230 | void tipc_cltr_send_ext_routes(struct cluster *c_ptr, u32 dest) |
276 | { | 231 | { |
277 | struct sk_buff *buf; | 232 | struct sk_buff *buf; |
@@ -282,7 +237,6 @@ void tipc_cltr_send_ext_routes(struct cluster *c_ptr, u32 dest) | |||
282 | 237 | ||
283 | if (in_own_cluster(c_ptr->addr)) | 238 | if (in_own_cluster(c_ptr->addr)) |
284 | return; | 239 | return; |
285 | assert(!is_slave(dest)); | ||
286 | assert(in_own_cluster(dest)); | 240 | assert(in_own_cluster(dest)); |
287 | highest = c_ptr->highest_node; | 241 | highest = c_ptr->highest_node; |
288 | buf = tipc_cltr_prepare_routing_msg(highest + 1, c_ptr->addr); | 242 | buf = tipc_cltr_prepare_routing_msg(highest + 1, c_ptr->addr); |
@@ -306,37 +260,6 @@ void tipc_cltr_send_ext_routes(struct cluster *c_ptr, u32 dest) | |||
306 | } | 260 | } |
307 | } | 261 | } |
308 | 262 | ||
309 | void tipc_cltr_send_local_routes(struct cluster *c_ptr, u32 dest) | ||
310 | { | ||
311 | struct sk_buff *buf; | ||
312 | struct tipc_msg *msg; | ||
313 | u32 highest = c_ptr->highest_node; | ||
314 | u32 n_num; | ||
315 | int send = 0; | ||
316 | |||
317 | assert(is_slave(dest)); | ||
318 | assert(in_own_cluster(c_ptr->addr)); | ||
319 | buf = tipc_cltr_prepare_routing_msg(highest, c_ptr->addr); | ||
320 | if (buf) { | ||
321 | msg = buf_msg(buf); | ||
322 | msg_set_remote_node(msg, c_ptr->addr); | ||
323 | msg_set_type(msg, LOCAL_ROUTING_TABLE); | ||
324 | for (n_num = 1; n_num <= highest; n_num++) { | ||
325 | if (c_ptr->nodes[n_num] && | ||
326 | tipc_node_has_active_links(c_ptr->nodes[n_num])) { | ||
327 | send = 1; | ||
328 | msg_set_dataoctet(msg, n_num); | ||
329 | } | ||
330 | } | ||
331 | if (send) | ||
332 | tipc_link_send(buf, dest, dest); | ||
333 | else | ||
334 | buf_discard(buf); | ||
335 | } else { | ||
336 | warn("Memory squeeze: broadcast of local route failed\n"); | ||
337 | } | ||
338 | } | ||
339 | |||
340 | void tipc_cltr_recv_routing_table(struct sk_buff *buf) | 263 | void tipc_cltr_recv_routing_table(struct sk_buff *buf) |
341 | { | 264 | { |
342 | struct tipc_msg *msg = buf_msg(buf); | 265 | struct tipc_msg *msg = buf_msg(buf); |
@@ -366,8 +289,6 @@ void tipc_cltr_recv_routing_table(struct sk_buff *buf) | |||
366 | c_num = tipc_cluster(rem_node); | 289 | c_num = tipc_cluster(rem_node); |
367 | 290 | ||
368 | switch (msg_type(msg)) { | 291 | switch (msg_type(msg)) { |
369 | case LOCAL_ROUTING_TABLE: | ||
370 | assert(is_slave(tipc_own_addr)); | ||
371 | case EXT_ROUTING_TABLE: | 292 | case EXT_ROUTING_TABLE: |
372 | for (n_num = 1; n_num < table_size; n_num++) { | 293 | for (n_num = 1; n_num < table_size; n_num++) { |
373 | if (node_table[n_num]) { | 294 | if (node_table[n_num]) { |
@@ -382,29 +303,10 @@ void tipc_cltr_recv_routing_table(struct sk_buff *buf) | |||
382 | } | 303 | } |
383 | break; | 304 | break; |
384 | case SLAVE_ROUTING_TABLE: | 305 | case SLAVE_ROUTING_TABLE: |
385 | assert(!is_slave(tipc_own_addr)); | ||
386 | assert(in_own_cluster(c_ptr->addr)); | 306 | assert(in_own_cluster(c_ptr->addr)); |
387 | for (n_num = 1; n_num < table_size; n_num++) { | ||
388 | if (node_table[n_num]) { | ||
389 | u32 slave_num = n_num + LOWEST_SLAVE; | ||
390 | u32 addr = tipc_addr(z_num, c_num, slave_num); | ||
391 | n_ptr = c_ptr->nodes[slave_num]; | ||
392 | if (!n_ptr) { | ||
393 | n_ptr = tipc_node_create(addr); | ||
394 | } | ||
395 | if (n_ptr) | ||
396 | tipc_node_add_router(n_ptr, router); | ||
397 | } | ||
398 | } | ||
399 | break; | 307 | break; |
400 | case ROUTE_ADDITION: | 308 | case ROUTE_ADDITION: |
401 | if (!is_slave(tipc_own_addr)) { | 309 | assert(!in_own_cluster(c_ptr->addr)); |
402 | assert(!in_own_cluster(c_ptr->addr) || | ||
403 | is_slave(rem_node)); | ||
404 | } else { | ||
405 | assert(in_own_cluster(c_ptr->addr) && | ||
406 | !is_slave(rem_node)); | ||
407 | } | ||
408 | n_ptr = c_ptr->nodes[tipc_node(rem_node)]; | 310 | n_ptr = c_ptr->nodes[tipc_node(rem_node)]; |
409 | if (!n_ptr) | 311 | if (!n_ptr) |
410 | n_ptr = tipc_node_create(rem_node); | 312 | n_ptr = tipc_node_create(rem_node); |
@@ -412,13 +314,7 @@ void tipc_cltr_recv_routing_table(struct sk_buff *buf) | |||
412 | tipc_node_add_router(n_ptr, router); | 314 | tipc_node_add_router(n_ptr, router); |
413 | break; | 315 | break; |
414 | case ROUTE_REMOVAL: | 316 | case ROUTE_REMOVAL: |
415 | if (!is_slave(tipc_own_addr)) { | 317 | assert(!in_own_cluster(c_ptr->addr)); |
416 | assert(!in_own_cluster(c_ptr->addr) || | ||
417 | is_slave(rem_node)); | ||
418 | } else { | ||
419 | assert(in_own_cluster(c_ptr->addr) && | ||
420 | !is_slave(rem_node)); | ||
421 | } | ||
422 | n_ptr = c_ptr->nodes[tipc_node(rem_node)]; | 318 | n_ptr = c_ptr->nodes[tipc_node(rem_node)]; |
423 | if (n_ptr) | 319 | if (n_ptr) |
424 | tipc_node_remove_router(n_ptr, router); | 320 | tipc_node_remove_router(n_ptr, router); |
@@ -431,22 +327,12 @@ void tipc_cltr_recv_routing_table(struct sk_buff *buf) | |||
431 | 327 | ||
432 | void tipc_cltr_remove_as_router(struct cluster *c_ptr, u32 router) | 328 | void tipc_cltr_remove_as_router(struct cluster *c_ptr, u32 router) |
433 | { | 329 | { |
434 | u32 start_entry; | ||
435 | u32 tstop; | ||
436 | u32 n_num; | 330 | u32 n_num; |
437 | 331 | ||
438 | if (is_slave(router)) | 332 | if (in_own_cluster(c_ptr->addr)) |
439 | return; /* Slave nodes can not be routers */ | 333 | return; |
440 | |||
441 | if (in_own_cluster(c_ptr->addr)) { | ||
442 | start_entry = LOWEST_SLAVE; | ||
443 | tstop = c_ptr->highest_slave; | ||
444 | } else { | ||
445 | start_entry = 1; | ||
446 | tstop = c_ptr->highest_node; | ||
447 | } | ||
448 | 334 | ||
449 | for (n_num = start_entry; n_num <= tstop; n_num++) { | 335 | for (n_num = 1; n_num <= c_ptr->highest_node; n_num++) { |
450 | if (c_ptr->nodes[n_num]) { | 336 | if (c_ptr->nodes[n_num]) { |
451 | tipc_node_remove_router(c_ptr->nodes[n_num], router); | 337 | tipc_node_remove_router(c_ptr->nodes[n_num], router); |
452 | } | 338 | } |
@@ -466,13 +352,11 @@ static void tipc_cltr_multicast(struct cluster *c_ptr, struct sk_buff *buf, | |||
466 | u32 tstop; | 352 | u32 tstop; |
467 | 353 | ||
468 | assert(lower <= upper); | 354 | assert(lower <= upper); |
469 | assert(((lower >= 1) && (lower <= tipc_max_nodes)) || | 355 | assert((lower >= 1) && (lower <= tipc_max_nodes)); |
470 | ((lower >= LOWEST_SLAVE) && (lower <= tipc_highest_allowed_slave))); | 356 | assert((upper >= 1) && (upper <= tipc_max_nodes)); |
471 | assert(((upper >= 1) && (upper <= tipc_max_nodes)) || | ||
472 | ((upper >= LOWEST_SLAVE) && (upper <= tipc_highest_allowed_slave))); | ||
473 | assert(in_own_cluster(c_ptr->addr)); | 357 | assert(in_own_cluster(c_ptr->addr)); |
474 | 358 | ||
475 | tstop = is_slave(upper) ? c_ptr->highest_slave : c_ptr->highest_node; | 359 | tstop = c_ptr->highest_node; |
476 | if (tstop > upper) | 360 | if (tstop > upper) |
477 | tstop = upper; | 361 | tstop = upper; |
478 | for (n_num = lower; n_num <= tstop; n_num++) { | 362 | for (n_num = lower; n_num <= tstop; n_num++) { |
@@ -498,32 +382,23 @@ void tipc_cltr_broadcast(struct sk_buff *buf) | |||
498 | struct cluster *c_ptr; | 382 | struct cluster *c_ptr; |
499 | struct tipc_node *n_ptr; | 383 | struct tipc_node *n_ptr; |
500 | u32 n_num; | 384 | u32 n_num; |
501 | u32 tstart; | ||
502 | u32 tstop; | ||
503 | u32 node_type; | ||
504 | 385 | ||
505 | if (tipc_mode == TIPC_NET_MODE) { | 386 | if (tipc_mode == TIPC_NET_MODE) { |
506 | c_ptr = tipc_cltr_find(tipc_own_addr); | 387 | c_ptr = tipc_cltr_find(tipc_own_addr); |
507 | assert(in_own_cluster(c_ptr->addr)); /* For now */ | 388 | assert(in_own_cluster(c_ptr->addr)); /* For now */ |
508 | 389 | ||
509 | /* Send to standard nodes, then repeat loop sending to slaves */ | 390 | /* Send to nodes */ |
510 | tstart = 1; | 391 | for (n_num = 1; n_num <= c_ptr->highest_node; n_num++) { |
511 | tstop = c_ptr->highest_node; | 392 | n_ptr = c_ptr->nodes[n_num]; |
512 | for (node_type = 1; node_type <= 2; node_type++) { | 393 | if (n_ptr && tipc_node_has_active_links(n_ptr)) { |
513 | for (n_num = tstart; n_num <= tstop; n_num++) { | 394 | buf_copy = skb_copy(buf, GFP_ATOMIC); |
514 | n_ptr = c_ptr->nodes[n_num]; | 395 | if (buf_copy == NULL) |
515 | if (n_ptr && tipc_node_has_active_links(n_ptr)) { | 396 | goto exit; |
516 | buf_copy = skb_copy(buf, GFP_ATOMIC); | 397 | msg_set_destnode(buf_msg(buf_copy), |
517 | if (buf_copy == NULL) | 398 | n_ptr->addr); |
518 | goto exit; | 399 | tipc_link_send(buf_copy, n_ptr->addr, |
519 | msg_set_destnode(buf_msg(buf_copy), | 400 | n_ptr->addr); |
520 | n_ptr->addr); | ||
521 | tipc_link_send(buf_copy, n_ptr->addr, | ||
522 | n_ptr->addr); | ||
523 | } | ||
524 | } | 401 | } |
525 | tstart = LOWEST_SLAVE; | ||
526 | tstop = c_ptr->highest_slave; | ||
527 | } | 402 | } |
528 | } | 403 | } |
529 | exit: | 404 | exit: |
@@ -532,7 +407,6 @@ exit: | |||
532 | 407 | ||
533 | int tipc_cltr_init(void) | 408 | int tipc_cltr_init(void) |
534 | { | 409 | { |
535 | tipc_highest_allowed_slave = LOWEST_SLAVE + tipc_max_slaves; | ||
536 | return tipc_cltr_create(tipc_own_addr) ? 0 : -ENOMEM; | 410 | return tipc_cltr_create(tipc_own_addr) ? 0 : -ENOMEM; |
537 | } | 411 | } |
538 | 412 | ||