Commit f4ad8a4b authored by Erik Hugne's avatar Erik Hugne Committed by David S. Miller

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: default avatarErik Hugne <erik.hugne@ericsson.com>
Signed-off-by: default avatarJon Maloy <jon.maloy@ericsson.com>
Acked-by: default avatarYing Xue <ying.xue@windriver.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 1764bcd9
...@@ -263,52 +263,54 @@ static void named_purge_publ(struct publication *publ) ...@@ -263,52 +263,54 @@ static void named_purge_publ(struct publication *publ)
} }
/** /**
* tipc_named_rcv - process name table update message sent by another node * tipc_update_nametbl - try to process a nametable update and notify
* subscribers
*
* tipc_nametbl_lock must be held.
* Returns the publication item if successful, otherwise NULL.
*/ */
void tipc_named_rcv(struct sk_buff *buf) struct publication *tipc_update_nametbl(struct distr_item *i, u32 node,
u32 dtype)
{ {
struct publication *publ; struct publication *publ = NULL;
struct tipc_msg *msg = buf_msg(buf);
struct distr_item *item = (struct distr_item *)msg_data(msg);
u32 count = msg_data_sz(msg) / ITEM_SIZE;
write_lock_bh(&tipc_nametbl_lock); if (dtype == PUBLICATION) {
while (count--) { publ = tipc_nametbl_insert_publ(ntohl(i->type), ntohl(i->lower),
if (msg_type(msg) == PUBLICATION) { ntohl(i->upper),
publ = tipc_nametbl_insert_publ(ntohl(item->type), TIPC_CLUSTER_SCOPE, node,
ntohl(item->lower), ntohl(i->ref), ntohl(i->key));
ntohl(item->upper),
TIPC_CLUSTER_SCOPE,
msg_orignode(msg),
ntohl(item->ref),
ntohl(item->key));
if (publ) { if (publ) {
tipc_nodesub_subscribe(&publ->subscr, tipc_nodesub_subscribe(&publ->subscr, node, publ,
msg_orignode(msg),
publ,
(net_ev_handler) (net_ev_handler)
named_purge_publ); named_purge_publ);
} }
} else if (msg_type(msg) == WITHDRAWAL) { } else if (dtype == WITHDRAWAL) {
publ = tipc_nametbl_remove_publ(ntohl(item->type), publ = tipc_nametbl_remove_publ(ntohl(i->type), ntohl(i->lower),
ntohl(item->lower), node, ntohl(i->ref),
msg_orignode(msg), ntohl(i->key));
ntohl(item->ref),
ntohl(item->key));
if (publ) { if (publ) {
tipc_nodesub_unsubscribe(&publ->subscr); tipc_nodesub_unsubscribe(&publ->subscr);
kfree(publ); kfree(publ);
} else {
pr_err("Unable to remove publication by node 0x%x\n"
" (type=%u, lower=%u, ref=%u, key=%u)\n",
msg_orignode(msg), ntohl(item->type),
ntohl(item->lower), ntohl(item->ref),
ntohl(item->key));
} }
} else { } else {
pr_warn("Unrecognized name table message received\n"); pr_warn("Unrecognized name table message received\n");
} }
return publ;
}
/**
* tipc_named_rcv - process name table update message sent by another node
*/
void tipc_named_rcv(struct sk_buff *buf)
{
struct tipc_msg *msg = buf_msg(buf);
struct distr_item *item = (struct distr_item *)msg_data(msg);
u32 count = msg_data_sz(msg) / ITEM_SIZE;
write_lock_bh(&tipc_nametbl_lock);
while (count--) {
tipc_update_nametbl(item, msg_orignode(msg),
msg_type(msg));
item++; item++;
} }
write_unlock_bh(&tipc_nametbl_lock); write_unlock_bh(&tipc_nametbl_lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment