xref: /linux/net/tipc/name_distr.c (revision 0fc4dffad13e81deb3bf72e74cac292172df5285)
1b97bf3fdSPer Liden /*
2b97bf3fdSPer Liden  * net/tipc/name_distr.c: TIPC name distribution code
3b97bf3fdSPer Liden  *
4a5325ae5SErik Hugne  * Copyright (c) 2000-2006, 2014, Ericsson AB
5431697ebSAllan Stephens  * Copyright (c) 2005, 2010-2011, Wind River Systems
6b97bf3fdSPer Liden  * All rights reserved.
7b97bf3fdSPer Liden  *
8b97bf3fdSPer Liden  * Redistribution and use in source and binary forms, with or without
9b97bf3fdSPer Liden  * modification, are permitted provided that the following conditions are met:
10b97bf3fdSPer Liden  *
119ea1fd3cSPer Liden  * 1. Redistributions of source code must retain the above copyright
129ea1fd3cSPer Liden  *    notice, this list of conditions and the following disclaimer.
139ea1fd3cSPer Liden  * 2. Redistributions in binary form must reproduce the above copyright
149ea1fd3cSPer Liden  *    notice, this list of conditions and the following disclaimer in the
159ea1fd3cSPer Liden  *    documentation and/or other materials provided with the distribution.
169ea1fd3cSPer Liden  * 3. Neither the names of the copyright holders nor the names of its
179ea1fd3cSPer Liden  *    contributors may be used to endorse or promote products derived from
189ea1fd3cSPer Liden  *    this software without specific prior written permission.
199ea1fd3cSPer Liden  *
209ea1fd3cSPer Liden  * Alternatively, this software may be distributed under the terms of the
219ea1fd3cSPer Liden  * GNU General Public License ("GPL") version 2 as published by the Free
229ea1fd3cSPer Liden  * Software Foundation.
23b97bf3fdSPer Liden  *
24b97bf3fdSPer Liden  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25b97bf3fdSPer Liden  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26b97bf3fdSPer Liden  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27b97bf3fdSPer Liden  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
28b97bf3fdSPer Liden  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29b97bf3fdSPer Liden  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30b97bf3fdSPer Liden  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31b97bf3fdSPer Liden  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32b97bf3fdSPer Liden  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33b97bf3fdSPer Liden  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34b97bf3fdSPer Liden  * POSSIBILITY OF SUCH DAMAGE.
35b97bf3fdSPer Liden  */
36b97bf3fdSPer Liden 
37b97bf3fdSPer Liden #include "core.h"
38b97bf3fdSPer Liden #include "link.h"
39b97bf3fdSPer Liden #include "name_distr.h"
40b97bf3fdSPer Liden 
41b97bf3fdSPer Liden /**
423f8375feSAllan Stephens  * struct publ_list - list of publications made by this node
433f8375feSAllan Stephens  * @list: circular list of publications
443f8375feSAllan Stephens  * @list_size: number of entries in list
45b97bf3fdSPer Liden  */
463f8375feSAllan Stephens struct publ_list {
473f8375feSAllan Stephens 	struct list_head list;
483f8375feSAllan Stephens 	u32 size;
493f8375feSAllan Stephens };
50b97bf3fdSPer Liden 
51a909804fSAllan Stephens static struct publ_list publ_zone = {
52a909804fSAllan Stephens 	.list = LIST_HEAD_INIT(publ_zone.list),
53a909804fSAllan Stephens 	.size = 0,
54a909804fSAllan Stephens };
55a909804fSAllan Stephens 
563f8375feSAllan Stephens static struct publ_list publ_cluster = {
573f8375feSAllan Stephens 	.list = LIST_HEAD_INIT(publ_cluster.list),
583f8375feSAllan Stephens 	.size = 0,
593f8375feSAllan Stephens };
60b97bf3fdSPer Liden 
61a909804fSAllan Stephens static struct publ_list publ_node = {
62a909804fSAllan Stephens 	.list = LIST_HEAD_INIT(publ_node.list),
63a909804fSAllan Stephens 	.size = 0,
64a909804fSAllan Stephens };
65a909804fSAllan Stephens 
66a909804fSAllan Stephens static struct publ_list *publ_lists[] = {
67a909804fSAllan Stephens 	NULL,
68a909804fSAllan Stephens 	&publ_zone,	/* publ_lists[TIPC_ZONE_SCOPE]		*/
69a909804fSAllan Stephens 	&publ_cluster,	/* publ_lists[TIPC_CLUSTER_SCOPE]	*/
70a909804fSAllan Stephens 	&publ_node	/* publ_lists[TIPC_NODE_SCOPE]		*/
71a909804fSAllan Stephens };
72a909804fSAllan Stephens 
73a909804fSAllan Stephens 
74a5325ae5SErik Hugne int sysctl_tipc_named_timeout __read_mostly = 2000;
75a5325ae5SErik Hugne 
76a5325ae5SErik Hugne /**
77a5325ae5SErik Hugne  * struct tipc_dist_queue - queue holding deferred name table updates
78a5325ae5SErik Hugne  */
79a5325ae5SErik Hugne static struct list_head tipc_dist_queue = LIST_HEAD_INIT(tipc_dist_queue);
80a5325ae5SErik Hugne 
81a5325ae5SErik Hugne struct distr_queue_item {
82a5325ae5SErik Hugne 	struct distr_item i;
83a5325ae5SErik Hugne 	u32 dtype;
84a5325ae5SErik Hugne 	u32 node;
85a5325ae5SErik Hugne 	unsigned long expires;
86a5325ae5SErik Hugne 	struct list_head next;
87a5325ae5SErik Hugne };
88a5325ae5SErik Hugne 
89b97bf3fdSPer Liden /**
90b97bf3fdSPer Liden  * publ_to_item - add publication info to a publication message
91b97bf3fdSPer Liden  */
92b97bf3fdSPer Liden static void publ_to_item(struct distr_item *i, struct publication *p)
93b97bf3fdSPer Liden {
94b97bf3fdSPer Liden 	i->type = htonl(p->type);
95b97bf3fdSPer Liden 	i->lower = htonl(p->lower);
96b97bf3fdSPer Liden 	i->upper = htonl(p->upper);
97b97bf3fdSPer Liden 	i->ref = htonl(p->ref);
98b97bf3fdSPer Liden 	i->key = htonl(p->key);
99b97bf3fdSPer Liden }
100b97bf3fdSPer Liden 
101b97bf3fdSPer Liden /**
102b97bf3fdSPer Liden  * named_prepare_buf - allocate & initialize a publication message
103b97bf3fdSPer Liden  */
104b97bf3fdSPer Liden static struct sk_buff *named_prepare_buf(u32 type, u32 size, u32 dest)
105b97bf3fdSPer Liden {
106741d9eb7SAllan Stephens 	struct sk_buff *buf = tipc_buf_acquire(INT_H_SIZE + size);
107b97bf3fdSPer Liden 	struct tipc_msg *msg;
108b97bf3fdSPer Liden 
109b97bf3fdSPer Liden 	if (buf != NULL) {
110b97bf3fdSPer Liden 		msg = buf_msg(buf);
111741d9eb7SAllan Stephens 		tipc_msg_init(msg, NAME_DISTRIBUTOR, type, INT_H_SIZE, dest);
112741d9eb7SAllan Stephens 		msg_set_size(msg, INT_H_SIZE + size);
113b97bf3fdSPer Liden 	}
114b97bf3fdSPer Liden 	return buf;
115b97bf3fdSPer Liden }
116b97bf3fdSPer Liden 
117eab8c045SYing Xue void named_cluster_distribute(struct sk_buff *buf)
1188f92df6aSAllan Stephens {
119dbdf6d24SJon Paul Maloy 	struct sk_buff *obuf;
120dbdf6d24SJon Paul Maloy 	struct tipc_node *node;
121dbdf6d24SJon Paul Maloy 	u32 dnode;
1228f92df6aSAllan Stephens 
1236c7a762eSYing Xue 	rcu_read_lock();
124dbdf6d24SJon Paul Maloy 	list_for_each_entry_rcu(node, &tipc_node_list, list) {
125dbdf6d24SJon Paul Maloy 		dnode = node->addr;
126dbdf6d24SJon Paul Maloy 		if (in_own_node(dnode))
127dbdf6d24SJon Paul Maloy 			continue;
128dbdf6d24SJon Paul Maloy 		if (!tipc_node_active_links(node))
129dbdf6d24SJon Paul Maloy 			continue;
130dbdf6d24SJon Paul Maloy 		obuf = skb_copy(buf, GFP_ATOMIC);
131dbdf6d24SJon Paul Maloy 		if (!obuf)
1328f92df6aSAllan Stephens 			break;
133dbdf6d24SJon Paul Maloy 		msg_set_destnode(buf_msg(obuf), dnode);
1349fbfb8b1SJon Paul Maloy 		tipc_link_xmit(obuf, dnode, dnode);
1358f92df6aSAllan Stephens 	}
1366c7a762eSYing Xue 	rcu_read_unlock();
1378f92df6aSAllan Stephens 
1385f6d9123SAllan Stephens 	kfree_skb(buf);
1398f92df6aSAllan Stephens }
1408f92df6aSAllan Stephens 
141b97bf3fdSPer Liden /**
1424323add6SPer Liden  * tipc_named_publish - tell other nodes about a new publication by this node
143b97bf3fdSPer Liden  */
144eab8c045SYing Xue struct sk_buff *tipc_named_publish(struct publication *publ)
145b97bf3fdSPer Liden {
146b97bf3fdSPer Liden 	struct sk_buff *buf;
147b97bf3fdSPer Liden 	struct distr_item *item;
148b97bf3fdSPer Liden 
149a909804fSAllan Stephens 	list_add_tail(&publ->local_list, &publ_lists[publ->scope]->list);
150a909804fSAllan Stephens 	publ_lists[publ->scope]->size++;
151b97bf3fdSPer Liden 
1521110b8d3SAllan Stephens 	if (publ->scope == TIPC_NODE_SCOPE)
153eab8c045SYing Xue 		return NULL;
1541110b8d3SAllan Stephens 
155b97bf3fdSPer Liden 	buf = named_prepare_buf(PUBLICATION, ITEM_SIZE, 0);
156b97bf3fdSPer Liden 	if (!buf) {
1572cf8aa19SErik Hugne 		pr_warn("Publication distribution failure\n");
158eab8c045SYing Xue 		return NULL;
159b97bf3fdSPer Liden 	}
160b97bf3fdSPer Liden 
161b97bf3fdSPer Liden 	item = (struct distr_item *)msg_data(buf_msg(buf));
162b97bf3fdSPer Liden 	publ_to_item(item, publ);
163eab8c045SYing Xue 	return buf;
164b97bf3fdSPer Liden }
165b97bf3fdSPer Liden 
166b97bf3fdSPer Liden /**
1674323add6SPer Liden  * tipc_named_withdraw - tell other nodes about a withdrawn publication by this node
168b97bf3fdSPer Liden  */
169eab8c045SYing Xue struct sk_buff *tipc_named_withdraw(struct publication *publ)
170b97bf3fdSPer Liden {
171b97bf3fdSPer Liden 	struct sk_buff *buf;
172b97bf3fdSPer Liden 	struct distr_item *item;
173b97bf3fdSPer Liden 
174b97bf3fdSPer Liden 	list_del(&publ->local_list);
175a909804fSAllan Stephens 	publ_lists[publ->scope]->size--;
176b97bf3fdSPer Liden 
1771110b8d3SAllan Stephens 	if (publ->scope == TIPC_NODE_SCOPE)
178eab8c045SYing Xue 		return NULL;
1791110b8d3SAllan Stephens 
180b97bf3fdSPer Liden 	buf = named_prepare_buf(WITHDRAWAL, ITEM_SIZE, 0);
181b97bf3fdSPer Liden 	if (!buf) {
1822cf8aa19SErik Hugne 		pr_warn("Withdrawal distribution failure\n");
183eab8c045SYing Xue 		return NULL;
184b97bf3fdSPer Liden 	}
185b97bf3fdSPer Liden 
186b97bf3fdSPer Liden 	item = (struct distr_item *)msg_data(buf_msg(buf));
187b97bf3fdSPer Liden 	publ_to_item(item, publ);
188eab8c045SYing Xue 	return buf;
189b97bf3fdSPer Liden }
190b97bf3fdSPer Liden 
191dbdf6d24SJon Paul Maloy /**
192e11aa059SAllan Stephens  * named_distribute - prepare name info for bulk distribution to another node
193dbdf6d24SJon Paul Maloy  * @msg_list: list of messages (buffers) to be returned from this function
194dbdf6d24SJon Paul Maloy  * @dnode: node to be updated
195dbdf6d24SJon Paul Maloy  * @pls: linked list of publication items to be packed into buffer chain
196e11aa059SAllan Stephens  */
197dbdf6d24SJon Paul Maloy static void named_distribute(struct list_head *msg_list, u32 dnode,
198dbdf6d24SJon Paul Maloy 			     struct publ_list *pls)
199e11aa059SAllan Stephens {
200e11aa059SAllan Stephens 	struct publication *publ;
201e11aa059SAllan Stephens 	struct sk_buff *buf = NULL;
202e11aa059SAllan Stephens 	struct distr_item *item = NULL;
203dbdf6d24SJon Paul Maloy 	uint dsz = pls->size * ITEM_SIZE;
204dbdf6d24SJon Paul Maloy 	uint msg_dsz = (tipc_node_get_mtu(dnode, 0) / ITEM_SIZE) * ITEM_SIZE;
205dbdf6d24SJon Paul Maloy 	uint rem = dsz;
206dbdf6d24SJon Paul Maloy 	uint msg_rem = 0;
207e11aa059SAllan Stephens 
208e11aa059SAllan Stephens 	list_for_each_entry(publ, &pls->list, local_list) {
209dbdf6d24SJon Paul Maloy 		/* Prepare next buffer: */
210e11aa059SAllan Stephens 		if (!buf) {
211dbdf6d24SJon Paul Maloy 			msg_rem = min_t(uint, rem, msg_dsz);
212dbdf6d24SJon Paul Maloy 			rem -= msg_rem;
213dbdf6d24SJon Paul Maloy 			buf = named_prepare_buf(PUBLICATION, msg_rem, dnode);
214e11aa059SAllan Stephens 			if (!buf) {
2152cf8aa19SErik Hugne 				pr_warn("Bulk publication failure\n");
216e11aa059SAllan Stephens 				return;
217e11aa059SAllan Stephens 			}
218e11aa059SAllan Stephens 			item = (struct distr_item *)msg_data(buf_msg(buf));
219e11aa059SAllan Stephens 		}
220dbdf6d24SJon Paul Maloy 
221dbdf6d24SJon Paul Maloy 		/* Pack publication into message: */
222e11aa059SAllan Stephens 		publ_to_item(item, publ);
223e11aa059SAllan Stephens 		item++;
224dbdf6d24SJon Paul Maloy 		msg_rem -= ITEM_SIZE;
225dbdf6d24SJon Paul Maloy 
226dbdf6d24SJon Paul Maloy 		/* Append full buffer to list: */
227dbdf6d24SJon Paul Maloy 		if (!msg_rem) {
228dbdf6d24SJon Paul Maloy 			list_add_tail((struct list_head *)buf, msg_list);
229e11aa059SAllan Stephens 			buf = NULL;
230e11aa059SAllan Stephens 		}
231e11aa059SAllan Stephens 	}
232e11aa059SAllan Stephens }
233e11aa059SAllan Stephens 
234b97bf3fdSPer Liden /**
2354323add6SPer Liden  * tipc_named_node_up - tell specified node about all publications by this node
236b97bf3fdSPer Liden  */
237dbdf6d24SJon Paul Maloy void tipc_named_node_up(u32 dnode)
238b97bf3fdSPer Liden {
239dbdf6d24SJon Paul Maloy 	LIST_HEAD(msg_list);
240dbdf6d24SJon Paul Maloy 	struct sk_buff *buf_chain;
2419aa88c2aSAllan Stephens 
2424323add6SPer Liden 	read_lock_bh(&tipc_nametbl_lock);
243dbdf6d24SJon Paul Maloy 	named_distribute(&msg_list, dnode, &publ_cluster);
244dbdf6d24SJon Paul Maloy 	named_distribute(&msg_list, dnode, &publ_zone);
2454323add6SPer Liden 	read_unlock_bh(&tipc_nametbl_lock);
2469aa88c2aSAllan Stephens 
247dbdf6d24SJon Paul Maloy 	/* Convert circular list to linear list and send: */
248dbdf6d24SJon Paul Maloy 	buf_chain = (struct sk_buff *)msg_list.next;
249dbdf6d24SJon Paul Maloy 	((struct sk_buff *)msg_list.prev)->next = NULL;
2509fbfb8b1SJon Paul Maloy 	tipc_link_xmit(buf_chain, dnode, dnode);
251b97bf3fdSPer Liden }
252b97bf3fdSPer Liden 
253b97bf3fdSPer Liden /**
254f1379173SAllan Stephens  * named_purge_publ - remove publication associated with a failed node
255b97bf3fdSPer Liden  *
256b97bf3fdSPer Liden  * Invoked for each publication issued by a newly failed node.
257b97bf3fdSPer Liden  * Removes publication structure from name table & deletes it.
258b97bf3fdSPer Liden  */
259f1379173SAllan Stephens static void named_purge_publ(struct publication *publ)
260b97bf3fdSPer Liden {
261b97bf3fdSPer Liden 	struct publication *p;
262f131072cSAllan Stephens 
2634323add6SPer Liden 	write_lock_bh(&tipc_nametbl_lock);
2644323add6SPer Liden 	p = tipc_nametbl_remove_publ(publ->type, publ->lower,
265b97bf3fdSPer Liden 				     publ->node, publ->ref, publ->key);
266431697ebSAllan Stephens 	if (p)
267431697ebSAllan Stephens 		tipc_nodesub_unsubscribe(&p->subscr);
2684323add6SPer Liden 	write_unlock_bh(&tipc_nametbl_lock);
269f131072cSAllan Stephens 
270f131072cSAllan Stephens 	if (p != publ) {
2712cf8aa19SErik Hugne 		pr_err("Unable to remove publication from failed node\n"
272f131072cSAllan Stephens 		       " (type=%u, lower=%u, node=0x%x, ref=%u, key=%u)\n",
2732cf8aa19SErik Hugne 		       publ->type, publ->lower, publ->node, publ->ref,
2742cf8aa19SErik Hugne 		       publ->key);
275f131072cSAllan Stephens 	}
276f131072cSAllan Stephens 
277f131072cSAllan Stephens 	kfree(p);
278f131072cSAllan Stephens }
279b97bf3fdSPer Liden 
280b97bf3fdSPer Liden /**
281f4ad8a4bSErik Hugne  * tipc_update_nametbl - try to process a nametable update and notify
282f4ad8a4bSErik Hugne  *			 subscribers
283f4ad8a4bSErik Hugne  *
284f4ad8a4bSErik Hugne  * tipc_nametbl_lock must be held.
285f4ad8a4bSErik Hugne  * Returns the publication item if successful, otherwise NULL.
286f4ad8a4bSErik Hugne  */
287*0fc4dffaSErik Hugne static bool tipc_update_nametbl(struct distr_item *i, u32 node, u32 dtype)
288f4ad8a4bSErik Hugne {
289f4ad8a4bSErik Hugne 	struct publication *publ = NULL;
290f4ad8a4bSErik Hugne 
291f4ad8a4bSErik Hugne 	if (dtype == PUBLICATION) {
292f4ad8a4bSErik Hugne 		publ = tipc_nametbl_insert_publ(ntohl(i->type), ntohl(i->lower),
293f4ad8a4bSErik Hugne 						ntohl(i->upper),
294f4ad8a4bSErik Hugne 						TIPC_CLUSTER_SCOPE, node,
295f4ad8a4bSErik Hugne 						ntohl(i->ref), ntohl(i->key));
296f4ad8a4bSErik Hugne 		if (publ) {
297f4ad8a4bSErik Hugne 			tipc_nodesub_subscribe(&publ->subscr, node, publ,
298f4ad8a4bSErik Hugne 					       (net_ev_handler)
299f4ad8a4bSErik Hugne 					       named_purge_publ);
300*0fc4dffaSErik Hugne 			return true;
301f4ad8a4bSErik Hugne 		}
302f4ad8a4bSErik Hugne 	} else if (dtype == WITHDRAWAL) {
303f4ad8a4bSErik Hugne 		publ = tipc_nametbl_remove_publ(ntohl(i->type), ntohl(i->lower),
304f4ad8a4bSErik Hugne 						node, ntohl(i->ref),
305f4ad8a4bSErik Hugne 						ntohl(i->key));
306f4ad8a4bSErik Hugne 		if (publ) {
307f4ad8a4bSErik Hugne 			tipc_nodesub_unsubscribe(&publ->subscr);
308f4ad8a4bSErik Hugne 			kfree(publ);
309*0fc4dffaSErik Hugne 			return true;
310f4ad8a4bSErik Hugne 		}
311f4ad8a4bSErik Hugne 	} else {
312f4ad8a4bSErik Hugne 		pr_warn("Unrecognized name table message received\n");
313f4ad8a4bSErik Hugne 	}
314*0fc4dffaSErik Hugne 	return false;
315f4ad8a4bSErik Hugne }
316f4ad8a4bSErik Hugne 
317f4ad8a4bSErik Hugne /**
318a5325ae5SErik Hugne  * tipc_named_add_backlog - add a failed name table update to the backlog
319a5325ae5SErik Hugne  *
320a5325ae5SErik Hugne  */
321a5325ae5SErik Hugne static void tipc_named_add_backlog(struct distr_item *i, u32 type, u32 node)
322a5325ae5SErik Hugne {
323a5325ae5SErik Hugne 	struct distr_queue_item *e;
324a5325ae5SErik Hugne 	unsigned long now = get_jiffies_64();
325a5325ae5SErik Hugne 
326a5325ae5SErik Hugne 	e = kzalloc(sizeof(*e), GFP_ATOMIC);
327a5325ae5SErik Hugne 	if (!e)
328a5325ae5SErik Hugne 		return;
329a5325ae5SErik Hugne 	e->dtype = type;
330a5325ae5SErik Hugne 	e->node = node;
331a5325ae5SErik Hugne 	e->expires = now + msecs_to_jiffies(sysctl_tipc_named_timeout);
332a5325ae5SErik Hugne 	memcpy(e, i, sizeof(*i));
333a5325ae5SErik Hugne 	list_add_tail(&e->next, &tipc_dist_queue);
334a5325ae5SErik Hugne }
335a5325ae5SErik Hugne 
336a5325ae5SErik Hugne /**
337a5325ae5SErik Hugne  * tipc_named_process_backlog - try to process any pending name table updates
338a5325ae5SErik Hugne  * from the network.
339a5325ae5SErik Hugne  */
340a5325ae5SErik Hugne void tipc_named_process_backlog(void)
341a5325ae5SErik Hugne {
342a5325ae5SErik Hugne 	struct distr_queue_item *e, *tmp;
343a5325ae5SErik Hugne 	char addr[16];
344a5325ae5SErik Hugne 	unsigned long now = get_jiffies_64();
345a5325ae5SErik Hugne 
346a5325ae5SErik Hugne 	list_for_each_entry_safe(e, tmp, &tipc_dist_queue, next) {
347a5325ae5SErik Hugne 		if (time_after(e->expires, now)) {
348a5325ae5SErik Hugne 			if (!tipc_update_nametbl(&e->i, e->node, e->dtype))
349a5325ae5SErik Hugne 				continue;
350a5325ae5SErik Hugne 		} else {
351a5325ae5SErik Hugne 			tipc_addr_string_fill(addr, e->node);
352a5325ae5SErik Hugne 			pr_warn_ratelimited("Dropping name table update (%d) of {%u, %u, %u} from %s key=%u\n",
353a5325ae5SErik Hugne 					    e->dtype, ntohl(e->i.type),
354a5325ae5SErik Hugne 					    ntohl(e->i.lower),
355a5325ae5SErik Hugne 					    ntohl(e->i.upper),
356a5325ae5SErik Hugne 					    addr, ntohl(e->i.key));
357a5325ae5SErik Hugne 		}
358a5325ae5SErik Hugne 		list_del(&e->next);
359a5325ae5SErik Hugne 		kfree(e);
360a5325ae5SErik Hugne 	}
361a5325ae5SErik Hugne }
362a5325ae5SErik Hugne 
363a5325ae5SErik Hugne /**
364247f0f3cSYing Xue  * tipc_named_rcv - process name table update message sent by another node
365b97bf3fdSPer Liden  */
366247f0f3cSYing Xue void tipc_named_rcv(struct sk_buff *buf)
367b97bf3fdSPer Liden {
368b97bf3fdSPer Liden 	struct tipc_msg *msg = buf_msg(buf);
369b97bf3fdSPer Liden 	struct distr_item *item = (struct distr_item *)msg_data(msg);
370b97bf3fdSPer Liden 	u32 count = msg_data_sz(msg) / ITEM_SIZE;
371a5325ae5SErik Hugne 	u32 node = msg_orignode(msg);
372b97bf3fdSPer Liden 
3734323add6SPer Liden 	write_lock_bh(&tipc_nametbl_lock);
374b97bf3fdSPer Liden 	while (count--) {
375a5325ae5SErik Hugne 		if (!tipc_update_nametbl(item, node, msg_type(msg)))
376a5325ae5SErik Hugne 			tipc_named_add_backlog(item, msg_type(msg), node);
377b97bf3fdSPer Liden 		item++;
378b97bf3fdSPer Liden 	}
379a5325ae5SErik Hugne 	tipc_named_process_backlog();
3804323add6SPer Liden 	write_unlock_bh(&tipc_nametbl_lock);
3815f6d9123SAllan Stephens 	kfree_skb(buf);
382b97bf3fdSPer Liden }
383b97bf3fdSPer Liden 
384b97bf3fdSPer Liden /**
3851110b8d3SAllan Stephens  * tipc_named_reinit - re-initialize local publications
386b97bf3fdSPer Liden  *
387945af1c3SAllan Stephens  * This routine is called whenever TIPC networking is enabled.
3881110b8d3SAllan Stephens  * All name table entries published by this node are updated to reflect
3891110b8d3SAllan Stephens  * the node's new network address.
390b97bf3fdSPer Liden  */
3914323add6SPer Liden void tipc_named_reinit(void)
392b97bf3fdSPer Liden {
393b97bf3fdSPer Liden 	struct publication *publ;
394a909804fSAllan Stephens 	int scope;
395b97bf3fdSPer Liden 
3964323add6SPer Liden 	write_lock_bh(&tipc_nametbl_lock);
397945af1c3SAllan Stephens 
3981110b8d3SAllan Stephens 	for (scope = TIPC_ZONE_SCOPE; scope <= TIPC_NODE_SCOPE; scope++)
399a909804fSAllan Stephens 		list_for_each_entry(publ, &publ_lists[scope]->list, local_list)
400b97bf3fdSPer Liden 			publ->node = tipc_own_addr;
401945af1c3SAllan Stephens 
4024323add6SPer Liden 	write_unlock_bh(&tipc_nametbl_lock);
403b97bf3fdSPer Liden }
404