Skip to content

Commit 1817877

Browse files
Richard Alpedavem330
authored andcommitted
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>
1 parent 37e2d48 commit 1817877

4 files changed

Lines changed: 27 additions & 41 deletions

File tree

‎net/tipc/config.c‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,10 +209,6 @@ struct sk_buff *tipc_cfg_do_cmd(struct net *net, u32 orig_node, u16 cmd,
209209
rep_tlv_buf = tipc_node_get_nodes(net, req_tlv_area,
210210
req_tlv_space);
211211
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;
216212
case TIPC_CMD_SHOW_NAME_TABLE:
217213
rep_tlv_buf = tipc_nametbl_get(net, req_tlv_area,
218214
req_tlv_space);

‎net/tipc/link.c‎

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1969,39 +1969,6 @@ static void link_reset_statistics(struct tipc_link *l_ptr)
19691969
l_ptr->stats.recv_info = l_ptr->next_in_no;
19701970
}
19711971

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-
20051972
static void link_print(struct tipc_link *l_ptr, const char *str)
20061973
{
20071974
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)
24242391
struct tipc_link *link;
24252392
struct tipc_node *node;
24262393
struct nlattr *attrs[TIPC_NLA_LINK_MAX + 1];
2427-
struct net *net = genl_info_net(info);
2394+
struct net *net = sock_net(skb->sk);
24282395

24292396
if (!info->attrs[TIPC_NLA_LINK])
24302397
return -EINVAL;

‎net/tipc/link.h‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,6 @@ void tipc_link_reset_fragments(struct tipc_link *l_ptr);
215215
int tipc_link_is_up(struct tipc_link *l_ptr);
216216
int tipc_link_is_active(struct tipc_link *l_ptr);
217217
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);
221218
void tipc_link_reset_all(struct tipc_node *node);
222219
void tipc_link_reset(struct tipc_link *l_ptr);
223220
void tipc_link_reset_list(struct net *net, unsigned int bearer_id);

‎net/tipc/netlink_compat.c‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,26 @@ static int tipc_nl_compat_link_set(struct sk_buff *skb,
606606
return 0;
607607
}
608608

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+
609629
static int tipc_nl_compat_handle(struct tipc_nl_compat_msg *msg)
610630
{
611631
struct tipc_nl_compat_cmd_dump dump;
@@ -650,6 +670,11 @@ static int tipc_nl_compat_handle(struct tipc_nl_compat_msg *msg)
650670
doit.doit = tipc_nl_link_set;
651671
doit.transcode = tipc_nl_compat_link_set;
652672
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);
653678
}
654679

655680
return -EOPNOTSUPP;
@@ -754,6 +779,7 @@ static int tipc_nl_compat_tmp_wrap(struct sk_buff *skb, struct genl_info *info)
754779
case TIPC_CMD_SET_LINK_TOL:
755780
case TIPC_CMD_SET_LINK_PRI:
756781
case TIPC_CMD_SET_LINK_WINDOW:
782+
case TIPC_CMD_RESET_LINK_STATS:
757783
return tipc_nl_compat_recv(skb, info);
758784
}
759785

0 commit comments

Comments
 (0)