diff options
author | Richard Alpe <richard.alpe@ericsson.com> | 2014-11-20 04:29:14 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-11-21 15:01:31 -0500 |
commit | ae36342b50a91cff188e417201452dc075a8f444 (patch) | |
tree | fa9b00a8a34f56f83cd90abad8d782ccb32207ce /net/tipc | |
parent | f96ce7a20d6972a834202f3cdd6a53fd0ee26a8e (diff) |
tipc: add link stat reset to new netlink api
Add TIPC_NL_LINK_RESET_STATS command to the new netlink API.
This command resets the link statistics for a particular link.
Netlink logical layout of link reset message:
-> link
-> name
Signed-off-by: Richard Alpe <richard.alpe@ericsson.com>
Reviewed-by: Erik Hugne <erik.hugne@ericsson.com>
Reviewed-by: Jon Maloy <jon.maloy@ericsson.com>
Acked-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc')
-rw-r--r-- | net/tipc/link.c | 49 | ||||
-rw-r--r-- | net/tipc/link.h | 1 | ||||
-rw-r--r-- | net/tipc/netlink.c | 5 |
3 files changed, 55 insertions, 0 deletions
diff --git a/net/tipc/link.c b/net/tipc/link.c index 6785dcfd2d23..629e8cf393bf 100644 --- a/net/tipc/link.c +++ b/net/tipc/link.c | |||
@@ -2783,3 +2783,52 @@ err_out: | |||
2783 | 2783 | ||
2784 | return err; | 2784 | return err; |
2785 | } | 2785 | } |
2786 | |||
2787 | int tipc_nl_link_reset_stats(struct sk_buff *skb, struct genl_info *info) | ||
2788 | { | ||
2789 | int err; | ||
2790 | char *link_name; | ||
2791 | unsigned int bearer_id; | ||
2792 | struct tipc_link *link; | ||
2793 | struct tipc_node *node; | ||
2794 | struct nlattr *attrs[TIPC_NLA_LINK_MAX + 1]; | ||
2795 | |||
2796 | if (!info->attrs[TIPC_NLA_LINK]) | ||
2797 | return -EINVAL; | ||
2798 | |||
2799 | err = nla_parse_nested(attrs, TIPC_NLA_LINK_MAX, | ||
2800 | info->attrs[TIPC_NLA_LINK], | ||
2801 | tipc_nl_link_policy); | ||
2802 | if (err) | ||
2803 | return err; | ||
2804 | |||
2805 | if (!attrs[TIPC_NLA_LINK_NAME]) | ||
2806 | return -EINVAL; | ||
2807 | |||
2808 | link_name = nla_data(attrs[TIPC_NLA_LINK_NAME]); | ||
2809 | |||
2810 | if (strcmp(link_name, tipc_bclink_name) == 0) { | ||
2811 | err = tipc_bclink_reset_stats(); | ||
2812 | if (err) | ||
2813 | return err; | ||
2814 | return 0; | ||
2815 | } | ||
2816 | |||
2817 | node = tipc_link_find_owner(link_name, &bearer_id); | ||
2818 | if (!node) | ||
2819 | return -EINVAL; | ||
2820 | |||
2821 | tipc_node_lock(node); | ||
2822 | |||
2823 | link = node->links[bearer_id]; | ||
2824 | if (!link) { | ||
2825 | tipc_node_unlock(node); | ||
2826 | return -EINVAL; | ||
2827 | } | ||
2828 | |||
2829 | link_reset_statistics(link); | ||
2830 | |||
2831 | tipc_node_unlock(node); | ||
2832 | |||
2833 | return 0; | ||
2834 | } | ||
diff --git a/net/tipc/link.h b/net/tipc/link.h index 3738ba11ce00..f463e7be801c 100644 --- a/net/tipc/link.h +++ b/net/tipc/link.h | |||
@@ -243,6 +243,7 @@ void tipc_link_retransmit(struct tipc_link *l_ptr, | |||
243 | int tipc_nl_link_dump(struct sk_buff *skb, struct netlink_callback *cb); | 243 | int tipc_nl_link_dump(struct sk_buff *skb, struct netlink_callback *cb); |
244 | int tipc_nl_link_get(struct sk_buff *skb, struct genl_info *info); | 244 | int tipc_nl_link_get(struct sk_buff *skb, struct genl_info *info); |
245 | int tipc_nl_link_set(struct sk_buff *skb, struct genl_info *info); | 245 | int tipc_nl_link_set(struct sk_buff *skb, struct genl_info *info); |
246 | int tipc_nl_link_reset_stats(struct sk_buff *skb, struct genl_info *info); | ||
246 | int tipc_nl_parse_link_prop(struct nlattr *prop, struct nlattr *props[]); | 247 | int tipc_nl_parse_link_prop(struct nlattr *prop, struct nlattr *props[]); |
247 | 248 | ||
248 | /* | 249 | /* |
diff --git a/net/tipc/netlink.c b/net/tipc/netlink.c index d4444e59bf98..68bfd11f232d 100644 --- a/net/tipc/netlink.c +++ b/net/tipc/netlink.c | |||
@@ -149,6 +149,11 @@ static const struct genl_ops tipc_genl_v2_ops[] = { | |||
149 | .cmd = TIPC_NL_LINK_SET, | 149 | .cmd = TIPC_NL_LINK_SET, |
150 | .doit = tipc_nl_link_set, | 150 | .doit = tipc_nl_link_set, |
151 | .policy = tipc_nl_policy, | 151 | .policy = tipc_nl_policy, |
152 | }, | ||
153 | { | ||
154 | .cmd = TIPC_NL_LINK_RESET_STATS, | ||
155 | .doit = tipc_nl_link_reset_stats, | ||
156 | .policy = tipc_nl_policy, | ||
152 | } | 157 | } |
153 | }; | 158 | }; |
154 | 159 | ||