netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: <richard.alpe@ericsson.com>
To: <netdev@vger.kernel.org>
Cc: tipc-discussion@lists.sourceforge.net
Subject: [PATCH net-next v1 15/17] tipc: convert legacy nl stats show to nl compat
Date: Mon, 9 Feb 2015 09:50:17 +0100	[thread overview]
Message-ID: <1423471819-23112-16-git-send-email-richard.alpe@ericsson.com> (raw)
In-Reply-To: <1423471819-23112-1-git-send-email-richard.alpe@ericsson.com>

From: Richard Alpe <richard.alpe@ericsson.com>

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>
---
 net/tipc/config.c         | 35 -----------------------------------
 net/tipc/netlink_compat.c | 15 +++++++++++++++
 2 files changed, 15 insertions(+), 35 deletions(-)

diff --git a/net/tipc/config.c b/net/tipc/config.c
index 019f46c..c2ad2ff 100644
--- a/net/tipc/config.c
+++ b/net/tipc/config.c
@@ -83,38 +83,6 @@ struct sk_buff *tipc_cfg_reply_string_type(u16 tlv_type, char *string)
 	return buf;
 }
 
-static struct sk_buff *tipc_show_stats(void)
-{
-	struct sk_buff *buf;
-	struct tlv_desc *rep_tlv;
-	char *pb;
-	int pb_len;
-	int str_len;
-	u32 value;
-
-	if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_UNSIGNED))
-		return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR);
-
-	value = ntohl(*(u32 *)TLV_DATA(req_tlv_area));
-	if (value != 0)
-		return tipc_cfg_reply_error_string("unsupported argument");
-
-	buf = tipc_cfg_reply_alloc(TLV_SPACE(ULTRA_STRING_MAX_LEN));
-	if (buf == NULL)
-		return NULL;
-
-	rep_tlv = (struct tlv_desc *)buf->data;
-	pb = TLV_DATA(rep_tlv);
-	pb_len = ULTRA_STRING_MAX_LEN;
-
-	str_len = tipc_snprintf(pb, pb_len, "TIPC version " TIPC_MOD_VER "\n");
-	str_len += 1;	/* for "\0" */
-	skb_put(buf, TLV_SPACE(str_len));
-	TLV_SET(rep_tlv, TIPC_TLV_ULTRA_STRING, NULL, str_len);
-
-	return buf;
-}
-
 struct sk_buff *tipc_cfg_do_cmd(struct net *net, u32 orig_node, u16 cmd,
 				const void *request_area, int request_space,
 				int reply_headroom)
@@ -142,9 +110,6 @@ struct sk_buff *tipc_cfg_do_cmd(struct net *net, u32 orig_node, u16 cmd,
 	case TIPC_CMD_NOOP:
 		rep_tlv_buf = tipc_cfg_reply_none();
 		break;
-	case TIPC_CMD_SHOW_STATS:
-		rep_tlv_buf = tipc_show_stats();
-		break;
 	case TIPC_CMD_NOT_NET_ADMIN:
 		rep_tlv_buf =
 			tipc_cfg_reply_error_string(TIPC_CFG_NOT_NET_ADMIN);
diff --git a/net/tipc/netlink_compat.c b/net/tipc/netlink_compat.c
index 4159090..cb9086d 100644
--- a/net/tipc/netlink_compat.c
+++ b/net/tipc/netlink_compat.c
@@ -888,6 +888,18 @@ static int tipc_nl_compat_net_dump(struct tipc_nl_compat_msg *msg,
 	return tipc_add_tlv(msg->rep, TIPC_TLV_UNSIGNED, &id, sizeof(id));
 }
 
+static int tipc_cmd_show_stats_compat(struct tipc_nl_compat_msg *msg)
+{
+	msg->rep = tipc_tlv_alloc(ULTRA_STRING_MAX_LEN);
+	if (!msg->rep)
+		return -ENOMEM;
+
+	tipc_tlv_init(msg->rep, TIPC_TLV_ULTRA_STRING);
+	tipc_tlv_sprintf(msg->rep, "TIPC version " TIPC_MOD_VER "\n");
+
+	return 0;
+}
+
 static int tipc_nl_compat_handle(struct tipc_nl_compat_msg *msg)
 {
 	struct tipc_nl_compat_cmd_dump dump;
@@ -976,6 +988,8 @@ static int tipc_nl_compat_handle(struct tipc_nl_compat_msg *msg)
 		dump.dumpit = tipc_nl_net_dump;
 		dump.format = tipc_nl_compat_net_dump;
 		return tipc_nl_compat_dumpit(&dump, msg);
+	case TIPC_CMD_SHOW_STATS:
+		return tipc_cmd_show_stats_compat(msg);
 	}
 
 	return -EOPNOTSUPP;
@@ -1088,6 +1102,7 @@ static int tipc_nl_compat_tmp_wrap(struct sk_buff *skb, struct genl_info *info)
 	case TIPC_CMD_SET_NODE_ADDR:
 	case TIPC_CMD_SET_NETID:
 	case TIPC_CMD_GET_NETID:
+	case TIPC_CMD_SHOW_STATS:
 		return tipc_nl_compat_recv(skb, info);
 	}
 
