* [PATCH net-next v2 0/5] tipc: netlink updates for neighbour monitor
@ 2016-07-26 6:47 Parthasarathy Bhuvaragan
2016-07-26 6:47 ` [PATCH net-next v2 1/5] tipc: introduce constants for tipc address validation Parthasarathy Bhuvaragan
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: Parthasarathy Bhuvaragan @ 2016-07-26 6:47 UTC (permalink / raw)
To: netdev; +Cc: jon.maloy, tipc-discussion
This series contains the updates to configure and read the attributes for
neighbour monitor.
v2: rebase on top of net-next
Parthasarathy Bhuvaragan (5):
tipc: introduce constants for tipc address validation
tipc: make cluster size threshold for monitoring configurable
tipc: get monitor threshold for the cluster
tipc: add a function to get the bearer name
tipc: dump monitor attributes
include/uapi/linux/tipc.h | 30 ++++++-
include/uapi/linux/tipc_netlink.h | 37 +++++++++
net/tipc/addr.h | 5 +-
net/tipc/bearer.c | 25 +++++-
net/tipc/bearer.h | 1 +
net/tipc/monitor.c | 152 +++++++++++++++++++++++++++++++++++
net/tipc/monitor.h | 9 +++
net/tipc/netlink.c | 27 ++++++-
net/tipc/netlink.h | 1 +
net/tipc/node.c | 165 ++++++++++++++++++++++++++++++++++++++
net/tipc/node.h | 5 ++
11 files changed, 445 insertions(+), 12 deletions(-)
--
2.1.4
------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH net-next v2 1/5] tipc: introduce constants for tipc address validation
2016-07-26 6:47 [PATCH net-next v2 0/5] tipc: netlink updates for neighbour monitor Parthasarathy Bhuvaragan
@ 2016-07-26 6:47 ` Parthasarathy Bhuvaragan
2016-07-26 6:47 ` [PATCH net-next v2 2/5] tipc: make cluster size threshold for monitoring configurable Parthasarathy Bhuvaragan
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Parthasarathy Bhuvaragan @ 2016-07-26 6:47 UTC (permalink / raw)
To: netdev; +Cc: jon.maloy, tipc-discussion
In this commit, we introduce defines for tipc address size,
offset and mask specification for Zone.Cluster.Node.
There is no functional change in this commit.
Reviewed-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: Parthasarathy Bhuvaragan <parthasarathy.bhuvaragan@ericsson.com>
---
include/uapi/linux/tipc.h | 30 ++++++++++++++++++++++++++----
net/tipc/addr.h | 5 +----
net/tipc/bearer.c | 4 ++--
3 files changed, 29 insertions(+), 10 deletions(-)
diff --git a/include/uapi/linux/tipc.h b/include/uapi/linux/tipc.h
index 6f71b9b41595..bf049e8fe31b 100644
--- a/include/uapi/linux/tipc.h
+++ b/include/uapi/linux/tipc.h
@@ -60,26 +60,48 @@ struct tipc_name_seq {
__u32 upper;
};
+/* TIPC Address Size, Offset, Mask specification for Z.C.N
+ */
+#define TIPC_NODE_BITS 12
+#define TIPC_CLUSTER_BITS 12
+#define TIPC_ZONE_BITS 8
+
+#define TIPC_NODE_OFFSET 0
+#define TIPC_CLUSTER_OFFSET TIPC_NODE_BITS
+#define TIPC_ZONE_OFFSET (TIPC_CLUSTER_OFFSET + TIPC_CLUSTER_BITS)
+
+#define TIPC_NODE_SIZE ((1UL << TIPC_NODE_BITS) - 1)
+#define TIPC_CLUSTER_SIZE ((1UL << TIPC_CLUSTER_BITS) - 1)
+#define TIPC_ZONE_SIZE ((1UL << TIPC_ZONE_BITS) - 1)
+
+#define TIPC_NODE_MASK (TIPC_NODE_SIZE << TIPC_NODE_OFFSET)
+#define TIPC_CLUSTER_MASK (TIPC_CLUSTER_SIZE << TIPC_CLUSTER_OFFSET)
+#define TIPC_ZONE_MASK (TIPC_ZONE_SIZE << TIPC_ZONE_OFFSET)
+
+#define TIPC_ZONE_CLUSTER_MASK (TIPC_ZONE_MASK | TIPC_CLUSTER_MASK)
+
static inline __u32 tipc_addr(unsigned int zone,
unsigned int cluster,
unsigned int node)
{
- return (zone << 24) | (cluster << 12) | node;
+ return (zone << TIPC_ZONE_OFFSET) |
+ (cluster << TIPC_CLUSTER_OFFSET) |
+ node;
}
static inline unsigned int tipc_zone(__u32 addr)
{
- return addr >> 24;
+ return addr >> TIPC_ZONE_OFFSET;
}
static inline unsigned int tipc_cluster(__u32 addr)
{
- return (addr >> 12) & 0xfff;
+ return (addr & TIPC_CLUSTER_MASK) >> TIPC_CLUSTER_OFFSET;
}
static inline unsigned int tipc_node(__u32 addr)
{
- return addr & 0xfff;
+ return addr & TIPC_NODE_MASK;
}
/*
diff --git a/net/tipc/addr.h b/net/tipc/addr.h
index 64f4004a6fac..bebb347803ce 100644
--- a/net/tipc/addr.h
+++ b/net/tipc/addr.h
@@ -43,9 +43,6 @@
#include <net/netns/generic.h>
#include "core.h"
-#define TIPC_ZONE_MASK 0xff000000u
-#define TIPC_CLUSTER_MASK 0xfffff000u
-
static inline u32 tipc_own_addr(struct net *net)
{
struct tipc_net *tn = net_generic(net, tipc_net_id);
@@ -60,7 +57,7 @@ static inline u32 tipc_zone_mask(u32 addr)
static inline u32 tipc_cluster_mask(u32 addr)
{
- return addr & TIPC_CLUSTER_MASK;
+ return addr & TIPC_ZONE_CLUSTER_MASK;
}
u32 tipc_own_addr(struct net *net);
diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c
index 4131d5a86f55..65b0998a9bab 100644
--- a/net/tipc/bearer.c
+++ b/net/tipc/bearer.c
@@ -225,7 +225,7 @@ static int tipc_enable_bearer(struct net *net, const char *name,
if (tipc_addr_domain_valid(disc_domain) &&
(disc_domain != tn->own_addr)) {
if (tipc_in_scope(disc_domain, tn->own_addr)) {
- disc_domain = tn->own_addr & TIPC_CLUSTER_MASK;
+ disc_domain = tn->own_addr & TIPC_ZONE_CLUSTER_MASK;
res = 0; /* accept any node in own cluster */
} else if (in_own_cluster_exact(net, disc_domain))
res = 0; /* accept specified node in own cluster */
@@ -832,7 +832,7 @@ int tipc_nl_bearer_enable(struct sk_buff *skb, struct genl_info *info)
u32 prio;
prio = TIPC_MEDIA_LINK_PRI;
- domain = tn->own_addr & TIPC_CLUSTER_MASK;
+ domain = tn->own_addr & TIPC_ZONE_CLUSTER_MASK;
if (!info->attrs[TIPC_NLA_BEARER])
return -EINVAL;
--
2.1.4
------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH net-next v2 2/5] tipc: make cluster size threshold for monitoring configurable
2016-07-26 6:47 [PATCH net-next v2 0/5] tipc: netlink updates for neighbour monitor Parthasarathy Bhuvaragan
2016-07-26 6:47 ` [PATCH net-next v2 1/5] tipc: introduce constants for tipc address validation Parthasarathy Bhuvaragan
@ 2016-07-26 6:47 ` Parthasarathy Bhuvaragan
2016-07-26 6:47 ` [PATCH net-next v2 3/5] tipc: get monitor threshold for the cluster Parthasarathy Bhuvaragan
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Parthasarathy Bhuvaragan @ 2016-07-26 6:47 UTC (permalink / raw)
To: netdev; +Cc: tipc-discussion, jon.maloy, maloy, ying.xue
In this commit, we introduce support to configure the minimum
threshold to activate the new link monitoring algorithm.
Reviewed-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: Parthasarathy Bhuvaragan <parthasarathy.bhuvaragan@ericsson.com>
---
include/uapi/linux/tipc_netlink.h | 11 +++++++++++
net/tipc/monitor.c | 12 ++++++++++++
net/tipc/monitor.h | 1 +
net/tipc/netlink.c | 15 +++++++++++++--
net/tipc/netlink.h | 1 +
net/tipc/node.c | 27 +++++++++++++++++++++++++++
net/tipc/node.h | 1 +
7 files changed, 66 insertions(+), 2 deletions(-)
diff --git a/include/uapi/linux/tipc_netlink.h b/include/uapi/linux/tipc_netlink.h
index d4c8f142ba63..d387b65a0d97 100644
--- a/include/uapi/linux/tipc_netlink.h
+++ b/include/uapi/linux/tipc_netlink.h
@@ -56,6 +56,7 @@ enum {
TIPC_NL_NET_GET,
TIPC_NL_NET_SET,
TIPC_NL_NAME_TABLE_GET,
+ TIPC_NL_MON_SET,
__TIPC_NL_CMD_MAX,
TIPC_NL_CMD_MAX = __TIPC_NL_CMD_MAX - 1
@@ -72,6 +73,7 @@ enum {
TIPC_NLA_NODE, /* nest */
TIPC_NLA_NET, /* nest */
TIPC_NLA_NAME_TABLE, /* nest */
+ TIPC_NLA_MON, /* nest */
__TIPC_NLA_MAX,
TIPC_NLA_MAX = __TIPC_NLA_MAX - 1
@@ -166,6 +168,15 @@ enum {
TIPC_NLA_NAME_TABLE_MAX = __TIPC_NLA_NAME_TABLE_MAX - 1
};
+/* Monitor info */
+enum {
+ TIPC_NLA_MON_UNSPEC,
+ TIPC_NLA_MON_ACTIVATION_THRESHOLD, /* u32 */
+
+ __TIPC_NLA_MON_MAX,
+ TIPC_NLA_MON_MAX = __TIPC_NLA_MON_MAX - 1
+};
+
/* Publication info */
enum {
TIPC_NLA_PUBL_UNSPEC,
diff --git a/net/tipc/monitor.c b/net/tipc/monitor.c
index 0d489e81fcca..3892d05b8b45 100644
--- a/net/tipc/monitor.c
+++ b/net/tipc/monitor.c
@@ -649,3 +649,15 @@ void tipc_mon_delete(struct net *net, int bearer_id)
kfree(self);
kfree(mon);
}
+
+int tipc_nl_monitor_set_threshold(struct net *net, u32 cluster_size)
+{
+ struct tipc_net *tn = tipc_net(net);
+
+ if (cluster_size > TIPC_CLUSTER_SIZE)
+ return -EINVAL;
+
+ tn->mon_threshold = cluster_size;
+
+ return 0;
+}
diff --git a/net/tipc/monitor.h b/net/tipc/monitor.h
index 598459cbed5d..91f5dd09432b 100644
--- a/net/tipc/monitor.h
+++ b/net/tipc/monitor.h
@@ -69,5 +69,6 @@ void tipc_mon_get_state(struct net *net, u32 addr,
int bearer_id);
void tipc_mon_remove_peer(struct net *net, u32 addr, int bearer_id);
+int tipc_nl_monitor_set_threshold(struct net *net, u32 cluster_size);
extern const int tipc_max_domain_size;
#endif
diff --git a/net/tipc/netlink.c b/net/tipc/netlink.c
index 56935df2167a..1e43ac0200ed 100644
--- a/net/tipc/netlink.c
+++ b/net/tipc/netlink.c
@@ -52,7 +52,8 @@ static const struct nla_policy tipc_nl_policy[TIPC_NLA_MAX + 1] = {
[TIPC_NLA_MEDIA] = { .type = NLA_NESTED, },
[TIPC_NLA_NODE] = { .type = NLA_NESTED, },
[TIPC_NLA_NET] = { .type = NLA_NESTED, },
- [TIPC_NLA_NAME_TABLE] = { .type = NLA_NESTED, }
+ [TIPC_NLA_NAME_TABLE] = { .type = NLA_NESTED, },
+ [TIPC_NLA_MON] = { .type = NLA_NESTED, },
};
const struct nla_policy
@@ -61,6 +62,11 @@ tipc_nl_name_table_policy[TIPC_NLA_NAME_TABLE_MAX + 1] = {
[TIPC_NLA_NAME_TABLE_PUBL] = { .type = NLA_NESTED }
};
+const struct nla_policy tipc_nl_monitor_policy[TIPC_NLA_MON_MAX + 1] = {
+ [TIPC_NLA_MON_UNSPEC] = { .type = NLA_UNSPEC },
+ [TIPC_NLA_MON_ACTIVATION_THRESHOLD] = { .type = NLA_U32 },
+};
+
const struct nla_policy tipc_nl_sock_policy[TIPC_NLA_SOCK_MAX + 1] = {
[TIPC_NLA_SOCK_UNSPEC] = { .type = NLA_UNSPEC },
[TIPC_NLA_SOCK_ADDR] = { .type = NLA_U32 },
@@ -214,7 +220,12 @@ static const struct genl_ops tipc_genl_v2_ops[] = {
.cmd = TIPC_NL_NAME_TABLE_GET,
.dumpit = tipc_nl_name_table_dump,
.policy = tipc_nl_policy,
- }
+ },
+ {
+ .cmd = TIPC_NL_MON_SET,
+ .doit = tipc_nl_node_set_monitor,
+ .policy = tipc_nl_policy,
+ },
};
int tipc_nlmsg_parse(const struct nlmsghdr *nlh, struct nlattr ***attr)
diff --git a/net/tipc/netlink.h b/net/tipc/netlink.h
index ed1dbcb4afbd..4ba0ad422110 100644
--- a/net/tipc/netlink.h
+++ b/net/tipc/netlink.h
@@ -55,6 +55,7 @@ extern const struct nla_policy tipc_nl_prop_policy[];
extern const struct nla_policy tipc_nl_bearer_policy[];
extern const struct nla_policy tipc_nl_media_policy[];
extern const struct nla_policy tipc_nl_udp_policy[];
+extern const struct nla_policy tipc_nl_monitor_policy[];
int tipc_netlink_start(void);
int tipc_netlink_compat_start(void);
diff --git a/net/tipc/node.c b/net/tipc/node.c
index 95cc78b51532..0fc531d0f709 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -1928,3 +1928,30 @@ out:
return skb->len;
}
+
+int tipc_nl_node_set_monitor(struct sk_buff *skb, struct genl_info *info)
+{
+ struct nlattr *attrs[TIPC_NLA_MON_MAX + 1];
+ struct net *net = sock_net(skb->sk);
+ int err;
+
+ if (!info->attrs[TIPC_NLA_MON])
+ return -EINVAL;
+
+ err = nla_parse_nested(attrs, TIPC_NLA_MON_MAX,
+ info->attrs[TIPC_NLA_MON],
+ tipc_nl_monitor_policy);
+ if (err)
+ return err;
+
+ if (attrs[TIPC_NLA_MON_ACTIVATION_THRESHOLD]) {
+ u32 val;
+
+ val = nla_get_u32(attrs[TIPC_NLA_MON_ACTIVATION_THRESHOLD]);
+ err = tipc_nl_monitor_set_threshold(net, val);
+ if (err)
+ return err;
+ }
+
+ return 0;
+}
diff --git a/net/tipc/node.h b/net/tipc/node.h
index 8264b3d97dc4..65aa12ede8a5 100644
--- a/net/tipc/node.h
+++ b/net/tipc/node.h
@@ -78,4 +78,5 @@ int tipc_nl_node_reset_link_stats(struct sk_buff *skb, struct genl_info *info);
int tipc_nl_node_get_link(struct sk_buff *skb, struct genl_info *info);
int tipc_nl_node_set_link(struct sk_buff *skb, struct genl_info *info);
+int tipc_nl_node_set_monitor(struct sk_buff *skb, struct genl_info *info);
#endif
--
2.1.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH net-next v2 3/5] tipc: get monitor threshold for the cluster
2016-07-26 6:47 [PATCH net-next v2 0/5] tipc: netlink updates for neighbour monitor Parthasarathy Bhuvaragan
2016-07-26 6:47 ` [PATCH net-next v2 1/5] tipc: introduce constants for tipc address validation Parthasarathy Bhuvaragan
2016-07-26 6:47 ` [PATCH net-next v2 2/5] tipc: make cluster size threshold for monitoring configurable Parthasarathy Bhuvaragan
@ 2016-07-26 6:47 ` Parthasarathy Bhuvaragan
2016-07-26 6:47 ` [PATCH net-next v2 4/5] tipc: add a function to get the bearer name Parthasarathy Bhuvaragan
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Parthasarathy Bhuvaragan @ 2016-07-26 6:47 UTC (permalink / raw)
To: netdev; +Cc: tipc-discussion, jon.maloy, maloy, ying.xue
In this commit, we add support to fetch the configured
cluster monitoring threshold.
Reviewed-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: Parthasarathy Bhuvaragan <parthasarathy.bhuvaragan@ericsson.com>
---
include/uapi/linux/tipc_netlink.h | 1 +
net/tipc/monitor.c | 7 ++++++
net/tipc/monitor.h | 2 ++
net/tipc/netlink.c | 5 ++++
net/tipc/node.c | 52 +++++++++++++++++++++++++++++++++++++++
net/tipc/node.h | 1 +
6 files changed, 68 insertions(+)
diff --git a/include/uapi/linux/tipc_netlink.h b/include/uapi/linux/tipc_netlink.h
index d387b65a0d97..d07c6ec76062 100644
--- a/include/uapi/linux/tipc_netlink.h
+++ b/include/uapi/linux/tipc_netlink.h
@@ -57,6 +57,7 @@ enum {
TIPC_NL_NET_SET,
TIPC_NL_NAME_TABLE_GET,
TIPC_NL_MON_SET,
+ TIPC_NL_MON_GET,
__TIPC_NL_CMD_MAX,
TIPC_NL_CMD_MAX = __TIPC_NL_CMD_MAX - 1
diff --git a/net/tipc/monitor.c b/net/tipc/monitor.c
index 3892d05b8b45..3579126e2ac8 100644
--- a/net/tipc/monitor.c
+++ b/net/tipc/monitor.c
@@ -661,3 +661,10 @@ int tipc_nl_monitor_set_threshold(struct net *net, u32 cluster_size)
return 0;
}
+
+int tipc_nl_monitor_get_threshold(struct net *net)
+{
+ struct tipc_net *tn = tipc_net(net);
+
+ return tn->mon_threshold;
+}
diff --git a/net/tipc/monitor.h b/net/tipc/monitor.h
index 91f5dd09432b..aedf62c60bd3 100644
--- a/net/tipc/monitor.h
+++ b/net/tipc/monitor.h
@@ -70,5 +70,7 @@ void tipc_mon_get_state(struct net *net, u32 addr,
void tipc_mon_remove_peer(struct net *net, u32 addr, int bearer_id);
int tipc_nl_monitor_set_threshold(struct net *net, u32 cluster_size);
+int tipc_nl_monitor_get_threshold(struct net *net);
+
extern const int tipc_max_domain_size;
#endif
diff --git a/net/tipc/netlink.c b/net/tipc/netlink.c
index 1e43ac0200ed..2cfc5f7c6380 100644
--- a/net/tipc/netlink.c
+++ b/net/tipc/netlink.c
@@ -226,6 +226,11 @@ static const struct genl_ops tipc_genl_v2_ops[] = {
.doit = tipc_nl_node_set_monitor,
.policy = tipc_nl_policy,
},
+ {
+ .cmd = TIPC_NL_MON_GET,
+ .doit = tipc_nl_node_get_monitor,
+ .policy = tipc_nl_policy,
+ },
};
int tipc_nlmsg_parse(const struct nlmsghdr *nlh, struct nlattr ***attr)
diff --git a/net/tipc/node.c b/net/tipc/node.c
index 0fc531d0f709..2a7e74753f9f 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -1955,3 +1955,55 @@ int tipc_nl_node_set_monitor(struct sk_buff *skb, struct genl_info *info)
return 0;
}
+
+static int __tipc_nl_add_monitor_prop(struct net *net, struct tipc_nl_msg *msg)
+{
+ struct nlattr *attrs;
+ void *hdr;
+ u32 val;
+
+ hdr = genlmsg_put(msg->skb, msg->portid, msg->seq, &tipc_genl_family,
+ 0, TIPC_NL_MON_GET);
+ if (!hdr)
+ return -EMSGSIZE;
+
+ attrs = nla_nest_start(msg->skb, TIPC_NLA_MON);
+ if (!attrs)
+ goto msg_full;
+
+ val = tipc_nl_monitor_get_threshold(net);
+
+ if (nla_put_u32(msg->skb, TIPC_NLA_MON_ACTIVATION_THRESHOLD, val))
+ goto attr_msg_full;
+
+ nla_nest_end(msg->skb, attrs);
+ genlmsg_end(msg->skb, hdr);
+
+ return 0;
+
+attr_msg_full:
+ nla_nest_cancel(msg->skb, attrs);
+msg_full:
+ genlmsg_cancel(msg->skb, hdr);
+
+ return -EMSGSIZE;
+}
+
+int tipc_nl_node_get_monitor(struct sk_buff *skb, struct genl_info *info)
+{
+ struct net *net = sock_net(skb->sk);
+ struct tipc_nl_msg msg;
+ int err;
+
+ msg.skb = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
+ msg.portid = info->snd_portid;
+ msg.seq = info->snd_seq;
+
+ err = __tipc_nl_add_monitor_prop(net, &msg);
+ if (err) {
+ nlmsg_free(msg.skb);
+ return err;
+ }
+
+ return genlmsg_reply(msg.skb, info);
+}
diff --git a/net/tipc/node.h b/net/tipc/node.h
index 65aa12ede8a5..216f053b817f 100644
--- a/net/tipc/node.h
+++ b/net/tipc/node.h
@@ -79,4 +79,5 @@ int tipc_nl_node_get_link(struct sk_buff *skb, struct genl_info *info);
int tipc_nl_node_set_link(struct sk_buff *skb, struct genl_info *info);
int tipc_nl_node_set_monitor(struct sk_buff *skb, struct genl_info *info);
+int tipc_nl_node_get_monitor(struct sk_buff *skb, struct genl_info *info);
#endif
--
2.1.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH net-next v2 4/5] tipc: add a function to get the bearer name
2016-07-26 6:47 [PATCH net-next v2 0/5] tipc: netlink updates for neighbour monitor Parthasarathy Bhuvaragan
` (2 preceding siblings ...)
2016-07-26 6:47 ` [PATCH net-next v2 3/5] tipc: get monitor threshold for the cluster Parthasarathy Bhuvaragan
@ 2016-07-26 6:47 ` Parthasarathy Bhuvaragan
2016-07-26 6:47 ` [PATCH net-next v2 5/5] tipc: dump monitor attributes Parthasarathy Bhuvaragan
2016-07-26 21:26 ` [PATCH net-next v2 0/5] tipc: netlink updates for neighbour monitor David Miller
5 siblings, 0 replies; 7+ messages in thread
From: Parthasarathy Bhuvaragan @ 2016-07-26 6:47 UTC (permalink / raw)
To: netdev; +Cc: tipc-discussion, jon.maloy, maloy, ying.xue
Introduce a new function to get the bearer name from
its id. This is used in subsequent commit.
Reviewed-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: Parthasarathy Bhuvaragan <parthasarathy.bhuvaragan@ericsson.com>
---
net/tipc/bearer.c | 21 +++++++++++++++++++++
net/tipc/bearer.h | 1 +
2 files changed, 22 insertions(+)
diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c
index 65b0998a9bab..65b1bbf133bd 100644
--- a/net/tipc/bearer.c
+++ b/net/tipc/bearer.c
@@ -171,6 +171,27 @@ struct tipc_bearer *tipc_bearer_find(struct net *net, const char *name)
return NULL;
}
+/* tipc_bearer_get_name - get the bearer name from its id.
+ * @net: network namespace
+ * @name: a pointer to the buffer where the name will be stored.
+ * @bearer_id: the id to get the name from.
+ */
+int tipc_bearer_get_name(struct net *net, char *name, u32 bearer_id)
+{
+ struct tipc_net *tn = tipc_net(net);
+ struct tipc_bearer *b;
+
+ if (bearer_id >= MAX_BEARERS)
+ return -EINVAL;
+
+ b = rtnl_dereference(tn->bearer_list[bearer_id]);
+ if (!b)
+ return -EINVAL;
+
+ strcpy(name, b->name);
+ return 0;
+}
+
void tipc_bearer_add_dest(struct net *net, u32 bearer_id, u32 dest)
{
struct tipc_net *tn = net_generic(net, tipc_net_id);
diff --git a/net/tipc/bearer.h b/net/tipc/bearer.h
index f1e6db5e6345..43757f1f9cb3 100644
--- a/net/tipc/bearer.h
+++ b/net/tipc/bearer.h
@@ -197,6 +197,7 @@ int tipc_l2_send_msg(struct net *net, struct sk_buff *buf,
void tipc_bearer_add_dest(struct net *net, u32 bearer_id, u32 dest);
void tipc_bearer_remove_dest(struct net *net, u32 bearer_id, u32 dest);
struct tipc_bearer *tipc_bearer_find(struct net *net, const char *name);
+int tipc_bearer_get_name(struct net *net, char *name, u32 bearer_id);
struct tipc_media *tipc_media_find(const char *name);
void tipc_bearer_reset_all(struct net *net);
int tipc_bearer_setup(void);
--
2.1.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH net-next v2 5/5] tipc: dump monitor attributes
2016-07-26 6:47 [PATCH net-next v2 0/5] tipc: netlink updates for neighbour monitor Parthasarathy Bhuvaragan
` (3 preceding siblings ...)
2016-07-26 6:47 ` [PATCH net-next v2 4/5] tipc: add a function to get the bearer name Parthasarathy Bhuvaragan
@ 2016-07-26 6:47 ` Parthasarathy Bhuvaragan
2016-07-26 21:26 ` [PATCH net-next v2 0/5] tipc: netlink updates for neighbour monitor David Miller
5 siblings, 0 replies; 7+ messages in thread
From: Parthasarathy Bhuvaragan @ 2016-07-26 6:47 UTC (permalink / raw)
To: netdev; +Cc: tipc-discussion, jon.maloy, maloy, ying.xue
In this commit, we dump the monitor attributes when queried.
The link monitor attributes are separated into two kinds:
1. general attributes per bearer
2. specific attributes per node/peer
This style resembles the socket attributes and the nametable
publications per socket.
Reviewed-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: Parthasarathy Bhuvaragan <parthasarathy.bhuvaragan@ericsson.com>
---
include/uapi/linux/tipc_netlink.h | 25 +++++++
net/tipc/monitor.c | 133 ++++++++++++++++++++++++++++++++++++++
net/tipc/monitor.h | 6 ++
net/tipc/netlink.c | 7 ++
net/tipc/node.c | 86 ++++++++++++++++++++++++
net/tipc/node.h | 3 +
6 files changed, 260 insertions(+)
diff --git a/include/uapi/linux/tipc_netlink.h b/include/uapi/linux/tipc_netlink.h
index d07c6ec76062..5f3f6d09fb79 100644
--- a/include/uapi/linux/tipc_netlink.h
+++ b/include/uapi/linux/tipc_netlink.h
@@ -58,6 +58,7 @@ enum {
TIPC_NL_NAME_TABLE_GET,
TIPC_NL_MON_SET,
TIPC_NL_MON_GET,
+ TIPC_NL_MON_PEER_GET,
__TIPC_NL_CMD_MAX,
TIPC_NL_CMD_MAX = __TIPC_NL_CMD_MAX - 1
@@ -75,6 +76,7 @@ enum {
TIPC_NLA_NET, /* nest */
TIPC_NLA_NAME_TABLE, /* nest */
TIPC_NLA_MON, /* nest */
+ TIPC_NLA_MON_PEER, /* nest */
__TIPC_NLA_MAX,
TIPC_NLA_MAX = __TIPC_NLA_MAX - 1
@@ -173,6 +175,11 @@ enum {
enum {
TIPC_NLA_MON_UNSPEC,
TIPC_NLA_MON_ACTIVATION_THRESHOLD, /* u32 */
+ TIPC_NLA_MON_REF, /* u32 */
+ TIPC_NLA_MON_ACTIVE, /* flag */
+ TIPC_NLA_MON_BEARER_NAME, /* string */
+ TIPC_NLA_MON_PEERCNT, /* u32 */
+ TIPC_NLA_MON_LISTGEN, /* u32 */
__TIPC_NLA_MON_MAX,
TIPC_NLA_MON_MAX = __TIPC_NLA_MON_MAX - 1
@@ -194,6 +201,24 @@ enum {
TIPC_NLA_PUBL_MAX = __TIPC_NLA_PUBL_MAX - 1
};
+/* Monitor peer info */
+enum {
+ TIPC_NLA_MON_PEER_UNSPEC,
+
+ TIPC_NLA_MON_PEER_ADDR, /* u32 */
+ TIPC_NLA_MON_PEER_DOMGEN, /* u32 */
+ TIPC_NLA_MON_PEER_APPLIED, /* u32 */
+ TIPC_NLA_MON_PEER_UPMAP, /* u64 */
+ TIPC_NLA_MON_PEER_MEMBERS, /* tlv */
+ TIPC_NLA_MON_PEER_UP, /* flag */
+ TIPC_NLA_MON_PEER_HEAD, /* flag */
+ TIPC_NLA_MON_PEER_LOCAL, /* flag */
+ TIPC_NLA_MON_PEER_PAD, /* flag */
+
+ __TIPC_NLA_MON_PEER_MAX,
+ TIPC_NLA_MON_PEER_MAX = __TIPC_NLA_MON_PEER_MAX - 1
+};
+
/* Nest, connection info */
enum {
TIPC_NLA_CON_UNSPEC,
diff --git a/net/tipc/monitor.c b/net/tipc/monitor.c
index 3579126e2ac8..be70a57c1ff9 100644
--- a/net/tipc/monitor.c
+++ b/net/tipc/monitor.c
@@ -33,9 +33,11 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
+#include <net/genetlink.h>
#include "core.h"
#include "addr.h"
#include "monitor.h"
+#include "bearer.h"
#define MAX_MON_DOMAIN 64
#define MON_TIMEOUT 120000
@@ -668,3 +670,134 @@ int tipc_nl_monitor_get_threshold(struct net *net)
return tn->mon_threshold;
}
+
+int __tipc_nl_add_monitor_peer(struct tipc_peer *peer, struct tipc_nl_msg *msg)
+{
+ struct tipc_mon_domain *dom = peer->domain;
+ struct nlattr *attrs;
+ void *hdr;
+
+ hdr = genlmsg_put(msg->skb, msg->portid, msg->seq, &tipc_genl_family,
+ NLM_F_MULTI, TIPC_NL_MON_PEER_GET);
+ if (!hdr)
+ return -EMSGSIZE;
+
+ attrs = nla_nest_start(msg->skb, TIPC_NLA_MON_PEER);
+ if (!attrs)
+ goto msg_full;
+
+ if (nla_put_u32(msg->skb, TIPC_NLA_MON_PEER_ADDR, peer->addr))
+ goto attr_msg_full;
+ if (nla_put_u32(msg->skb, TIPC_NLA_MON_PEER_APPLIED, peer->applied))
+ goto attr_msg_full;
+
+ if (peer->is_up)
+ if (nla_put_flag(msg->skb, TIPC_NLA_MON_PEER_UP))
+ goto attr_msg_full;
+ if (peer->is_local)
+ if (nla_put_flag(msg->skb, TIPC_NLA_MON_PEER_LOCAL))
+ goto attr_msg_full;
+ if (peer->is_head)
+ if (nla_put_flag(msg->skb, TIPC_NLA_MON_PEER_HEAD))
+ goto attr_msg_full;
+
+ if (dom) {
+ if (nla_put_u32(msg->skb, TIPC_NLA_MON_PEER_DOMGEN, dom->gen))
+ goto attr_msg_full;
+ if (nla_put_u64_64bit(msg->skb, TIPC_NLA_MON_PEER_UPMAP,
+ dom->up_map, TIPC_NLA_MON_PEER_PAD))
+ goto attr_msg_full;
+ if (nla_put(msg->skb, TIPC_NLA_MON_PEER_MEMBERS,
+ dom->member_cnt * sizeof(u32), &dom->members))
+ goto attr_msg_full;
+ }
+
+ nla_nest_end(msg->skb, attrs);
+ genlmsg_end(msg->skb, hdr);
+ return 0;
+
+attr_msg_full:
+ nla_nest_cancel(msg->skb, attrs);
+msg_full:
+ genlmsg_cancel(msg->skb, hdr);
+
+ return -EMSGSIZE;
+}
+
+int tipc_nl_add_monitor_peer(struct net *net, struct tipc_nl_msg *msg,
+ u32 bearer_id, u32 *prev_node)
+{
+ struct tipc_monitor *mon = tipc_monitor(net, bearer_id);
+ struct tipc_peer *peer = mon->self;
+
+ if (!mon)
+ return -EINVAL;
+
+ read_lock_bh(&mon->lock);
+ do {
+ if (*prev_node) {
+ if (peer->addr == *prev_node)
+ *prev_node = 0;
+ else
+ continue;
+ }
+ if (__tipc_nl_add_monitor_peer(peer, msg)) {
+ *prev_node = peer->addr;
+ read_unlock_bh(&mon->lock);
+ return -EMSGSIZE;
+ }
+ } while ((peer = peer_nxt(peer)) != mon->self);
+ read_unlock_bh(&mon->lock);
+
+ return 0;
+}
+
+int __tipc_nl_add_monitor(struct net *net, struct tipc_nl_msg *msg,
+ u32 bearer_id)
+{
+ struct tipc_monitor *mon = tipc_monitor(net, bearer_id);
+ char bearer_name[TIPC_MAX_BEARER_NAME];
+ struct nlattr *attrs;
+ void *hdr;
+ int ret;
+
+ ret = tipc_bearer_get_name(net, bearer_name, bearer_id);
+ if (ret || !mon)
+ return -EINVAL;
+
+ hdr = genlmsg_put(msg->skb, msg->portid, msg->seq, &tipc_genl_family,
+ NLM_F_MULTI, TIPC_NL_MON_GET);
+ if (!hdr)
+ return -EMSGSIZE;
+
+ attrs = nla_nest_start(msg->skb, TIPC_NLA_MON);
+ if (!attrs)
+ goto msg_full;
+
+ read_lock_bh(&mon->lock);
+ if (nla_put_u32(msg->skb, TIPC_NLA_MON_REF, bearer_id))
+ goto attr_msg_full;
+ if (tipc_mon_is_active(net, mon))
+ if (nla_put_flag(msg->skb, TIPC_NLA_MON_ACTIVE))
+ goto attr_msg_full;
+ if (nla_put_string(msg->skb, TIPC_NLA_MON_BEARER_NAME, bearer_name))
+ goto attr_msg_full;
+ if (nla_put_u32(msg->skb, TIPC_NLA_MON_PEERCNT, mon->peer_cnt))
+ goto attr_msg_full;
+ if (nla_put_u32(msg->skb, TIPC_NLA_MON_LISTGEN, mon->list_gen))
+ goto attr_msg_full;
+
+ read_unlock_bh(&mon->lock);
+ nla_nest_end(msg->skb, attrs);
+ genlmsg_end(msg->skb, hdr);
+
+ return 0;
+
+attr_msg_full:
+ nla_nest_cancel(msg->skb, attrs);
+msg_full:
+ genlmsg_cancel(msg->skb, hdr);
+ read_unlock_bh(&mon->lock);
+
+ return -EMSGSIZE;
+}
diff --git a/net/tipc/monitor.h b/net/tipc/monitor.h
index aedf62c60bd3..2a21b93e0d04 100644
--- a/net/tipc/monitor.h
+++ b/net/tipc/monitor.h
@@ -36,6 +36,8 @@
#ifndef _TIPC_MONITOR_H
#define _TIPC_MONITOR_H
+#include "netlink.h"
+
/* struct tipc_mon_state: link instance's cache of monitor list and domain state
* @list_gen: current generation of this node's monitor list
* @gen: current generation of this node's local domain
@@ -71,6 +73,10 @@ void tipc_mon_remove_peer(struct net *net, u32 addr, int bearer_id);
int tipc_nl_monitor_set_threshold(struct net *net, u32 cluster_size);
int tipc_nl_monitor_get_threshold(struct net *net);
+int __tipc_nl_add_monitor(struct net *net, struct tipc_nl_msg *msg,
+ u32 bearer_id);
+int tipc_nl_add_monitor_peer(struct net *net, struct tipc_nl_msg *msg,
+ u32 bearer_id, u32 *prev_node);
extern const int tipc_max_domain_size;
#endif
diff --git a/net/tipc/netlink.c b/net/tipc/netlink.c
index 2cfc5f7c6380..a84daec0afe9 100644
--- a/net/tipc/netlink.c
+++ b/net/tipc/netlink.c
@@ -64,6 +64,7 @@ tipc_nl_name_table_policy[TIPC_NLA_NAME_TABLE_MAX + 1] = {
const struct nla_policy tipc_nl_monitor_policy[TIPC_NLA_MON_MAX + 1] = {
[TIPC_NLA_MON_UNSPEC] = { .type = NLA_UNSPEC },
+ [TIPC_NLA_MON_REF] = { .type = NLA_U32 },
[TIPC_NLA_MON_ACTIVATION_THRESHOLD] = { .type = NLA_U32 },
};
@@ -229,6 +230,12 @@ static const struct genl_ops tipc_genl_v2_ops[] = {
{
.cmd = TIPC_NL_MON_GET,
.doit = tipc_nl_node_get_monitor,
+ .dumpit = tipc_nl_node_dump_monitor,
+ .policy = tipc_nl_policy,
+ },
+ {
+ .cmd = TIPC_NL_MON_PEER_GET,
+ .dumpit = tipc_nl_node_dump_monitor_peer,
.policy = tipc_nl_policy,
},
};
diff --git a/net/tipc/node.c b/net/tipc/node.c
index 2a7e74753f9f..21974191e425 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -2007,3 +2007,89 @@ int tipc_nl_node_get_monitor(struct sk_buff *skb, struct genl_info *info)
return genlmsg_reply(msg.skb, info);
}
+
+int tipc_nl_node_dump_monitor(struct sk_buff *skb, struct netlink_callback *cb)
+{
+ struct net *net = sock_net(skb->sk);
+ u32 prev_bearer = cb->args[0];
+ struct tipc_nl_msg msg;
+ int err;
+ int i;
+
+ if (prev_bearer == MAX_BEARERS)
+ return 0;
+
+ msg.skb = skb;
+ msg.portid = NETLINK_CB(cb->skb).portid;
+ msg.seq = cb->nlh->nlmsg_seq;
+
+ rtnl_lock();
+ for (i = prev_bearer; i < MAX_BEARERS; i++) {
+ prev_bearer = i;
+ err = __tipc_nl_add_monitor(net, &msg, prev_bearer);
+ if (err)
+ goto out;
+ }
+
+out:
+ rtnl_unlock();
+ cb->args[0] = prev_bearer;
+
+ return skb->len;
+}
+
+int tipc_nl_node_dump_monitor_peer(struct sk_buff *skb,
+ struct netlink_callback *cb)
+{
+ struct net *net = sock_net(skb->sk);
+ u32 prev_node = cb->args[1];
+ u32 bearer_id = cb->args[2];
+ int done = cb->args[0];
+ struct tipc_nl_msg msg;
+ int err;
+
+ if (!prev_node) {
+ struct nlattr **attrs;
+ struct nlattr *mon[TIPC_NLA_MON_MAX + 1];
+
+ err = tipc_nlmsg_parse(cb->nlh, &attrs);
+ if (err)
+ return err;
+
+ if (!attrs[TIPC_NLA_MON])
+ return -EINVAL;
+
+ err = nla_parse_nested(mon, TIPC_NLA_MON_MAX,
+ attrs[TIPC_NLA_MON],
+ tipc_nl_monitor_policy);
+ if (err)
+ return err;
+
+ if (!mon[TIPC_NLA_MON_REF])
+ return -EINVAL;
+
+ bearer_id = nla_get_u32(mon[TIPC_NLA_MON_REF]);
+
+ if (bearer_id >= MAX_BEARERS)
+ return -EINVAL;
+ }
+
+ if (done)
+ return 0;
+
+ msg.skb = skb;
+ msg.portid = NETLINK_CB(cb->skb).portid;
+ msg.seq = cb->nlh->nlmsg_seq;
+
+ rtnl_lock();
+ err = tipc_nl_add_monitor_peer(net, &msg, bearer_id, &prev_node);
+ if (!err)
+ done = 1;
+
+ rtnl_unlock();
+ cb->args[0] = done;
+ cb->args[1] = prev_node;
+ cb->args[2] = bearer_id;
+
+ return skb->len;
+}
diff --git a/net/tipc/node.h b/net/tipc/node.h
index 216f053b817f..d69fdfcc0ec9 100644
--- a/net/tipc/node.h
+++ b/net/tipc/node.h
@@ -80,4 +80,7 @@ int tipc_nl_node_set_link(struct sk_buff *skb, struct genl_info *info);
int tipc_nl_node_set_monitor(struct sk_buff *skb, struct genl_info *info);
int tipc_nl_node_get_monitor(struct sk_buff *skb, struct genl_info *info);
+int tipc_nl_node_dump_monitor(struct sk_buff *skb, struct netlink_callback *cb);
+int tipc_nl_node_dump_monitor_peer(struct sk_buff *skb,
+ struct netlink_callback *cb);
#endif
--
2.1.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH net-next v2 0/5] tipc: netlink updates for neighbour monitor
2016-07-26 6:47 [PATCH net-next v2 0/5] tipc: netlink updates for neighbour monitor Parthasarathy Bhuvaragan
` (4 preceding siblings ...)
2016-07-26 6:47 ` [PATCH net-next v2 5/5] tipc: dump monitor attributes Parthasarathy Bhuvaragan
@ 2016-07-26 21:26 ` David Miller
5 siblings, 0 replies; 7+ messages in thread
From: David Miller @ 2016-07-26 21:26 UTC (permalink / raw)
To: parthasarathy.bhuvaragan
Cc: netdev, tipc-discussion, jon.maloy, maloy, ying.xue
From: Parthasarathy Bhuvaragan <parthasarathy.bhuvaragan@ericsson.com>
Date: Tue, 26 Jul 2016 08:47:17 +0200
> This series contains the updates to configure and read the attributes for
> neighbour monitor.
>
> v2: rebase on top of net-next
Series applied, thanks.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2016-07-26 21:27 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-26 6:47 [PATCH net-next v2 0/5] tipc: netlink updates for neighbour monitor Parthasarathy Bhuvaragan
2016-07-26 6:47 ` [PATCH net-next v2 1/5] tipc: introduce constants for tipc address validation Parthasarathy Bhuvaragan
2016-07-26 6:47 ` [PATCH net-next v2 2/5] tipc: make cluster size threshold for monitoring configurable Parthasarathy Bhuvaragan
2016-07-26 6:47 ` [PATCH net-next v2 3/5] tipc: get monitor threshold for the cluster Parthasarathy Bhuvaragan
2016-07-26 6:47 ` [PATCH net-next v2 4/5] tipc: add a function to get the bearer name Parthasarathy Bhuvaragan
2016-07-26 6:47 ` [PATCH net-next v2 5/5] tipc: dump monitor attributes Parthasarathy Bhuvaragan
2016-07-26 21:26 ` [PATCH net-next v2 0/5] tipc: netlink updates for neighbour monitor David Miller
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).