From: ogawa.yasufumi@lab.ntt.co.jp
To: spp@dpdk.org, ferruh.yigit@intel.com, ogawa.yasufumi@lab.ntt.co.jp
Subject: [spp] [PATCH 6/6] spp_vm: refactor log of patch command
Date: Tue, 9 Oct 2018 19:54:00 +0900 [thread overview]
Message-ID: <20181009105400.42817-7-ogawa.yasufumi@lab.ntt.co.jp> (raw)
In-Reply-To: <20181009105400.42817-1-ogawa.yasufumi@lab.ntt.co.jp>
From: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
To describe the result of patch command correctly, refactor log message.
Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
src/vm/main.c | 36 +++++++++++++++++++++---------------
1 file changed, 21 insertions(+), 15 deletions(-)
diff --git a/src/vm/main.c b/src/vm/main.c
index 997db5b..1d7d83a 100644
--- a/src/vm/main.c
+++ b/src/vm/main.c
@@ -260,17 +260,19 @@ do_del(char *res_uid)
return 0;
}
+/* Return 0 if invalid */
static int
-is_valid_port(int port_id)
+is_valid_port(uint16_t port_id)
{
- if (port_id < 0 || port_id > RTE_MAX_ETHPORTS)
+ if (port_id > RTE_MAX_ETHPORTS)
return 0;
return port_map[port_id].id != PORT_RESET;
}
+/* Return -1 as an error if given patch is invalid */
static int
-add_patch(int in_port, int out_port)
+add_patch(uint16_t in_port, uint16_t out_port)
{
if (!is_valid_port(in_port) || !is_valid_port(out_port))
return -1;
@@ -497,31 +499,35 @@ parse_command(char *str)
if (in_port == PORT_RESET && out_port == PORT_RESET) {
char err_msg[128];
memset(err_msg, '\0', sizeof(err_msg));
- sprintf(err_msg, "%s '%s:%d' and '%s:%d' %s",
- "Failed to patch, both of",
+ sprintf(err_msg, "%s '%s:%d' and '%s:%d'",
+ "Patch not found, both of",
in_p_type, in_p_id,
- out_p_type, out_p_id,
- "not found");
+ out_p_type, out_p_id);
RTE_LOG(ERR, APP, "%s\n", err_msg);
- return 0;
} else if (in_port == PORT_RESET) {
char err_msg[128];
memset(err_msg, '\0', sizeof(err_msg));
- sprintf(err_msg, "%s '%s:%d' not found",
- "Failed to patch, in_port",
+ sprintf(err_msg, "%s '%s:%d'",
+ "Patch not found, in_port",
in_p_type, in_p_id);
RTE_LOG(ERR, APP, "%s\n", err_msg);
- return 0;
} else if (out_port == PORT_RESET) {
char err_msg[128];
memset(err_msg, '\0', sizeof(err_msg));
- sprintf(err_msg, "%s '%s:%d' not found",
- "Failed to patch, out_port",
+ sprintf(err_msg, "%s '%s:%d'",
+ "Patch not found, out_port",
out_p_type, out_p_id);
RTE_LOG(ERR, APP, "%s\n", err_msg);
}
- add_patch(in_port, out_port);
+ if (add_patch(in_port, out_port) == 0)
+ RTE_LOG(INFO, APP,
+ "Patched '%s:%d' and '%s:%d'\n",
+ in_p_type, in_p_id,
+ out_p_type, out_p_id);
+ else
+ RTE_LOG(ERR, APP, "Failed to patch\n");
+ ret = 0;
}
} else if (strncmp(str, "del", 3) == 0) {
RTE_LOG(DEBUG, APP, "Received del command\n");
@@ -646,7 +652,7 @@ main(int argc, char *argv[])
RTE_LOG(DEBUG, APP, "Received string: %s\n", str);
ret = parse_command(str);
- if (ret < 0)
+ if (ret < 0) /* terminate process if exit is called */
break;
/*Send the message back to client*/
--
2.7.4
prev parent reply other threads:[~2018-10-09 10:54 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-09 10:53 [spp] [PATCH 0/6] Fix bug of assigning ports ogawa.yasufumi
2018-10-09 10:53 ` [spp] [PATCH 1/6] spp_nfv: fix bug of do_del if port does not exist ogawa.yasufumi
2018-10-09 10:53 ` [spp] [PATCH 2/6] spp_nfv: refactor log of patch command ogawa.yasufumi
2018-10-09 10:53 ` [spp] [PATCH 3/6] spp_vm: fix bug of do_del if port does not exist ogawa.yasufumi
2018-10-09 10:53 ` [spp] [PATCH 4/6] spp_vm: fix to use uint16_t port_id in do_add ogawa.yasufumi
2018-10-09 10:53 ` [spp] [PATCH 5/6] spp_vm: correct error handling if patch cmd failed ogawa.yasufumi
2018-10-09 10:54 ` ogawa.yasufumi [this message]
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=20181009105400.42817-7-ogawa.yasufumi@lab.ntt.co.jp \
--to=ogawa.yasufumi@lab.ntt.co.jp \
--cc=ferruh.yigit@intel.com \
--cc=spp@dpdk.org \
/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).