-- 
2.1.4


------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/

  parent reply	other threads:[~2015-02-09  8:50 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-09  8:50 [PATCH net-next v1 00/17] tipc: new compat layer for the legacy NL API richard.alpe
2015-02-09  8:50 ` [PATCH net-next v1 01/17] tipc: move and rename the legacy nl api to "nl compat" richard.alpe
2015-02-09  8:50 ` [PATCH net-next v1 02/17] tipc: convert legacy nl bearer dump to nl compat richard.alpe
2015-02-09  8:50 ` [PATCH net-next v1 03/17] tipc: convert legacy nl bearer enable/disable " richard.alpe
2015-02-09  8:50 ` [PATCH net-next v1 04/17] tipc: convert legacy nl link stat " richard.alpe
2015-02-09  8:50 ` [PATCH net-next v1 05/17] tipc: convert legacy nl link dump " richard.alpe
2015-02-09  8:50 ` [PATCH net-next v1 06/17] tipc: convert legacy nl link prop set " richard.alpe
2015-02-09  8:50 ` [PATCH net-next v1 07/17] tipc: convert legacy nl link stat reset " richard.alpe
2015-02-09  8:50 ` [PATCH net-next v1 08/17] tipc: convert legacy nl name table dump " richard.alpe
2015-02-09  8:50 ` [PATCH net-next v1 09/17] tipc: convert legacy nl socket " richard.alpe
2015-02-09  8:50 ` [PATCH net-next v1 10/17] tipc: convert legacy nl media " richard.alpe
2015-02-09  8:50 ` [PATCH net-next v1 11/17] tipc: convert legacy nl node " richard.alpe
2015-02-09  8:50 ` [PATCH net-next v1 12/17] tipc: convert legacy nl node addr set " richard.alpe
2015-02-09  8:50 ` [PATCH net-next v1 13/17] tipc: convert legacy nl net id " richard.alpe
2015-02-09  8:50 ` [PATCH net-next v1 14/17] tipc: convert legacy nl net id get " richard.alpe
2015-02-09  8:50 ` richard.alpe [this message]
2015-02-09  8:50 ` [PATCH net-next v1 16/17] tipc: nl compat add noop and remove legacy nl framework richard.alpe
2015-02-09  8:50 ` [PATCH net-next v1 17/17] tipc: remove tipc_snprintf richard.alpe
2015-02-09 21:21 ` [PATCH net-next v1 00/17] tipc: new compat layer for the legacy NL API David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1423471819-23112-16-git-send-email-richard.alpe@ericsson.com \
    --to=richard.alpe@ericsson.com \
    --cc=netdev@vger.kernel.org \
    --cc=tipc-discussion@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).