diff options
| author | Richard Alpe <richard.alpe@ericsson.com> | 2015-02-09 03:50:09 -0500 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2015-02-09 16:20:48 -0500 |
| commit | 1817877b3cd7b4dc73e4a1514d5f48eaa3989ec9 (patch) | |
| tree | 7aa83bc3d462fc0ba6e14c211435f8fbcce9075c | |
| parent | 37e2d4843f9e2f5aad6bf3be5dad174f2838f375 (diff) | |
tipc: convert legacy nl link stat reset to nl compat
Convert TIPC_CMD_RESET_LINK_STATS to compat doit.
Signed-off-by: Richard Alpe <richard.alpe@ericsson.com>
Reviewed-by: Erik Hugne <erik.hugne@ericsson.com>
Reviewed-by: Ying Xue <ying.xue@windriver.com>
Reviewed-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
| -rw-r--r-- | net/tipc/config.c | 4 | ||||
| -rw-r--r-- | net/tipc/link.c | 35 | ||||
| -rw-r--r-- | net/tipc/link.h | 3 | ||||
| -rw-r--r-- | net/tipc/netlink_compat.c | 26 |
4 files changed, 27 insertions, 41 deletions
diff --git a/net/tipc/config.c b/net/tipc/config.c index 75a130e493f5..11c16d191fa2 100644 --- a/net/tipc/config.c +++ b/net/tipc/config.c | |||
| @@ -209,10 +209,6 @@ struct sk_buff *tipc_cfg_do_cmd(struct net *net, u32 orig_node, u16 cmd, | |||
| 209 | rep_tlv_buf = tipc_node_get_nodes(net, req_tlv_area, | 209 | rep_tlv_buf = tipc_node_get_nodes(net, req_tlv_area, |
| 210 | req_tlv_space); | 210 | req_tlv_space); |
| 211 | break; | 211 | break; |
| 212 | case TIPC_CMD_RESET_LINK_STATS: | ||
| 213 | rep_tlv_buf = tipc_link_cmd_reset_stats(net, req_tlv_area, | ||
| 214 | req_tlv_space); | ||
| 215 | break; | ||
| 216 | case TIPC_CMD_SHOW_NAME_TABLE: | 212 | case TIPC_CMD_SHOW_NAME_TABLE: |
| 217 | rep_tlv_buf = tipc_nametbl_get(net, req_tlv_area, | 213 | rep_tlv_buf = tipc_nametbl_get(net, req_tlv_area, |
| 218 | req_tlv_space); | 214 | req_tlv_space); |
diff --git a/net/tipc/link.c b/net/tipc/link.c index ec136b5cc339..dfe6f4d0b402 100644 --- a/net/tipc/link.c +++ b/net/tipc/link.c | |||
| @@ -1969,39 +1969,6 @@ static void link_reset_statistics(struct tipc_link *l_ptr) | |||
| 1969 | l_ptr->stats.recv_info = l_ptr->next_in_no; | 1969 | l_ptr->stats.recv_info = l_ptr->next_in_no; |
| 1970 | } | 1970 | } |
| 1971 | 1971 | ||
| 1972 | struct sk_buff *tipc_link_cmd_reset_stats(struct net *net, | ||
| 1973 | const void *req_tlv_area, | ||
| 1974 | int req_tlv_space) | ||
| 1975 | { | ||
| 1976 | char *link_name; | ||
| 1977 | struct tipc_link *l_ptr; | ||
| 1978 | struct tipc_node *node; | ||
| 1979 | unsigned int bearer_id; | ||
| 1980 | |||
| 1981 | if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_LINK_NAME)) | ||
| 1982 | return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR); | ||
| 1983 | |||
| 1984 | link_name = (char *)TLV_DATA(req_tlv_area); | ||
| 1985 | if (!strcmp(link_name, tipc_bclink_name)) { | ||
| 1986 | if (tipc_bclink_reset_stats(net)) | ||
| 1987 | return tipc_cfg_reply_error_string("link not found"); | ||
| 1988 | return tipc_cfg_reply_none(); | ||
| 1989 | } | ||
| 1990 | node = tipc_link_find_owner(net, link_name, &bearer_id); | ||
| 1991 | if (!node) | ||
| 1992 | return tipc_cfg_reply_error_string("link not found"); | ||
| 1993 | |||
| 1994 | tipc_node_lock(node); | ||
| 1995 | l_ptr = node->links[bearer_id]; | ||
| 1996 | if (!l_ptr) { | ||
| 1997 | tipc_node_unlock(node); | ||
| 1998 | return tipc_cfg_reply_error_string("link not found"); | ||
| 1999 | } | ||
| 2000 | link_reset_statistics(l_ptr); | ||
| 2001 | tipc_node_unlock(node); | ||
| 2002 | return tipc_cfg_reply_none(); | ||
| 2003 | } | ||
| 2004 | |||
| 2005 | static void link_print(struct tipc_link *l_ptr, const char *str) | 1972 | static void link_print(struct tipc_link *l_ptr, const char *str) |
| 2006 | { | 1973 | { |
| 2007 | struct tipc_net *tn = net_generic(l_ptr->owner->net, tipc_net_id); | 1974 | struct tipc_net *tn = net_generic(l_ptr->owner->net, tipc_net_id); |
| @@ -2424,7 +2391,7 @@ int tipc_nl_link_reset_stats(struct sk_buff *skb, struct genl_info *info) | |||
| 2424 | struct tipc_link *link; | 2391 | struct tipc_link *link; |
| 2425 | struct tipc_node *node; | 2392 | struct tipc_node *node; |
| 2426 | struct nlattr *attrs[TIPC_NLA_LINK_MAX + 1]; | 2393 | struct nlattr *attrs[TIPC_NLA_LINK_MAX + 1]; |
| 2427 | struct net *net = genl_info_net(info); | 2394 | struct net *net = sock_net(skb->sk); |
| 2428 | 2395 | ||
| 2429 | if (!info->attrs[TIPC_NLA_LINK]) | 2396 | if (!info->attrs[TIPC_NLA_LINK]) |
| 2430 | return -EINVAL; | 2397 | return -EINVAL; |
diff --git a/net/tipc/link.h b/net/tipc/link.h index 6eb9d606063b..7aeb52092bf3 100644 --- a/net/tipc/link.h +++ b/net/tipc/link.h | |||
| @@ -215,9 +215,6 @@ void tipc_link_reset_fragments(struct tipc_link *l_ptr); | |||
| 215 | int tipc_link_is_up(struct tipc_link *l_ptr); | 215 | int tipc_link_is_up(struct tipc_link *l_ptr); |
| 216 | int tipc_link_is_active(struct tipc_link *l_ptr); | 216 | int tipc_link_is_active(struct tipc_link *l_ptr); |
| 217 | void tipc_link_purge_queues(struct tipc_link *l_ptr); | 217 | void tipc_link_purge_queues(struct tipc_link *l_ptr); |
| 218 | struct sk_buff *tipc_link_cmd_reset_stats(struct net *net, | ||
| 219 | const void *req_tlv_area, | ||
| 220 | int req_tlv_space); | ||
| 221 | void tipc_link_reset_all(struct tipc_node *node); | 218 | void tipc_link_reset_all(struct tipc_node *node); |
| 222 | void tipc_link_reset(struct tipc_link *l_ptr); | 219 | void tipc_link_reset(struct tipc_link *l_ptr); |
| 223 | void tipc_link_reset_list(struct net *net, unsigned int bearer_id); | 220 | void tipc_link_reset_list(struct net *net, unsigned int bearer_id); |
diff --git a/net/tipc/netlink_compat.c b/net/tipc/netlink_compat.c index 056532b41e7e..02461233b6d8 100644 --- a/net/tipc/netlink_compat.c +++ b/net/tipc/netlink_compat.c | |||
| @@ -606,6 +606,26 @@ static int tipc_nl_compat_link_set(struct sk_buff *skb, | |||
| 606 | return 0; | 606 | return 0; |
| 607 | } | 607 | } |
| 608 | 608 | ||
| 609 | static int tipc_nl_compat_link_reset_stats(struct sk_buff *skb, | ||
| 610 | struct tipc_nl_compat_msg *msg) | ||
| 611 | { | ||
| 612 | char *name; | ||
| 613 | struct nlattr *link; | ||
| 614 | |||
| 615 | name = (char *)TLV_DATA(msg->req); | ||
| 616 | |||
| 617 | link = nla_nest_start(skb, TIPC_NLA_LINK); | ||
| 618 | if (!link) | ||
| 619 | return -EMSGSIZE; | ||
| 620 | |||
| 621 | if (nla_put_string(skb, TIPC_NLA_LINK_NAME, name)) | ||
| 622 | return -EMSGSIZE; | ||
| 623 | |||
| 624 | nla_nest_end(skb, link); | ||
| 625 | |||
| 626 | return 0; | ||
| 627 | } | ||
| 628 | |||
| 609 | static int tipc_nl_compat_handle(struct tipc_nl_compat_msg *msg) | 629 | static int tipc_nl_compat_handle(struct tipc_nl_compat_msg *msg) |
| 610 | { | 630 | { |
| 611 | struct tipc_nl_compat_cmd_dump dump; | 631 | struct tipc_nl_compat_cmd_dump dump; |
| @@ -650,6 +670,11 @@ static int tipc_nl_compat_handle(struct tipc_nl_compat_msg *msg) | |||
| 650 | doit.doit = tipc_nl_link_set; | 670 | doit.doit = tipc_nl_link_set; |
| 651 | doit.transcode = tipc_nl_compat_link_set; | 671 | doit.transcode = tipc_nl_compat_link_set; |
| 652 | return tipc_nl_compat_doit(&doit, msg); | 672 | return tipc_nl_compat_doit(&doit, msg); |
| 673 | case TIPC_CMD_RESET_LINK_STATS: | ||
| 674 | msg->req_type = TIPC_TLV_LINK_NAME; | ||
| 675 | doit.doit = tipc_nl_link_reset_stats; | ||
| 676 | doit.transcode = tipc_nl_compat_link_reset_stats; | ||
| 677 | return tipc_nl_compat_doit(&doit, msg); | ||
| 653 | } | 678 | } |
| 654 | 679 | ||
| 655 | return -EOPNOTSUPP; | 680 | return -EOPNOTSUPP; |
| @@ -754,6 +779,7 @@ static int tipc_nl_compat_tmp_wrap(struct sk_buff *skb, struct genl_info *info) | |||
| 754 | case TIPC_CMD_SET_LINK_TOL: | 779 | case TIPC_CMD_SET_LINK_TOL: |
| 755 | case TIPC_CMD_SET_LINK_PRI: | 780 | case TIPC_CMD_SET_LINK_PRI: |
| 756 | case TIPC_CMD_SET_LINK_WINDOW: | 781 | case TIPC_CMD_SET_LINK_WINDOW: |
| 782 | case TIPC_CMD_RESET_LINK_STATS: | ||
| 757 | return tipc_nl_compat_recv(skb, info); | 783 | return tipc_nl_compat_recv(skb, info); |
| 758 | } | 784 | } |
| 759 | 785 | ||
