aboutsummaryrefslogtreecommitdiff
path: root/net/tipc/node_subscr.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/tipc/node_subscr.c')
-rw-r--r--net/tipc/node_subscr.c47
1 files changed, 31 insertions, 16 deletions
diff --git a/net/tipc/node_subscr.c b/net/tipc/node_subscr.c
index afeea121d8b..7c59ab1d6ec 100644
--- a/net/tipc/node_subscr.c
+++ b/net/tipc/node_subscr.c
@@ -1,8 +1,8 @@
/*
* net/tipc/node_subscr.c: TIPC "node down" subscription handling
- *
+ *
* Copyright (c) 1995-2006, Ericsson AB
- * Copyright (c) 2005, Wind River Systems
+ * Copyright (c) 2005, 2010-2011, Wind River Systems
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -35,30 +35,29 @@
*/
#include "core.h"
-#include "dbg.h"
#include "node_subscr.h"
#include "node.h"
-#include "addr.h"
/**
* tipc_nodesub_subscribe - create "node down" subscription for specified node
*/
-
-void tipc_nodesub_subscribe(struct node_subscr *node_sub, u32 addr,
- void *usr_handle, net_ev_handler handle_down)
+void tipc_nodesub_subscribe(struct tipc_node_subscr *node_sub, u32 addr,
+ void *usr_handle, net_ev_handler handle_down)
{
- node_sub->node = 0;
- if (addr == tipc_own_addr)
- return;
- if (!tipc_addr_node_valid(addr)) {
- warn("node_subscr with illegal %x\n", addr);
+ if (in_own_node(addr)) {
+ node_sub->node = NULL;
return;
}
+ node_sub->node = tipc_node_find(addr);
+ if (!node_sub->node) {
+ pr_warn("Node subscription rejected, unknown node 0x%x\n",
+ addr);
+ return;
+ }
node_sub->handle_node_down = handle_down;
node_sub->usr_handle = usr_handle;
- node_sub->node = tipc_node_find(addr);
- assert(node_sub->node);
+
tipc_node_lock(node_sub->node);
list_add_tail(&node_sub->nodesub_list, &node_sub->node->nsub);
tipc_node_unlock(node_sub->node);
@@ -67,8 +66,7 @@ void tipc_nodesub_subscribe(struct node_subscr *node_sub, u32 addr,
/**
* tipc_nodesub_unsubscribe - cancel "node down" subscription (if any)
*/
-
-void tipc_nodesub_unsubscribe(struct node_subscr *node_sub)
+void tipc_nodesub_unsubscribe(struct tipc_node_subscr *node_sub)
{
if (!node_sub->node)
return;
@@ -77,3 +75,20 @@ void tipc_nodesub_unsubscribe(struct node_subscr *node_sub)
list_del_init(&node_sub->nodesub_list);
tipc_node_unlock(node_sub->node);
}
+
+/**
+ * tipc_nodesub_notify - notify subscribers that a node is unreachable
+ *
+ * Note: node is locked by caller
+ */
+void tipc_nodesub_notify(struct list_head *nsub_list)
+{
+ struct tipc_node_subscr *ns, *safe;
+
+ list_for_each_entry_safe(ns, safe, nsub_list, nodesub_list) {
+ if (ns->handle_node_down) {
+ ns->handle_node_down(ns->usr_handle);
+ ns->handle_node_down = NULL;
+ }
+ }
+}