name_distr.c (a02001086bbfb4da35d1228bebc2f1b442db455f) | name_distr.c (a8f48af587b0f257c49dce5b49a62554a4b8627e) |
---|---|
1/* 2 * net/tipc/name_distr.c: TIPC name distribution code 3 * 4 * Copyright (c) 2000-2006, 2014, Ericsson AB 5 * Copyright (c) 2005, 2010-2011, Wind River Systems 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 236 unchanged lines hidden (view full) --- 245 read_unlock_bh(&tipc_nametbl_lock); 246 247 /* Convert circular list to linear list and send: */ 248 buf_chain = (struct sk_buff *)msg_list.next; 249 ((struct sk_buff *)msg_list.prev)->next = NULL; 250 tipc_link_xmit(buf_chain, dnode, dnode); 251} 252 | 1/* 2 * net/tipc/name_distr.c: TIPC name distribution code 3 * 4 * Copyright (c) 2000-2006, 2014, Ericsson AB 5 * Copyright (c) 2005, 2010-2011, Wind River Systems 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 236 unchanged lines hidden (view full) --- 245 read_unlock_bh(&tipc_nametbl_lock); 246 247 /* Convert circular list to linear list and send: */ 248 buf_chain = (struct sk_buff *)msg_list.next; 249 ((struct sk_buff *)msg_list.prev)->next = NULL; 250 tipc_link_xmit(buf_chain, dnode, dnode); 251} 252 |
253static void tipc_publ_subscribe(struct publication *publ, u32 addr) 254{ 255 struct tipc_node *node; 256 257 if (in_own_node(addr)) 258 return; 259 260 node = tipc_node_find(addr); 261 if (!node) { 262 pr_warn("Node subscription rejected, unknown node 0x%x\n", 263 addr); 264 return; 265 } 266 267 tipc_node_lock(node); 268 list_add_tail(&publ->nodesub_list, &node->publ_list); 269 tipc_node_unlock(node); 270} 271 272static void tipc_publ_unsubscribe(struct publication *publ, u32 addr) 273{ 274 struct tipc_node *node; 275 276 node = tipc_node_find(addr); 277 if (!node) 278 return; 279 280 tipc_node_lock(node); 281 list_del_init(&publ->nodesub_list); 282 tipc_node_unlock(node); 283} 284 |
|
253/** | 285/** |
254 * named_purge_publ - remove publication associated with a failed node | 286 * tipc_publ_purge - remove publication associated with a failed node |
255 * 256 * Invoked for each publication issued by a newly failed node. 257 * Removes publication structure from name table & deletes it. 258 */ | 287 * 288 * Invoked for each publication issued by a newly failed node. 289 * Removes publication structure from name table & deletes it. 290 */ |
259static void named_purge_publ(struct publication *publ) | 291static void tipc_publ_purge(struct publication *publ, u32 addr) |
260{ 261 struct publication *p; 262 263 write_lock_bh(&tipc_nametbl_lock); 264 p = tipc_nametbl_remove_publ(publ->type, publ->lower, 265 publ->node, publ->ref, publ->key); 266 if (p) | 292{ 293 struct publication *p; 294 295 write_lock_bh(&tipc_nametbl_lock); 296 p = tipc_nametbl_remove_publ(publ->type, publ->lower, 297 publ->node, publ->ref, publ->key); 298 if (p) |
267 tipc_nodesub_unsubscribe(&p->subscr); | 299 tipc_publ_unsubscribe(p, addr); |
268 write_unlock_bh(&tipc_nametbl_lock); 269 270 if (p != publ) { 271 pr_err("Unable to remove publication from failed node\n" 272 " (type=%u, lower=%u, node=0x%x, ref=%u, key=%u)\n", 273 publ->type, publ->lower, publ->node, publ->ref, 274 publ->key); 275 } 276 277 kfree(p); 278} 279 | 300 write_unlock_bh(&tipc_nametbl_lock); 301 302 if (p != publ) { 303 pr_err("Unable to remove publication from failed node\n" 304 " (type=%u, lower=%u, node=0x%x, ref=%u, key=%u)\n", 305 publ->type, publ->lower, publ->node, publ->ref, 306 publ->key); 307 } 308 309 kfree(p); 310} 311 |
312void tipc_publ_notify(struct list_head *nsub_list, u32 addr) 313{ 314 struct publication *publ, *tmp; 315 316 list_for_each_entry_safe(publ, tmp, nsub_list, nodesub_list) 317 tipc_publ_purge(publ, addr); 318} 319 |
|
280/** 281 * tipc_update_nametbl - try to process a nametable update and notify 282 * subscribers 283 * 284 * tipc_nametbl_lock must be held. 285 * Returns the publication item if successful, otherwise NULL. 286 */ 287static bool tipc_update_nametbl(struct distr_item *i, u32 node, u32 dtype) 288{ 289 struct publication *publ = NULL; 290 291 if (dtype == PUBLICATION) { 292 publ = tipc_nametbl_insert_publ(ntohl(i->type), ntohl(i->lower), 293 ntohl(i->upper), 294 TIPC_CLUSTER_SCOPE, node, 295 ntohl(i->ref), ntohl(i->key)); 296 if (publ) { | 320/** 321 * tipc_update_nametbl - try to process a nametable update and notify 322 * subscribers 323 * 324 * tipc_nametbl_lock must be held. 325 * Returns the publication item if successful, otherwise NULL. 326 */ 327static bool tipc_update_nametbl(struct distr_item *i, u32 node, u32 dtype) 328{ 329 struct publication *publ = NULL; 330 331 if (dtype == PUBLICATION) { 332 publ = tipc_nametbl_insert_publ(ntohl(i->type), ntohl(i->lower), 333 ntohl(i->upper), 334 TIPC_CLUSTER_SCOPE, node, 335 ntohl(i->ref), ntohl(i->key)); 336 if (publ) { |
297 tipc_nodesub_subscribe(&publ->subscr, node, publ, 298 (net_ev_handler) 299 named_purge_publ); | 337 tipc_publ_subscribe(publ, node); |
300 return true; 301 } 302 } else if (dtype == WITHDRAWAL) { 303 publ = tipc_nametbl_remove_publ(ntohl(i->type), ntohl(i->lower), 304 node, ntohl(i->ref), 305 ntohl(i->key)); 306 if (publ) { | 338 return true; 339 } 340 } else if (dtype == WITHDRAWAL) { 341 publ = tipc_nametbl_remove_publ(ntohl(i->type), ntohl(i->lower), 342 node, ntohl(i->ref), 343 ntohl(i->key)); 344 if (publ) { |
307 tipc_nodesub_unsubscribe(&publ->subscr); | 345 tipc_publ_unsubscribe(publ, node); |
308 kfree(publ); 309 return true; 310 } 311 } else { 312 pr_warn("Unrecognized name table message received\n"); 313 } 314 return false; 315} --- 88 unchanged lines hidden --- | 346 kfree(publ); 347 return true; 348 } 349 } else { 350 pr_warn("Unrecognized name table message received\n"); 351 } 352 return false; 353} --- 88 unchanged lines hidden --- |