aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/link.c
diff options
context:
space:
mode:
authorRichard Alpe <richard.alpe@ericsson.com>2014-11-20 04:29:14 -0500
committerDavid S. Miller <davem@davemloft.net>2014-11-21 15:01:31 -0500
commitae36342b50a91cff188e417201452dc075a8f444 (patch)
treefa9b00a8a34f56f83cd90abad8d782ccb32207ce /net/tipc/link.c
parentf96ce7a20d6972a834202f3cdd6a53fd0ee26a8e (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/link.c')
-rw-r--r--net/tipc/link.c49
1 files changed, 49 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
2787int 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}