From: Jon Maloy <jon.maloy@ericsson.com>
To: <davem@davemloft.net>, <netdev@vger.kernel.org>
Cc: <parthasarathy.bhuvaragan@ericsson.com>, <ying.xue@windriver.com>,
<tipc-discussion@lists.sourceforge.net>
Subject: [net-next v2 03/18] tipc: add ability to obtain node availability status from other files
Date: Fri, 13 Oct 2017 11:04:19 +0200 [thread overview]
Message-ID: <1507885474-11213-4-git-send-email-jon.maloy@ericsson.com> (raw)
In-Reply-To: <1507885474-11213-1-git-send-email-jon.maloy@ericsson.com>
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>
---
net/tipc/node.c | 26 +++++++++++++++++++++-----
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 198dbc7..6cc1ae6 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -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 struct tipc_node *tipc_node_find(struct net *net, u32 addr);
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 {
u32 port;
@@ -657,7 +657,7 @@ static void __tipc_node_link_down(struct tipc_node *n, int *bearer_id,
*slot1 = i;
}
- if (!tipc_node_is_up(n)) {
+ if (!node_is_up(n)) {
if (tipc_link_peer_is_down(l))
tipc_node_fsm_evt(n, PEER_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)
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;
}
+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,
struct tipc_bearer *b,
u16 capabilities, u32 signature,
@@ -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))
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))
goto attr_msg_full;
@@ -1249,7 +1265,7 @@ void tipc_node_broadcast(struct net *net, struct sk_buff *skb)
dst = n->addr;
if (in_own_node(net, dst))
continue;
- if (!tipc_node_is_up(n))
+ if (!node_is_up(n))
continue;
txskb = pskb_copy(skb, GFP_ATOMIC);
if (!txskb)
diff --git a/net/tipc/node.h b/net/tipc/node.h
index 898c229..8db59fe 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);
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);
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);
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);
--
2.1.4
next prev parent reply other threads:[~2017-10-13 9:04 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-13 9:04 [net-next v2 00/18] tipc: Introduce Communcation Group feature Jon Maloy
2017-10-13 9:04 ` [net-next v2 01/18] tipc: add ability to order and receive topology events in driver Jon Maloy
2017-10-13 9:04 ` [net-next v2 02/18] tipc: improve address sanity check in tipc_connect() Jon Maloy
2017-10-13 9:04 ` Jon Maloy [this message]
2017-10-13 9:04 ` [net-next v2 04/18] tipc: refactor function filter_rcv() Jon Maloy
2017-10-13 9:04 ` [net-next v2 05/18] tipc: add new function for sending multiple small messages Jon Maloy
2017-10-13 9:04 ` [net-next v2 06/18] tipc: improve destination linked list Jon Maloy
2017-10-13 9:04 ` [net-next v2 07/18] tipc: introduce communication groups Jon Maloy
2017-10-13 9:04 ` [net-next v2 08/18] tipc: add second source address to recvmsg()/recvfrom() Jon Maloy
2017-10-13 9:04 ` [net-next v2 09/18] tipc: receive group membership events via member socket Jon Maloy
2017-10-13 9:04 ` [net-next v2 10/18] tipc: introduce flow control for group broadcast messages Jon Maloy
2017-10-13 9:04 ` [net-next v2 11/18] tipc: introduce group unicast messaging Jon Maloy
2017-10-13 9:04 ` [net-next v2 12/18] tipc: introduce group anycast messaging Jon Maloy
2017-10-13 9:04 ` [net-next v2 13/18] tipc: introduce group multicast messaging Jon Maloy
2017-10-13 9:04 ` [net-next v2 14/18] tipc: guarantee group unicast doesn't bypass group broadcast Jon Maloy
2017-10-13 9:04 ` [net-next v2 15/18] tipc: guarantee that group broadcast doesn't bypass group unicast Jon Maloy
2017-10-13 9:04 ` [net-next v2 16/18] tipc: guarantee delivery of UP event before first broadcast Jon Maloy
2017-10-13 9:04 ` [net-next v2 17/18] tipc: guarantee delivery of last broadcast before DOWN event Jon Maloy
2017-10-13 9:04 ` [net-next v2 18/18] tipc: add multipoint-to-point flow control Jon Maloy
2017-10-13 15:51 ` [net-next v2 00/18] tipc: Introduce Communcation Group feature David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1507885474-11213-4-git-send-email-jon.maloy@ericsson.com \
--to=jon.maloy@ericsson.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=parthasarathy.bhuvaragan@ericsson.com \
--cc=tipc-discussion@lists.sourceforge.net \
--cc=ying.xue@windriver.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).