aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/link.c
diff options
context:
space:
mode:
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}