diff options
author | Parthasarathy Bhuvaragan <parthasarathy.bhuvaragan@ericsson.com> | 2016-07-26 02:47:22 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-07-26 17:26:42 -0400 |
commit | cf6f7e1d51090772d5ff7355aaf0fcff17f20d1a (patch) | |
tree | f80b57ee326824ceda895bab95b821eb14b9b9d1 /net/tipc/node.c | |
parent | ff0d3e78a67a8edd09688f073361de9ed8abf9dc (diff) |
tipc: dump monitor attributes
In this commit, we dump the monitor attributes when queried.
The link monitor attributes are separated into two kinds:
1. general attributes per bearer
2. specific attributes per node/peer
This style resembles the socket attributes and the nametable
publications per socket.
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>
Diffstat (limited to 'net/tipc/node.c')
-rw-r--r-- | net/tipc/node.c | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/net/tipc/node.c b/net/tipc/node.c index 2a7e74753f9f..21974191e425 100644 --- a/net/tipc/node.c +++ b/net/tipc/node.c | |||
@@ -2007,3 +2007,89 @@ int tipc_nl_node_get_monitor(struct sk_buff *skb, struct genl_info *info) | |||
2007 | 2007 | ||
2008 | return genlmsg_reply(msg.skb, info); | 2008 | return genlmsg_reply(msg.skb, info); |
2009 | } | 2009 | } |
2010 | |||
2011 | int tipc_nl_node_dump_monitor(struct sk_buff *skb, struct netlink_callback *cb) | ||
2012 | { | ||
2013 | struct net *net = sock_net(skb->sk); | ||
2014 | u32 prev_bearer = cb->args[0]; | ||
2015 | struct tipc_nl_msg msg; | ||
2016 | int err; | ||
2017 | int i; | ||
2018 | |||
2019 | if (prev_bearer == MAX_BEARERS) | ||
2020 | return 0; | ||
2021 | |||
2022 | msg.skb = skb; | ||
2023 | msg.portid = NETLINK_CB(cb->skb).portid; | ||
2024 | msg.seq = cb->nlh->nlmsg_seq; | ||
2025 | |||
2026 | rtnl_lock(); | ||
2027 | for (i = prev_bearer; i < MAX_BEARERS; i++) { | ||
2028 | prev_bearer = i; | ||
2029 | err = __tipc_nl_add_monitor(net, &msg, prev_bearer); | ||
2030 | if (err) | ||
2031 | goto out; | ||
2032 | } | ||
2033 | |||
2034 | out: | ||
2035 | rtnl_unlock(); | ||
2036 | cb->args[0] = prev_bearer; | ||
2037 | |||
2038 | return skb->len; | ||
2039 | } | ||
2040 | |||
2041 | int tipc_nl_node_dump_monitor_peer(struct sk_buff *skb, | ||
2042 | struct netlink_callback *cb) | ||
2043 | { | ||
2044 | struct net *net = sock_net(skb->sk); | ||
2045 | u32 prev_node = cb->args[1]; | ||
2046 | u32 bearer_id = cb->args[2]; | ||
2047 | int done = cb->args[0]; | ||
2048 | struct tipc_nl_msg msg; | ||
2049 | int err; | ||
2050 | |||
2051 | if (!prev_node) { | ||
2052 | struct nlattr **attrs; | ||
2053 | struct nlattr *mon[TIPC_NLA_MON_MAX + 1]; | ||
2054 | |||
2055 | err = tipc_nlmsg_parse(cb->nlh, &attrs); | ||
2056 | if (err) | ||
2057 | return err; | ||
2058 | |||
2059 | if (!attrs[TIPC_NLA_MON]) | ||
2060 | return -EINVAL; | ||
2061 | |||
2062 | err = nla_parse_nested(mon, TIPC_NLA_MON_MAX, | ||
2063 | attrs[TIPC_NLA_MON], | ||
2064 | tipc_nl_monitor_policy); | ||
2065 | if (err) | ||
2066 | return err; | ||
2067 | |||
2068 | if (!mon[TIPC_NLA_MON_REF]) | ||
2069 | return -EINVAL; | ||
2070 | |||
2071 | bearer_id = nla_get_u32(mon[TIPC_NLA_MON_REF]); | ||
2072 | |||
2073 | if (bearer_id >= MAX_BEARERS) | ||
2074 | return -EINVAL; | ||
2075 | } | ||
2076 | |||
2077 | if (done) | ||
2078 | return 0; | ||
2079 | |||
2080 | msg.skb = skb; | ||
2081 | msg.portid = NETLINK_CB(cb->skb).portid; | ||
2082 | msg.seq = cb->nlh->nlmsg_seq; | ||
2083 | |||
2084 | rtnl_lock(); | ||
2085 | err = tipc_nl_add_monitor_peer(net, &msg, bearer_id, &prev_node); | ||
2086 | if (!err) | ||
2087 | done = 1; | ||
2088 | |||
2089 | rtnl_unlock(); | ||
2090 | cb->args[0] = done; | ||
2091 | cb->args[1] = prev_node; | ||
2092 | cb->args[2] = bearer_id; | ||
2093 | |||
2094 | return skb->len; | ||
2095 | } | ||