Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Parthasarathy Bhuvaragan and committed by
David S. Miller
7b3f5229 9ff26e9f

+66 -2
+11
include/uapi/linux/tipc_netlink.h
··· 56 56 TIPC_NL_NET_GET, 57 57 TIPC_NL_NET_SET, 58 58 TIPC_NL_NAME_TABLE_GET, 59 + TIPC_NL_MON_SET, 59 60 60 61 __TIPC_NL_CMD_MAX, 61 62 TIPC_NL_CMD_MAX = __TIPC_NL_CMD_MAX - 1 ··· 73 72 TIPC_NLA_NODE, /* nest */ 74 73 TIPC_NLA_NET, /* nest */ 75 74 TIPC_NLA_NAME_TABLE, /* nest */ 75 + TIPC_NLA_MON, /* nest */ 76 76 77 77 __TIPC_NLA_MAX, 78 78 TIPC_NLA_MAX = __TIPC_NLA_MAX - 1 ··· 166 164 167 165 __TIPC_NLA_NAME_TABLE_MAX, 168 166 TIPC_NLA_NAME_TABLE_MAX = __TIPC_NLA_NAME_TABLE_MAX - 1 167 + }; 168 + 169 + /* Monitor info */ 170 + enum { 171 + TIPC_NLA_MON_UNSPEC, 172 + TIPC_NLA_MON_ACTIVATION_THRESHOLD, /* u32 */ 173 + 174 + __TIPC_NLA_MON_MAX, 175 + TIPC_NLA_MON_MAX = __TIPC_NLA_MON_MAX - 1 169 176 }; 170 177 171 178 /* Publication info */
+12
net/tipc/monitor.c
··· 649 649 kfree(self); 650 650 kfree(mon); 651 651 } 652 + 653 + int 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 + }
+1
net/tipc/monitor.h
··· 69 69 int bearer_id); 70 70 void tipc_mon_remove_peer(struct net *net, u32 addr, int bearer_id); 71 71 72 + int tipc_nl_monitor_set_threshold(struct net *net, u32 cluster_size); 72 73 extern const int tipc_max_domain_size; 73 74 #endif
+13 -2
net/tipc/netlink.c
··· 52 52 [TIPC_NLA_MEDIA] = { .type = NLA_NESTED, }, 53 53 [TIPC_NLA_NODE] = { .type = NLA_NESTED, }, 54 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 58 59 const struct nla_policy 59 60 tipc_nl_name_table_policy[TIPC_NLA_NAME_TABLE_MAX + 1] = { 60 61 [TIPC_NLA_NAME_TABLE_UNSPEC] = { .type = NLA_UNSPEC }, 61 62 [TIPC_NLA_NAME_TABLE_PUBL] = { .type = NLA_NESTED } 63 + }; 64 + 65 + const 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 }, 62 68 }; 63 69 64 70 const struct nla_policy tipc_nl_sock_policy[TIPC_NLA_SOCK_MAX + 1] = { ··· 220 214 .cmd = TIPC_NL_NAME_TABLE_GET, 221 215 .dumpit = tipc_nl_name_table_dump, 222 216 .policy = tipc_nl_policy, 223 - } 217 + }, 218 + { 219 + .cmd = TIPC_NL_MON_SET, 220 + .doit = tipc_nl_node_set_monitor, 221 + .policy = tipc_nl_policy, 222 + }, 224 223 }; 225 224 226 225 int tipc_nlmsg_parse(const struct nlmsghdr *nlh, struct nlattr ***attr)
+1
net/tipc/netlink.h
··· 55 55 extern const struct nla_policy tipc_nl_bearer_policy[]; 56 56 extern const struct nla_policy tipc_nl_media_policy[]; 57 57 extern const struct nla_policy tipc_nl_udp_policy[]; 58 + extern const struct nla_policy tipc_nl_monitor_policy[]; 58 59 59 60 int tipc_netlink_start(void); 60 61 int tipc_netlink_compat_start(void);
+27
net/tipc/node.c
··· 1928 1928 1929 1929 return skb->len; 1930 1930 } 1931 + 1932 + int 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 + }
+1
net/tipc/node.h
··· 78 78 int tipc_nl_node_get_link(struct sk_buff *skb, struct genl_info *info); 79 79 int tipc_nl_node_set_link(struct sk_buff *skb, struct genl_info *info); 80 80 81 + int tipc_nl_node_set_monitor(struct sk_buff *skb, struct genl_info *info); 81 82 #endif