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 41a5325ae5SErik Hugne int sysctl_tipc_named_timeout __read_mostly = 2000; 42a5325ae5SErik Hugne 43a5325ae5SErik Hugne struct distr_queue_item { 44a5325ae5SErik Hugne struct distr_item i; 45a5325ae5SErik Hugne u32 dtype; 46a5325ae5SErik Hugne u32 node; 47a5325ae5SErik Hugne unsigned long expires; 48a5325ae5SErik Hugne struct list_head next; 49a5325ae5SErik Hugne }; 50a5325ae5SErik Hugne 51b97bf3fdSPer Liden /** 52b97bf3fdSPer Liden * publ_to_item - add publication info to a publication message 53b97bf3fdSPer Liden */ 54b97bf3fdSPer Liden static void publ_to_item(struct distr_item *i, struct publication *p) 55b97bf3fdSPer Liden { 56b97bf3fdSPer Liden i->type = htonl(p->type); 57b97bf3fdSPer Liden i->lower = htonl(p->lower); 58b97bf3fdSPer Liden i->upper = htonl(p->upper); 59e50e73e1SJon Maloy i->port = htonl(p->port); 60b97bf3fdSPer Liden i->key = htonl(p->key); 61b97bf3fdSPer Liden } 62b97bf3fdSPer Liden 63b97bf3fdSPer Liden /** 64b97bf3fdSPer Liden * named_prepare_buf - allocate & initialize a publication message 65d2f394dcSParthasarathy Bhuvaragan * 66d2f394dcSParthasarathy Bhuvaragan * The buffer returned is of size INT_H_SIZE + payload size 67b97bf3fdSPer Liden */ 6834747539SYing Xue static struct sk_buff *named_prepare_buf(struct net *net, u32 type, u32 size, 6934747539SYing Xue u32 dest) 70b97bf3fdSPer Liden { 7157d5f64dSParthasarathy Bhuvaragan struct sk_buff *buf = tipc_buf_acquire(INT_H_SIZE + size, GFP_ATOMIC); 7223fd3eacSJon Maloy u32 self = tipc_own_addr(net); 73b97bf3fdSPer Liden struct tipc_msg *msg; 74b97bf3fdSPer Liden 75b97bf3fdSPer Liden if (buf != NULL) { 76b97bf3fdSPer Liden msg = buf_msg(buf); 7723fd3eacSJon Maloy tipc_msg_init(self, msg, NAME_DISTRIBUTOR, 7823fd3eacSJon Maloy type, INT_H_SIZE, dest); 79741d9eb7SAllan Stephens msg_set_size(msg, INT_H_SIZE + size); 80b97bf3fdSPer Liden } 81b97bf3fdSPer Liden return buf; 82b97bf3fdSPer Liden } 83b97bf3fdSPer Liden 84b97bf3fdSPer Liden /** 854323add6SPer Liden * tipc_named_publish - tell other nodes about a new publication by this node 86b97bf3fdSPer Liden */ 874ac1c8d0SYing Xue struct sk_buff *tipc_named_publish(struct net *net, struct publication *publ) 88b97bf3fdSPer Liden { 8964a52b26SJon Maloy struct name_table *nt = tipc_name_table(net); 90b97bf3fdSPer Liden struct distr_item *item; 9164a52b26SJon Maloy struct sk_buff *skb; 92b97bf3fdSPer Liden 9364a52b26SJon Maloy if (publ->scope == TIPC_NODE_SCOPE) { 94935439ccSJon Maloy list_add_tail_rcu(&publ->binding_node, &nt->node_scope); 95eab8c045SYing Xue return NULL; 9664a52b26SJon Maloy } 97988f3f16SJon Maloy write_lock_bh(&nt->cluster_scope_lock); 98988f3f16SJon Maloy list_add_tail(&publ->binding_node, &nt->cluster_scope); 99988f3f16SJon Maloy write_unlock_bh(&nt->cluster_scope_lock); 10064a52b26SJon Maloy skb = named_prepare_buf(net, PUBLICATION, ITEM_SIZE, 0); 10164a52b26SJon Maloy if (!skb) { 1022cf8aa19SErik Hugne pr_warn("Publication distribution failure\n"); 103eab8c045SYing Xue return NULL; 104b97bf3fdSPer Liden } 105cad2929dSHoang Huu Le msg_set_named_seqno(buf_msg(skb), nt->snd_nxt++); 106cad2929dSHoang Huu Le msg_set_non_legacy(buf_msg(skb)); 10764a52b26SJon Maloy item = (struct distr_item *)msg_data(buf_msg(skb)); 108b97bf3fdSPer Liden publ_to_item(item, publ); 10964a52b26SJon Maloy return skb; 110b97bf3fdSPer Liden } 111b97bf3fdSPer Liden 112b97bf3fdSPer Liden /** 1134323add6SPer Liden * tipc_named_withdraw - tell other nodes about a withdrawn publication by this node 114b97bf3fdSPer Liden */ 11534747539SYing Xue struct sk_buff *tipc_named_withdraw(struct net *net, struct publication *publ) 116b97bf3fdSPer Liden { 117988f3f16SJon Maloy struct name_table *nt = tipc_name_table(net); 118b97bf3fdSPer Liden struct distr_item *item; 119cad2929dSHoang Huu Le struct sk_buff *skb; 120b97bf3fdSPer Liden 121988f3f16SJon Maloy write_lock_bh(&nt->cluster_scope_lock); 122988f3f16SJon Maloy list_del(&publ->binding_node); 123988f3f16SJon Maloy write_unlock_bh(&nt->cluster_scope_lock); 1241110b8d3SAllan Stephens if (publ->scope == TIPC_NODE_SCOPE) 125eab8c045SYing Xue return NULL; 1261110b8d3SAllan Stephens 127cad2929dSHoang Huu Le skb = named_prepare_buf(net, WITHDRAWAL, ITEM_SIZE, 0); 128cad2929dSHoang Huu Le if (!skb) { 1292cf8aa19SErik Hugne pr_warn("Withdrawal distribution failure\n"); 130eab8c045SYing Xue return NULL; 131b97bf3fdSPer Liden } 132cad2929dSHoang Huu Le msg_set_named_seqno(buf_msg(skb), nt->snd_nxt++); 133cad2929dSHoang Huu Le msg_set_non_legacy(buf_msg(skb)); 134cad2929dSHoang Huu Le item = (struct distr_item *)msg_data(buf_msg(skb)); 135b97bf3fdSPer Liden publ_to_item(item, publ); 136cad2929dSHoang Huu Le return skb; 137b97bf3fdSPer Liden } 138b97bf3fdSPer Liden 139dbdf6d24SJon Paul Maloy /** 140e11aa059SAllan Stephens * named_distribute - prepare name info for bulk distribution to another node 141a6ca1094SYing Xue * @list: list of messages (buffers) to be returned from this function 142dbdf6d24SJon Paul Maloy * @dnode: node to be updated 143dbdf6d24SJon Paul Maloy * @pls: linked list of publication items to be packed into buffer chain 144e11aa059SAllan Stephens */ 145f2f9800dSYing Xue static void named_distribute(struct net *net, struct sk_buff_head *list, 146cad2929dSHoang Huu Le u32 dnode, struct list_head *pls, u16 seqno) 147e11aa059SAllan Stephens { 148e11aa059SAllan Stephens struct publication *publ; 149a6ca1094SYing Xue struct sk_buff *skb = NULL; 150e11aa059SAllan Stephens struct distr_item *item = NULL; 151f73b1281SHoang Le u32 msg_dsz = ((tipc_node_get_mtu(net, dnode, 0, false) - INT_H_SIZE) / 152d2f394dcSParthasarathy Bhuvaragan ITEM_SIZE) * ITEM_SIZE; 153d2f394dcSParthasarathy Bhuvaragan u32 msg_rem = msg_dsz; 154cad2929dSHoang Huu Le struct tipc_msg *hdr; 155e11aa059SAllan Stephens 156988f3f16SJon Maloy list_for_each_entry(publ, pls, binding_node) { 157dbdf6d24SJon Paul Maloy /* Prepare next buffer: */ 158a6ca1094SYing Xue if (!skb) { 15934747539SYing Xue skb = named_prepare_buf(net, PUBLICATION, msg_rem, 16034747539SYing Xue dnode); 161a6ca1094SYing Xue if (!skb) { 1622cf8aa19SErik Hugne pr_warn("Bulk publication failure\n"); 163e11aa059SAllan Stephens return; 164e11aa059SAllan Stephens } 165cad2929dSHoang Huu Le hdr = buf_msg(skb); 166cad2929dSHoang Huu Le msg_set_bc_ack_invalid(hdr, true); 167cad2929dSHoang Huu Le msg_set_bulk(hdr); 168cad2929dSHoang Huu Le msg_set_non_legacy(hdr); 169cad2929dSHoang Huu Le item = (struct distr_item *)msg_data(hdr); 170e11aa059SAllan Stephens } 171dbdf6d24SJon Paul Maloy 172dbdf6d24SJon Paul Maloy /* Pack publication into message: */ 173e11aa059SAllan Stephens publ_to_item(item, publ); 174e11aa059SAllan Stephens item++; 175dbdf6d24SJon Paul Maloy msg_rem -= ITEM_SIZE; 176dbdf6d24SJon Paul Maloy 177dbdf6d24SJon Paul Maloy /* Append full buffer to list: */ 178dbdf6d24SJon Paul Maloy if (!msg_rem) { 179a6ca1094SYing Xue __skb_queue_tail(list, skb); 180a6ca1094SYing Xue skb = NULL; 1811b61e70aSYing Xue msg_rem = msg_dsz; 182e11aa059SAllan Stephens } 183e11aa059SAllan Stephens } 1841b61e70aSYing Xue if (skb) { 185cad2929dSHoang Huu Le hdr = buf_msg(skb); 186cad2929dSHoang Huu Le msg_set_size(hdr, INT_H_SIZE + (msg_dsz - msg_rem)); 1871b61e70aSYing Xue skb_trim(skb, INT_H_SIZE + (msg_dsz - msg_rem)); 1881b61e70aSYing Xue __skb_queue_tail(list, skb); 1891b61e70aSYing Xue } 190cad2929dSHoang Huu Le hdr = buf_msg(skb_peek_tail(list)); 191cad2929dSHoang Huu Le msg_set_last_bulk(hdr); 192cad2929dSHoang Huu Le msg_set_named_seqno(hdr, seqno); 193e11aa059SAllan Stephens } 194e11aa059SAllan Stephens 195b97bf3fdSPer Liden /** 1964323add6SPer Liden * tipc_named_node_up - tell specified node about all publications by this node 197b97bf3fdSPer Liden */ 198cad2929dSHoang Huu Le void tipc_named_node_up(struct net *net, u32 dnode, u16 capabilities) 199b97bf3fdSPer Liden { 20064a52b26SJon Maloy struct name_table *nt = tipc_name_table(net); 201cad2929dSHoang Huu Le struct tipc_net *tn = tipc_net(net); 202a6ca1094SYing Xue struct sk_buff_head head; 203cad2929dSHoang Huu Le u16 seqno; 204a6ca1094SYing Xue 205e654f9f5SJon Maloy __skb_queue_head_init(&head); 206cad2929dSHoang Huu Le spin_lock_bh(&tn->nametbl_lock); 207cad2929dSHoang Huu Le if (!(capabilities & TIPC_NAMED_BCAST)) 208cad2929dSHoang Huu Le nt->rc_dests++; 209cad2929dSHoang Huu Le seqno = nt->snd_nxt; 210cad2929dSHoang Huu Le spin_unlock_bh(&tn->nametbl_lock); 2119aa88c2aSAllan Stephens 212988f3f16SJon Maloy read_lock_bh(&nt->cluster_scope_lock); 213cad2929dSHoang Huu Le named_distribute(net, &head, dnode, &nt->cluster_scope, seqno); 214c49a0a84SJon Paul Maloy tipc_node_xmit(net, &head, dnode, 0); 215988f3f16SJon Maloy read_unlock_bh(&nt->cluster_scope_lock); 216b97bf3fdSPer Liden } 217b97bf3fdSPer Liden 218b97bf3fdSPer Liden /** 219a8f48af5SYing Xue * tipc_publ_purge - remove publication associated with a failed node 220b97bf3fdSPer Liden * 221b97bf3fdSPer Liden * Invoked for each publication issued by a newly failed node. 222b97bf3fdSPer Liden * Removes publication structure from name table & deletes it. 223b97bf3fdSPer Liden */ 224f2f9800dSYing Xue static void tipc_publ_purge(struct net *net, struct publication *publ, u32 addr) 225b97bf3fdSPer Liden { 22637922ea4SJon Maloy struct tipc_net *tn = tipc_net(net); 227b97bf3fdSPer Liden struct publication *p; 228f131072cSAllan Stephens 2294ac1c8d0SYing Xue spin_lock_bh(&tn->nametbl_lock); 23037922ea4SJon Maloy p = tipc_nametbl_remove_publ(net, publ->type, publ->lower, publ->upper, 23137922ea4SJon Maloy publ->node, publ->key); 232431697ebSAllan Stephens if (p) 233935439ccSJon Maloy tipc_node_unsubscribe(net, &p->binding_node, addr); 2344ac1c8d0SYing Xue spin_unlock_bh(&tn->nametbl_lock); 235f131072cSAllan Stephens 236f131072cSAllan Stephens if (p != publ) { 2372cf8aa19SErik Hugne pr_err("Unable to remove publication from failed node\n" 238e50e73e1SJon Maloy " (type=%u, lower=%u, node=0x%x, port=%u, key=%u)\n", 239e50e73e1SJon Maloy publ->type, publ->lower, publ->node, publ->port, 2402cf8aa19SErik Hugne publ->key); 241f131072cSAllan Stephens } 242f131072cSAllan Stephens 24342dec1dbSXin Long if (p) 24497ede29eSYing Xue kfree_rcu(p, rcu); 245f131072cSAllan Stephens } 246b97bf3fdSPer Liden 247ddb1d339SErik Hugne /** 248ddb1d339SErik Hugne * tipc_dist_queue_purge - remove deferred updates from a node that went down 249ddb1d339SErik Hugne */ 250ddb1d339SErik Hugne static void tipc_dist_queue_purge(struct net *net, u32 addr) 251ddb1d339SErik Hugne { 252ddb1d339SErik Hugne struct tipc_net *tn = net_generic(net, tipc_net_id); 253ddb1d339SErik Hugne struct distr_queue_item *e, *tmp; 254ddb1d339SErik Hugne 255ddb1d339SErik Hugne spin_lock_bh(&tn->nametbl_lock); 256ddb1d339SErik Hugne list_for_each_entry_safe(e, tmp, &tn->dist_queue, next) { 257ddb1d339SErik Hugne if (e->node != addr) 258ddb1d339SErik Hugne continue; 259ddb1d339SErik Hugne list_del(&e->next); 260ddb1d339SErik Hugne kfree(e); 261ddb1d339SErik Hugne } 262ddb1d339SErik Hugne spin_unlock_bh(&tn->nametbl_lock); 263ddb1d339SErik Hugne } 264ddb1d339SErik Hugne 265cad2929dSHoang Huu Le void tipc_publ_notify(struct net *net, struct list_head *nsub_list, 266cad2929dSHoang Huu Le u32 addr, u16 capabilities) 267a8f48af5SYing Xue { 268cad2929dSHoang Huu Le struct name_table *nt = tipc_name_table(net); 269cad2929dSHoang Huu Le struct tipc_net *tn = tipc_net(net); 270cad2929dSHoang Huu Le 271a8f48af5SYing Xue struct publication *publ, *tmp; 272a8f48af5SYing Xue 273935439ccSJon Maloy list_for_each_entry_safe(publ, tmp, nsub_list, binding_node) 274f2f9800dSYing Xue tipc_publ_purge(net, publ, addr); 275ddb1d339SErik Hugne tipc_dist_queue_purge(net, addr); 276cad2929dSHoang Huu Le spin_lock_bh(&tn->nametbl_lock); 277cad2929dSHoang Huu Le if (!(capabilities & TIPC_NAMED_BCAST)) 278cad2929dSHoang Huu Le nt->rc_dests--; 279cad2929dSHoang Huu Le spin_unlock_bh(&tn->nametbl_lock); 280a8f48af5SYing Xue } 281a8f48af5SYing Xue 282b97bf3fdSPer Liden /** 283f4ad8a4bSErik Hugne * tipc_update_nametbl - try to process a nametable update and notify 284f4ad8a4bSErik Hugne * subscribers 285f4ad8a4bSErik Hugne * 286f4ad8a4bSErik Hugne * tipc_nametbl_lock must be held. 287f4ad8a4bSErik Hugne * Returns the publication item if successful, otherwise NULL. 288f4ad8a4bSErik Hugne */ 289f2f9800dSYing Xue static bool tipc_update_nametbl(struct net *net, struct distr_item *i, 290f2f9800dSYing Xue u32 node, u32 dtype) 291f4ad8a4bSErik Hugne { 29237922ea4SJon Maloy struct publication *p = NULL; 29337922ea4SJon Maloy u32 lower = ntohl(i->lower); 29437922ea4SJon Maloy u32 upper = ntohl(i->upper); 29537922ea4SJon Maloy u32 type = ntohl(i->type); 29637922ea4SJon Maloy u32 port = ntohl(i->port); 29737922ea4SJon Maloy u32 key = ntohl(i->key); 298f4ad8a4bSErik Hugne 299f4ad8a4bSErik Hugne if (dtype == PUBLICATION) { 30037922ea4SJon Maloy p = tipc_nametbl_insert_publ(net, type, lower, upper, 301f4ad8a4bSErik Hugne TIPC_CLUSTER_SCOPE, node, 30237922ea4SJon Maloy port, key); 30337922ea4SJon Maloy if (p) { 30437922ea4SJon Maloy tipc_node_subscribe(net, &p->binding_node, node); 3050fc4dffaSErik Hugne return true; 306f4ad8a4bSErik Hugne } 307f4ad8a4bSErik Hugne } else if (dtype == WITHDRAWAL) { 30837922ea4SJon Maloy p = tipc_nametbl_remove_publ(net, type, lower, 30937922ea4SJon Maloy upper, node, key); 31037922ea4SJon Maloy if (p) { 31137922ea4SJon Maloy tipc_node_unsubscribe(net, &p->binding_node, node); 31237922ea4SJon Maloy kfree_rcu(p, rcu); 3130fc4dffaSErik Hugne return true; 314f4ad8a4bSErik Hugne } 31537922ea4SJon Maloy pr_warn_ratelimited("Failed to remove binding %u,%u from %x\n", 31637922ea4SJon Maloy type, lower, node); 317f4ad8a4bSErik Hugne } else { 318f4ad8a4bSErik Hugne pr_warn("Unrecognized name table message received\n"); 319f4ad8a4bSErik Hugne } 3200fc4dffaSErik Hugne return false; 321f4ad8a4bSErik Hugne } 322f4ad8a4bSErik Hugne 323cad2929dSHoang Huu Le static struct sk_buff *tipc_named_dequeue(struct sk_buff_head *namedq, 324cad2929dSHoang Huu Le u16 *rcv_nxt, bool *open) 325cad2929dSHoang Huu Le { 326cad2929dSHoang Huu Le struct sk_buff *skb, *tmp; 327cad2929dSHoang Huu Le struct tipc_msg *hdr; 328cad2929dSHoang Huu Le u16 seqno; 329cad2929dSHoang Huu Le 330*7b50ee3dSHoang Huu Le spin_lock_bh(&namedq->lock); 331cad2929dSHoang Huu Le skb_queue_walk_safe(namedq, skb, tmp) { 332*7b50ee3dSHoang Huu Le if (unlikely(skb_linearize(skb))) { 333*7b50ee3dSHoang Huu Le __skb_unlink(skb, namedq); 334*7b50ee3dSHoang Huu Le kfree_skb(skb); 335*7b50ee3dSHoang Huu Le continue; 336*7b50ee3dSHoang Huu Le } 337cad2929dSHoang Huu Le hdr = buf_msg(skb); 338cad2929dSHoang Huu Le seqno = msg_named_seqno(hdr); 339cad2929dSHoang Huu Le if (msg_is_last_bulk(hdr)) { 340cad2929dSHoang Huu Le *rcv_nxt = seqno; 341cad2929dSHoang Huu Le *open = true; 342cad2929dSHoang Huu Le } 343cad2929dSHoang Huu Le 344cad2929dSHoang Huu Le if (msg_is_bulk(hdr) || msg_is_legacy(hdr)) { 345cad2929dSHoang Huu Le __skb_unlink(skb, namedq); 346*7b50ee3dSHoang Huu Le spin_unlock_bh(&namedq->lock); 347cad2929dSHoang Huu Le return skb; 348cad2929dSHoang Huu Le } 349cad2929dSHoang Huu Le 350cad2929dSHoang Huu Le if (*open && (*rcv_nxt == seqno)) { 351cad2929dSHoang Huu Le (*rcv_nxt)++; 352cad2929dSHoang Huu Le __skb_unlink(skb, namedq); 353*7b50ee3dSHoang Huu Le spin_unlock_bh(&namedq->lock); 354cad2929dSHoang Huu Le return skb; 355cad2929dSHoang Huu Le } 356cad2929dSHoang Huu Le 357cad2929dSHoang Huu Le if (less(seqno, *rcv_nxt)) { 358cad2929dSHoang Huu Le __skb_unlink(skb, namedq); 359cad2929dSHoang Huu Le kfree_skb(skb); 360cad2929dSHoang Huu Le continue; 361cad2929dSHoang Huu Le } 362cad2929dSHoang Huu Le } 363*7b50ee3dSHoang Huu Le spin_unlock_bh(&namedq->lock); 364cad2929dSHoang Huu Le return NULL; 365cad2929dSHoang Huu Le } 366cad2929dSHoang Huu Le 367f4ad8a4bSErik Hugne /** 368c637c103SJon Paul Maloy * tipc_named_rcv - process name table update messages sent by another node 369b97bf3fdSPer Liden */ 370cad2929dSHoang Huu Le void tipc_named_rcv(struct net *net, struct sk_buff_head *namedq, 371cad2929dSHoang Huu Le u16 *rcv_nxt, bool *open) 372b97bf3fdSPer Liden { 373cad2929dSHoang Huu Le struct tipc_net *tn = tipc_net(net); 374c637c103SJon Paul Maloy struct distr_item *item; 375cad2929dSHoang Huu Le struct tipc_msg *hdr; 376c637c103SJon Paul Maloy struct sk_buff *skb; 377cad2929dSHoang Huu Le u32 count, node; 378b97bf3fdSPer Liden 3794ac1c8d0SYing Xue spin_lock_bh(&tn->nametbl_lock); 380cad2929dSHoang Huu Le while ((skb = tipc_named_dequeue(namedq, rcv_nxt, open))) { 381cad2929dSHoang Huu Le hdr = buf_msg(skb); 382cad2929dSHoang Huu Le node = msg_orignode(hdr); 383cad2929dSHoang Huu Le item = (struct distr_item *)msg_data(hdr); 384cad2929dSHoang Huu Le count = msg_data_sz(hdr) / ITEM_SIZE; 385b97bf3fdSPer Liden while (count--) { 386cad2929dSHoang Huu Le tipc_update_nametbl(net, item, node, msg_type(hdr)); 387b97bf3fdSPer Liden item++; 388b97bf3fdSPer Liden } 389c637c103SJon Paul Maloy kfree_skb(skb); 390c637c103SJon Paul Maloy } 3914ac1c8d0SYing Xue spin_unlock_bh(&tn->nametbl_lock); 392b97bf3fdSPer Liden } 393b97bf3fdSPer Liden 394b97bf3fdSPer Liden /** 3951110b8d3SAllan Stephens * tipc_named_reinit - re-initialize local publications 396b97bf3fdSPer Liden * 397945af1c3SAllan Stephens * This routine is called whenever TIPC networking is enabled. 3981110b8d3SAllan Stephens * All name table entries published by this node are updated to reflect 3991110b8d3SAllan Stephens * the node's new network address. 400b97bf3fdSPer Liden */ 4014ac1c8d0SYing Xue void tipc_named_reinit(struct net *net) 402b97bf3fdSPer Liden { 40364a52b26SJon Maloy struct name_table *nt = tipc_name_table(net); 40464a52b26SJon Maloy struct tipc_net *tn = tipc_net(net); 405b97bf3fdSPer Liden struct publication *publ; 40623fd3eacSJon Maloy u32 self = tipc_own_addr(net); 407b97bf3fdSPer Liden 4084ac1c8d0SYing Xue spin_lock_bh(&tn->nametbl_lock); 409945af1c3SAllan Stephens 410935439ccSJon Maloy list_for_each_entry_rcu(publ, &nt->node_scope, binding_node) 41123fd3eacSJon Maloy publ->node = self; 412935439ccSJon Maloy list_for_each_entry_rcu(publ, &nt->cluster_scope, binding_node) 41323fd3eacSJon Maloy publ->node = self; 414cad2929dSHoang Huu Le nt->rc_dests = 0; 4154ac1c8d0SYing Xue spin_unlock_bh(&tn->nametbl_lock); 416b97bf3fdSPer Liden } 417