* [PATCH net-next v2 0/2] tipc: add support for link state subscriptions
@ 2014-04-24 14:26 erik.hugne
2014-04-24 14:26 ` [PATCH net-next v2 1/2] " erik.hugne
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: erik.hugne @ 2014-04-24 14:26 UTC (permalink / raw)
To: netdev, tipc-discussion, jon.maloy, maloy
Cc: ying.xue, paul.gortmaker, richard.alpe, Erik Hugne
From: Erik Hugne <erik.hugne@ericsson.com>
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
Erik Hugne (2):
tipc: add support for link state subscriptions
tipc: add ioctl to fetch link names
include/uapi/linux/tipc.h | 23 +++++++++++++++++++++++
include/uapi/linux/tipc_config.h | 10 +---------
net/tipc/node.c | 33 ++++++++++++++++++++++++++++++++-
net/tipc/node.h | 1 +
net/tipc/socket.c | 29 ++++++++++++++++++++++++++---
5 files changed, 83 insertions(+), 13 deletions(-)
--
1.8.3.2
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH net-next v2 1/2] tipc: add support for link state subscriptions
2014-04-24 14:26 [PATCH net-next v2 0/2] tipc: add support for link state subscriptions erik.hugne
@ 2014-04-24 14:26 ` erik.hugne
2014-04-24 14:26 ` [PATCH net-next v2 2/2] tipc: add ioctl to fetch link names erik.hugne
2014-04-26 16:13 ` [PATCH net-next v2 0/2] tipc: add support for link state subscriptions David Miller
2 siblings, 0 replies; 4+ messages in thread
From: erik.hugne @ 2014-04-24 14:26 UTC (permalink / raw)
To: netdev, tipc-discussion, jon.maloy, maloy
Cc: ying.xue, paul.gortmaker, richard.alpe, Erik Hugne
From: Erik Hugne <erik.hugne@ericsson.com>
When links are established over a bearer plane, we create a node
local publication containing information about the peer node and
bearer plane. This allows TIPC applications to use the standard
TIPC topology server subscription mechanism to get notifications
when a link goes up or down.
Signed-off-by: Erik Hugne <erik.hugne@ericsson.com>
Reviewed-by: Ying Xue <ying.xue@windriver.com>
Reviewed-by: Jon Maloy <jon.maloy@ericsson.com>
---
include/uapi/linux/tipc.h | 1 +
net/tipc/node.c | 6 +++++-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/include/uapi/linux/tipc.h b/include/uapi/linux/tipc.h
index 852373d..53cd790 100644
--- a/include/uapi/linux/tipc.h
+++ b/include/uapi/linux/tipc.h
@@ -87,6 +87,7 @@ static inline unsigned int tipc_node(__u32 addr)
#define TIPC_CFG_SRV 0 /* configuration service name type */
#define TIPC_TOP_SRV 1 /* topology service name type */
+#define TIPC_LINK_STATE 2 /* link state name type */
#define TIPC_RESERVED_TYPES 64 /* lowest user-publishable name type */
/*
diff --git a/net/tipc/node.c b/net/tipc/node.c
index be90115..3b86a74 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",
--
1.8.3.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH net-next v2 2/2] tipc: add ioctl to fetch link names
2014-04-24 14:26 [PATCH net-next v2 0/2] tipc: add support for link state subscriptions erik.hugne
2014-04-24 14:26 ` [PATCH net-next v2 1/2] " erik.hugne
@ 2014-04-24 14:26 ` erik.hugne
2014-04-26 16:13 ` [PATCH net-next v2 0/2] tipc: add support for link state subscriptions David Miller
2 siblings, 0 replies; 4+ messages in thread
From: erik.hugne @ 2014-04-24 14:26 UTC (permalink / raw)
To: netdev, tipc-discussion, jon.maloy, maloy
Cc: ying.xue, paul.gortmaker, richard.alpe, Erik Hugne
From: Erik Hugne <erik.hugne@ericsson.com>
We add a new ioctl for AF_TIPC that can be used to fetch the
logical name for a link to a remote node on a given bearer. This
should be used in combination with link state subscriptions.
The logical name size limit definitions are moved to tipc.h, as
they are now also needed by the new ioctl.
Signed-off-by: Erik Hugne <erik.hugne@ericsson.com>
Reviewed-by: Ying Xue <ying.xue@windriver.com>
Reviewed-by: Jon Maloy <jon.maloy@ericsson.com>
---
include/uapi/linux/tipc.h | 22 ++++++++++++++++++++++
include/uapi/linux/tipc_config.h | 10 +---------
net/tipc/node.c | 27 +++++++++++++++++++++++++++
net/tipc/node.h | 1 +
net/tipc/socket.c | 29 ++++++++++++++++++++++++++---
5 files changed, 77 insertions(+), 12 deletions(-)
diff --git a/include/uapi/linux/tipc.h b/include/uapi/linux/tipc.h
index 53cd790..6f71b9b 100644
--- a/include/uapi/linux/tipc.h
+++ b/include/uapi/linux/tipc.h
@@ -38,6 +38,7 @@
#define _LINUX_TIPC_H_
#include <linux/types.h>
+#include <linux/sockios.h>
/*
* TIPC addressing primitives
@@ -207,4 +208,25 @@ struct sockaddr_tipc {
#define TIPC_NODE_RECVQ_DEPTH 131 /* Default: none (read only) */
#define TIPC_SOCK_RECVQ_DEPTH 132 /* Default: none (read only) */
+/*
+ * Maximum sizes of TIPC bearer-related names (including terminating NULL)
+ * The string formatting for each name element is:
+ * media: media
+ * interface: media:interface name
+ * link: Z.C.N:interface-Z.C.N:interface
+ *
+ */
+
+#define TIPC_MAX_MEDIA_NAME 16
+#define TIPC_MAX_IF_NAME 16
+#define TIPC_MAX_BEARER_NAME 32
+#define TIPC_MAX_LINK_NAME 60
+
+#define SIOCGETLINKNAME SIOCPROTOPRIVATE
+
+struct tipc_sioc_ln_req {
+ __u32 peer;
+ __u32 bearer_id;
+ char linkname[TIPC_MAX_LINK_NAME];
+};
#endif
diff --git a/include/uapi/linux/tipc_config.h b/include/uapi/linux/tipc_config.h
index 6b0bff0..41a76ac 100644
--- a/include/uapi/linux/tipc_config.h
+++ b/include/uapi/linux/tipc_config.h
@@ -39,6 +39,7 @@
#include <linux/types.h>
#include <linux/string.h>
+#include <linux/tipc.h>
#include <asm/byteorder.h>
#ifndef __KERNEL__
@@ -155,15 +156,6 @@
#define TIPC_TLV_PORT_REF 26 /* 32-bit port reference */
/*
- * Maximum sizes of TIPC bearer-related names (including terminating NUL)
- */
-
-#define TIPC_MAX_MEDIA_NAME 16 /* format = media */
-#define TIPC_MAX_IF_NAME 16 /* format = interface */
-#define TIPC_MAX_BEARER_NAME 32 /* format = media:interface */
-#define TIPC_MAX_LINK_NAME 60 /* format = Z.C.N:interface-Z.C.N:interface */
-
-/*
* Link priority limits (min, default, max, media default)
*/
diff --git a/net/tipc/node.c b/net/tipc/node.c
index 3b86a74..1f938f3 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -438,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;
+}
diff --git a/net/tipc/node.h b/net/tipc/node.h
index 7cbb8ce..411b191 100644
--- a/net/tipc/node.h
+++ b/net/tipc/node.h
@@ -118,6 +118,7 @@ int tipc_node_active_links(struct tipc_node *n_ptr);
int tipc_node_is_up(struct tipc_node *n_ptr);
struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space);
struct sk_buff *tipc_node_get_nodes(const void *req_tlv_area, int req_tlv_space);
+int tipc_node_get_linkname(u32 bearer_id, u32 node, char *linkname, size_t len);
static inline void tipc_node_lock(struct tipc_node *n_ptr)
{
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index 3c02569..3f9912f 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -36,6 +36,7 @@
#include "core.h"
#include "port.h"
+#include "node.h"
#include <linux/export.h>
@@ -1905,6 +1906,28 @@ static int tipc_getsockopt(struct socket *sock, int lvl, int opt,
return put_user(sizeof(value), ol);
}
+int tipc_ioctl(struct socket *sk, unsigned int cmd, unsigned long arg)
+{
+ struct tipc_sioc_ln_req lnr;
+ void __user *argp = (void __user *)arg;
+
+ switch (cmd) {
+ case SIOCGETLINKNAME:
+ if (copy_from_user(&lnr, argp, sizeof(lnr)))
+ return -EFAULT;
+ if (!tipc_node_get_linkname(lnr.bearer_id, lnr.peer,
+ lnr.linkname, TIPC_MAX_LINK_NAME)) {
+ if (copy_to_user(argp, &lnr, sizeof(lnr)))
+ return -EFAULT;
+ return 0;
+ }
+ return -EADDRNOTAVAIL;
+ break;
+ default:
+ return -ENOIOCTLCMD;
+ }
+}
+
/* Protocol switches for the various types of TIPC sockets */
static const struct proto_ops msg_ops = {
@@ -1917,7 +1940,7 @@ static const struct proto_ops msg_ops = {
.accept = sock_no_accept,
.getname = tipc_getname,
.poll = tipc_poll,
- .ioctl = sock_no_ioctl,
+ .ioctl = tipc_ioctl,
.listen = sock_no_listen,
.shutdown = tipc_shutdown,
.setsockopt = tipc_setsockopt,
@@ -1938,7 +1961,7 @@ static const struct proto_ops packet_ops = {
.accept = tipc_accept,
.getname = tipc_getname,
.poll = tipc_poll,
- .ioctl = sock_no_ioctl,
+ .ioctl = tipc_ioctl,
.listen = tipc_listen,
.shutdown = tipc_shutdown,
.setsockopt = tipc_setsockopt,
@@ -1959,7 +1982,7 @@ static const struct proto_ops stream_ops = {
.accept = tipc_accept,
.getname = tipc_getname,
.poll = tipc_poll,
- .ioctl = sock_no_ioctl,
+ .ioctl = tipc_ioctl,
.listen = tipc_listen,
.shutdown = tipc_shutdown,
.setsockopt = tipc_setsockopt,
--
1.8.3.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net-next v2 0/2] tipc: add support for link state subscriptions
2014-04-24 14:26 [PATCH net-next v2 0/2] tipc: add support for link state subscriptions erik.hugne
2014-04-24 14:26 ` [PATCH net-next v2 1/2] " erik.hugne
2014-04-24 14:26 ` [PATCH net-next v2 2/2] tipc: add ioctl to fetch link names erik.hugne
@ 2014-04-26 16:13 ` David Miller
2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2014-04-26 16:13 UTC (permalink / raw)
To: erik.hugne
Cc: netdev, tipc-discussion, jon.maloy, maloy, ying.xue,
paul.gortmaker, richard.alpe
From: <erik.hugne@ericsson.com>
Date: Thu, 24 Apr 2014 16:26:45 +0200
> From: Erik Hugne <erik.hugne@ericsson.com>
>
> 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
Series applied, thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-04-26 16:14 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-24 14:26 [PATCH net-next v2 0/2] tipc: add support for link state subscriptions erik.hugne
2014-04-24 14:26 ` [PATCH net-next v2 1/2] " erik.hugne
2014-04-24 14:26 ` [PATCH net-next v2 2/2] tipc: add ioctl to fetch link names erik.hugne
2014-04-26 16:13 ` [PATCH net-next v2 0/2] tipc: add support for link state subscriptions David Miller
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.