tipc: get monitor threshold for the cluster
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> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
7b3f522964
commit
bf1035b2ff
6 changed files with 68 additions and 0 deletions
|
@ -57,6 +57,7 @@ enum {
|
||||||
TIPC_NL_NET_SET,
|
TIPC_NL_NET_SET,
|
||||||
TIPC_NL_NAME_TABLE_GET,
|
TIPC_NL_NAME_TABLE_GET,
|
||||||
TIPC_NL_MON_SET,
|
TIPC_NL_MON_SET,
|
||||||
|
TIPC_NL_MON_GET,
|
||||||
|
|
||||||
__TIPC_NL_CMD_MAX,
|
__TIPC_NL_CMD_MAX,
|
||||||
TIPC_NL_CMD_MAX = __TIPC_NL_CMD_MAX - 1
|
TIPC_NL_CMD_MAX = __TIPC_NL_CMD_MAX - 1
|
||||||
|
|
|
@ -661,3 +661,10 @@ int tipc_nl_monitor_set_threshold(struct net *net, u32 cluster_size)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int tipc_nl_monitor_get_threshold(struct net *net)
|
||||||
|
{
|
||||||
|
struct tipc_net *tn = tipc_net(net);
|
||||||
|
|
||||||
|
return tn->mon_threshold;
|
||||||
|
}
|
||||||
|
|
|
@ -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);
|
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_set_threshold(struct net *net, u32 cluster_size);
|
||||||
|
int tipc_nl_monitor_get_threshold(struct net *net);
|
||||||
|
|
||||||
extern const int tipc_max_domain_size;
|
extern const int tipc_max_domain_size;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -226,6 +226,11 @@ static const struct genl_ops tipc_genl_v2_ops[] = {
|
||||||
.doit = tipc_nl_node_set_monitor,
|
.doit = tipc_nl_node_set_monitor,
|
||||||
.policy = tipc_nl_policy,
|
.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)
|
int tipc_nlmsg_parse(const struct nlmsghdr *nlh, struct nlattr ***attr)
|
||||||
|
|
|
@ -1955,3 +1955,55 @@ int tipc_nl_node_set_monitor(struct sk_buff *skb, struct genl_info *info)
|
||||||
|
|
||||||
return 0;
|
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);
|
||||||
|
}
|
||||||
|
|
|
@ -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_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_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
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue