aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/name_distr.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/tipc/name_distr.c')
-rw-r--r--net/tipc/name_distr.c64
1 files changed, 32 insertions, 32 deletions
diff --git a/net/tipc/name_distr.c b/net/tipc/name_distr.c
index 7bf87cb26ef3..39fd1619febf 100644
--- a/net/tipc/name_distr.c
+++ b/net/tipc/name_distr.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * net/tipc/name_distr.c: TIPC name distribution code 2 * net/tipc/name_distr.c: TIPC name distribution code
3 * 3 *
4 * Copyright (c) 2000-2006, Ericsson AB 4 * Copyright (c) 2000-2006, Ericsson AB
5 * Copyright (c) 2005, Wind River Systems 5 * Copyright (c) 2005, Wind River Systems
6 * All rights reserved. 6 * All rights reserved.
@@ -53,15 +53,15 @@
53 * @upper: name sequence upper bound 53 * @upper: name sequence upper bound
54 * @ref: publishing port reference 54 * @ref: publishing port reference
55 * @key: publication key 55 * @key: publication key
56 * 56 *
57 * ===> All fields are stored in network byte order. <=== 57 * ===> All fields are stored in network byte order. <===
58 * 58 *
59 * First 3 fields identify (name or) name sequence being published. 59 * First 3 fields identify (name or) name sequence being published.
60 * Reference field uniquely identifies port that published name sequence. 60 * Reference field uniquely identifies port that published name sequence.
61 * Key field uniquely identifies publication, in the event a port has 61 * Key field uniquely identifies publication, in the event a port has
62 * multiple publications of the same name sequence. 62 * multiple publications of the same name sequence.
63 * 63 *
64 * Note: There is no field that identifies the publishing node because it is 64 * Note: There is no field that identifies the publishing node because it is
65 * the same for all items contained within a publication message. 65 * the same for all items contained within a publication message.
66 */ 66 */
67 67
@@ -74,12 +74,12 @@ struct distr_item {
74}; 74};
75 75
76/** 76/**
77 * List of externally visible publications by this node -- 77 * List of externally visible publications by this node --
78 * that is, all publications having scope > TIPC_NODE_SCOPE. 78 * that is, all publications having scope > TIPC_NODE_SCOPE.
79 */ 79 */
80 80
81static LIST_HEAD(publ_root); 81static LIST_HEAD(publ_root);
82static u32 publ_cnt = 0; 82static u32 publ_cnt = 0;
83 83
84/** 84/**
85 * publ_to_item - add publication info to a publication message 85 * publ_to_item - add publication info to a publication message
@@ -101,12 +101,12 @@ static void publ_to_item(struct distr_item *i, struct publication *p)
101 101
102static struct sk_buff *named_prepare_buf(u32 type, u32 size, u32 dest) 102static struct sk_buff *named_prepare_buf(u32 type, u32 size, u32 dest)
103{ 103{
104 struct sk_buff *buf = buf_acquire(LONG_H_SIZE + size); 104 struct sk_buff *buf = buf_acquire(LONG_H_SIZE + size);
105 struct tipc_msg *msg; 105 struct tipc_msg *msg;
106 106
107 if (buf != NULL) { 107 if (buf != NULL) {
108 msg = buf_msg(buf); 108 msg = buf_msg(buf);
109 msg_init(msg, NAME_DISTRIBUTOR, type, TIPC_OK, 109 msg_init(msg, NAME_DISTRIBUTOR, type, TIPC_OK,
110 LONG_H_SIZE, dest); 110 LONG_H_SIZE, dest);
111 msg_set_size(msg, LONG_H_SIZE + size); 111 msg_set_size(msg, LONG_H_SIZE + size);
112 } 112 }
@@ -174,7 +174,7 @@ void tipc_named_node_up(unsigned long node)
174 u32 rest; 174 u32 rest;
175 u32 max_item_buf; 175 u32 max_item_buf;
176 176
177 read_lock_bh(&tipc_nametbl_lock); 177 read_lock_bh(&tipc_nametbl_lock);
178 max_item_buf = TIPC_MAX_USER_MSG_SIZE / ITEM_SIZE; 178 max_item_buf = TIPC_MAX_USER_MSG_SIZE / ITEM_SIZE;
179 max_item_buf *= ITEM_SIZE; 179 max_item_buf *= ITEM_SIZE;
180 rest = publ_cnt * ITEM_SIZE; 180 rest = publ_cnt * ITEM_SIZE;
@@ -183,7 +183,7 @@ void tipc_named_node_up(unsigned long node)
183 if (!buf) { 183 if (!buf) {
184 left = (rest <= max_item_buf) ? rest : max_item_buf; 184 left = (rest <= max_item_buf) ? rest : max_item_buf;
185 rest -= left; 185 rest -= left;
186 buf = named_prepare_buf(PUBLICATION, left, node); 186 buf = named_prepare_buf(PUBLICATION, left, node);
187 if (!buf) { 187 if (!buf) {
188 warn("Bulk publication distribution failure\n"); 188 warn("Bulk publication distribution failure\n");
189 goto exit; 189 goto exit;
@@ -196,20 +196,20 @@ void tipc_named_node_up(unsigned long node)
196 if (!left) { 196 if (!left) {
197 msg_set_link_selector(buf_msg(buf), node); 197 msg_set_link_selector(buf_msg(buf), node);
198 dbg("tipc_named_node_up: sending publish msg to " 198 dbg("tipc_named_node_up: sending publish msg to "
199 "<%u.%u.%u>\n", tipc_zone(node), 199 "<%u.%u.%u>\n", tipc_zone(node),
200 tipc_cluster(node), tipc_node(node)); 200 tipc_cluster(node), tipc_node(node));
201 tipc_link_send(buf, node, node); 201 tipc_link_send(buf, node, node);
202 buf = NULL; 202 buf = NULL;
203 } 203 }
204 } 204 }
205exit: 205exit:
206 read_unlock_bh(&tipc_nametbl_lock); 206 read_unlock_bh(&tipc_nametbl_lock);
207} 207}
208 208
209/** 209/**
210 * node_is_down - remove publication associated with a failed node 210 * node_is_down - remove publication associated with a failed node
211 * 211 *
212 * Invoked for each publication issued by a newly failed node. 212 * Invoked for each publication issued by a newly failed node.
213 * Removes publication structure from name table & deletes it. 213 * Removes publication structure from name table & deletes it.
214 * In rare cases the link may have come back up again when this 214 * In rare cases the link may have come back up again when this
215 * function is called, and we have two items representing the same 215 * function is called, and we have two items representing the same
@@ -221,15 +221,15 @@ static void node_is_down(struct publication *publ)
221{ 221{
222 struct publication *p; 222 struct publication *p;
223 223
224 write_lock_bh(&tipc_nametbl_lock); 224 write_lock_bh(&tipc_nametbl_lock);
225 dbg("node_is_down: withdrawing %u, %u, %u\n", 225 dbg("node_is_down: withdrawing %u, %u, %u\n",
226 publ->type, publ->lower, publ->upper); 226 publ->type, publ->lower, publ->upper);
227 publ->key += 1222345; 227 publ->key += 1222345;
228 p = tipc_nametbl_remove_publ(publ->type, publ->lower, 228 p = tipc_nametbl_remove_publ(publ->type, publ->lower,
229 publ->node, publ->ref, publ->key); 229 publ->node, publ->ref, publ->key);
230 write_unlock_bh(&tipc_nametbl_lock); 230 write_unlock_bh(&tipc_nametbl_lock);
231 231
232 if (p != publ) { 232 if (p != publ) {
233 err("Unable to remove publication from failed node\n" 233 err("Unable to remove publication from failed node\n"
234 "(type=%u, lower=%u, node=0x%x, ref=%u, key=%u)\n", 234 "(type=%u, lower=%u, node=0x%x, ref=%u, key=%u)\n",
235 publ->type, publ->lower, publ->node, publ->ref, publ->key); 235 publ->type, publ->lower, publ->node, publ->ref, publ->key);
@@ -251,27 +251,27 @@ void tipc_named_recv(struct sk_buff *buf)
251 struct distr_item *item = (struct distr_item *)msg_data(msg); 251 struct distr_item *item = (struct distr_item *)msg_data(msg);
252 u32 count = msg_data_sz(msg) / ITEM_SIZE; 252 u32 count = msg_data_sz(msg) / ITEM_SIZE;
253 253
254 write_lock_bh(&tipc_nametbl_lock); 254 write_lock_bh(&tipc_nametbl_lock);
255 while (count--) { 255 while (count--) {
256 if (msg_type(msg) == PUBLICATION) { 256 if (msg_type(msg) == PUBLICATION) {
257 dbg("tipc_named_recv: got publication for %u, %u, %u\n", 257 dbg("tipc_named_recv: got publication for %u, %u, %u\n",
258 ntohl(item->type), ntohl(item->lower), 258 ntohl(item->type), ntohl(item->lower),
259 ntohl(item->upper)); 259 ntohl(item->upper));
260 publ = tipc_nametbl_insert_publ(ntohl(item->type), 260 publ = tipc_nametbl_insert_publ(ntohl(item->type),
261 ntohl(item->lower), 261 ntohl(item->lower),
262 ntohl(item->upper), 262 ntohl(item->upper),
263 TIPC_CLUSTER_SCOPE, 263 TIPC_CLUSTER_SCOPE,
264 msg_orignode(msg), 264 msg_orignode(msg),
265 ntohl(item->ref), 265 ntohl(item->ref),
266 ntohl(item->key)); 266 ntohl(item->key));
267 if (publ) { 267 if (publ) {
268 tipc_nodesub_subscribe(&publ->subscr, 268 tipc_nodesub_subscribe(&publ->subscr,
269 msg_orignode(msg), 269 msg_orignode(msg),
270 publ, 270 publ,
271 (net_ev_handler)node_is_down); 271 (net_ev_handler)node_is_down);
272 } 272 }
273 } else if (msg_type(msg) == WITHDRAWAL) { 273 } else if (msg_type(msg) == WITHDRAWAL) {
274 dbg("tipc_named_recv: got withdrawl for %u, %u, %u\n", 274 dbg("tipc_named_recv: got withdrawl for %u, %u, %u\n",
275 ntohl(item->type), ntohl(item->lower), 275 ntohl(item->type), ntohl(item->lower),
276 ntohl(item->upper)); 276 ntohl(item->upper));
277 publ = tipc_nametbl_remove_publ(ntohl(item->type), 277 publ = tipc_nametbl_remove_publ(ntohl(item->type),
@@ -282,7 +282,7 @@ void tipc_named_recv(struct sk_buff *buf)
282 282
283 if (publ) { 283 if (publ) {
284 tipc_nodesub_unsubscribe(&publ->subscr); 284 tipc_nodesub_unsubscribe(&publ->subscr);
285 kfree(publ); 285 kfree(publ);
286 } else { 286 } else {
287 err("Unable to remove publication by node 0x%x\n" 287 err("Unable to remove publication by node 0x%x\n"
288 "(type=%u, lower=%u, ref=%u, key=%u)\n", 288 "(type=%u, lower=%u, ref=%u, key=%u)\n",
@@ -295,13 +295,13 @@ void tipc_named_recv(struct sk_buff *buf)
295 } 295 }
296 item++; 296 item++;
297 } 297 }
298 write_unlock_bh(&tipc_nametbl_lock); 298 write_unlock_bh(&tipc_nametbl_lock);
299 buf_discard(buf); 299 buf_discard(buf);
300} 300}
301 301
302/** 302/**
303 * tipc_named_reinit - re-initialize local publication list 303 * tipc_named_reinit - re-initialize local publication list
304 * 304 *
305 * This routine is called whenever TIPC networking is (re)enabled. 305 * This routine is called whenever TIPC networking is (re)enabled.
306 * All existing publications by this node that have "cluster" or "zone" scope 306 * All existing publications by this node that have "cluster" or "zone" scope
307 * are updated to reflect the node's current network address. 307 * are updated to reflect the node's current network address.
@@ -312,11 +312,11 @@ void tipc_named_reinit(void)
312{ 312{
313 struct publication *publ; 313 struct publication *publ;
314 314
315 write_lock_bh(&tipc_nametbl_lock); 315 write_lock_bh(&tipc_nametbl_lock);
316 list_for_each_entry(publ, &publ_root, local_list) { 316 list_for_each_entry(publ, &publ_root, local_list) {
317 if (publ->node == tipc_own_addr) 317 if (publ->node == tipc_own_addr)
318 break; 318 break;
319 publ->node = tipc_own_addr; 319 publ->node = tipc_own_addr;
320 } 320 }
321 write_unlock_bh(&tipc_nametbl_lock); 321 write_unlock_bh(&tipc_nametbl_lock);
322} 322}