diff options
author | Erik Hugne <erik.hugne@ericsson.com> | 2014-08-28 03:08:46 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-09-01 20:51:48 -0400 |
commit | f4ad8a4b8b9f490a15c3239e0d6ac99e7e438d34 (patch) | |
tree | 3f90f7dbc3a2fe371eba723550d2197d22303481 /net/tipc | |
parent | 1764bcd9fe0fa075b3c847836b646c386f7a672b (diff) |
tipc: refactor name table updates out of named packet receive routine
We need to perform the same actions when processing deferred name
table updates, so this functionality is moved to a separate
function.
Signed-off-by: Erik Hugne <erik.hugne@ericsson.com>
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Acked-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc')
-rw-r--r-- | net/tipc/name_distr.c | 74 |
1 files changed, 38 insertions, 36 deletions
diff --git a/net/tipc/name_distr.c b/net/tipc/name_distr.c index dcc15bcd5692..0591f33b8384 100644 --- a/net/tipc/name_distr.c +++ b/net/tipc/name_distr.c | |||
@@ -263,52 +263,54 @@ static void named_purge_publ(struct publication *publ) | |||
263 | } | 263 | } |
264 | 264 | ||
265 | /** | 265 | /** |
266 | * tipc_update_nametbl - try to process a nametable update and notify | ||
267 | * subscribers | ||
268 | * | ||
269 | * tipc_nametbl_lock must be held. | ||
270 | * Returns the publication item if successful, otherwise NULL. | ||
271 | */ | ||
272 | struct publication *tipc_update_nametbl(struct distr_item *i, u32 node, | ||
273 | u32 dtype) | ||
274 | { | ||
275 | struct publication *publ = NULL; | ||
276 | |||
277 | if (dtype == PUBLICATION) { | ||
278 | publ = tipc_nametbl_insert_publ(ntohl(i->type), ntohl(i->lower), | ||
279 | ntohl(i->upper), | ||
280 | TIPC_CLUSTER_SCOPE, node, | ||
281 | ntohl(i->ref), ntohl(i->key)); | ||
282 | if (publ) { | ||
283 | tipc_nodesub_subscribe(&publ->subscr, node, publ, | ||
284 | (net_ev_handler) | ||
285 | named_purge_publ); | ||
286 | } | ||
287 | } else if (dtype == WITHDRAWAL) { | ||
288 | publ = tipc_nametbl_remove_publ(ntohl(i->type), ntohl(i->lower), | ||
289 | node, ntohl(i->ref), | ||
290 | ntohl(i->key)); | ||
291 | if (publ) { | ||
292 | tipc_nodesub_unsubscribe(&publ->subscr); | ||
293 | kfree(publ); | ||
294 | } | ||
295 | } else { | ||
296 | pr_warn("Unrecognized name table message received\n"); | ||
297 | } | ||
298 | return publ; | ||
299 | } | ||
300 | |||
301 | /** | ||
266 | * tipc_named_rcv - process name table update message sent by another node | 302 | * tipc_named_rcv - process name table update message sent by another node |
267 | */ | 303 | */ |
268 | void tipc_named_rcv(struct sk_buff *buf) | 304 | void tipc_named_rcv(struct sk_buff *buf) |
269 | { | 305 | { |
270 | struct publication *publ; | ||
271 | struct tipc_msg *msg = buf_msg(buf); | 306 | struct tipc_msg *msg = buf_msg(buf); |
272 | struct distr_item *item = (struct distr_item *)msg_data(msg); | 307 | struct distr_item *item = (struct distr_item *)msg_data(msg); |
273 | u32 count = msg_data_sz(msg) / ITEM_SIZE; | 308 | u32 count = msg_data_sz(msg) / ITEM_SIZE; |
274 | 309 | ||
275 | write_lock_bh(&tipc_nametbl_lock); | 310 | write_lock_bh(&tipc_nametbl_lock); |
276 | while (count--) { | 311 | while (count--) { |
277 | if (msg_type(msg) == PUBLICATION) { | 312 | tipc_update_nametbl(item, msg_orignode(msg), |
278 | publ = tipc_nametbl_insert_publ(ntohl(item->type), | 313 | msg_type(msg)); |
279 | ntohl(item->lower), | ||
280 | ntohl(item->upper), | ||
281 | TIPC_CLUSTER_SCOPE, | ||
282 | msg_orignode(msg), | ||
283 | ntohl(item->ref), | ||
284 | ntohl(item->key)); | ||
285 | if (publ) { | ||
286 | tipc_nodesub_subscribe(&publ->subscr, | ||
287 | msg_orignode(msg), | ||
288 | publ, | ||
289 | (net_ev_handler) | ||
290 | named_purge_publ); | ||
291 | } | ||
292 | } else if (msg_type(msg) == WITHDRAWAL) { | ||
293 | publ = tipc_nametbl_remove_publ(ntohl(item->type), | ||
294 | ntohl(item->lower), | ||
295 | msg_orignode(msg), | ||
296 | ntohl(item->ref), | ||
297 | ntohl(item->key)); | ||
298 | |||
299 | if (publ) { | ||
300 | tipc_nodesub_unsubscribe(&publ->subscr); | ||
301 | kfree(publ); | ||
302 | } else { | ||
303 | pr_err("Unable to remove publication by node 0x%x\n" | ||
304 | " (type=%u, lower=%u, ref=%u, key=%u)\n", | ||
305 | msg_orignode(msg), ntohl(item->type), | ||
306 | ntohl(item->lower), ntohl(item->ref), | ||
307 | ntohl(item->key)); | ||
308 | } | ||
309 | } else { | ||
310 | pr_warn("Unrecognized name table message received\n"); | ||
311 | } | ||
312 | item++; | 314 | item++; |
313 | } | 315 | } |
314 | write_unlock_bh(&tipc_nametbl_lock); | 316 | write_unlock_bh(&tipc_nametbl_lock); |