Skip to content

Commit 38077b8

Browse files
Jon Maloydavem330
authored andcommitted
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 <[email protected]> Acked-by: Ying Xue <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 2399883 commit 38077b8

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

net/tipc/node.c

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ static void tipc_node_timeout(unsigned long data);
157157
static void tipc_node_fsm_evt(struct tipc_node *n, int evt);
158158
static struct tipc_node *tipc_node_find(struct net *net, u32 addr);
159159
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);
161161

162162
struct tipc_sock_conn {
163163
u32 port;
@@ -657,7 +657,7 @@ static void __tipc_node_link_down(struct tipc_node *n, int *bearer_id,
657657
*slot1 = i;
658658
}
659659

660-
if (!tipc_node_is_up(n)) {
660+
if (!node_is_up(n)) {
661661
if (tipc_link_peer_is_down(l))
662662
tipc_node_fsm_evt(n, PEER_LOST_CONTACT_EVT);
663663
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)
717717
tipc_sk_rcv(n->net, &le->inputq);
718718
}
719719

720-
static bool tipc_node_is_up(struct tipc_node *n)
720+
static bool node_is_up(struct tipc_node *n)
721721
{
722722
return n->active_links[0] != INVALID_BEARER_ID;
723723
}
724724

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+
725741
void tipc_node_check_dest(struct net *net, u32 onode,
726742
struct tipc_bearer *b,
727743
u16 capabilities, u32 signature,
@@ -1149,7 +1165,7 @@ static int __tipc_nl_add_node(struct tipc_nl_msg *msg, struct tipc_node *node)
11491165

11501166
if (nla_put_u32(msg->skb, TIPC_NLA_NODE_ADDR, node->addr))
11511167
goto attr_msg_full;
1152-
if (tipc_node_is_up(node))
1168+
if (node_is_up(node))
11531169
if (nla_put_flag(msg->skb, TIPC_NLA_NODE_UP))
11541170
goto attr_msg_full;
11551171

@@ -1249,7 +1265,7 @@ void tipc_node_broadcast(struct net *net, struct sk_buff *skb)
12491265
dst = n->addr;
12501266
if (in_own_node(net, dst))
12511267
continue;
1252-
if (!tipc_node_is_up(n))
1268+
if (!node_is_up(n))
12531269
continue;
12541270
txskb = pskb_copy(skb, GFP_ATOMIC);
12551271
if (!txskb)

net/tipc/node.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ void tipc_node_broadcast(struct net *net, struct sk_buff *skb);
7676
int tipc_node_add_conn(struct net *net, u32 dnode, u32 port, u32 peer_port);
7777
void tipc_node_remove_conn(struct net *net, u32 dnode, u32 port);
7878
int tipc_node_get_mtu(struct net *net, u32 addr, u32 sel);
79+
bool tipc_node_is_up(struct net *net, u32 addr);
7980
u16 tipc_node_get_capabilities(struct net *net, u32 addr);
8081
int tipc_nl_node_dump(struct sk_buff *skb, struct netlink_callback *cb);
8182
int tipc_nl_node_dump_link(struct sk_buff *skb, struct netlink_callback *cb);

0 commit comments

Comments
 (0)