diff options
-rw-r--r-- | include/uapi/linux/tipc_netlink.h | 1 | ||||
-rw-r--r-- | net/tipc/monitor.c | 7 | ||||
-rw-r--r-- | net/tipc/monitor.h | 2 | ||||
-rw-r--r-- | net/tipc/netlink.c | 5 | ||||
-rw-r--r-- | net/tipc/node.c | 52 | ||||
-rw-r--r-- | net/tipc/node.h | 1 |
6 files changed, 68 insertions, 0 deletions
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 { | |||
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 | TIPC_NL_MON_SET, |
60 | TIPC_NL_MON_GET, | ||
60 | 61 | ||
61 | __TIPC_NL_CMD_MAX, | 62 | __TIPC_NL_CMD_MAX, |
62 | TIPC_NL_CMD_MAX = __TIPC_NL_CMD_MAX - 1 | 63 | 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) | |||
661 | 661 | ||
662 | return 0; | 662 | return 0; |
663 | } | 663 | } |
664 | |||
665 | int tipc_nl_monitor_get_threshold(struct net *net) | ||
666 | { | ||
667 | struct tipc_net *tn = tipc_net(net); | ||
668 | |||
669 | return tn->mon_threshold; | ||
670 | } | ||
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, | |||
70 | void tipc_mon_remove_peer(struct net *net, u32 addr, int bearer_id); | 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 | int tipc_nl_monitor_set_threshold(struct net *net, u32 cluster_size); |
73 | int tipc_nl_monitor_get_threshold(struct net *net); | ||
74 | |||
73 | extern const int tipc_max_domain_size; | 75 | extern const int tipc_max_domain_size; |
74 | #endif | 76 | #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[] = { | |||
226 | .doit = tipc_nl_node_set_monitor, | 226 | .doit = tipc_nl_node_set_monitor, |
227 | .policy = tipc_nl_policy, | 227 | .policy = tipc_nl_policy, |
228 | }, | 228 | }, |
229 | { | ||
230 | .cmd = TIPC_NL_MON_GET, | ||
231 | .doit = tipc_nl_node_get_monitor, | ||
232 | .policy = tipc_nl_policy, | ||
233 | }, | ||
229 | }; | 234 | }; |
230 | 235 | ||
231 | int tipc_nlmsg_parse(const struct nlmsghdr *nlh, struct nlattr ***attr) | 236 | 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) | |||
1955 | 1955 | ||
1956 | return 0; | 1956 | return 0; |
1957 | } | 1957 | } |
1958 | |||
1959 | static int __tipc_nl_add_monitor_prop(struct net *net, struct tipc_nl_msg *msg) | ||
1960 | { | ||
1961 | struct nlattr *attrs; | ||
1962 | void *hdr; | ||
1963 | u32 val; | ||
1964 | |||
1965 | hdr = genlmsg_put(msg->skb, msg->portid, msg->seq, &tipc_genl_family, | ||
1966 | 0, TIPC_NL_MON_GET); | ||
1967 | if (!hdr) | ||
1968 | return -EMSGSIZE; | ||
1969 | |||
1970 | attrs = nla_nest_start(msg->skb, TIPC_NLA_MON); | ||
1971 | if (!attrs) | ||
1972 | goto msg_full; | ||
1973 | |||
1974 | val = tipc_nl_monitor_get_threshold(net); | ||
1975 | |||
1976 | if (nla_put_u32(msg->skb, TIPC_NLA_MON_ACTIVATION_THRESHOLD, val)) | ||
1977 | goto attr_msg_full; | ||
1978 | |||
1979 | nla_nest_end(msg->skb, attrs); | ||
1980 | genlmsg_end(msg->skb, hdr); | ||
1981 | |||
1982 | return 0; | ||
1983 | |||
1984 | attr_msg_full: | ||
1985 | nla_nest_cancel(msg->skb, attrs); | ||
1986 | msg_full: | ||
1987 | genlmsg_cancel(msg->skb, hdr); | ||
1988 | |||
1989 | return -EMSGSIZE; | ||
1990 | } | ||
1991 | |||
1992 | int tipc_nl_node_get_monitor(struct sk_buff *skb, struct genl_info *info) | ||
1993 | { | ||
1994 | struct net *net = sock_net(skb->sk); | ||
1995 | struct tipc_nl_msg msg; | ||
1996 | int err; | ||
1997 | |||
1998 | msg.skb = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); | ||
1999 | msg.portid = info->snd_portid; | ||
2000 | msg.seq = info->snd_seq; | ||
2001 | |||
2002 | err = __tipc_nl_add_monitor_prop(net, &msg); | ||
2003 | if (err) { | ||
2004 | nlmsg_free(msg.skb); | ||
2005 | return err; | ||
2006 | } | ||
2007 | |||
2008 | return genlmsg_reply(msg.skb, info); | ||
2009 | } | ||
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); | |||
79 | int tipc_nl_node_set_link(struct sk_buff *skb, struct genl_info *info); | 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 | int tipc_nl_node_set_monitor(struct sk_buff *skb, struct genl_info *info); |
82 | int tipc_nl_node_get_monitor(struct sk_buff *skb, struct genl_info *info); | ||
82 | #endif | 83 | #endif |