aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/name_table.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/tipc/name_table.c')
-rw-r--r--net/tipc/name_table.c48
1 files changed, 21 insertions, 27 deletions
diff --git a/net/tipc/name_table.c b/net/tipc/name_table.c
index 89eb5621ebba..c6a1ae36952e 100644
--- a/net/tipc/name_table.c
+++ b/net/tipc/name_table.c
@@ -114,10 +114,8 @@ struct name_table {
114}; 114};
115 115
116static struct name_table table; 116static struct name_table table;
117static atomic_t rsv_publ_ok = ATOMIC_INIT(0);
118DEFINE_RWLOCK(tipc_nametbl_lock); 117DEFINE_RWLOCK(tipc_nametbl_lock);
119 118
120
121static int hash(int x) 119static int hash(int x)
122{ 120{
123 return x & (tipc_nametbl_size - 1); 121 return x & (tipc_nametbl_size - 1);
@@ -270,6 +268,13 @@ static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq,
270 } 268 }
271 269
272 info = sseq->info; 270 info = sseq->info;
271
272 /* Check if an identical publication already exists */
273 list_for_each_entry(publ, &info->zone_list, zone_list) {
274 if ((publ->ref == port) && (publ->key == key) &&
275 (!publ->node || (publ->node == node)))
276 return NULL;
277 }
273 } else { 278 } else {
274 u32 inspos; 279 u32 inspos;
275 struct sub_seq *freesseq; 280 struct sub_seq *freesseq;
@@ -534,10 +539,17 @@ struct publication *tipc_nametbl_remove_publ(u32 type, u32 lower,
534} 539}
535 540
536/* 541/*
537 * tipc_nametbl_translate - translate name to port id 542 * tipc_nametbl_translate - perform name translation
543 *
544 * On entry, 'destnode' is the search domain used during translation.
538 * 545 *
539 * Note: on entry 'destnode' is the search domain used during translation; 546 * On exit:
540 * on exit it passes back the node address of the matching port (if any) 547 * - if name translation is deferred to another node/cluster/zone,
548 * leaves 'destnode' unchanged (will be non-zero) and returns 0
549 * - if name translation is attempted and succeeds, sets 'destnode'
550 * to publishing node and returns port reference (will be non-zero)
551 * - if name translation is attempted and fails, sets 'destnode' to 0
552 * and returns 0
541 */ 553 */
542 554
543u32 tipc_nametbl_translate(u32 type, u32 instance, u32 *destnode) 555u32 tipc_nametbl_translate(u32 type, u32 instance, u32 *destnode)
@@ -547,6 +559,7 @@ u32 tipc_nametbl_translate(u32 type, u32 instance, u32 *destnode)
547 struct publication *publ; 559 struct publication *publ;
548 struct name_seq *seq; 560 struct name_seq *seq;
549 u32 ref = 0; 561 u32 ref = 0;
562 u32 node = 0;
550 563
551 if (!tipc_in_scope(*destnode, tipc_own_addr)) 564 if (!tipc_in_scope(*destnode, tipc_own_addr))
552 return 0; 565 return 0;
@@ -604,11 +617,12 @@ u32 tipc_nametbl_translate(u32 type, u32 instance, u32 *destnode)
604 } 617 }
605 618
606 ref = publ->ref; 619 ref = publ->ref;
607 *destnode = publ->node; 620 node = publ->node;
608no_match: 621no_match:
609 spin_unlock_bh(&seq->lock); 622 spin_unlock_bh(&seq->lock);
610not_found: 623not_found:
611 read_unlock_bh(&tipc_nametbl_lock); 624 read_unlock_bh(&tipc_nametbl_lock);
625 *destnode = node;
612 return ref; 626 return ref;
613} 627}
614 628
@@ -665,22 +679,7 @@ exit:
665 return res; 679 return res;
666} 680}
667 681
668/** 682/*
669 * tipc_nametbl_publish_rsv - publish port name using a reserved name type
670 */
671
672int tipc_nametbl_publish_rsv(u32 ref, unsigned int scope,
673 struct tipc_name_seq const *seq)
674{
675 int res;
676
677 atomic_inc(&rsv_publ_ok);
678 res = tipc_publish(ref, scope, seq);
679 atomic_dec(&rsv_publ_ok);
680 return res;
681}
682
683/**
684 * tipc_nametbl_publish - add name publication to network name tables 683 * tipc_nametbl_publish - add name publication to network name tables
685 */ 684 */
686 685
@@ -694,11 +693,6 @@ struct publication *tipc_nametbl_publish(u32 type, u32 lower, u32 upper,
694 tipc_max_publications); 693 tipc_max_publications);
695 return NULL; 694 return NULL;
696 } 695 }
697 if ((type < TIPC_RESERVED_TYPES) && !atomic_read(&rsv_publ_ok)) {
698 warn("Publication failed, reserved name {%u,%u,%u}\n",
699 type, lower, upper);
700 return NULL;
701 }
702 696
703 write_lock_bh(&tipc_nametbl_lock); 697 write_lock_bh(&tipc_nametbl_lock);
704 table.local_publ_count++; 698 table.local_publ_count++;