aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorParthasarathy Bhuvaragan <parthasarathy.bhuvaragan@ericsson.com>2016-07-26 02:47:19 -0400
committerDavid S. Miller <davem@davemloft.net>2016-07-26 17:26:42 -0400
commit7b3f52296493656015f0c0deddb6e90e36b9cda2 (patch)
tree08a395cd2b131c0b64e3e96d1c9e543ff6d9dfd0
parent9ff26e9fabaf52f28fb5e875c0b9ffc2d1512039 (diff)
tipc: make cluster size threshold for monitoring configurable
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> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/uapi/linux/tipc_netlink.h11
-rw-r--r--net/tipc/monitor.c12
-rw-r--r--net/tipc/monitor.h1
-rw-r--r--net/tipc/netlink.c15
-rw-r--r--net/tipc/netlink.h1
-rw-r--r--net/tipc/node.c27
-rw-r--r--net/tipc/node.h1
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 {
56 TIPC_NL_NET_GET, 56 TIPC_NL_NET_GET,
57 TIPC_NL_NET_SET, 57 TIPC_NL_NET_SET,
58 TIPC_NL_NAME_TABLE_GET, 58 TIPC_NL_NAME_TABLE_GET,
59 TIPC_NL_MON_SET,
59 60
60 __TIPC_NL_CMD_MAX, 61 __TIPC_NL_CMD_MAX,
61 TIPC_NL_CMD_MAX = __TIPC_NL_CMD_MAX - 1 62 TIPC_NL_CMD_MAX = __TIPC_NL_CMD_MAX - 1
@@ -72,6 +73,7 @@ enum {
72 TIPC_NLA_NODE, /* nest */ 73 TIPC_NLA_NODE, /* nest */
73 TIPC_NLA_NET, /* nest */ 74 TIPC_NLA_NET, /* nest */
74 TIPC_NLA_NAME_TABLE, /* nest */ 75 TIPC_NLA_NAME_TABLE, /* nest */
76 TIPC_NLA_MON, /* nest */
75 77
76 __TIPC_NLA_MAX, 78 __TIPC_NLA_MAX,
77 TIPC_NLA_MAX = __TIPC_NLA_MAX - 1 79 TIPC_NLA_MAX = __TIPC_NLA_MAX - 1
@@ -166,6 +168,15 @@ enum {
166 TIPC_NLA_NAME_TABLE_MAX = __TIPC_NLA_NAME_TABLE_MAX - 1 168 TIPC_NLA_NAME_TABLE_MAX = __TIPC_NLA_NAME_TABLE_MAX - 1
167}; 169};
168 170
171/* Monitor info */
172enum {
173 TIPC_NLA_MON_UNSPEC,
174 TIPC_NLA_MON_ACTIVATION_THRESHOLD, /* u32 */
175
176 __TIPC_NLA_MON_MAX,
177 TIPC_NLA_MON_MAX = __TIPC_NLA_MON_MAX - 1
178};
179
169/* Publication info */ 180/* Publication info */
170enum { 181enum {
171 TIPC_NLA_PUBL_UNSPEC, 182 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)
649 kfree(self); 649 kfree(self);
650 kfree(mon); 650 kfree(mon);
651} 651}
652
653int tipc_nl_monitor_set_threshold(struct net *net, u32 cluster_size)
654{
655 struct tipc_net *tn = tipc_net(net);
656
657 if (cluster_size > TIPC_CLUSTER_SIZE)
658 return -EINVAL;
659
660 tn->mon_threshold = cluster_size;
661
662 return 0;
663}
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,
69 int bearer_id); 69 int bearer_id);
70void tipc_mon_remove_peer(struct net *net, u32 addr, int bearer_id); 70void tipc_mon_remove_peer(struct net *net, u32 addr, int bearer_id);
71 71
72int tipc_nl_monitor_set_threshold(struct net *net, u32 cluster_size);
72extern const int tipc_max_domain_size; 73extern const int tipc_max_domain_size;
73#endif 74#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] = {
52 [TIPC_NLA_MEDIA] = { .type = NLA_NESTED, }, 52 [TIPC_NLA_MEDIA] = { .type = NLA_NESTED, },
53 [TIPC_NLA_NODE] = { .type = NLA_NESTED, }, 53 [TIPC_NLA_NODE] = { .type = NLA_NESTED, },
54 [TIPC_NLA_NET] = { .type = NLA_NESTED, }, 54 [TIPC_NLA_NET] = { .type = NLA_NESTED, },
55 [TIPC_NLA_NAME_TABLE] = { .type = NLA_NESTED, } 55 [TIPC_NLA_NAME_TABLE] = { .type = NLA_NESTED, },
56 [TIPC_NLA_MON] = { .type = NLA_NESTED, },
56}; 57};
57 58
58const struct nla_policy 59const struct nla_policy
@@ -61,6 +62,11 @@ tipc_nl_name_table_policy[TIPC_NLA_NAME_TABLE_MAX + 1] = {
61 [TIPC_NLA_NAME_TABLE_PUBL] = { .type = NLA_NESTED } 62 [TIPC_NLA_NAME_TABLE_PUBL] = { .type = NLA_NESTED }
62}; 63};
63 64
65const struct nla_policy tipc_nl_monitor_policy[TIPC_NLA_MON_MAX + 1] = {
66 [TIPC_NLA_MON_UNSPEC] = { .type = NLA_UNSPEC },
67 [TIPC_NLA_MON_ACTIVATION_THRESHOLD] = { .type = NLA_U32 },
68};
69
64const struct nla_policy tipc_nl_sock_policy[TIPC_NLA_SOCK_MAX + 1] = { 70const struct nla_policy tipc_nl_sock_policy[TIPC_NLA_SOCK_MAX + 1] = {
65 [TIPC_NLA_SOCK_UNSPEC] = { .type = NLA_UNSPEC }, 71 [TIPC_NLA_SOCK_UNSPEC] = { .type = NLA_UNSPEC },
66 [TIPC_NLA_SOCK_ADDR] = { .type = NLA_U32 }, 72 [TIPC_NLA_SOCK_ADDR] = { .type = NLA_U32 },
@@ -214,7 +220,12 @@ static const struct genl_ops tipc_genl_v2_ops[] = {
214 .cmd = TIPC_NL_NAME_TABLE_GET, 220 .cmd = TIPC_NL_NAME_TABLE_GET,
215 .dumpit = tipc_nl_name_table_dump, 221 .dumpit = tipc_nl_name_table_dump,
216 .policy = tipc_nl_policy, 222 .policy = tipc_nl_policy,
217 } 223 },
224 {
225 .cmd = TIPC_NL_MON_SET,
226 .doit = tipc_nl_node_set_monitor,
227 .policy = tipc_nl_policy,
228 },
218}; 229};
219 230
220int tipc_nlmsg_parse(const struct nlmsghdr *nlh, struct nlattr ***attr) 231int 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[];
55extern const struct nla_policy tipc_nl_bearer_policy[]; 55extern const struct nla_policy tipc_nl_bearer_policy[];
56extern const struct nla_policy tipc_nl_media_policy[]; 56extern const struct nla_policy tipc_nl_media_policy[];
57extern const struct nla_policy tipc_nl_udp_policy[]; 57extern const struct nla_policy tipc_nl_udp_policy[];
58extern const struct nla_policy tipc_nl_monitor_policy[];
58 59
59int tipc_netlink_start(void); 60int tipc_netlink_start(void);
60int tipc_netlink_compat_start(void); 61int 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:
1928 1928
1929 return skb->len; 1929 return skb->len;
1930} 1930}
1931
1932int tipc_nl_node_set_monitor(struct sk_buff *skb, struct genl_info *info)
1933{
1934 struct nlattr *attrs[TIPC_NLA_MON_MAX + 1];
1935 struct net *net = sock_net(skb->sk);
1936 int err;
1937
1938 if (!info->attrs[TIPC_NLA_MON])
1939 return -EINVAL;
1940
1941 err = nla_parse_nested(attrs, TIPC_NLA_MON_MAX,
1942 info->attrs[TIPC_NLA_MON],
1943 tipc_nl_monitor_policy);
1944 if (err)
1945 return err;
1946
1947 if (attrs[TIPC_NLA_MON_ACTIVATION_THRESHOLD]) {
1948 u32 val;
1949
1950 val = nla_get_u32(attrs[TIPC_NLA_MON_ACTIVATION_THRESHOLD]);
1951 err = tipc_nl_monitor_set_threshold(net, val);
1952 if (err)
1953 return err;
1954 }
1955
1956 return 0;
1957}
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);
78int tipc_nl_node_get_link(struct sk_buff *skb, struct genl_info *info); 78int tipc_nl_node_get_link(struct sk_buff *skb, struct genl_info *info);
79int tipc_nl_node_set_link(struct sk_buff *skb, struct genl_info *info); 79int tipc_nl_node_set_link(struct sk_buff *skb, struct genl_info *info);
80 80
81int tipc_nl_node_set_monitor(struct sk_buff *skb, struct genl_info *info);
81#endif 82#endif