History

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

Richard Alpe committed 11 years ago

Commit ae363421 parent f96ce7a4 files · +56 −0Browse files

Unified · Split

4 files
  1. include/uapi/linux/tipc_netlink.h +1 −0
  2. net/tipc/link.c +49 −0
  3. net/tipc/link.h +1 −0
  4. net/tipc/netlink.c +5 −0
include/uapi/linux/tipc_netlink.h+1−0
@@ -49,6 +49,7 @@ enum { · 48 unmodified lines
4949 TIPC_NL_PUBL_GET,
5050 TIPC_NL_LINK_GET,
5151 TIPC_NL_LINK_SET,
52+ TIPC_NL_LINK_RESET_STATS,
5253
5354 __TIPC_NL_CMD_MAX,
5455 TIPC_NL_CMD_MAX = __TIPC_NL_CMD_MAX - 1
net/tipc/link.c+49−0
@@ -2783,3 +2783,52 @@ err_out: · 2782 unmodified lines
27832783
27842784 return err;
27852785 }
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+}
net/tipc/link.h+1−0
@@ -243,6 +243,7 @@ void tipc_link_retransmit(struct tipc_link *l_ptr, · 242 unmodified lines
243243 int tipc_nl_link_dump(struct sk_buff *skb, struct netlink_callback *cb);
244244 int tipc_nl_link_get(struct sk_buff *skb, struct genl_info *info);
245245 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);
246247 int tipc_nl_parse_link_prop(struct nlattr *prop, struct nlattr *props[]);
247248
248249 /*
net/tipc/netlink.c+5−0
@@ -149,6 +149,11 @@ static const struct genl_ops tipc_genl_v2_ops[] = { · 148 unmodified lines
149149 .cmd = TIPC_NL_LINK_SET,
150150 .doit = tipc_nl_link_set,
151151 .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,
152157 }
153158 };
154159

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t