Commit 38077b8e authored by Jon Maloy's avatar Jon Maloy Committed by David S. Miller

tipc: add ability to obtain node availability status from other files

In the coming commits, functions at the socket level will need the
ability to read the availability status of a given node. We therefore
introduce a new function for this purpose, while renaming the existing
static function currently having the wanted name.
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 23998835
...@@ -157,7 +157,7 @@ static void tipc_node_timeout(unsigned long data); ...@@ -157,7 +157,7 @@ static void tipc_node_timeout(unsigned long data);
static void tipc_node_fsm_evt(struct tipc_node *n, int evt); static void tipc_node_fsm_evt(struct tipc_node *n, int evt);
static struct tipc_node *tipc_node_find(struct net *net, u32 addr); static struct tipc_node *tipc_node_find(struct net *net, u32 addr);
static void tipc_node_put(struct tipc_node *node); static void tipc_node_put(struct tipc_node *node);
static bool tipc_node_is_up(struct tipc_node *n); static bool node_is_up(struct tipc_node *n);
struct tipc_sock_conn { struct tipc_sock_conn {
u32 port; u32 port;
...@@ -657,7 +657,7 @@ static void __tipc_node_link_down(struct tipc_node *n, int *bearer_id, ...@@ -657,7 +657,7 @@ static void __tipc_node_link_down(struct tipc_node *n, int *bearer_id,
*slot1 = i; *slot1 = i;
} }
if (!tipc_node_is_up(n)) { if (!node_is_up(n)) {
if (tipc_link_peer_is_down(l)) if (tipc_link_peer_is_down(l))
tipc_node_fsm_evt(n, PEER_LOST_CONTACT_EVT); tipc_node_fsm_evt(n, PEER_LOST_CONTACT_EVT);
tipc_node_fsm_evt(n, SELF_LOST_CONTACT_EVT); tipc_node_fsm_evt(n, SELF_LOST_CONTACT_EVT);
...@@ -717,11 +717,27 @@ static void tipc_node_link_down(struct tipc_node *n, int bearer_id, bool delete) ...@@ -717,11 +717,27 @@ static void tipc_node_link_down(struct tipc_node *n, int bearer_id, bool delete)
tipc_sk_rcv(n->net, &le->inputq); tipc_sk_rcv(n->net, &le->inputq);
} }
static bool tipc_node_is_up(struct tipc_node *n) static bool node_is_up(struct tipc_node *n)
{ {
return n->active_links[0] != INVALID_BEARER_ID; return n->active_links[0] != INVALID_BEARER_ID;
} }
bool tipc_node_is_up(struct net *net, u32 addr)
{
struct tipc_node *n;
bool retval = false;
if (in_own_node(net, addr))
return true;
n = tipc_node_find(net, addr);
if (!n)
return false;
retval = node_is_up(n);
tipc_node_put(n);
return retval;
}
void tipc_node_check_dest(struct net *net, u32 onode, void tipc_node_check_dest(struct net *net, u32 onode,
struct tipc_bearer *b, struct tipc_bearer *b,
u16 capabilities, u32 signature, u16 capabilities, u32 signature,
...@@ -1149,7 +1165,7 @@ static int __tipc_nl_add_node(struct tipc_nl_msg *msg, struct tipc_node *node) ...@@ -1149,7 +1165,7 @@ static int __tipc_nl_add_node(struct tipc_nl_msg *msg, struct tipc_node *node)
if (nla_put_u32(msg->skb, TIPC_NLA_NODE_ADDR, node->addr)) if (nla_put_u32(msg->skb, TIPC_NLA_NODE_ADDR, node->addr))
goto attr_msg_full; goto attr_msg_full;
if (tipc_node_is_up(node)) if (node_is_up(node))
if (nla_put_flag(msg->skb, TIPC_NLA_NODE_UP)) if (nla_put_flag(msg->skb, TIPC_NLA_NODE_UP))
goto attr_msg_full; goto attr_msg_full;
...@@ -1249,7 +1265,7 @@ void tipc_node_broadcast(struct net *net, struct sk_buff *skb) ...@@ -1249,7 +1265,7 @@ void tipc_node_broadcast(struct net *net, struct sk_buff *skb)
dst = n->addr; dst = n->addr;
if (in_own_node(net, dst)) if (in_own_node(net, dst))
continue; continue;
if (!tipc_node_is_up(n)) if (!node_is_up(n))
continue; continue;
txskb = pskb_copy(skb, GFP_ATOMIC); txskb = pskb_copy(skb, GFP_ATOMIC);
if (!txskb) if (!txskb)
......
...@@ -76,6 +76,7 @@ void tipc_node_broadcast(struct net *net, struct sk_buff *skb); ...@@ -76,6 +76,7 @@ void tipc_node_broadcast(struct net *net, struct sk_buff *skb);
int tipc_node_add_conn(struct net *net, u32 dnode, u32 port, u32 peer_port); int tipc_node_add_conn(struct net *net, u32 dnode, u32 port, u32 peer_port);
void tipc_node_remove_conn(struct net *net, u32 dnode, u32 port); void tipc_node_remove_conn(struct net *net, u32 dnode, u32 port);
int tipc_node_get_mtu(struct net *net, u32 addr, u32 sel); int tipc_node_get_mtu(struct net *net, u32 addr, u32 sel);
bool tipc_node_is_up(struct net *net, u32 addr);
u16 tipc_node_get_capabilities(struct net *net, u32 addr); u16 tipc_node_get_capabilities(struct net *net, u32 addr);
int tipc_nl_node_dump(struct sk_buff *skb, struct netlink_callback *cb); int tipc_nl_node_dump(struct sk_buff *skb, struct netlink_callback *cb);
int tipc_nl_node_dump_link(struct sk_buff *skb, struct netlink_callback *cb); int tipc_nl_node_dump_link(struct sk_buff *skb, struct netlink_callback *cb);
......
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