diff options
Diffstat (limited to 'net/tipc/name_table.c')
-rw-r--r-- | net/tipc/name_table.c | 98 |
1 files changed, 32 insertions, 66 deletions
diff --git a/net/tipc/name_table.c b/net/tipc/name_table.c index c6a1ae36952e..010f24a59da2 100644 --- a/net/tipc/name_table.c +++ b/net/tipc/name_table.c | |||
@@ -56,7 +56,6 @@ static int tipc_nametbl_size = 1024; /* must be a power of 2 */ | |||
56 | * publications of the associated name sequence belong to it. | 56 | * publications of the associated name sequence belong to it. |
57 | * (The cluster and node lists may be empty.) | 57 | * (The cluster and node lists may be empty.) |
58 | */ | 58 | */ |
59 | |||
60 | struct name_info { | 59 | struct name_info { |
61 | struct list_head node_list; | 60 | struct list_head node_list; |
62 | struct list_head cluster_list; | 61 | struct list_head cluster_list; |
@@ -72,7 +71,6 @@ struct name_info { | |||
72 | * @upper: name sequence upper bound | 71 | * @upper: name sequence upper bound |
73 | * @info: pointer to name sequence publication info | 72 | * @info: pointer to name sequence publication info |
74 | */ | 73 | */ |
75 | |||
76 | struct sub_seq { | 74 | struct sub_seq { |
77 | u32 lower; | 75 | u32 lower; |
78 | u32 upper; | 76 | u32 upper; |
@@ -90,7 +88,6 @@ struct sub_seq { | |||
90 | * @subscriptions: list of subscriptions for this 'type' | 88 | * @subscriptions: list of subscriptions for this 'type' |
91 | * @lock: spinlock controlling access to publication lists of all sub-sequences | 89 | * @lock: spinlock controlling access to publication lists of all sub-sequences |
92 | */ | 90 | */ |
93 | |||
94 | struct name_seq { | 91 | struct name_seq { |
95 | u32 type; | 92 | u32 type; |
96 | struct sub_seq *sseqs; | 93 | struct sub_seq *sseqs; |
@@ -107,7 +104,6 @@ struct name_seq { | |||
107 | * accessed via hashing on 'type'; name sequence lists are *not* sorted | 104 | * accessed via hashing on 'type'; name sequence lists are *not* sorted |
108 | * @local_publ_count: number of publications issued by this node | 105 | * @local_publ_count: number of publications issued by this node |
109 | */ | 106 | */ |
110 | |||
111 | struct name_table { | 107 | struct name_table { |
112 | struct hlist_head *types; | 108 | struct hlist_head *types; |
113 | u32 local_publ_count; | 109 | u32 local_publ_count; |
@@ -124,7 +120,6 @@ static int hash(int x) | |||
124 | /** | 120 | /** |
125 | * publ_create - create a publication structure | 121 | * publ_create - create a publication structure |
126 | */ | 122 | */ |
127 | |||
128 | static struct publication *publ_create(u32 type, u32 lower, u32 upper, | 123 | static struct publication *publ_create(u32 type, u32 lower, u32 upper, |
129 | u32 scope, u32 node, u32 port_ref, | 124 | u32 scope, u32 node, u32 port_ref, |
130 | u32 key) | 125 | u32 key) |
@@ -151,7 +146,6 @@ static struct publication *publ_create(u32 type, u32 lower, u32 upper, | |||
151 | /** | 146 | /** |
152 | * tipc_subseq_alloc - allocate a specified number of sub-sequence structures | 147 | * tipc_subseq_alloc - allocate a specified number of sub-sequence structures |
153 | */ | 148 | */ |
154 | |||
155 | static struct sub_seq *tipc_subseq_alloc(u32 cnt) | 149 | static struct sub_seq *tipc_subseq_alloc(u32 cnt) |
156 | { | 150 | { |
157 | struct sub_seq *sseq = kcalloc(cnt, sizeof(struct sub_seq), GFP_ATOMIC); | 151 | struct sub_seq *sseq = kcalloc(cnt, sizeof(struct sub_seq), GFP_ATOMIC); |
@@ -163,7 +157,6 @@ static struct sub_seq *tipc_subseq_alloc(u32 cnt) | |||
163 | * | 157 | * |
164 | * Allocates a single sub-sequence structure and sets it to all 0's. | 158 | * Allocates a single sub-sequence structure and sets it to all 0's. |
165 | */ | 159 | */ |
166 | |||
167 | static struct name_seq *tipc_nameseq_create(u32 type, struct hlist_head *seq_head) | 160 | static struct name_seq *tipc_nameseq_create(u32 type, struct hlist_head *seq_head) |
168 | { | 161 | { |
169 | struct name_seq *nseq = kzalloc(sizeof(*nseq), GFP_ATOMIC); | 162 | struct name_seq *nseq = kzalloc(sizeof(*nseq), GFP_ATOMIC); |
@@ -186,12 +179,23 @@ static struct name_seq *tipc_nameseq_create(u32 type, struct hlist_head *seq_hea | |||
186 | return nseq; | 179 | return nseq; |
187 | } | 180 | } |
188 | 181 | ||
189 | /** | 182 | /* |
183 | * nameseq_delete_empty - deletes a name sequence structure if now unused | ||
184 | */ | ||
185 | static void nameseq_delete_empty(struct name_seq *seq) | ||
186 | { | ||
187 | if (!seq->first_free && list_empty(&seq->subscriptions)) { | ||
188 | hlist_del_init(&seq->ns_list); | ||
189 | kfree(seq->sseqs); | ||
190 | kfree(seq); | ||
191 | } | ||
192 | } | ||
193 | |||
194 | /* | ||
190 | * nameseq_find_subseq - find sub-sequence (if any) matching a name instance | 195 | * nameseq_find_subseq - find sub-sequence (if any) matching a name instance |
191 | * | 196 | * |
192 | * Very time-critical, so binary searches through sub-sequence array. | 197 | * Very time-critical, so binary searches through sub-sequence array. |
193 | */ | 198 | */ |
194 | |||
195 | static struct sub_seq *nameseq_find_subseq(struct name_seq *nseq, | 199 | static struct sub_seq *nameseq_find_subseq(struct name_seq *nseq, |
196 | u32 instance) | 200 | u32 instance) |
197 | { | 201 | { |
@@ -221,7 +225,6 @@ static struct sub_seq *nameseq_find_subseq(struct name_seq *nseq, | |||
221 | * | 225 | * |
222 | * Note: Similar to binary search code for locating a sub-sequence. | 226 | * Note: Similar to binary search code for locating a sub-sequence. |
223 | */ | 227 | */ |
224 | |||
225 | static u32 nameseq_locate_subseq(struct name_seq *nseq, u32 instance) | 228 | static u32 nameseq_locate_subseq(struct name_seq *nseq, u32 instance) |
226 | { | 229 | { |
227 | struct sub_seq *sseqs = nseq->sseqs; | 230 | struct sub_seq *sseqs = nseq->sseqs; |
@@ -242,9 +245,8 @@ static u32 nameseq_locate_subseq(struct name_seq *nseq, u32 instance) | |||
242 | } | 245 | } |
243 | 246 | ||
244 | /** | 247 | /** |
245 | * tipc_nameseq_insert_publ - | 248 | * tipc_nameseq_insert_publ |
246 | */ | 249 | */ |
247 | |||
248 | static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq, | 250 | static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq, |
249 | u32 type, u32 lower, u32 upper, | 251 | u32 type, u32 lower, u32 upper, |
250 | u32 scope, u32 node, u32 port, u32 key) | 252 | u32 scope, u32 node, u32 port, u32 key) |
@@ -260,7 +262,6 @@ static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq, | |||
260 | if (sseq) { | 262 | if (sseq) { |
261 | 263 | ||
262 | /* Lower end overlaps existing entry => need an exact match */ | 264 | /* Lower end overlaps existing entry => need an exact match */ |
263 | |||
264 | if ((sseq->lower != lower) || (sseq->upper != upper)) { | 265 | if ((sseq->lower != lower) || (sseq->upper != upper)) { |
265 | warn("Cannot publish {%u,%u,%u}, overlap error\n", | 266 | warn("Cannot publish {%u,%u,%u}, overlap error\n", |
266 | type, lower, upper); | 267 | type, lower, upper); |
@@ -280,11 +281,9 @@ static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq, | |||
280 | struct sub_seq *freesseq; | 281 | struct sub_seq *freesseq; |
281 | 282 | ||
282 | /* Find where lower end should be inserted */ | 283 | /* Find where lower end should be inserted */ |
283 | |||
284 | inspos = nameseq_locate_subseq(nseq, lower); | 284 | inspos = nameseq_locate_subseq(nseq, lower); |
285 | 285 | ||
286 | /* Fail if upper end overlaps into an existing entry */ | 286 | /* Fail if upper end overlaps into an existing entry */ |
287 | |||
288 | if ((inspos < nseq->first_free) && | 287 | if ((inspos < nseq->first_free) && |
289 | (upper >= nseq->sseqs[inspos].lower)) { | 288 | (upper >= nseq->sseqs[inspos].lower)) { |
290 | warn("Cannot publish {%u,%u,%u}, overlap error\n", | 289 | warn("Cannot publish {%u,%u,%u}, overlap error\n", |
@@ -293,7 +292,6 @@ static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq, | |||
293 | } | 292 | } |
294 | 293 | ||
295 | /* Ensure there is space for new sub-sequence */ | 294 | /* Ensure there is space for new sub-sequence */ |
296 | |||
297 | if (nseq->first_free == nseq->alloc) { | 295 | if (nseq->first_free == nseq->alloc) { |
298 | struct sub_seq *sseqs = tipc_subseq_alloc(nseq->alloc * 2); | 296 | struct sub_seq *sseqs = tipc_subseq_alloc(nseq->alloc * 2); |
299 | 297 | ||
@@ -321,7 +319,6 @@ static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq, | |||
321 | INIT_LIST_HEAD(&info->zone_list); | 319 | INIT_LIST_HEAD(&info->zone_list); |
322 | 320 | ||
323 | /* Insert new sub-sequence */ | 321 | /* Insert new sub-sequence */ |
324 | |||
325 | sseq = &nseq->sseqs[inspos]; | 322 | sseq = &nseq->sseqs[inspos]; |
326 | freesseq = &nseq->sseqs[nseq->first_free]; | 323 | freesseq = &nseq->sseqs[nseq->first_free]; |
327 | memmove(sseq + 1, sseq, (freesseq - sseq) * sizeof(*sseq)); | 324 | memmove(sseq + 1, sseq, (freesseq - sseq) * sizeof(*sseq)); |
@@ -333,8 +330,7 @@ static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq, | |||
333 | created_subseq = 1; | 330 | created_subseq = 1; |
334 | } | 331 | } |
335 | 332 | ||
336 | /* Insert a publication: */ | 333 | /* Insert a publication */ |
337 | |||
338 | publ = publ_create(type, lower, upper, scope, node, port, key); | 334 | publ = publ_create(type, lower, upper, scope, node, port, key); |
339 | if (!publ) | 335 | if (!publ) |
340 | return NULL; | 336 | return NULL; |
@@ -347,14 +343,12 @@ static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq, | |||
347 | info->cluster_list_size++; | 343 | info->cluster_list_size++; |
348 | } | 344 | } |
349 | 345 | ||
350 | if (node == tipc_own_addr) { | 346 | if (in_own_node(node)) { |
351 | list_add(&publ->node_list, &info->node_list); | 347 | list_add(&publ->node_list, &info->node_list); |
352 | info->node_list_size++; | 348 | info->node_list_size++; |
353 | } | 349 | } |
354 | 350 | ||
355 | /* | 351 | /* Any subscriptions waiting for notification? */ |
356 | * Any subscriptions waiting for notification? | ||
357 | */ | ||
358 | list_for_each_entry_safe(s, st, &nseq->subscriptions, nameseq_list) { | 352 | list_for_each_entry_safe(s, st, &nseq->subscriptions, nameseq_list) { |
359 | tipc_subscr_report_overlap(s, | 353 | tipc_subscr_report_overlap(s, |
360 | publ->lower, | 354 | publ->lower, |
@@ -368,7 +362,7 @@ static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq, | |||
368 | } | 362 | } |
369 | 363 | ||
370 | /** | 364 | /** |
371 | * tipc_nameseq_remove_publ - | 365 | * tipc_nameseq_remove_publ |
372 | * | 366 | * |
373 | * NOTE: There may be cases where TIPC is asked to remove a publication | 367 | * NOTE: There may be cases where TIPC is asked to remove a publication |
374 | * that is not in the name table. For example, if another node issues a | 368 | * that is not in the name table. For example, if another node issues a |
@@ -378,7 +372,6 @@ static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq, | |||
378 | * A failed withdraw request simply returns a failure indication and lets the | 372 | * A failed withdraw request simply returns a failure indication and lets the |
379 | * caller issue any error or warning messages associated with such a problem. | 373 | * caller issue any error or warning messages associated with such a problem. |
380 | */ | 374 | */ |
381 | |||
382 | static struct publication *tipc_nameseq_remove_publ(struct name_seq *nseq, u32 inst, | 375 | static struct publication *tipc_nameseq_remove_publ(struct name_seq *nseq, u32 inst, |
383 | u32 node, u32 ref, u32 key) | 376 | u32 node, u32 ref, u32 key) |
384 | { | 377 | { |
@@ -395,7 +388,6 @@ static struct publication *tipc_nameseq_remove_publ(struct name_seq *nseq, u32 i | |||
395 | info = sseq->info; | 388 | info = sseq->info; |
396 | 389 | ||
397 | /* Locate publication, if it exists */ | 390 | /* Locate publication, if it exists */ |
398 | |||
399 | list_for_each_entry(publ, &info->zone_list, zone_list) { | 391 | list_for_each_entry(publ, &info->zone_list, zone_list) { |
400 | if ((publ->key == key) && (publ->ref == ref) && | 392 | if ((publ->key == key) && (publ->ref == ref) && |
401 | (!publ->node || (publ->node == node))) | 393 | (!publ->node || (publ->node == node))) |
@@ -405,26 +397,22 @@ static struct publication *tipc_nameseq_remove_publ(struct name_seq *nseq, u32 i | |||
405 | 397 | ||
406 | found: | 398 | found: |
407 | /* Remove publication from zone scope list */ | 399 | /* Remove publication from zone scope list */ |
408 | |||
409 | list_del(&publ->zone_list); | 400 | list_del(&publ->zone_list); |
410 | info->zone_list_size--; | 401 | info->zone_list_size--; |
411 | 402 | ||
412 | /* Remove publication from cluster scope list, if present */ | 403 | /* Remove publication from cluster scope list, if present */ |
413 | |||
414 | if (in_own_cluster(node)) { | 404 | if (in_own_cluster(node)) { |
415 | list_del(&publ->cluster_list); | 405 | list_del(&publ->cluster_list); |
416 | info->cluster_list_size--; | 406 | info->cluster_list_size--; |
417 | } | 407 | } |
418 | 408 | ||
419 | /* Remove publication from node scope list, if present */ | 409 | /* Remove publication from node scope list, if present */ |
420 | 410 | if (in_own_node(node)) { | |
421 | if (node == tipc_own_addr) { | ||
422 | list_del(&publ->node_list); | 411 | list_del(&publ->node_list); |
423 | info->node_list_size--; | 412 | info->node_list_size--; |
424 | } | 413 | } |
425 | 414 | ||
426 | /* Contract subseq list if no more publications for that subseq */ | 415 | /* Contract subseq list if no more publications for that subseq */ |
427 | |||
428 | if (list_empty(&info->zone_list)) { | 416 | if (list_empty(&info->zone_list)) { |
429 | kfree(info); | 417 | kfree(info); |
430 | free = &nseq->sseqs[nseq->first_free--]; | 418 | free = &nseq->sseqs[nseq->first_free--]; |
@@ -433,7 +421,6 @@ found: | |||
433 | } | 421 | } |
434 | 422 | ||
435 | /* Notify any waiting subscriptions */ | 423 | /* Notify any waiting subscriptions */ |
436 | |||
437 | list_for_each_entry_safe(s, st, &nseq->subscriptions, nameseq_list) { | 424 | list_for_each_entry_safe(s, st, &nseq->subscriptions, nameseq_list) { |
438 | tipc_subscr_report_overlap(s, | 425 | tipc_subscr_report_overlap(s, |
439 | publ->lower, | 426 | publ->lower, |
@@ -452,7 +439,6 @@ found: | |||
452 | * the prescribed number of events if there is any sub- | 439 | * the prescribed number of events if there is any sub- |
453 | * sequence overlapping with the requested sequence | 440 | * sequence overlapping with the requested sequence |
454 | */ | 441 | */ |
455 | |||
456 | static void tipc_nameseq_subscribe(struct name_seq *nseq, | 442 | static void tipc_nameseq_subscribe(struct name_seq *nseq, |
457 | struct tipc_subscription *s) | 443 | struct tipc_subscription *s) |
458 | { | 444 | { |
@@ -504,9 +490,10 @@ struct publication *tipc_nametbl_insert_publ(u32 type, u32 lower, u32 upper, | |||
504 | { | 490 | { |
505 | struct name_seq *seq = nametbl_find_seq(type); | 491 | struct name_seq *seq = nametbl_find_seq(type); |
506 | 492 | ||
507 | if (lower > upper) { | 493 | if ((scope < TIPC_ZONE_SCOPE) || (scope > TIPC_NODE_SCOPE) || |
508 | warn("Failed to publish illegal {%u,%u,%u}\n", | 494 | (lower > upper)) { |
509 | type, lower, upper); | 495 | dbg("Failed to publish illegal {%u,%u,%u} with scope %u\n", |
496 | type, lower, upper, scope); | ||
510 | return NULL; | 497 | return NULL; |
511 | } | 498 | } |
512 | 499 | ||
@@ -529,12 +516,7 @@ struct publication *tipc_nametbl_remove_publ(u32 type, u32 lower, | |||
529 | return NULL; | 516 | return NULL; |
530 | 517 | ||
531 | publ = tipc_nameseq_remove_publ(seq, lower, node, ref, key); | 518 | publ = tipc_nameseq_remove_publ(seq, lower, node, ref, key); |
532 | 519 | nameseq_delete_empty(seq); | |
533 | if (!seq->first_free && list_empty(&seq->subscriptions)) { | ||
534 | hlist_del_init(&seq->ns_list); | ||
535 | kfree(seq->sseqs); | ||
536 | kfree(seq); | ||
537 | } | ||
538 | return publ; | 520 | return publ; |
539 | } | 521 | } |
540 | 522 | ||
@@ -551,7 +533,6 @@ struct publication *tipc_nametbl_remove_publ(u32 type, u32 lower, | |||
551 | * - if name translation is attempted and fails, sets 'destnode' to 0 | 533 | * - if name translation is attempted and fails, sets 'destnode' to 0 |
552 | * and returns 0 | 534 | * and returns 0 |
553 | */ | 535 | */ |
554 | |||
555 | u32 tipc_nametbl_translate(u32 type, u32 instance, u32 *destnode) | 536 | u32 tipc_nametbl_translate(u32 type, u32 instance, u32 *destnode) |
556 | { | 537 | { |
557 | struct sub_seq *sseq; | 538 | struct sub_seq *sseq; |
@@ -574,7 +555,7 @@ u32 tipc_nametbl_translate(u32 type, u32 instance, u32 *destnode) | |||
574 | spin_lock_bh(&seq->lock); | 555 | spin_lock_bh(&seq->lock); |
575 | info = sseq->info; | 556 | info = sseq->info; |
576 | 557 | ||
577 | /* Closest-First Algorithm: */ | 558 | /* Closest-First Algorithm */ |
578 | if (likely(!*destnode)) { | 559 | if (likely(!*destnode)) { |
579 | if (!list_empty(&info->node_list)) { | 560 | if (!list_empty(&info->node_list)) { |
580 | publ = list_first_entry(&info->node_list, | 561 | publ = list_first_entry(&info->node_list, |
@@ -597,14 +578,14 @@ u32 tipc_nametbl_translate(u32 type, u32 instance, u32 *destnode) | |||
597 | } | 578 | } |
598 | } | 579 | } |
599 | 580 | ||
600 | /* Round-Robin Algorithm: */ | 581 | /* Round-Robin Algorithm */ |
601 | else if (*destnode == tipc_own_addr) { | 582 | else if (*destnode == tipc_own_addr) { |
602 | if (list_empty(&info->node_list)) | 583 | if (list_empty(&info->node_list)) |
603 | goto no_match; | 584 | goto no_match; |
604 | publ = list_first_entry(&info->node_list, struct publication, | 585 | publ = list_first_entry(&info->node_list, struct publication, |
605 | node_list); | 586 | node_list); |
606 | list_move_tail(&publ->node_list, &info->node_list); | 587 | list_move_tail(&publ->node_list, &info->node_list); |
607 | } else if (in_own_cluster(*destnode)) { | 588 | } else if (in_own_cluster_exact(*destnode)) { |
608 | if (list_empty(&info->cluster_list)) | 589 | if (list_empty(&info->cluster_list)) |
609 | goto no_match; | 590 | goto no_match; |
610 | publ = list_first_entry(&info->cluster_list, struct publication, | 591 | publ = list_first_entry(&info->cluster_list, struct publication, |
@@ -638,7 +619,6 @@ not_found: | |||
638 | * | 619 | * |
639 | * Returns non-zero if any off-node ports overlap | 620 | * Returns non-zero if any off-node ports overlap |
640 | */ | 621 | */ |
641 | |||
642 | int tipc_nametbl_mc_translate(u32 type, u32 lower, u32 upper, u32 limit, | 622 | int tipc_nametbl_mc_translate(u32 type, u32 lower, u32 upper, u32 limit, |
643 | struct tipc_port_list *dports) | 623 | struct tipc_port_list *dports) |
644 | { | 624 | { |
@@ -682,7 +662,6 @@ exit: | |||
682 | /* | 662 | /* |
683 | * tipc_nametbl_publish - add name publication to network name tables | 663 | * tipc_nametbl_publish - add name publication to network name tables |
684 | */ | 664 | */ |
685 | |||
686 | struct publication *tipc_nametbl_publish(u32 type, u32 lower, u32 upper, | 665 | struct publication *tipc_nametbl_publish(u32 type, u32 lower, u32 upper, |
687 | u32 scope, u32 port_ref, u32 key) | 666 | u32 scope, u32 port_ref, u32 key) |
688 | { | 667 | { |
@@ -695,11 +674,12 @@ struct publication *tipc_nametbl_publish(u32 type, u32 lower, u32 upper, | |||
695 | } | 674 | } |
696 | 675 | ||
697 | write_lock_bh(&tipc_nametbl_lock); | 676 | write_lock_bh(&tipc_nametbl_lock); |
698 | table.local_publ_count++; | ||
699 | publ = tipc_nametbl_insert_publ(type, lower, upper, scope, | 677 | publ = tipc_nametbl_insert_publ(type, lower, upper, scope, |
700 | tipc_own_addr, port_ref, key); | 678 | tipc_own_addr, port_ref, key); |
701 | if (publ && (scope != TIPC_NODE_SCOPE)) | 679 | if (likely(publ)) { |
680 | table.local_publ_count++; | ||
702 | tipc_named_publish(publ); | 681 | tipc_named_publish(publ); |
682 | } | ||
703 | write_unlock_bh(&tipc_nametbl_lock); | 683 | write_unlock_bh(&tipc_nametbl_lock); |
704 | return publ; | 684 | return publ; |
705 | } | 685 | } |
@@ -707,7 +687,6 @@ struct publication *tipc_nametbl_publish(u32 type, u32 lower, u32 upper, | |||
707 | /** | 687 | /** |
708 | * tipc_nametbl_withdraw - withdraw name publication from network name tables | 688 | * tipc_nametbl_withdraw - withdraw name publication from network name tables |
709 | */ | 689 | */ |
710 | |||
711 | int tipc_nametbl_withdraw(u32 type, u32 lower, u32 ref, u32 key) | 690 | int tipc_nametbl_withdraw(u32 type, u32 lower, u32 ref, u32 key) |
712 | { | 691 | { |
713 | struct publication *publ; | 692 | struct publication *publ; |
@@ -716,8 +695,7 @@ int tipc_nametbl_withdraw(u32 type, u32 lower, u32 ref, u32 key) | |||
716 | publ = tipc_nametbl_remove_publ(type, lower, tipc_own_addr, ref, key); | 695 | publ = tipc_nametbl_remove_publ(type, lower, tipc_own_addr, ref, key); |
717 | if (likely(publ)) { | 696 | if (likely(publ)) { |
718 | table.local_publ_count--; | 697 | table.local_publ_count--; |
719 | if (publ->scope != TIPC_NODE_SCOPE) | 698 | tipc_named_withdraw(publ); |
720 | tipc_named_withdraw(publ); | ||
721 | write_unlock_bh(&tipc_nametbl_lock); | 699 | write_unlock_bh(&tipc_nametbl_lock); |
722 | list_del_init(&publ->pport_list); | 700 | list_del_init(&publ->pport_list); |
723 | kfree(publ); | 701 | kfree(publ); |
@@ -733,7 +711,6 @@ int tipc_nametbl_withdraw(u32 type, u32 lower, u32 ref, u32 key) | |||
733 | /** | 711 | /** |
734 | * tipc_nametbl_subscribe - add a subscription object to the name table | 712 | * tipc_nametbl_subscribe - add a subscription object to the name table |
735 | */ | 713 | */ |
736 | |||
737 | void tipc_nametbl_subscribe(struct tipc_subscription *s) | 714 | void tipc_nametbl_subscribe(struct tipc_subscription *s) |
738 | { | 715 | { |
739 | u32 type = s->seq.type; | 716 | u32 type = s->seq.type; |
@@ -757,7 +734,6 @@ void tipc_nametbl_subscribe(struct tipc_subscription *s) | |||
757 | /** | 734 | /** |
758 | * tipc_nametbl_unsubscribe - remove a subscription object from name table | 735 | * tipc_nametbl_unsubscribe - remove a subscription object from name table |
759 | */ | 736 | */ |
760 | |||
761 | void tipc_nametbl_unsubscribe(struct tipc_subscription *s) | 737 | void tipc_nametbl_unsubscribe(struct tipc_subscription *s) |
762 | { | 738 | { |
763 | struct name_seq *seq; | 739 | struct name_seq *seq; |
@@ -768,11 +744,7 @@ void tipc_nametbl_unsubscribe(struct tipc_subscription *s) | |||
768 | spin_lock_bh(&seq->lock); | 744 | spin_lock_bh(&seq->lock); |
769 | list_del_init(&s->nameseq_list); | 745 | list_del_init(&s->nameseq_list); |
770 | spin_unlock_bh(&seq->lock); | 746 | spin_unlock_bh(&seq->lock); |
771 | if ((seq->first_free == 0) && list_empty(&seq->subscriptions)) { | 747 | nameseq_delete_empty(seq); |
772 | hlist_del_init(&seq->ns_list); | ||
773 | kfree(seq->sseqs); | ||
774 | kfree(seq); | ||
775 | } | ||
776 | } | 748 | } |
777 | write_unlock_bh(&tipc_nametbl_lock); | 749 | write_unlock_bh(&tipc_nametbl_lock); |
778 | } | 750 | } |
@@ -781,7 +753,6 @@ void tipc_nametbl_unsubscribe(struct tipc_subscription *s) | |||
781 | /** | 753 | /** |
782 | * subseq_list: print specified sub-sequence contents into the given buffer | 754 | * subseq_list: print specified sub-sequence contents into the given buffer |
783 | */ | 755 | */ |
784 | |||
785 | static void subseq_list(struct sub_seq *sseq, struct print_buf *buf, u32 depth, | 756 | static void subseq_list(struct sub_seq *sseq, struct print_buf *buf, u32 depth, |
786 | u32 index) | 757 | u32 index) |
787 | { | 758 | { |
@@ -818,7 +789,6 @@ static void subseq_list(struct sub_seq *sseq, struct print_buf *buf, u32 depth, | |||
818 | /** | 789 | /** |
819 | * nameseq_list: print specified name sequence contents into the given buffer | 790 | * nameseq_list: print specified name sequence contents into the given buffer |
820 | */ | 791 | */ |
821 | |||
822 | static void nameseq_list(struct name_seq *seq, struct print_buf *buf, u32 depth, | 792 | static void nameseq_list(struct name_seq *seq, struct print_buf *buf, u32 depth, |
823 | u32 type, u32 lowbound, u32 upbound, u32 index) | 793 | u32 type, u32 lowbound, u32 upbound, u32 index) |
824 | { | 794 | { |
@@ -849,7 +819,6 @@ static void nameseq_list(struct name_seq *seq, struct print_buf *buf, u32 depth, | |||
849 | /** | 819 | /** |
850 | * nametbl_header - print name table header into the given buffer | 820 | * nametbl_header - print name table header into the given buffer |
851 | */ | 821 | */ |
852 | |||
853 | static void nametbl_header(struct print_buf *buf, u32 depth) | 822 | static void nametbl_header(struct print_buf *buf, u32 depth) |
854 | { | 823 | { |
855 | const char *header[] = { | 824 | const char *header[] = { |
@@ -871,7 +840,6 @@ static void nametbl_header(struct print_buf *buf, u32 depth) | |||
871 | /** | 840 | /** |
872 | * nametbl_list - print specified name table contents into the given buffer | 841 | * nametbl_list - print specified name table contents into the given buffer |
873 | */ | 842 | */ |
874 | |||
875 | static void nametbl_list(struct print_buf *buf, u32 depth_info, | 843 | static void nametbl_list(struct print_buf *buf, u32 depth_info, |
876 | u32 type, u32 lowbound, u32 upbound) | 844 | u32 type, u32 lowbound, u32 upbound) |
877 | { | 845 | { |
@@ -970,7 +938,6 @@ void tipc_nametbl_stop(void) | |||
970 | return; | 938 | return; |
971 | 939 | ||
972 | /* Verify name table is empty, then release it */ | 940 | /* Verify name table is empty, then release it */ |
973 | |||
974 | write_lock_bh(&tipc_nametbl_lock); | 941 | write_lock_bh(&tipc_nametbl_lock); |
975 | for (i = 0; i < tipc_nametbl_size; i++) { | 942 | for (i = 0; i < tipc_nametbl_size; i++) { |
976 | if (!hlist_empty(&table.types[i])) | 943 | if (!hlist_empty(&table.types[i])) |
@@ -980,4 +947,3 @@ void tipc_nametbl_stop(void) | |||
980 | table.types = NULL; | 947 | table.types = NULL; |
981 | write_unlock_bh(&tipc_nametbl_lock); | 948 | write_unlock_bh(&tipc_nametbl_lock); |
982 | } | 949 | } |
983 | |||