diff options
Diffstat (limited to 'net/tipc/name_table.c')
-rw-r--r-- | net/tipc/name_table.c | 62 |
1 files changed, 33 insertions, 29 deletions
diff --git a/net/tipc/name_table.c b/net/tipc/name_table.c index 3f4b23bd08f7..d129422fc5c2 100644 --- a/net/tipc/name_table.c +++ b/net/tipc/name_table.c | |||
@@ -46,7 +46,7 @@ | |||
46 | #include "cluster.h" | 46 | #include "cluster.h" |
47 | #include "bcast.h" | 47 | #include "bcast.h" |
48 | 48 | ||
49 | int tipc_nametbl_size = 1024; /* must be a power of 2 */ | 49 | static int tipc_nametbl_size = 1024; /* must be a power of 2 */ |
50 | 50 | ||
51 | /** | 51 | /** |
52 | * struct sub_seq - container for all published instances of a name sequence | 52 | * struct sub_seq - container for all published instances of a name sequence |
@@ -104,7 +104,7 @@ static atomic_t rsv_publ_ok = ATOMIC_INIT(0); | |||
104 | rwlock_t tipc_nametbl_lock = RW_LOCK_UNLOCKED; | 104 | rwlock_t tipc_nametbl_lock = RW_LOCK_UNLOCKED; |
105 | 105 | ||
106 | 106 | ||
107 | static inline int hash(int x) | 107 | static int hash(int x) |
108 | { | 108 | { |
109 | return(x & (tipc_nametbl_size - 1)); | 109 | return(x & (tipc_nametbl_size - 1)); |
110 | } | 110 | } |
@@ -121,7 +121,7 @@ static struct publication *publ_create(u32 type, u32 lower, u32 upper, | |||
121 | (struct publication *)kmalloc(sizeof(*publ), GFP_ATOMIC); | 121 | (struct publication *)kmalloc(sizeof(*publ), GFP_ATOMIC); |
122 | if (publ == NULL) { | 122 | if (publ == NULL) { |
123 | warn("Memory squeeze; failed to create publication\n"); | 123 | warn("Memory squeeze; failed to create publication\n"); |
124 | return 0; | 124 | return NULL; |
125 | } | 125 | } |
126 | 126 | ||
127 | memset(publ, 0, sizeof(*publ)); | 127 | memset(publ, 0, sizeof(*publ)); |
@@ -142,7 +142,7 @@ static struct publication *publ_create(u32 type, u32 lower, u32 upper, | |||
142 | * tipc_subseq_alloc - allocate a specified number of sub-sequence structures | 142 | * tipc_subseq_alloc - allocate a specified number of sub-sequence structures |
143 | */ | 143 | */ |
144 | 144 | ||
145 | struct sub_seq *tipc_subseq_alloc(u32 cnt) | 145 | static struct sub_seq *tipc_subseq_alloc(u32 cnt) |
146 | { | 146 | { |
147 | u32 sz = cnt * sizeof(struct sub_seq); | 147 | u32 sz = cnt * sizeof(struct sub_seq); |
148 | struct sub_seq *sseq = (struct sub_seq *)kmalloc(sz, GFP_ATOMIC); | 148 | struct sub_seq *sseq = (struct sub_seq *)kmalloc(sz, GFP_ATOMIC); |
@@ -158,7 +158,7 @@ struct sub_seq *tipc_subseq_alloc(u32 cnt) | |||
158 | * 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. |
159 | */ | 159 | */ |
160 | 160 | ||
161 | struct name_seq *tipc_nameseq_create(u32 type, struct hlist_head *seq_head) | 161 | static struct name_seq *tipc_nameseq_create(u32 type, struct hlist_head *seq_head) |
162 | { | 162 | { |
163 | struct name_seq *nseq = | 163 | struct name_seq *nseq = |
164 | (struct name_seq *)kmalloc(sizeof(*nseq), GFP_ATOMIC); | 164 | (struct name_seq *)kmalloc(sizeof(*nseq), GFP_ATOMIC); |
@@ -168,7 +168,7 @@ struct name_seq *tipc_nameseq_create(u32 type, struct hlist_head *seq_head) | |||
168 | warn("Memory squeeze; failed to create name sequence\n"); | 168 | warn("Memory squeeze; failed to create name sequence\n"); |
169 | kfree(nseq); | 169 | kfree(nseq); |
170 | kfree(sseq); | 170 | kfree(sseq); |
171 | return 0; | 171 | return NULL; |
172 | } | 172 | } |
173 | 173 | ||
174 | memset(nseq, 0, sizeof(*nseq)); | 174 | memset(nseq, 0, sizeof(*nseq)); |
@@ -190,8 +190,8 @@ struct name_seq *tipc_nameseq_create(u32 type, struct hlist_head *seq_head) | |||
190 | * Very time-critical, so binary searches through sub-sequence array. | 190 | * Very time-critical, so binary searches through sub-sequence array. |
191 | */ | 191 | */ |
192 | 192 | ||
193 | static inline struct sub_seq *nameseq_find_subseq(struct name_seq *nseq, | 193 | static struct sub_seq *nameseq_find_subseq(struct name_seq *nseq, |
194 | u32 instance) | 194 | u32 instance) |
195 | { | 195 | { |
196 | struct sub_seq *sseqs = nseq->sseqs; | 196 | struct sub_seq *sseqs = nseq->sseqs; |
197 | int low = 0; | 197 | int low = 0; |
@@ -207,7 +207,7 @@ static inline struct sub_seq *nameseq_find_subseq(struct name_seq *nseq, | |||
207 | else | 207 | else |
208 | return &sseqs[mid]; | 208 | return &sseqs[mid]; |
209 | } | 209 | } |
210 | return 0; | 210 | return NULL; |
211 | } | 211 | } |
212 | 212 | ||
213 | /** | 213 | /** |
@@ -243,9 +243,9 @@ static u32 nameseq_locate_subseq(struct name_seq *nseq, u32 instance) | |||
243 | * tipc_nameseq_insert_publ - | 243 | * tipc_nameseq_insert_publ - |
244 | */ | 244 | */ |
245 | 245 | ||
246 | struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq, | 246 | static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq, |
247 | u32 type, u32 lower, u32 upper, | 247 | u32 type, u32 lower, u32 upper, |
248 | u32 scope, u32 node, u32 port, u32 key) | 248 | u32 scope, u32 node, u32 port, u32 key) |
249 | { | 249 | { |
250 | struct subscription *s; | 250 | struct subscription *s; |
251 | struct subscription *st; | 251 | struct subscription *st; |
@@ -263,7 +263,7 @@ struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq, | |||
263 | 263 | ||
264 | if ((sseq->lower != lower) || (sseq->upper != upper)) { | 264 | if ((sseq->lower != lower) || (sseq->upper != upper)) { |
265 | warn("Overlapping publ <%u,%u,%u>\n", type, lower, upper); | 265 | warn("Overlapping publ <%u,%u,%u>\n", type, lower, upper); |
266 | return 0; | 266 | return NULL; |
267 | } | 267 | } |
268 | } else { | 268 | } else { |
269 | u32 inspos; | 269 | u32 inspos; |
@@ -278,7 +278,7 @@ struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq, | |||
278 | if ((inspos < nseq->first_free) && | 278 | if ((inspos < nseq->first_free) && |
279 | (upper >= nseq->sseqs[inspos].lower)) { | 279 | (upper >= nseq->sseqs[inspos].lower)) { |
280 | warn("Overlapping publ <%u,%u,%u>\n", type, lower, upper); | 280 | warn("Overlapping publ <%u,%u,%u>\n", type, lower, upper); |
281 | return 0; | 281 | return NULL; |
282 | } | 282 | } |
283 | 283 | ||
284 | /* Ensure there is space for new sub-sequence */ | 284 | /* Ensure there is space for new sub-sequence */ |
@@ -294,7 +294,7 @@ struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq, | |||
294 | nseq->alloc *= 2; | 294 | nseq->alloc *= 2; |
295 | } else { | 295 | } else { |
296 | warn("Memory squeeze; failed to create sub-sequence\n"); | 296 | warn("Memory squeeze; failed to create sub-sequence\n"); |
297 | return 0; | 297 | return NULL; |
298 | } | 298 | } |
299 | } | 299 | } |
300 | dbg("Have %u sseqs for type %u\n", nseq->alloc, type); | 300 | dbg("Have %u sseqs for type %u\n", nseq->alloc, type); |
@@ -319,7 +319,7 @@ struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq, | |||
319 | 319 | ||
320 | publ = publ_create(type, lower, upper, scope, node, port, key); | 320 | publ = publ_create(type, lower, upper, scope, node, port, key); |
321 | if (!publ) | 321 | if (!publ) |
322 | return 0; | 322 | return NULL; |
323 | dbg("inserting publ %x, node=%x publ->node=%x, subscr->node=%x\n", | 323 | dbg("inserting publ %x, node=%x publ->node=%x, subscr->node=%x\n", |
324 | publ, node, publ->node, publ->subscr.node); | 324 | publ, node, publ->node, publ->subscr.node); |
325 | 325 | ||
@@ -369,8 +369,8 @@ struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq, | |||
369 | * tipc_nameseq_remove_publ - | 369 | * tipc_nameseq_remove_publ - |
370 | */ | 370 | */ |
371 | 371 | ||
372 | struct publication *tipc_nameseq_remove_publ(struct name_seq *nseq, u32 inst, | 372 | static struct publication *tipc_nameseq_remove_publ(struct name_seq *nseq, u32 inst, |
373 | u32 node, u32 ref, u32 key) | 373 | u32 node, u32 ref, u32 key) |
374 | { | 374 | { |
375 | struct publication *publ; | 375 | struct publication *publ; |
376 | struct publication *prev; | 376 | struct publication *prev; |
@@ -394,7 +394,7 @@ struct publication *tipc_nameseq_remove_publ(struct name_seq *nseq, u32 inst, | |||
394 | i, &nseq->sseqs[i], nseq->sseqs[i].lower, | 394 | i, &nseq->sseqs[i], nseq->sseqs[i].lower, |
395 | nseq->sseqs[i].upper); | 395 | nseq->sseqs[i].upper); |
396 | } | 396 | } |
397 | return 0; | 397 | return NULL; |
398 | } | 398 | } |
399 | dbg("nameseq_remove: seq: %x, sseq %x, <%u,%u> key %u\n", | 399 | dbg("nameseq_remove: seq: %x, sseq %x, <%u,%u> key %u\n", |
400 | nseq, sseq, nseq->type, inst, key); | 400 | nseq, sseq, nseq->type, inst, key); |
@@ -413,7 +413,7 @@ struct publication *tipc_nameseq_remove_publ(struct name_seq *nseq, u32 inst, | |||
413 | prev->zone_list_next = publ->zone_list_next; | 413 | prev->zone_list_next = publ->zone_list_next; |
414 | sseq->zone_list = publ->zone_list_next; | 414 | sseq->zone_list = publ->zone_list_next; |
415 | } else { | 415 | } else { |
416 | sseq->zone_list = 0; | 416 | sseq->zone_list = NULL; |
417 | } | 417 | } |
418 | 418 | ||
419 | if (in_own_cluster(node)) { | 419 | if (in_own_cluster(node)) { |
@@ -431,7 +431,7 @@ struct publication *tipc_nameseq_remove_publ(struct name_seq *nseq, u32 inst, | |||
431 | prev->cluster_list_next = publ->cluster_list_next; | 431 | prev->cluster_list_next = publ->cluster_list_next; |
432 | sseq->cluster_list = publ->cluster_list_next; | 432 | sseq->cluster_list = publ->cluster_list_next; |
433 | } else { | 433 | } else { |
434 | sseq->cluster_list = 0; | 434 | sseq->cluster_list = NULL; |
435 | } | 435 | } |
436 | } | 436 | } |
437 | 437 | ||
@@ -450,7 +450,7 @@ struct publication *tipc_nameseq_remove_publ(struct name_seq *nseq, u32 inst, | |||
450 | prev->node_list_next = publ->node_list_next; | 450 | prev->node_list_next = publ->node_list_next; |
451 | sseq->node_list = publ->node_list_next; | 451 | sseq->node_list = publ->node_list_next; |
452 | } else { | 452 | } else { |
453 | sseq->node_list = 0; | 453 | sseq->node_list = NULL; |
454 | } | 454 | } |
455 | } | 455 | } |
456 | assert(!publ->node || (publ->node == node)); | 456 | assert(!publ->node || (publ->node == node)); |
@@ -535,7 +535,7 @@ static struct name_seq *nametbl_find_seq(u32 type) | |||
535 | } | 535 | } |
536 | } | 536 | } |
537 | 537 | ||
538 | return 0; | 538 | return NULL; |
539 | }; | 539 | }; |
540 | 540 | ||
541 | struct publication *tipc_nametbl_insert_publ(u32 type, u32 lower, u32 upper, | 541 | struct publication *tipc_nametbl_insert_publ(u32 type, u32 lower, u32 upper, |
@@ -547,7 +547,7 @@ struct publication *tipc_nametbl_insert_publ(u32 type, u32 lower, u32 upper, | |||
547 | if (lower > upper) { | 547 | if (lower > upper) { |
548 | warn("Failed to publish illegal <%u,%u,%u>\n", | 548 | warn("Failed to publish illegal <%u,%u,%u>\n", |
549 | type, lower, upper); | 549 | type, lower, upper); |
550 | return 0; | 550 | return NULL; |
551 | } | 551 | } |
552 | 552 | ||
553 | dbg("Publishing <%u,%u,%u> from %x\n", type, lower, upper, node); | 553 | dbg("Publishing <%u,%u,%u> from %x\n", type, lower, upper, node); |
@@ -556,7 +556,7 @@ struct publication *tipc_nametbl_insert_publ(u32 type, u32 lower, u32 upper, | |||
556 | dbg("tipc_nametbl_insert_publ: created %x\n", seq); | 556 | dbg("tipc_nametbl_insert_publ: created %x\n", seq); |
557 | } | 557 | } |
558 | if (!seq) | 558 | if (!seq) |
559 | return 0; | 559 | return NULL; |
560 | 560 | ||
561 | assert(seq->type == type); | 561 | assert(seq->type == type); |
562 | return tipc_nameseq_insert_publ(seq, type, lower, upper, | 562 | return tipc_nameseq_insert_publ(seq, type, lower, upper, |
@@ -570,7 +570,7 @@ struct publication *tipc_nametbl_remove_publ(u32 type, u32 lower, | |||
570 | struct name_seq *seq = nametbl_find_seq(type); | 570 | struct name_seq *seq = nametbl_find_seq(type); |
571 | 571 | ||
572 | if (!seq) | 572 | if (!seq) |
573 | return 0; | 573 | return NULL; |
574 | 574 | ||
575 | dbg("Withdrawing <%u,%u> from %x\n", type, lower, node); | 575 | dbg("Withdrawing <%u,%u> from %x\n", type, lower, node); |
576 | publ = tipc_nameseq_remove_publ(seq, lower, node, ref, key); | 576 | publ = tipc_nameseq_remove_publ(seq, lower, node, ref, key); |
@@ -594,7 +594,7 @@ struct publication *tipc_nametbl_remove_publ(u32 type, u32 lower, | |||
594 | u32 tipc_nametbl_translate(u32 type, u32 instance, u32 *destnode) | 594 | u32 tipc_nametbl_translate(u32 type, u32 instance, u32 *destnode) |
595 | { | 595 | { |
596 | struct sub_seq *sseq; | 596 | struct sub_seq *sseq; |
597 | struct publication *publ = 0; | 597 | struct publication *publ = NULL; |
598 | struct name_seq *seq; | 598 | struct name_seq *seq; |
599 | u32 ref; | 599 | u32 ref; |
600 | 600 | ||
@@ -740,12 +740,12 @@ struct publication *tipc_nametbl_publish(u32 type, u32 lower, u32 upper, | |||
740 | if (table.local_publ_count >= tipc_max_publications) { | 740 | if (table.local_publ_count >= tipc_max_publications) { |
741 | warn("Failed publish: max %u local publication\n", | 741 | warn("Failed publish: max %u local publication\n", |
742 | tipc_max_publications); | 742 | tipc_max_publications); |
743 | return 0; | 743 | return NULL; |
744 | } | 744 | } |
745 | if ((type < TIPC_RESERVED_TYPES) && !atomic_read(&rsv_publ_ok)) { | 745 | if ((type < TIPC_RESERVED_TYPES) && !atomic_read(&rsv_publ_ok)) { |
746 | warn("Failed to publish reserved name <%u,%u,%u>\n", | 746 | warn("Failed to publish reserved name <%u,%u,%u>\n", |
747 | type, lower, upper); | 747 | type, lower, upper); |
748 | return 0; | 748 | return NULL; |
749 | } | 749 | } |
750 | 750 | ||
751 | write_lock_bh(&tipc_nametbl_lock); | 751 | write_lock_bh(&tipc_nametbl_lock); |
@@ -983,6 +983,7 @@ static void nametbl_list(struct print_buf *buf, u32 depth_info, | |||
983 | } | 983 | } |
984 | } | 984 | } |
985 | 985 | ||
986 | #if 0 | ||
986 | void tipc_nametbl_print(struct print_buf *buf, const char *str) | 987 | void tipc_nametbl_print(struct print_buf *buf, const char *str) |
987 | { | 988 | { |
988 | tipc_printf(buf, str); | 989 | tipc_printf(buf, str); |
@@ -990,6 +991,7 @@ void tipc_nametbl_print(struct print_buf *buf, const char *str) | |||
990 | nametbl_list(buf, 0, 0, 0, 0); | 991 | nametbl_list(buf, 0, 0, 0, 0); |
991 | read_unlock_bh(&tipc_nametbl_lock); | 992 | read_unlock_bh(&tipc_nametbl_lock); |
992 | } | 993 | } |
994 | #endif | ||
993 | 995 | ||
994 | #define MAX_NAME_TBL_QUERY 32768 | 996 | #define MAX_NAME_TBL_QUERY 32768 |
995 | 997 | ||
@@ -1023,10 +1025,12 @@ struct sk_buff *tipc_nametbl_get(const void *req_tlv_area, int req_tlv_space) | |||
1023 | return buf; | 1025 | return buf; |
1024 | } | 1026 | } |
1025 | 1027 | ||
1028 | #if 0 | ||
1026 | void tipc_nametbl_dump(void) | 1029 | void tipc_nametbl_dump(void) |
1027 | { | 1030 | { |
1028 | nametbl_list(TIPC_CONS, 0, 0, 0, 0); | 1031 | nametbl_list(TIPC_CONS, 0, 0, 0, 0); |
1029 | } | 1032 | } |
1033 | #endif | ||
1030 | 1034 | ||
1031 | int tipc_nametbl_init(void) | 1035 | int tipc_nametbl_init(void) |
1032 | { | 1036 | { |