Skip to content

Commit 7b3f522

Browse files
Parthasarathy Bhuvaragandavem330
authored andcommitted
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>
1 parent 9ff26e9 commit 7b3f522

7 files changed

Lines changed: 66 additions & 2 deletions

File tree

include/uapi/linux/tipc_netlink.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ enum {
5656
TIPC_NL_NET_GET,
5757
TIPC_NL_NET_SET,
5858
TIPC_NL_NAME_TABLE_GET,
59+
TIPC_NL_MON_SET,
5960

6061
__TIPC_NL_CMD_MAX,
6162
TIPC_NL_CMD_MAX = __TIPC_NL_CMD_MAX - 1
@@ -72,6 +73,7 @@ enum {
7273
TIPC_NLA_NODE, /* nest */
7374
TIPC_NLA_NET, /* nest */
7475
TIPC_NLA_NAME_TABLE, /* nest */
76+
TIPC_NLA_MON, /* nest */
7577

7678
__TIPC_NLA_MAX,
7779
TIPC_NLA_MAX = __TIPC_NLA_MAX - 1
@@ -166,6 +168,15 @@ enum {
166168
TIPC_NLA_NAME_TABLE_MAX = __TIPC_NLA_NAME_TABLE_MAX - 1
167169
};
168170

171+
/* Monitor info */
172+
enum {
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+
169180
/* Publication info */
170181
enum {
171182
TIPC_NLA_PUBL_UNSPEC,

net/tipc/monitor.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,3 +649,15 @@ void tipc_mon_delete(struct net *net, int bearer_id)
649649
kfree(self);
650650
kfree(mon);
651651
}
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+
}

net/tipc/monitor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,5 +69,6 @@ void tipc_mon_get_state(struct net *net, u32 addr,
6969
int bearer_id);
7070
void tipc_mon_remove_peer(struct net *net, u32 addr, int bearer_id);
7171

72+
int tipc_nl_monitor_set_threshold(struct net *net, u32 cluster_size);
7273
extern const int tipc_max_domain_size;
7374
#endif

net/tipc/netlink.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ static const struct nla_policy tipc_nl_policy[TIPC_NLA_MAX + 1] = {
5252
[TIPC_NLA_MEDIA] = { .type = NLA_NESTED, },
5353
[TIPC_NLA_NODE] = { .type = NLA_NESTED, },
5454
[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, },
5657
};
5758

5859
const struct nla_policy
@@ -61,6 +62,11 @@ tipc_nl_name_table_policy[TIPC_NLA_NAME_TABLE_MAX + 1] = {
6162
[TIPC_NLA_NAME_TABLE_PUBL] = { .type = NLA_NESTED }
6263
};
6364

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 },
68+
};
69+
6470
const struct nla_policy tipc_nl_sock_policy[TIPC_NLA_SOCK_MAX + 1] = {
6571
[TIPC_NLA_SOCK_UNSPEC] = { .type = NLA_UNSPEC },
6672
[TIPC_NLA_SOCK_ADDR] = { .type = NLA_U32 },
@@ -214,7 +220,12 @@ static const struct genl_ops tipc_genl_v2_ops[] = {
214220
.cmd = TIPC_NL_NAME_TABLE_GET,
215221
.dumpit = tipc_nl_name_table_dump,
216222
.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+
},
218229
};
219230

220231
int tipc_nlmsg_parse(const struct nlmsghdr *nlh, struct nlattr ***attr)

net/tipc/netlink.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ extern const struct nla_policy tipc_nl_prop_policy[];
5555
extern const struct nla_policy tipc_nl_bearer_policy[];
5656
extern const struct nla_policy tipc_nl_media_policy[];
5757
extern const struct nla_policy tipc_nl_udp_policy[];
58+
extern const struct nla_policy tipc_nl_monitor_policy[];
5859

5960
int tipc_netlink_start(void);
6061
int tipc_netlink_compat_start(void);

net/tipc/node.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1928,3 +1928,30 @@ int tipc_nl_node_dump_link(struct sk_buff *skb, struct netlink_callback *cb)
19281928

19291929
return skb->len;
19301930
}
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+
}

net/tipc/node.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,5 @@ int tipc_nl_node_reset_link_stats(struct sk_buff *skb, struct genl_info *info);
7878
int tipc_nl_node_get_link(struct sk_buff *skb, struct genl_info *info);
7979
int tipc_nl_node_set_link(struct sk_buff *skb, struct genl_info *info);
8080

81+
int tipc_nl_node_set_monitor(struct sk_buff *skb, struct genl_info *info);
8182
#endif

0 commit comments

Comments
 (0)