Skip to content

Commit 5a81a63

Browse files
Richard Alpedavem330
authored andcommitted
tipc: convert legacy nl stats show to nl compat
Convert TIPC_CMD_SHOW_STATS to compat layer. This command does not have any counterpart in the new API, meaning it now solely exists as a function in the compat layer. 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 3c26181 commit 5a81a63

2 files changed

Lines changed: 15 additions & 35 deletions

File tree

‎net/tipc/config.c‎

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -83,38 +83,6 @@ struct sk_buff *tipc_cfg_reply_string_type(u16 tlv_type, char *string)
8383
return buf;
8484
}
8585

86-
static struct sk_buff *tipc_show_stats(void)
87-
{
88-
struct sk_buff *buf;
89-
struct tlv_desc *rep_tlv;
90-
char *pb;
91-
int pb_len;
92-
int str_len;
93-
u32 value;
94-
95-
if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_UNSIGNED))
96-
return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR);
97-
98-
value = ntohl(*(u32 *)TLV_DATA(req_tlv_area));
99-
if (value != 0)
100-
return tipc_cfg_reply_error_string("unsupported argument");
101-
102-
buf = tipc_cfg_reply_alloc(TLV_SPACE(ULTRA_STRING_MAX_LEN));
103-
if (buf == NULL)
104-
return NULL;
105-
106-
rep_tlv = (struct tlv_desc *)buf->data;
107-
pb = TLV_DATA(rep_tlv);
108-
pb_len = ULTRA_STRING_MAX_LEN;
109-
110-
str_len = tipc_snprintf(pb, pb_len, "TIPC version " TIPC_MOD_VER "\n");
111-
str_len += 1; /* for "\0" */
112-
skb_put(buf, TLV_SPACE(str_len));
113-
TLV_SET(rep_tlv, TIPC_TLV_ULTRA_STRING, NULL, str_len);
114-
115-
return buf;
116-
}
117-
11886
struct sk_buff *tipc_cfg_do_cmd(struct net *net, u32 orig_node, u16 cmd,
11987
const void *request_area, int request_space,
12088
int reply_headroom)
@@ -142,9 +110,6 @@ struct sk_buff *tipc_cfg_do_cmd(struct net *net, u32 orig_node, u16 cmd,
142110
case TIPC_CMD_NOOP:
143111
rep_tlv_buf = tipc_cfg_reply_none();
144112
break;
145-
case TIPC_CMD_SHOW_STATS:
146-
rep_tlv_buf = tipc_show_stats();
147-
break;
148113
case TIPC_CMD_NOT_NET_ADMIN:
149114
rep_tlv_buf =
150115
tipc_cfg_reply_error_string(TIPC_CFG_NOT_NET_ADMIN);

‎net/tipc/netlink_compat.c‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -888,6 +888,18 @@ static int tipc_nl_compat_net_dump(struct tipc_nl_compat_msg *msg,
888888
return tipc_add_tlv(msg->rep, TIPC_TLV_UNSIGNED, &id, sizeof(id));
889889
}
890890

891+
static int tipc_cmd_show_stats_compat(struct tipc_nl_compat_msg *msg)
892+
{
893+
msg->rep = tipc_tlv_alloc(ULTRA_STRING_MAX_LEN);
894+
if (!msg->rep)
895+
return -ENOMEM;
896+
897+
tipc_tlv_init(msg->rep, TIPC_TLV_ULTRA_STRING);
898+
tipc_tlv_sprintf(msg->rep, "TIPC version " TIPC_MOD_VER "\n");
899+
900+
return 0;
901+
}
902+
891903
static int tipc_nl_compat_handle(struct tipc_nl_compat_msg *msg)
892904
{
893905
struct tipc_nl_compat_cmd_dump dump;
@@ -976,6 +988,8 @@ static int tipc_nl_compat_handle(struct tipc_nl_compat_msg *msg)
976988
dump.dumpit = tipc_nl_net_dump;
977989
dump.format = tipc_nl_compat_net_dump;
978990
return tipc_nl_compat_dumpit(&dump, msg);
991+
case TIPC_CMD_SHOW_STATS:
992+
return tipc_cmd_show_stats_compat(msg);
979993
}
980994

981995
return -EOPNOTSUPP;
@@ -1088,6 +1102,7 @@ static int tipc_nl_compat_tmp_wrap(struct sk_buff *skb, struct genl_info *info)
10881102
case TIPC_CMD_SET_NODE_ADDR:
10891103
case TIPC_CMD_SET_NETID:
10901104
case TIPC_CMD_GET_NETID:
1105+
case TIPC_CMD_SHOW_STATS:
10911106
return tipc_nl_compat_recv(skb, info);
10921107
}
10931108

0 commit comments

Comments
 (0)