summaryrefslogtreecommitdiff
path: root/net/tipc/node.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2014-04-26 12:13:30 -0400
committerDavid S. Miller <davem@davemloft.net>2014-04-26 12:13:30 -0400
commit7f51531c11be9f6ebace405aec724ffac043a8f5 (patch)
tree0520313d3d6afcc42d7aaf27fbe699e8bc71e2d5 /net/tipc/node.c
parentd42f157b3498a042d9930506d4b55ded5dcb35c0 (diff)
parent78acb1f9b898e85fa2c1e28e700b54b66b288e8d (diff)
Merge branch 'tipc-next'
Erik Hugne says: ==================== tipc: add support for link state subscriptions Low level topology information like TIPC link up/down is useful for applications like teamd to make smarter failover decisions in a HA cluster environment. Fetching logical link names through an ioctl may hurt the eyes of some. Suggestions for a more elegant way of doing this would be appreciated in that case. :) v2: -Properly based on net-next -Off-list comments from Billie Alsup: -Add a string length parameter to tipc_node_get_linkname -Use TIPC_MAX_LINK_NAME definition instead of hardcoded value in tipc_sioc_ln_req linkname ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc/node.c')
-rw-r--r--net/tipc/node.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/net/tipc/node.c b/net/tipc/node.c
index be90115cda1a..1f938f3dba4b 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -144,9 +144,11 @@ void tipc_node_stop(void)
void tipc_node_link_up(struct tipc_node *n_ptr, struct tipc_link *l_ptr)
{
struct tipc_link **active = &n_ptr->active_links[0];
+ u32 addr = n_ptr->addr;
n_ptr->working_links++;
-
+ tipc_nametbl_publish(TIPC_LINK_STATE, addr, addr, TIPC_NODE_SCOPE,
+ l_ptr->bearer_id, addr);
pr_info("Established link <%s> on network plane %c\n",
l_ptr->name, l_ptr->net_plane);
@@ -203,8 +205,10 @@ static void node_select_active_links(struct tipc_node *n_ptr)
void tipc_node_link_down(struct tipc_node *n_ptr, struct tipc_link *l_ptr)
{
struct tipc_link **active;
+ u32 addr = n_ptr->addr;
n_ptr->working_links--;
+ tipc_nametbl_withdraw(TIPC_LINK_STATE, addr, l_ptr->bearer_id, addr);
if (!tipc_link_is_active(l_ptr)) {
pr_info("Lost standby link <%s> on network plane %c\n",
@@ -434,3 +438,30 @@ struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space)
rcu_read_unlock();
return buf;
}
+
+/**
+ * tipc_node_get_linkname - get the name of a link
+ *
+ * @bearer_id: id of the bearer
+ * @node: peer node address
+ * @linkname: link name output buffer
+ *
+ * Returns 0 on success
+ */
+int tipc_node_get_linkname(u32 bearer_id, u32 addr, char *linkname, size_t len)
+{
+ struct tipc_link *link;
+ struct tipc_node *node = tipc_node_find(addr);
+
+ if ((bearer_id > MAX_BEARERS) || !node)
+ return -EINVAL;
+ tipc_node_lock(node);
+ link = node->links[bearer_id];
+ if (link) {
+ strncpy(linkname, link->name, len);
+ tipc_node_unlock(node);
+ return 0;
+ }
+ tipc_node_unlock(node);
+ return -EINVAL;
+}