From: yasufum.o@gmail.com
To: spp@dpdk.org, ferruh.yigit@intel.com, yasufum.o@gmail.com
Subject: [spp] [PATCH 2/4] spp_vf: remove global vars of spp-ctl IP and port
Date: Mon, 24 Jun 2019 19:44:09 +0900 [thread overview]
Message-ID: <20190624104411.24977-3-yasufum.o@gmail.com> (raw)
In-Reply-To: <20190624104411.24977-1-yasufum.o@gmail.com>
From: Yasufumi Ogawa <yasufum.o@gmail.com>
This update is to remove global `startup_params` from spp_vf, and change
to use getter and setter for IP addr and port of spp-ctl.
Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
src/shared/common.c | 4 +--
src/vf/spp_vf.c | 60 +++++++++++++++++----------------------------
2 files changed, 24 insertions(+), 40 deletions(-)
diff --git a/src/shared/common.c b/src/shared/common.c
index a195929..b261fb0 100644
--- a/src/shared/common.c
+++ b/src/shared/common.c
@@ -122,11 +122,11 @@ int get_sec_dir(char *proc_name, char *dir_name)
/* Get IP address of spp_ctl as string. */
int get_spp_ctl_ip(char *s_ip)
{
- sprintf(s_ip, "%s", spp_ctl_ip);
if (spp_ctl_ip == NULL) {
- RTE_LOG(ERR, SHARED, "Failed to get IP of spp_ctl.\n");
+ RTE_LOG(ERR, SHARED, "IP addr of spp_ctl not initialized.\n");
return -1;
}
+ sprintf(s_ip, "%s", spp_ctl_ip);
return 0;
}
diff --git a/src/vf/spp_vf.c b/src/vf/spp_vf.c
index f4bafb4..d8098f2 100644
--- a/src/vf/spp_vf.c
+++ b/src/vf/spp_vf.c
@@ -57,44 +57,24 @@ usage(const char *progname)
, progname);
}
-/* Parse options for server IP and port */
-static int
-parse_app_server(const char *server_str, char *server_ip, int *server_port)
-{
- const char delim[2] = ":";
- unsigned int pos = 0;
- int port = 0;
- char *endptr = NULL;
-
- pos = strcspn(server_str, delim);
- if (pos >= strlen(server_str))
- return SPP_RET_NG;
-
- port = strtol(&server_str[pos+1], &endptr, 0);
- if (unlikely(&server_str[pos+1] == endptr) ||
- unlikely(*endptr != '\0'))
- return SPP_RET_NG;
-
- memcpy(server_ip, server_str, pos);
- server_ip[pos] = '\0';
- *server_port = port;
- RTE_LOG(DEBUG, APP, "Set server IP = %s\n", server_ip);
- RTE_LOG(DEBUG, APP, "Set server port = %d\n", *server_port);
- return SPP_RET_OK;
-}
-
/* Parse options for client app */
static int
parse_app_args(int argc, char *argv[])
{
+ int cli_id; /* Client ID. */
+ char *ctl_ip; /* IP address of spp_ctl. */
+ int ctl_port; /* Port num to connect spp_ctl. */
+ int ret;
int cnt;
- int cli_id;
+ int option_index, opt;
+
int proc_flg = 0;
int server_flg = 0;
- int option_index, opt;
+
const int argcopt = argc;
char *argvopt[argcopt];
const char *progname = argv[0];
+
static struct option lgopts[] = {
{ "client-id", required_argument, NULL,
SPP_LONGOPT_RETVAL_CLIENT_ID },
@@ -132,9 +112,10 @@ parse_app_args(int argc, char *argv[])
g_enable_vhost_cli = 1;
break;
case 's':
- if (parse_app_server(optarg, g_startup_param.server_ip,
- &g_startup_param.server_port) !=
- SPP_RET_OK) {
+ ret = parse_server(&ctl_ip, &ctl_port, optarg);
+ set_spp_ctl_ip(ctl_ip);
+ set_spp_ctl_port(ctl_port);
+ if (ret != SPP_RET_OK) {
usage(progname);
return SPP_RET_NG;
}
@@ -154,8 +135,7 @@ parse_app_args(int argc, char *argv[])
RTE_LOG(INFO, APP,
"Parsed app args (client_id=%d,server=%s:%d,"
"vhost_client=%d)\n",
- cli_id, g_startup_param.server_ip,
- g_startup_param.server_port, g_enable_vhost_cli);
+ cli_id, ctl_ip, ctl_port, g_enable_vhost_cli);
return SPP_RET_OK;
}
@@ -222,6 +202,11 @@ int
main(int argc, char *argv[])
{
int ret = SPP_RET_NG;
+ char ctl_ip[IPADDR_LEN] = { 0 };
+ int ctl_port;
+ int ret_cmd_init;
+ unsigned int lcore_id = 0;
+
#ifdef SPP_DEMONIZE
/* Daemonize process */
int ret_daemon = daemon(0, 0);
@@ -274,10 +259,10 @@ main(int argc, char *argv[])
spp_port_ability_init();
/* Setup connection for accepting commands from controller */
- int ret_command_init = sppwk_cmd_runner_conn(
- g_startup_param.server_ip,
- g_startup_param.server_port);
- if (unlikely(ret_command_init != SPP_RET_OK))
+ get_spp_ctl_ip(ctl_ip);
+ ctl_port = get_spp_ctl_port();
+ ret_cmd_init = sppwk_cmd_runner_conn(ctl_ip, ctl_port);
+ if (unlikely(ret_cmd_init != SPP_RET_OK))
break;
#ifdef SPP_RINGLATENCYSTATS_ENABLE
@@ -289,7 +274,6 @@ main(int argc, char *argv[])
#endif /* SPP_RINGLATENCYSTATS_ENABLE */
/* Start worker threads of classifier and forwarder */
- unsigned int lcore_id = 0;
RTE_LCORE_FOREACH_SLAVE(lcore_id) {
rte_eal_remote_launch(slave_main, NULL, lcore_id);
}
--
2.17.1
next prev parent reply other threads:[~2019-06-24 10:44 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-24 10:44 [spp] [PATCH 0/4] Remove global vars of IP and port of spp-ctl yasufum.o
2019-06-24 10:44 ` [spp] [PATCH 1/4] spp_nfv: remove global vars of spp-ctl IP and port yasufum.o
2019-06-24 10:44 ` yasufum.o [this message]
2019-06-24 10:44 ` [spp] [PATCH 3/4] spp_mirror: remove global vars " yasufum.o
2019-06-24 10:44 ` [spp] [PATCH 4/4] spp_pcap: " yasufum.o
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=20190624104411.24977-3-yasufum.o@gmail.com \
--to=yasufum.o@gmail.com \
--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).