diff options
author | Jon Maloy <jon.maloy@ericsson.com> | 2017-10-13 05:04:19 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-10-13 11:46:00 -0400 |
commit | 38077b8ef831daba55913f7e24732b062d0bdebb (patch) | |
tree | 4978469c4e0187b6b535f917a1190e68f5b94b1e /net/tipc | |
parent | 23998835be98a6842e5698fa1824f404c7de850d (diff) |
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: 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/node.c | 26 | ||||
-rw-r--r-- | net/tipc/node.h | 1 |
2 files changed, 22 insertions, 5 deletions
diff --git a/net/tipc/node.c b/net/tipc/node.c index 198dbc7adbe1..6cc1ae600820 100644 --- a/net/tipc/node.c +++ b/net/tipc/node.c | |||
@@ -157,7 +157,7 @@ static void tipc_node_timeout(unsigned long data); | |||
157 | static void tipc_node_fsm_evt(struct tipc_node *n, int evt); | 157 | static void tipc_node_fsm_evt(struct tipc_node *n, int evt); |
158 | static struct tipc_node *tipc_node_find(struct net *net, u32 addr); | 158 | static struct tipc_node *tipc_node_find(struct net *net, u32 addr); |
159 | static void tipc_node_put(struct tipc_node *node); | 159 | static void tipc_node_put(struct tipc_node *node); |
160 | static bool tipc_node_is_up(struct tipc_node *n); | 160 | static bool node_is_up(struct tipc_node *n); |
161 | 161 | ||
162 | struct tipc_sock_conn { | 162 | struct tipc_sock_conn { |
163 | u32 port; | 163 | u32 port; |
@@ -657,7 +657,7 @@ static void __tipc_node_link_down(struct tipc_node *n, int *bearer_id, | |||
657 | *slot1 = i; | 657 | *slot1 = i; |
658 | } | 658 | } |
659 | 659 | ||
660 | if (!tipc_node_is_up(n)) { | 660 | if (!node_is_up(n)) { |
661 | if (tipc_link_peer_is_down(l)) | 661 | if (tipc_link_peer_is_down(l)) |
662 | tipc_node_fsm_evt(n, PEER_LOST_CONTACT_EVT); | 662 | tipc_node_fsm_evt(n, PEER_LOST_CONTACT_EVT); |
663 | tipc_node_fsm_evt(n, SELF_LOST_CONTACT_EVT); | 663 | 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 | tipc_sk_rcv(n->net, &le->inputq); | 717 | tipc_sk_rcv(n->net, &le->inputq); |
718 | } | 718 | } |
719 | 719 | ||
720 | static bool tipc_node_is_up(struct tipc_node *n) | 720 | static bool node_is_up(struct tipc_node *n) |
721 | { | 721 | { |
722 | return n->active_links[0] != INVALID_BEARER_ID; | 722 | return n->active_links[0] != INVALID_BEARER_ID; |
723 | } | 723 | } |
724 | 724 | ||
725 | bool tipc_node_is_up(struct net *net, u32 addr) | ||
726 | { | ||
727 | struct tipc_node *n; | ||
728 | bool retval = false; | ||
729 | |||
730 | if (in_own_node(net, addr)) | ||
731 | return true; | ||
732 | |||
733 | n = tipc_node_find(net, addr); | ||
734 | if (!n) | ||
735 | return false; | ||
736 | retval = node_is_up(n); | ||
737 | tipc_node_put(n); | ||
738 | return retval; | ||
739 | } | ||
740 | |||
725 | void tipc_node_check_dest(struct net *net, u32 onode, | 741 | void tipc_node_check_dest(struct net *net, u32 onode, |
726 | struct tipc_bearer *b, | 742 | struct tipc_bearer *b, |
727 | u16 capabilities, u32 signature, | 743 | u16 capabilities, u32 signature, |
@@ -1149,7 +1165,7 @@ static int __tipc_nl_add_node(struct tipc_nl_msg *msg, struct tipc_node *node) | |||
1149 | 1165 | ||
1150 | if (nla_put_u32(msg->skb, TIPC_NLA_NODE_ADDR, node->addr)) | 1166 | if (nla_put_u32(msg->skb, TIPC_NLA_NODE_ADDR, node->addr)) |
1151 | goto attr_msg_full; | 1167 | goto attr_msg_full; |
1152 | if (tipc_node_is_up(node)) | 1168 | if (node_is_up(node)) |
1153 | if (nla_put_flag(msg->skb, TIPC_NLA_NODE_UP)) | 1169 | if (nla_put_flag(msg->skb, TIPC_NLA_NODE_UP)) |
1154 | goto attr_msg_full; | 1170 | goto attr_msg_full; |
1155 | 1171 | ||
@@ -1249,7 +1265,7 @@ void tipc_node_broadcast(struct net *net, struct sk_buff *skb) | |||
1249 | dst = n->addr; | 1265 | dst = n->addr; |
1250 | if (in_own_node(net, dst)) | 1266 | if (in_own_node(net, dst)) |
1251 | continue; | 1267 | continue; |
1252 | if (!tipc_node_is_up(n)) | 1268 | if (!node_is_up(n)) |
1253 | continue; | 1269 | continue; |
1254 | txskb = pskb_copy(skb, GFP_ATOMIC); | 1270 | txskb = pskb_copy(skb, GFP_ATOMIC); |
1255 | if (!txskb) | 1271 | if (!txskb) |
diff --git a/net/tipc/node.h b/net/tipc/node.h index 898c22916984..8db59feb122f 100644 --- a/net/tipc/node.h +++ b/net/tipc/node.h | |||
@@ -76,6 +76,7 @@ void tipc_node_broadcast(struct net *net, struct sk_buff *skb); | |||
76 | int tipc_node_add_conn(struct net *net, u32 dnode, u32 port, u32 peer_port); | 76 | int tipc_node_add_conn(struct net *net, u32 dnode, u32 port, u32 peer_port); |
77 | void tipc_node_remove_conn(struct net *net, u32 dnode, u32 port); | 77 | void tipc_node_remove_conn(struct net *net, u32 dnode, u32 port); |
78 | int tipc_node_get_mtu(struct net *net, u32 addr, u32 sel); | 78 | int tipc_node_get_mtu(struct net *net, u32 addr, u32 sel); |
79 | bool tipc_node_is_up(struct net *net, u32 addr); | ||
79 | u16 tipc_node_get_capabilities(struct net *net, u32 addr); | 80 | u16 tipc_node_get_capabilities(struct net *net, u32 addr); |
80 | int tipc_nl_node_dump(struct sk_buff *skb, struct netlink_callback *cb); | 81 | int tipc_nl_node_dump(struct sk_buff *skb, struct netlink_callback *cb); |
81 | int tipc_nl_node_dump_link(struct sk_buff *skb, struct netlink_callback *cb); | 82 | int tipc_nl_node_dump_link(struct sk_buff *skb, struct netlink_callback *cb); |