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
Unified · Split
| @@ -49,6 +49,7 @@ enum { · 48 unmodified lines | |||
| 49 | TIPC_NL_PUBL_GET, | 49 | TIPC_NL_PUBL_GET, |
| 50 | TIPC_NL_LINK_GET, | 50 | TIPC_NL_LINK_GET, |
| 51 | TIPC_NL_LINK_SET, | 51 | TIPC_NL_LINK_SET, |
| 52 | TIPC_NL_LINK_RESET_STATS, | ||
| 52 | 53 | ||
| 53 | __TIPC_NL_CMD_MAX, | 54 | __TIPC_NL_CMD_MAX, |
| 54 | TIPC_NL_CMD_MAX = __TIPC_NL_CMD_MAX - 1 | 55 | TIPC_NL_CMD_MAX = __TIPC_NL_CMD_MAX - 1 |
| @@ -2783,3 +2783,52 @@ err_out: · 2782 unmodified lines | |||
| 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 | } | ||
| @@ -243,6 +243,7 @@ void tipc_link_retransmit(struct tipc_link *l_ptr, · 242 unmodified lines | |||
| 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 | /* |
| @@ -149,6 +149,11 @@ static const struct genl_ops tipc_genl_v2_ops[] = { · 148 unmodified lines | |||
| 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 | ||