Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 1 | /* |
| 2 | * net/tipc/name_table.c: TIPC name table code |
| 3 | * |
Per Liden | 593a5f2 | 2006-01-11 19:14:19 +0100 | [diff] [blame] | 4 | * Copyright (c) 2000-2006, Ericsson AB |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 5 | * Copyright (c) 2004-2005, Wind River Systems |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 6 | * All rights reserved. |
| 7 | * |
Per Liden | 9ea1fd3 | 2006-01-11 13:30:43 +0100 | [diff] [blame] | 8 | * Redistribution and use in source and binary forms, with or without |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 9 | * modification, are permitted provided that the following conditions are met: |
| 10 | * |
Per Liden | 9ea1fd3 | 2006-01-11 13:30:43 +0100 | [diff] [blame] | 11 | * 1. Redistributions of source code must retain the above copyright |
| 12 | * notice, this list of conditions and the following disclaimer. |
| 13 | * 2. Redistributions in binary form must reproduce the above copyright |
| 14 | * notice, this list of conditions and the following disclaimer in the |
| 15 | * documentation and/or other materials provided with the distribution. |
| 16 | * 3. Neither the names of the copyright holders nor the names of its |
| 17 | * contributors may be used to endorse or promote products derived from |
| 18 | * this software without specific prior written permission. |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 19 | * |
Per Liden | 9ea1fd3 | 2006-01-11 13:30:43 +0100 | [diff] [blame] | 20 | * Alternatively, this software may be distributed under the terms of the |
| 21 | * GNU General Public License ("GPL") version 2 as published by the Free |
| 22 | * Software Foundation. |
| 23 | * |
| 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 27 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
| 28 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 29 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 30 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 31 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 32 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 34 | * POSSIBILITY OF SUCH DAMAGE. |
| 35 | */ |
| 36 | |
| 37 | #include "core.h" |
| 38 | #include "config.h" |
| 39 | #include "dbg.h" |
| 40 | #include "name_table.h" |
| 41 | #include "name_distr.h" |
| 42 | #include "addr.h" |
| 43 | #include "node_subscr.h" |
| 44 | #include "subscr.h" |
| 45 | #include "port.h" |
| 46 | #include "cluster.h" |
| 47 | #include "bcast.h" |
| 48 | |
Adrian Bunk | 988f088 | 2006-03-20 22:37:52 -0800 | [diff] [blame] | 49 | static int tipc_nametbl_size = 1024; /* must be a power of 2 */ |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 50 | |
| 51 | /** |
| 52 | * struct sub_seq - container for all published instances of a name sequence |
| 53 | * @lower: name sequence lower bound |
| 54 | * @upper: name sequence upper bound |
| 55 | * @node_list: circular list of matching publications with >= node scope |
| 56 | * @cluster_list: circular list of matching publications with >= cluster scope |
| 57 | * @zone_list: circular list of matching publications with >= zone scope |
| 58 | */ |
| 59 | |
| 60 | struct sub_seq { |
| 61 | u32 lower; |
| 62 | u32 upper; |
| 63 | struct publication *node_list; |
| 64 | struct publication *cluster_list; |
| 65 | struct publication *zone_list; |
| 66 | }; |
| 67 | |
| 68 | /** |
| 69 | * struct name_seq - container for all published instances of a name type |
| 70 | * @type: 32 bit 'type' value for name sequence |
| 71 | * @sseq: pointer to dynamically-sized array of sub-sequences of this 'type'; |
| 72 | * sub-sequences are sorted in ascending order |
| 73 | * @alloc: number of sub-sequences currently in array |
Allan Stephens | f131072 | 2006-06-25 23:51:37 -0700 | [diff] [blame] | 74 | * @first_free: array index of first unused sub-sequence entry |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 75 | * @ns_list: links to adjacent name sequences in hash chain |
| 76 | * @subscriptions: list of subscriptions for this 'type' |
| 77 | * @lock: spinlock controlling access to name sequence structure |
| 78 | */ |
| 79 | |
| 80 | struct name_seq { |
| 81 | u32 type; |
| 82 | struct sub_seq *sseqs; |
| 83 | u32 alloc; |
| 84 | u32 first_free; |
| 85 | struct hlist_node ns_list; |
| 86 | struct list_head subscriptions; |
| 87 | spinlock_t lock; |
| 88 | }; |
| 89 | |
| 90 | /** |
| 91 | * struct name_table - table containing all existing port name publications |
| 92 | * @types: pointer to fixed-sized array of name sequence lists, |
| 93 | * accessed via hashing on 'type'; name sequence lists are *not* sorted |
| 94 | * @local_publ_count: number of publications issued by this node |
| 95 | */ |
| 96 | |
| 97 | struct name_table { |
| 98 | struct hlist_head *types; |
| 99 | u32 local_publ_count; |
| 100 | }; |
| 101 | |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 102 | static struct name_table table = { NULL } ; |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 103 | static atomic_t rsv_publ_ok = ATOMIC_INIT(0); |
Ingo Molnar | 34af946 | 2006-06-27 02:53:55 -0700 | [diff] [blame^] | 104 | DEFINE_RWLOCK(tipc_nametbl_lock); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 105 | |
| 106 | |
Sam Ravnborg | 05790c6 | 2006-03-20 22:37:04 -0800 | [diff] [blame] | 107 | static int hash(int x) |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 108 | { |
| 109 | return(x & (tipc_nametbl_size - 1)); |
| 110 | } |
| 111 | |
| 112 | /** |
| 113 | * publ_create - create a publication structure |
| 114 | */ |
| 115 | |
| 116 | static struct publication *publ_create(u32 type, u32 lower, u32 upper, |
| 117 | u32 scope, u32 node, u32 port_ref, |
| 118 | u32 key) |
| 119 | { |
| 120 | struct publication *publ = |
| 121 | (struct publication *)kmalloc(sizeof(*publ), GFP_ATOMIC); |
| 122 | if (publ == NULL) { |
Allan Stephens | a10bd92 | 2006-06-25 23:52:17 -0700 | [diff] [blame] | 123 | warn("Publication creation failure, no memory\n"); |
Sam Ravnborg | 1fc54d8 | 2006-03-20 22:36:47 -0800 | [diff] [blame] | 124 | return NULL; |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 125 | } |
| 126 | |
| 127 | memset(publ, 0, sizeof(*publ)); |
| 128 | publ->type = type; |
| 129 | publ->lower = lower; |
| 130 | publ->upper = upper; |
| 131 | publ->scope = scope; |
| 132 | publ->node = node; |
| 133 | publ->ref = port_ref; |
| 134 | publ->key = key; |
| 135 | INIT_LIST_HEAD(&publ->local_list); |
| 136 | INIT_LIST_HEAD(&publ->pport_list); |
| 137 | INIT_LIST_HEAD(&publ->subscr.nodesub_list); |
| 138 | return publ; |
| 139 | } |
| 140 | |
| 141 | /** |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 142 | * tipc_subseq_alloc - allocate a specified number of sub-sequence structures |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 143 | */ |
| 144 | |
Adrian Bunk | 988f088 | 2006-03-20 22:37:52 -0800 | [diff] [blame] | 145 | static struct sub_seq *tipc_subseq_alloc(u32 cnt) |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 146 | { |
| 147 | u32 sz = cnt * sizeof(struct sub_seq); |
| 148 | struct sub_seq *sseq = (struct sub_seq *)kmalloc(sz, GFP_ATOMIC); |
| 149 | |
| 150 | if (sseq) |
| 151 | memset(sseq, 0, sz); |
| 152 | return sseq; |
| 153 | } |
| 154 | |
| 155 | /** |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 156 | * tipc_nameseq_create - create a name sequence structure for the specified 'type' |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 157 | * |
| 158 | * Allocates a single sub-sequence structure and sets it to all 0's. |
| 159 | */ |
| 160 | |
Adrian Bunk | 988f088 | 2006-03-20 22:37:52 -0800 | [diff] [blame] | 161 | static struct name_seq *tipc_nameseq_create(u32 type, struct hlist_head *seq_head) |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 162 | { |
| 163 | struct name_seq *nseq = |
| 164 | (struct name_seq *)kmalloc(sizeof(*nseq), GFP_ATOMIC); |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 165 | struct sub_seq *sseq = tipc_subseq_alloc(1); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 166 | |
| 167 | if (!nseq || !sseq) { |
Allan Stephens | a10bd92 | 2006-06-25 23:52:17 -0700 | [diff] [blame] | 168 | warn("Name sequence creation failed, no memory\n"); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 169 | kfree(nseq); |
| 170 | kfree(sseq); |
Sam Ravnborg | 1fc54d8 | 2006-03-20 22:36:47 -0800 | [diff] [blame] | 171 | return NULL; |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 172 | } |
| 173 | |
| 174 | memset(nseq, 0, sizeof(*nseq)); |
Ingo Molnar | 34af946 | 2006-06-27 02:53:55 -0700 | [diff] [blame^] | 175 | spin_lock_init(&nseq->lock); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 176 | nseq->type = type; |
| 177 | nseq->sseqs = sseq; |
Allan Stephens | f131072 | 2006-06-25 23:51:37 -0700 | [diff] [blame] | 178 | dbg("tipc_nameseq_create(): nseq = %p, type %u, ssseqs %p, ff: %u\n", |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 179 | nseq, type, nseq->sseqs, nseq->first_free); |
| 180 | nseq->alloc = 1; |
| 181 | INIT_HLIST_NODE(&nseq->ns_list); |
| 182 | INIT_LIST_HEAD(&nseq->subscriptions); |
| 183 | hlist_add_head(&nseq->ns_list, seq_head); |
| 184 | return nseq; |
| 185 | } |
| 186 | |
| 187 | /** |
| 188 | * nameseq_find_subseq - find sub-sequence (if any) matching a name instance |
| 189 | * |
| 190 | * Very time-critical, so binary searches through sub-sequence array. |
| 191 | */ |
| 192 | |
Sam Ravnborg | 05790c6 | 2006-03-20 22:37:04 -0800 | [diff] [blame] | 193 | static struct sub_seq *nameseq_find_subseq(struct name_seq *nseq, |
| 194 | u32 instance) |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 195 | { |
| 196 | struct sub_seq *sseqs = nseq->sseqs; |
| 197 | int low = 0; |
| 198 | int high = nseq->first_free - 1; |
| 199 | int mid; |
| 200 | |
| 201 | while (low <= high) { |
| 202 | mid = (low + high) / 2; |
| 203 | if (instance < sseqs[mid].lower) |
| 204 | high = mid - 1; |
| 205 | else if (instance > sseqs[mid].upper) |
| 206 | low = mid + 1; |
| 207 | else |
| 208 | return &sseqs[mid]; |
| 209 | } |
Sam Ravnborg | 1fc54d8 | 2006-03-20 22:36:47 -0800 | [diff] [blame] | 210 | return NULL; |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 211 | } |
| 212 | |
| 213 | /** |
| 214 | * nameseq_locate_subseq - determine position of name instance in sub-sequence |
| 215 | * |
| 216 | * Returns index in sub-sequence array of the entry that contains the specified |
| 217 | * instance value; if no entry contains that value, returns the position |
| 218 | * where a new entry for it would be inserted in the array. |
| 219 | * |
| 220 | * Note: Similar to binary search code for locating a sub-sequence. |
| 221 | */ |
| 222 | |
| 223 | static u32 nameseq_locate_subseq(struct name_seq *nseq, u32 instance) |
| 224 | { |
| 225 | struct sub_seq *sseqs = nseq->sseqs; |
| 226 | int low = 0; |
| 227 | int high = nseq->first_free - 1; |
| 228 | int mid; |
| 229 | |
| 230 | while (low <= high) { |
| 231 | mid = (low + high) / 2; |
| 232 | if (instance < sseqs[mid].lower) |
| 233 | high = mid - 1; |
| 234 | else if (instance > sseqs[mid].upper) |
| 235 | low = mid + 1; |
| 236 | else |
| 237 | return mid; |
| 238 | } |
| 239 | return low; |
| 240 | } |
| 241 | |
| 242 | /** |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 243 | * tipc_nameseq_insert_publ - |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 244 | */ |
| 245 | |
Adrian Bunk | 988f088 | 2006-03-20 22:37:52 -0800 | [diff] [blame] | 246 | static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq, |
| 247 | u32 type, u32 lower, u32 upper, |
| 248 | u32 scope, u32 node, u32 port, u32 key) |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 249 | { |
| 250 | struct subscription *s; |
| 251 | struct subscription *st; |
| 252 | struct publication *publ; |
| 253 | struct sub_seq *sseq; |
| 254 | int created_subseq = 0; |
| 255 | |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 256 | sseq = nameseq_find_subseq(nseq, lower); |
Allan Stephens | f131072 | 2006-06-25 23:51:37 -0700 | [diff] [blame] | 257 | dbg("nameseq_ins: for seq %p, {%u,%u}, found sseq %p\n", |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 258 | nseq, type, lower, sseq); |
| 259 | if (sseq) { |
| 260 | |
| 261 | /* Lower end overlaps existing entry => need an exact match */ |
| 262 | |
| 263 | if ((sseq->lower != lower) || (sseq->upper != upper)) { |
Allan Stephens | f131072 | 2006-06-25 23:51:37 -0700 | [diff] [blame] | 264 | warn("Cannot publish {%u,%u,%u}, overlap error\n", |
| 265 | type, lower, upper); |
Sam Ravnborg | 1fc54d8 | 2006-03-20 22:36:47 -0800 | [diff] [blame] | 266 | return NULL; |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 267 | } |
| 268 | } else { |
| 269 | u32 inspos; |
| 270 | struct sub_seq *freesseq; |
| 271 | |
| 272 | /* Find where lower end should be inserted */ |
| 273 | |
| 274 | inspos = nameseq_locate_subseq(nseq, lower); |
| 275 | |
| 276 | /* Fail if upper end overlaps into an existing entry */ |
| 277 | |
| 278 | if ((inspos < nseq->first_free) && |
| 279 | (upper >= nseq->sseqs[inspos].lower)) { |
Allan Stephens | f131072 | 2006-06-25 23:51:37 -0700 | [diff] [blame] | 280 | warn("Cannot publish {%u,%u,%u}, overlap error\n", |
| 281 | type, lower, upper); |
Sam Ravnborg | 1fc54d8 | 2006-03-20 22:36:47 -0800 | [diff] [blame] | 282 | return NULL; |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 283 | } |
| 284 | |
| 285 | /* Ensure there is space for new sub-sequence */ |
| 286 | |
| 287 | if (nseq->first_free == nseq->alloc) { |
Allan Stephens | 9ab230f | 2006-06-25 23:37:24 -0700 | [diff] [blame] | 288 | struct sub_seq *sseqs = tipc_subseq_alloc(nseq->alloc * 2); |
| 289 | |
| 290 | if (!sseqs) { |
Allan Stephens | f131072 | 2006-06-25 23:51:37 -0700 | [diff] [blame] | 291 | warn("Cannot publish {%u,%u,%u}, no memory\n", |
| 292 | type, lower, upper); |
Sam Ravnborg | 1fc54d8 | 2006-03-20 22:36:47 -0800 | [diff] [blame] | 293 | return NULL; |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 294 | } |
Allan Stephens | 9ab230f | 2006-06-25 23:37:24 -0700 | [diff] [blame] | 295 | dbg("Allocated %u more sseqs\n", nseq->alloc); |
| 296 | memcpy(sseqs, nseq->sseqs, |
| 297 | nseq->alloc * sizeof(struct sub_seq)); |
| 298 | kfree(nseq->sseqs); |
| 299 | nseq->sseqs = sseqs; |
| 300 | nseq->alloc *= 2; |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 301 | } |
| 302 | dbg("Have %u sseqs for type %u\n", nseq->alloc, type); |
| 303 | |
| 304 | /* Insert new sub-sequence */ |
| 305 | |
| 306 | dbg("ins in pos %u, ff = %u\n", inspos, nseq->first_free); |
| 307 | sseq = &nseq->sseqs[inspos]; |
| 308 | freesseq = &nseq->sseqs[nseq->first_free]; |
| 309 | memmove(sseq + 1, sseq, (freesseq - sseq) * sizeof (*sseq)); |
| 310 | memset(sseq, 0, sizeof (*sseq)); |
| 311 | nseq->first_free++; |
| 312 | sseq->lower = lower; |
| 313 | sseq->upper = upper; |
| 314 | created_subseq = 1; |
| 315 | } |
Allan Stephens | f131072 | 2006-06-25 23:51:37 -0700 | [diff] [blame] | 316 | dbg("inserting {%u,%u,%u} from <0x%x:%u> into sseq %p(%u,%u) of seq %p\n", |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 317 | type, lower, upper, node, port, sseq, |
| 318 | sseq->lower, sseq->upper, nseq); |
| 319 | |
| 320 | /* Insert a publication: */ |
| 321 | |
| 322 | publ = publ_create(type, lower, upper, scope, node, port, key); |
| 323 | if (!publ) |
Sam Ravnborg | 1fc54d8 | 2006-03-20 22:36:47 -0800 | [diff] [blame] | 324 | return NULL; |
Allan Stephens | f131072 | 2006-06-25 23:51:37 -0700 | [diff] [blame] | 325 | dbg("inserting publ %p, node=0x%x publ->node=0x%x, subscr->node=%p\n", |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 326 | publ, node, publ->node, publ->subscr.node); |
| 327 | |
| 328 | if (!sseq->zone_list) |
| 329 | sseq->zone_list = publ->zone_list_next = publ; |
| 330 | else { |
| 331 | publ->zone_list_next = sseq->zone_list->zone_list_next; |
| 332 | sseq->zone_list->zone_list_next = publ; |
| 333 | } |
| 334 | |
| 335 | if (in_own_cluster(node)) { |
| 336 | if (!sseq->cluster_list) |
| 337 | sseq->cluster_list = publ->cluster_list_next = publ; |
| 338 | else { |
| 339 | publ->cluster_list_next = |
| 340 | sseq->cluster_list->cluster_list_next; |
| 341 | sseq->cluster_list->cluster_list_next = publ; |
| 342 | } |
| 343 | } |
| 344 | |
| 345 | if (node == tipc_own_addr) { |
| 346 | if (!sseq->node_list) |
| 347 | sseq->node_list = publ->node_list_next = publ; |
| 348 | else { |
| 349 | publ->node_list_next = sseq->node_list->node_list_next; |
| 350 | sseq->node_list->node_list_next = publ; |
| 351 | } |
| 352 | } |
| 353 | |
| 354 | /* |
| 355 | * Any subscriptions waiting for notification? |
| 356 | */ |
| 357 | list_for_each_entry_safe(s, st, &nseq->subscriptions, nameseq_list) { |
| 358 | dbg("calling report_overlap()\n"); |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 359 | tipc_subscr_report_overlap(s, |
| 360 | publ->lower, |
| 361 | publ->upper, |
| 362 | TIPC_PUBLISHED, |
| 363 | publ->ref, |
| 364 | publ->node, |
| 365 | created_subseq); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 366 | } |
| 367 | return publ; |
| 368 | } |
| 369 | |
| 370 | /** |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 371 | * tipc_nameseq_remove_publ - |
Allan Stephens | f131072 | 2006-06-25 23:51:37 -0700 | [diff] [blame] | 372 | * |
| 373 | * 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 |
| 375 | * publication for a name sequence that overlaps an existing name sequence |
| 376 | * the publication will not be recorded, which means the publication won't |
| 377 | * be found when the name sequence is later withdrawn by that node. |
| 378 | * 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. |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 380 | */ |
| 381 | |
Adrian Bunk | 988f088 | 2006-03-20 22:37:52 -0800 | [diff] [blame] | 382 | static struct publication *tipc_nameseq_remove_publ(struct name_seq *nseq, u32 inst, |
| 383 | u32 node, u32 ref, u32 key) |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 384 | { |
| 385 | struct publication *publ; |
Allan Stephens | f131072 | 2006-06-25 23:51:37 -0700 | [diff] [blame] | 386 | struct publication *curr; |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 387 | struct publication *prev; |
| 388 | struct sub_seq *sseq = nameseq_find_subseq(nseq, inst); |
| 389 | struct sub_seq *free; |
| 390 | struct subscription *s, *st; |
| 391 | int removed_subseq = 0; |
| 392 | |
Allan Stephens | f131072 | 2006-06-25 23:51:37 -0700 | [diff] [blame] | 393 | if (!sseq) |
Sam Ravnborg | 1fc54d8 | 2006-03-20 22:36:47 -0800 | [diff] [blame] | 394 | return NULL; |
Allan Stephens | f131072 | 2006-06-25 23:51:37 -0700 | [diff] [blame] | 395 | |
| 396 | dbg("tipc_nameseq_remove_publ: seq: %p, sseq %p, {%u,%u}, key %u\n", |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 397 | nseq, sseq, nseq->type, inst, key); |
| 398 | |
Allan Stephens | f131072 | 2006-06-25 23:51:37 -0700 | [diff] [blame] | 399 | /* Remove publication from zone scope list */ |
| 400 | |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 401 | prev = sseq->zone_list; |
| 402 | publ = sseq->zone_list->zone_list_next; |
| 403 | while ((publ->key != key) || (publ->ref != ref) || |
| 404 | (publ->node && (publ->node != node))) { |
| 405 | prev = publ; |
| 406 | publ = publ->zone_list_next; |
Allan Stephens | f131072 | 2006-06-25 23:51:37 -0700 | [diff] [blame] | 407 | if (prev == sseq->zone_list) { |
| 408 | |
| 409 | /* Prevent endless loop if publication not found */ |
| 410 | |
| 411 | return NULL; |
| 412 | } |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 413 | } |
| 414 | if (publ != sseq->zone_list) |
| 415 | prev->zone_list_next = publ->zone_list_next; |
| 416 | else if (publ->zone_list_next != publ) { |
| 417 | prev->zone_list_next = publ->zone_list_next; |
| 418 | sseq->zone_list = publ->zone_list_next; |
| 419 | } else { |
Sam Ravnborg | 1fc54d8 | 2006-03-20 22:36:47 -0800 | [diff] [blame] | 420 | sseq->zone_list = NULL; |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 421 | } |
| 422 | |
Allan Stephens | f131072 | 2006-06-25 23:51:37 -0700 | [diff] [blame] | 423 | /* Remove publication from cluster scope list, if present */ |
| 424 | |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 425 | if (in_own_cluster(node)) { |
| 426 | prev = sseq->cluster_list; |
Allan Stephens | f131072 | 2006-06-25 23:51:37 -0700 | [diff] [blame] | 427 | curr = sseq->cluster_list->cluster_list_next; |
| 428 | while (curr != publ) { |
| 429 | prev = curr; |
| 430 | curr = curr->cluster_list_next; |
| 431 | if (prev == sseq->cluster_list) { |
| 432 | |
| 433 | /* Prevent endless loop for malformed list */ |
| 434 | |
| 435 | err("Unable to de-list cluster publication\n" |
| 436 | "{%u%u}, node=0x%x, ref=%u, key=%u)\n", |
| 437 | publ->type, publ->lower, publ->node, |
| 438 | publ->ref, publ->key); |
| 439 | goto end_cluster; |
| 440 | } |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 441 | } |
| 442 | if (publ != sseq->cluster_list) |
| 443 | prev->cluster_list_next = publ->cluster_list_next; |
| 444 | else if (publ->cluster_list_next != publ) { |
| 445 | prev->cluster_list_next = publ->cluster_list_next; |
| 446 | sseq->cluster_list = publ->cluster_list_next; |
| 447 | } else { |
Sam Ravnborg | 1fc54d8 | 2006-03-20 22:36:47 -0800 | [diff] [blame] | 448 | sseq->cluster_list = NULL; |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 449 | } |
| 450 | } |
Allan Stephens | f131072 | 2006-06-25 23:51:37 -0700 | [diff] [blame] | 451 | end_cluster: |
| 452 | |
| 453 | /* Remove publication from node scope list, if present */ |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 454 | |
| 455 | if (node == tipc_own_addr) { |
| 456 | prev = sseq->node_list; |
Allan Stephens | f131072 | 2006-06-25 23:51:37 -0700 | [diff] [blame] | 457 | curr = sseq->node_list->node_list_next; |
| 458 | while (curr != publ) { |
| 459 | prev = curr; |
| 460 | curr = curr->node_list_next; |
| 461 | if (prev == sseq->node_list) { |
| 462 | |
| 463 | /* Prevent endless loop for malformed list */ |
| 464 | |
| 465 | err("Unable to de-list node publication\n" |
| 466 | "{%u%u}, node=0x%x, ref=%u, key=%u)\n", |
| 467 | publ->type, publ->lower, publ->node, |
| 468 | publ->ref, publ->key); |
| 469 | goto end_node; |
| 470 | } |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 471 | } |
| 472 | if (publ != sseq->node_list) |
| 473 | prev->node_list_next = publ->node_list_next; |
| 474 | else if (publ->node_list_next != publ) { |
| 475 | prev->node_list_next = publ->node_list_next; |
| 476 | sseq->node_list = publ->node_list_next; |
| 477 | } else { |
Sam Ravnborg | 1fc54d8 | 2006-03-20 22:36:47 -0800 | [diff] [blame] | 478 | sseq->node_list = NULL; |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 479 | } |
| 480 | } |
Allan Stephens | f131072 | 2006-06-25 23:51:37 -0700 | [diff] [blame] | 481 | end_node: |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 482 | |
Allan Stephens | f131072 | 2006-06-25 23:51:37 -0700 | [diff] [blame] | 483 | /* Contract subseq list if no more publications for that subseq */ |
| 484 | |
| 485 | if (!sseq->zone_list) { |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 486 | free = &nseq->sseqs[nseq->first_free--]; |
| 487 | memmove(sseq, sseq + 1, (free - (sseq + 1)) * sizeof (*sseq)); |
| 488 | removed_subseq = 1; |
| 489 | } |
| 490 | |
Allan Stephens | f131072 | 2006-06-25 23:51:37 -0700 | [diff] [blame] | 491 | /* Notify any waiting subscriptions */ |
| 492 | |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 493 | list_for_each_entry_safe(s, st, &nseq->subscriptions, nameseq_list) { |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 494 | tipc_subscr_report_overlap(s, |
| 495 | publ->lower, |
| 496 | publ->upper, |
| 497 | TIPC_WITHDRAWN, |
| 498 | publ->ref, |
| 499 | publ->node, |
| 500 | removed_subseq); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 501 | } |
Allan Stephens | f131072 | 2006-06-25 23:51:37 -0700 | [diff] [blame] | 502 | |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 503 | return publ; |
| 504 | } |
| 505 | |
| 506 | /** |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 507 | * tipc_nameseq_subscribe: attach a subscription, and issue |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 508 | * the prescribed number of events if there is any sub- |
| 509 | * sequence overlapping with the requested sequence |
| 510 | */ |
| 511 | |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 512 | void tipc_nameseq_subscribe(struct name_seq *nseq, struct subscription *s) |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 513 | { |
| 514 | struct sub_seq *sseq = nseq->sseqs; |
| 515 | |
| 516 | list_add(&s->nameseq_list, &nseq->subscriptions); |
| 517 | |
| 518 | if (!sseq) |
| 519 | return; |
| 520 | |
| 521 | while (sseq != &nseq->sseqs[nseq->first_free]) { |
| 522 | struct publication *zl = sseq->zone_list; |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 523 | if (zl && tipc_subscr_overlap(s,sseq->lower,sseq->upper)) { |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 524 | struct publication *crs = zl; |
| 525 | int must_report = 1; |
| 526 | |
| 527 | do { |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 528 | tipc_subscr_report_overlap(s, |
| 529 | sseq->lower, |
| 530 | sseq->upper, |
| 531 | TIPC_PUBLISHED, |
| 532 | crs->ref, |
| 533 | crs->node, |
| 534 | must_report); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 535 | must_report = 0; |
| 536 | crs = crs->zone_list_next; |
| 537 | } while (crs != zl); |
| 538 | } |
| 539 | sseq++; |
| 540 | } |
| 541 | } |
| 542 | |
| 543 | static struct name_seq *nametbl_find_seq(u32 type) |
| 544 | { |
| 545 | struct hlist_head *seq_head; |
| 546 | struct hlist_node *seq_node; |
| 547 | struct name_seq *ns; |
| 548 | |
| 549 | dbg("find_seq %u,(%u,0x%x) table = %p, hash[type] = %u\n", |
| 550 | type, ntohl(type), type, table.types, hash(type)); |
| 551 | |
| 552 | seq_head = &table.types[hash(type)]; |
| 553 | hlist_for_each_entry(ns, seq_node, seq_head, ns_list) { |
| 554 | if (ns->type == type) { |
Allan Stephens | f131072 | 2006-06-25 23:51:37 -0700 | [diff] [blame] | 555 | dbg("found %p\n", ns); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 556 | return ns; |
| 557 | } |
| 558 | } |
| 559 | |
Sam Ravnborg | 1fc54d8 | 2006-03-20 22:36:47 -0800 | [diff] [blame] | 560 | return NULL; |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 561 | }; |
| 562 | |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 563 | struct publication *tipc_nametbl_insert_publ(u32 type, u32 lower, u32 upper, |
| 564 | u32 scope, u32 node, u32 port, u32 key) |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 565 | { |
| 566 | struct name_seq *seq = nametbl_find_seq(type); |
| 567 | |
Allan Stephens | f131072 | 2006-06-25 23:51:37 -0700 | [diff] [blame] | 568 | dbg("tipc_nametbl_insert_publ: {%u,%u,%u} found %p\n", type, lower, upper, seq); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 569 | if (lower > upper) { |
Allan Stephens | f131072 | 2006-06-25 23:51:37 -0700 | [diff] [blame] | 570 | warn("Failed to publish illegal {%u,%u,%u}\n", |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 571 | type, lower, upper); |
Sam Ravnborg | 1fc54d8 | 2006-03-20 22:36:47 -0800 | [diff] [blame] | 572 | return NULL; |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 573 | } |
| 574 | |
Allan Stephens | f131072 | 2006-06-25 23:51:37 -0700 | [diff] [blame] | 575 | dbg("Publishing {%u,%u,%u} from 0x%x\n", type, lower, upper, node); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 576 | if (!seq) { |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 577 | seq = tipc_nameseq_create(type, &table.types[hash(type)]); |
Allan Stephens | f131072 | 2006-06-25 23:51:37 -0700 | [diff] [blame] | 578 | dbg("tipc_nametbl_insert_publ: created %p\n", seq); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 579 | } |
| 580 | if (!seq) |
Sam Ravnborg | 1fc54d8 | 2006-03-20 22:36:47 -0800 | [diff] [blame] | 581 | return NULL; |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 582 | |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 583 | return tipc_nameseq_insert_publ(seq, type, lower, upper, |
| 584 | scope, node, port, key); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 585 | } |
| 586 | |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 587 | struct publication *tipc_nametbl_remove_publ(u32 type, u32 lower, |
| 588 | u32 node, u32 ref, u32 key) |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 589 | { |
| 590 | struct publication *publ; |
| 591 | struct name_seq *seq = nametbl_find_seq(type); |
| 592 | |
| 593 | if (!seq) |
Sam Ravnborg | 1fc54d8 | 2006-03-20 22:36:47 -0800 | [diff] [blame] | 594 | return NULL; |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 595 | |
Allan Stephens | f131072 | 2006-06-25 23:51:37 -0700 | [diff] [blame] | 596 | dbg("Withdrawing {%u,%u} from 0x%x\n", type, lower, node); |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 597 | publ = tipc_nameseq_remove_publ(seq, lower, node, ref, key); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 598 | |
| 599 | if (!seq->first_free && list_empty(&seq->subscriptions)) { |
| 600 | hlist_del_init(&seq->ns_list); |
| 601 | kfree(seq->sseqs); |
| 602 | kfree(seq); |
| 603 | } |
| 604 | return publ; |
| 605 | } |
| 606 | |
| 607 | /* |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 608 | * tipc_nametbl_translate(): Translate tipc_name -> tipc_portid. |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 609 | * Very time-critical. |
| 610 | * |
| 611 | * Note: on entry 'destnode' is the search domain used during translation; |
| 612 | * on exit it passes back the node address of the matching port (if any) |
| 613 | */ |
| 614 | |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 615 | u32 tipc_nametbl_translate(u32 type, u32 instance, u32 *destnode) |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 616 | { |
| 617 | struct sub_seq *sseq; |
Sam Ravnborg | 1fc54d8 | 2006-03-20 22:36:47 -0800 | [diff] [blame] | 618 | struct publication *publ = NULL; |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 619 | struct name_seq *seq; |
| 620 | u32 ref; |
| 621 | |
| 622 | if (!in_scope(*destnode, tipc_own_addr)) |
| 623 | return 0; |
| 624 | |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 625 | read_lock_bh(&tipc_nametbl_lock); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 626 | seq = nametbl_find_seq(type); |
| 627 | if (unlikely(!seq)) |
| 628 | goto not_found; |
| 629 | sseq = nameseq_find_subseq(seq, instance); |
| 630 | if (unlikely(!sseq)) |
| 631 | goto not_found; |
| 632 | spin_lock_bh(&seq->lock); |
| 633 | |
| 634 | /* Closest-First Algorithm: */ |
| 635 | if (likely(!*destnode)) { |
| 636 | publ = sseq->node_list; |
| 637 | if (publ) { |
| 638 | sseq->node_list = publ->node_list_next; |
| 639 | found: |
| 640 | ref = publ->ref; |
| 641 | *destnode = publ->node; |
| 642 | spin_unlock_bh(&seq->lock); |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 643 | read_unlock_bh(&tipc_nametbl_lock); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 644 | return ref; |
| 645 | } |
| 646 | publ = sseq->cluster_list; |
| 647 | if (publ) { |
| 648 | sseq->cluster_list = publ->cluster_list_next; |
| 649 | goto found; |
| 650 | } |
| 651 | publ = sseq->zone_list; |
| 652 | if (publ) { |
| 653 | sseq->zone_list = publ->zone_list_next; |
| 654 | goto found; |
| 655 | } |
| 656 | } |
| 657 | |
| 658 | /* Round-Robin Algorithm: */ |
| 659 | else if (*destnode == tipc_own_addr) { |
| 660 | publ = sseq->node_list; |
| 661 | if (publ) { |
| 662 | sseq->node_list = publ->node_list_next; |
| 663 | goto found; |
| 664 | } |
| 665 | } else if (in_own_cluster(*destnode)) { |
| 666 | publ = sseq->cluster_list; |
| 667 | if (publ) { |
| 668 | sseq->cluster_list = publ->cluster_list_next; |
| 669 | goto found; |
| 670 | } |
| 671 | } else { |
| 672 | publ = sseq->zone_list; |
| 673 | if (publ) { |
| 674 | sseq->zone_list = publ->zone_list_next; |
| 675 | goto found; |
| 676 | } |
| 677 | } |
| 678 | spin_unlock_bh(&seq->lock); |
| 679 | not_found: |
| 680 | *destnode = 0; |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 681 | read_unlock_bh(&tipc_nametbl_lock); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 682 | return 0; |
| 683 | } |
| 684 | |
| 685 | /** |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 686 | * tipc_nametbl_mc_translate - find multicast destinations |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 687 | * |
| 688 | * Creates list of all local ports that overlap the given multicast address; |
| 689 | * also determines if any off-node ports overlap. |
| 690 | * |
| 691 | * Note: Publications with a scope narrower than 'limit' are ignored. |
| 692 | * (i.e. local node-scope publications mustn't receive messages arriving |
| 693 | * from another node, even if the multcast link brought it here) |
| 694 | * |
| 695 | * Returns non-zero if any off-node ports overlap |
| 696 | */ |
| 697 | |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 698 | int tipc_nametbl_mc_translate(u32 type, u32 lower, u32 upper, u32 limit, |
| 699 | struct port_list *dports) |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 700 | { |
| 701 | struct name_seq *seq; |
| 702 | struct sub_seq *sseq; |
| 703 | struct sub_seq *sseq_stop; |
| 704 | int res = 0; |
| 705 | |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 706 | read_lock_bh(&tipc_nametbl_lock); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 707 | seq = nametbl_find_seq(type); |
| 708 | if (!seq) |
| 709 | goto exit; |
| 710 | |
| 711 | spin_lock_bh(&seq->lock); |
| 712 | |
| 713 | sseq = seq->sseqs + nameseq_locate_subseq(seq, lower); |
| 714 | sseq_stop = seq->sseqs + seq->first_free; |
| 715 | for (; sseq != sseq_stop; sseq++) { |
| 716 | struct publication *publ; |
| 717 | |
| 718 | if (sseq->lower > upper) |
| 719 | break; |
| 720 | publ = sseq->cluster_list; |
| 721 | if (publ && (publ->scope <= limit)) |
| 722 | do { |
| 723 | if (publ->node == tipc_own_addr) |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 724 | tipc_port_list_add(dports, publ->ref); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 725 | else |
| 726 | res = 1; |
| 727 | publ = publ->cluster_list_next; |
| 728 | } while (publ != sseq->cluster_list); |
| 729 | } |
| 730 | |
| 731 | spin_unlock_bh(&seq->lock); |
| 732 | exit: |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 733 | read_unlock_bh(&tipc_nametbl_lock); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 734 | return res; |
| 735 | } |
| 736 | |
| 737 | /** |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 738 | * tipc_nametbl_publish_rsv - publish port name using a reserved name type |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 739 | */ |
| 740 | |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 741 | int tipc_nametbl_publish_rsv(u32 ref, unsigned int scope, |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 742 | struct tipc_name_seq const *seq) |
| 743 | { |
| 744 | int res; |
| 745 | |
| 746 | atomic_inc(&rsv_publ_ok); |
| 747 | res = tipc_publish(ref, scope, seq); |
| 748 | atomic_dec(&rsv_publ_ok); |
| 749 | return res; |
| 750 | } |
| 751 | |
| 752 | /** |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 753 | * tipc_nametbl_publish - add name publication to network name tables |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 754 | */ |
| 755 | |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 756 | struct publication *tipc_nametbl_publish(u32 type, u32 lower, u32 upper, |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 757 | u32 scope, u32 port_ref, u32 key) |
| 758 | { |
| 759 | struct publication *publ; |
| 760 | |
| 761 | if (table.local_publ_count >= tipc_max_publications) { |
Allan Stephens | a10bd92 | 2006-06-25 23:52:17 -0700 | [diff] [blame] | 762 | warn("Publication failed, local publication limit reached (%u)\n", |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 763 | tipc_max_publications); |
Sam Ravnborg | 1fc54d8 | 2006-03-20 22:36:47 -0800 | [diff] [blame] | 764 | return NULL; |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 765 | } |
| 766 | if ((type < TIPC_RESERVED_TYPES) && !atomic_read(&rsv_publ_ok)) { |
Allan Stephens | f131072 | 2006-06-25 23:51:37 -0700 | [diff] [blame] | 767 | warn("Publication failed, reserved name {%u,%u,%u}\n", |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 768 | type, lower, upper); |
Sam Ravnborg | 1fc54d8 | 2006-03-20 22:36:47 -0800 | [diff] [blame] | 769 | return NULL; |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 770 | } |
| 771 | |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 772 | write_lock_bh(&tipc_nametbl_lock); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 773 | table.local_publ_count++; |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 774 | publ = tipc_nametbl_insert_publ(type, lower, upper, scope, |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 775 | tipc_own_addr, port_ref, key); |
| 776 | if (publ && (scope != TIPC_NODE_SCOPE)) { |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 777 | tipc_named_publish(publ); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 778 | } |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 779 | write_unlock_bh(&tipc_nametbl_lock); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 780 | return publ; |
| 781 | } |
| 782 | |
| 783 | /** |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 784 | * tipc_nametbl_withdraw - withdraw name publication from network name tables |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 785 | */ |
| 786 | |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 787 | int tipc_nametbl_withdraw(u32 type, u32 lower, u32 ref, u32 key) |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 788 | { |
| 789 | struct publication *publ; |
| 790 | |
Allan Stephens | f131072 | 2006-06-25 23:51:37 -0700 | [diff] [blame] | 791 | dbg("tipc_nametbl_withdraw: {%u,%u}, key=%u\n", type, lower, key); |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 792 | write_lock_bh(&tipc_nametbl_lock); |
| 793 | publ = tipc_nametbl_remove_publ(type, lower, tipc_own_addr, ref, key); |
Allan Stephens | f131072 | 2006-06-25 23:51:37 -0700 | [diff] [blame] | 794 | if (likely(publ)) { |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 795 | table.local_publ_count--; |
| 796 | if (publ->scope != TIPC_NODE_SCOPE) |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 797 | tipc_named_withdraw(publ); |
| 798 | write_unlock_bh(&tipc_nametbl_lock); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 799 | list_del_init(&publ->pport_list); |
| 800 | kfree(publ); |
| 801 | return 1; |
| 802 | } |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 803 | write_unlock_bh(&tipc_nametbl_lock); |
Allan Stephens | f131072 | 2006-06-25 23:51:37 -0700 | [diff] [blame] | 804 | err("Unable to remove local publication\n" |
| 805 | "(type=%u, lower=%u, ref=%u, key=%u)\n", |
| 806 | type, lower, ref, key); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 807 | return 0; |
| 808 | } |
| 809 | |
| 810 | /** |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 811 | * tipc_nametbl_subscribe - add a subscription object to the name table |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 812 | */ |
| 813 | |
Allan Stephens | f131072 | 2006-06-25 23:51:37 -0700 | [diff] [blame] | 814 | void tipc_nametbl_subscribe(struct subscription *s) |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 815 | { |
| 816 | u32 type = s->seq.type; |
| 817 | struct name_seq *seq; |
| 818 | |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 819 | write_lock_bh(&tipc_nametbl_lock); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 820 | seq = nametbl_find_seq(type); |
| 821 | if (!seq) { |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 822 | seq = tipc_nameseq_create(type, &table.types[hash(type)]); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 823 | } |
| 824 | if (seq){ |
| 825 | spin_lock_bh(&seq->lock); |
Allan Stephens | f131072 | 2006-06-25 23:51:37 -0700 | [diff] [blame] | 826 | dbg("tipc_nametbl_subscribe:found %p for {%u,%u,%u}\n", |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 827 | seq, type, s->seq.lower, s->seq.upper); |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 828 | tipc_nameseq_subscribe(seq, s); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 829 | spin_unlock_bh(&seq->lock); |
Allan Stephens | f131072 | 2006-06-25 23:51:37 -0700 | [diff] [blame] | 830 | } else { |
| 831 | warn("Failed to create subscription for {%u,%u,%u}\n", |
| 832 | s->seq.type, s->seq.lower, s->seq.upper); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 833 | } |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 834 | write_unlock_bh(&tipc_nametbl_lock); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 835 | } |
| 836 | |
| 837 | /** |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 838 | * tipc_nametbl_unsubscribe - remove a subscription object from name table |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 839 | */ |
| 840 | |
Allan Stephens | f131072 | 2006-06-25 23:51:37 -0700 | [diff] [blame] | 841 | void tipc_nametbl_unsubscribe(struct subscription *s) |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 842 | { |
| 843 | struct name_seq *seq; |
| 844 | |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 845 | write_lock_bh(&tipc_nametbl_lock); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 846 | seq = nametbl_find_seq(s->seq.type); |
| 847 | if (seq != NULL){ |
| 848 | spin_lock_bh(&seq->lock); |
| 849 | list_del_init(&s->nameseq_list); |
| 850 | spin_unlock_bh(&seq->lock); |
| 851 | if ((seq->first_free == 0) && list_empty(&seq->subscriptions)) { |
| 852 | hlist_del_init(&seq->ns_list); |
| 853 | kfree(seq->sseqs); |
| 854 | kfree(seq); |
| 855 | } |
| 856 | } |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 857 | write_unlock_bh(&tipc_nametbl_lock); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 858 | } |
| 859 | |
| 860 | |
| 861 | /** |
| 862 | * subseq_list: print specified sub-sequence contents into the given buffer |
| 863 | */ |
| 864 | |
| 865 | static void subseq_list(struct sub_seq *sseq, struct print_buf *buf, u32 depth, |
| 866 | u32 index) |
| 867 | { |
| 868 | char portIdStr[27]; |
| 869 | char *scopeStr; |
| 870 | struct publication *publ = sseq->zone_list; |
| 871 | |
| 872 | tipc_printf(buf, "%-10u %-10u ", sseq->lower, sseq->upper); |
| 873 | |
| 874 | if (depth == 2 || !publ) { |
| 875 | tipc_printf(buf, "\n"); |
| 876 | return; |
| 877 | } |
| 878 | |
| 879 | do { |
| 880 | sprintf (portIdStr, "<%u.%u.%u:%u>", |
| 881 | tipc_zone(publ->node), tipc_cluster(publ->node), |
| 882 | tipc_node(publ->node), publ->ref); |
| 883 | tipc_printf(buf, "%-26s ", portIdStr); |
| 884 | if (depth > 3) { |
| 885 | if (publ->node != tipc_own_addr) |
| 886 | scopeStr = ""; |
| 887 | else if (publ->scope == TIPC_NODE_SCOPE) |
| 888 | scopeStr = "node"; |
| 889 | else if (publ->scope == TIPC_CLUSTER_SCOPE) |
| 890 | scopeStr = "cluster"; |
| 891 | else |
| 892 | scopeStr = "zone"; |
| 893 | tipc_printf(buf, "%-10u %s", publ->key, scopeStr); |
| 894 | } |
| 895 | |
| 896 | publ = publ->zone_list_next; |
| 897 | if (publ == sseq->zone_list) |
| 898 | break; |
| 899 | |
| 900 | tipc_printf(buf, "\n%33s", " "); |
| 901 | } while (1); |
| 902 | |
| 903 | tipc_printf(buf, "\n"); |
| 904 | } |
| 905 | |
| 906 | /** |
| 907 | * nameseq_list: print specified name sequence contents into the given buffer |
| 908 | */ |
| 909 | |
| 910 | static void nameseq_list(struct name_seq *seq, struct print_buf *buf, u32 depth, |
| 911 | u32 type, u32 lowbound, u32 upbound, u32 index) |
| 912 | { |
| 913 | struct sub_seq *sseq; |
| 914 | char typearea[11]; |
| 915 | |
| 916 | sprintf(typearea, "%-10u", seq->type); |
| 917 | |
| 918 | if (depth == 1) { |
| 919 | tipc_printf(buf, "%s\n", typearea); |
| 920 | return; |
| 921 | } |
| 922 | |
| 923 | for (sseq = seq->sseqs; sseq != &seq->sseqs[seq->first_free]; sseq++) { |
| 924 | if ((lowbound <= sseq->upper) && (upbound >= sseq->lower)) { |
| 925 | tipc_printf(buf, "%s ", typearea); |
| 926 | subseq_list(sseq, buf, depth, index); |
| 927 | sprintf(typearea, "%10s", " "); |
| 928 | } |
| 929 | } |
| 930 | } |
| 931 | |
| 932 | /** |
| 933 | * nametbl_header - print name table header into the given buffer |
| 934 | */ |
| 935 | |
| 936 | static void nametbl_header(struct print_buf *buf, u32 depth) |
| 937 | { |
| 938 | tipc_printf(buf, "Type "); |
| 939 | |
| 940 | if (depth > 1) |
| 941 | tipc_printf(buf, "Lower Upper "); |
| 942 | if (depth > 2) |
| 943 | tipc_printf(buf, "Port Identity "); |
| 944 | if (depth > 3) |
| 945 | tipc_printf(buf, "Publication"); |
| 946 | |
| 947 | tipc_printf(buf, "\n-----------"); |
| 948 | |
| 949 | if (depth > 1) |
| 950 | tipc_printf(buf, "--------------------- "); |
| 951 | if (depth > 2) |
| 952 | tipc_printf(buf, "-------------------------- "); |
| 953 | if (depth > 3) |
| 954 | tipc_printf(buf, "------------------"); |
| 955 | |
| 956 | tipc_printf(buf, "\n"); |
| 957 | } |
| 958 | |
| 959 | /** |
| 960 | * nametbl_list - print specified name table contents into the given buffer |
| 961 | */ |
| 962 | |
| 963 | static void nametbl_list(struct print_buf *buf, u32 depth_info, |
| 964 | u32 type, u32 lowbound, u32 upbound) |
| 965 | { |
| 966 | struct hlist_head *seq_head; |
| 967 | struct hlist_node *seq_node; |
| 968 | struct name_seq *seq; |
| 969 | int all_types; |
| 970 | u32 depth; |
| 971 | u32 i; |
| 972 | |
| 973 | all_types = (depth_info & TIPC_NTQ_ALLTYPES); |
| 974 | depth = (depth_info & ~TIPC_NTQ_ALLTYPES); |
| 975 | |
| 976 | if (depth == 0) |
| 977 | return; |
| 978 | |
| 979 | if (all_types) { |
| 980 | /* display all entries in name table to specified depth */ |
| 981 | nametbl_header(buf, depth); |
| 982 | lowbound = 0; |
| 983 | upbound = ~0; |
| 984 | for (i = 0; i < tipc_nametbl_size; i++) { |
| 985 | seq_head = &table.types[i]; |
| 986 | hlist_for_each_entry(seq, seq_node, seq_head, ns_list) { |
| 987 | nameseq_list(seq, buf, depth, seq->type, |
| 988 | lowbound, upbound, i); |
| 989 | } |
| 990 | } |
| 991 | } else { |
| 992 | /* display only the sequence that matches the specified type */ |
| 993 | if (upbound < lowbound) { |
| 994 | tipc_printf(buf, "invalid name sequence specified\n"); |
| 995 | return; |
| 996 | } |
| 997 | nametbl_header(buf, depth); |
| 998 | i = hash(type); |
| 999 | seq_head = &table.types[i]; |
| 1000 | hlist_for_each_entry(seq, seq_node, seq_head, ns_list) { |
| 1001 | if (seq->type == type) { |
| 1002 | nameseq_list(seq, buf, depth, type, |
| 1003 | lowbound, upbound, i); |
| 1004 | break; |
| 1005 | } |
| 1006 | } |
| 1007 | } |
| 1008 | } |
| 1009 | |
Adrian Bunk | 988f088 | 2006-03-20 22:37:52 -0800 | [diff] [blame] | 1010 | #if 0 |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 1011 | void tipc_nametbl_print(struct print_buf *buf, const char *str) |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 1012 | { |
| 1013 | tipc_printf(buf, str); |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 1014 | read_lock_bh(&tipc_nametbl_lock); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 1015 | nametbl_list(buf, 0, 0, 0, 0); |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 1016 | read_unlock_bh(&tipc_nametbl_lock); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 1017 | } |
Adrian Bunk | 988f088 | 2006-03-20 22:37:52 -0800 | [diff] [blame] | 1018 | #endif |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 1019 | |
| 1020 | #define MAX_NAME_TBL_QUERY 32768 |
| 1021 | |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 1022 | struct sk_buff *tipc_nametbl_get(const void *req_tlv_area, int req_tlv_space) |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 1023 | { |
| 1024 | struct sk_buff *buf; |
| 1025 | struct tipc_name_table_query *argv; |
| 1026 | struct tlv_desc *rep_tlv; |
| 1027 | struct print_buf b; |
| 1028 | int str_len; |
| 1029 | |
| 1030 | if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_NAME_TBL_QUERY)) |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 1031 | return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 1032 | |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 1033 | buf = tipc_cfg_reply_alloc(TLV_SPACE(MAX_NAME_TBL_QUERY)); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 1034 | if (!buf) |
| 1035 | return NULL; |
| 1036 | |
| 1037 | rep_tlv = (struct tlv_desc *)buf->data; |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 1038 | tipc_printbuf_init(&b, TLV_DATA(rep_tlv), MAX_NAME_TBL_QUERY); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 1039 | argv = (struct tipc_name_table_query *)TLV_DATA(req_tlv_area); |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 1040 | read_lock_bh(&tipc_nametbl_lock); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 1041 | nametbl_list(&b, ntohl(argv->depth), ntohl(argv->type), |
| 1042 | ntohl(argv->lowbound), ntohl(argv->upbound)); |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 1043 | read_unlock_bh(&tipc_nametbl_lock); |
| 1044 | str_len = tipc_printbuf_validate(&b); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 1045 | |
| 1046 | skb_put(buf, TLV_SPACE(str_len)); |
| 1047 | TLV_SET(rep_tlv, TIPC_TLV_ULTRA_STRING, NULL, str_len); |
| 1048 | |
| 1049 | return buf; |
| 1050 | } |
| 1051 | |
Adrian Bunk | 988f088 | 2006-03-20 22:37:52 -0800 | [diff] [blame] | 1052 | #if 0 |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 1053 | void tipc_nametbl_dump(void) |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 1054 | { |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 1055 | nametbl_list(TIPC_CONS, 0, 0, 0, 0); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 1056 | } |
Adrian Bunk | 988f088 | 2006-03-20 22:37:52 -0800 | [diff] [blame] | 1057 | #endif |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 1058 | |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 1059 | int tipc_nametbl_init(void) |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 1060 | { |
| 1061 | int array_size = sizeof(struct hlist_head) * tipc_nametbl_size; |
| 1062 | |
| 1063 | table.types = (struct hlist_head *)kmalloc(array_size, GFP_ATOMIC); |
| 1064 | if (!table.types) |
| 1065 | return -ENOMEM; |
| 1066 | |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 1067 | write_lock_bh(&tipc_nametbl_lock); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 1068 | memset(table.types, 0, array_size); |
| 1069 | table.local_publ_count = 0; |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 1070 | write_unlock_bh(&tipc_nametbl_lock); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 1071 | return 0; |
| 1072 | } |
| 1073 | |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 1074 | void tipc_nametbl_stop(void) |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 1075 | { |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 1076 | u32 i; |
| 1077 | |
| 1078 | if (!table.types) |
| 1079 | return; |
| 1080 | |
Allan Stephens | f131072 | 2006-06-25 23:51:37 -0700 | [diff] [blame] | 1081 | /* Verify name table is empty, then release it */ |
| 1082 | |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 1083 | write_lock_bh(&tipc_nametbl_lock); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 1084 | for (i = 0; i < tipc_nametbl_size; i++) { |
Allan Stephens | f131072 | 2006-06-25 23:51:37 -0700 | [diff] [blame] | 1085 | if (!hlist_empty(&table.types[i])) |
| 1086 | err("tipc_nametbl_stop(): hash chain %u is non-null\n", i); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 1087 | } |
| 1088 | kfree(table.types); |
| 1089 | table.types = NULL; |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 1090 | write_unlock_bh(&tipc_nametbl_lock); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 1091 | } |
Allan Stephens | f131072 | 2006-06-25 23:51:37 -0700 | [diff] [blame] | 1092 | |