summaryrefslogtreecommitdiffstats
path: root/stacks/lwip_stack
diff options
context:
space:
mode:
Diffstat (limited to 'stacks/lwip_stack')
-rw-r--r--stacks/lwip_stack/CMakeLists.txt2
-rw-r--r--stacks/lwip_stack/app_conf/module_config.json27
-rw-r--r--stacks/lwip_stack/configure/module_config.json17
-rw-r--r--stacks/lwip_stack/configure/nStackConfig.json (renamed from stacks/lwip_stack/app_conf/nStackConfig.json)0
-rw-r--r--stacks/lwip_stack/configure/rd_config.json (renamed from stacks/lwip_stack/app_conf/rd_config.json)0
-rw-r--r--stacks/lwip_stack/doc/README.md11
-rw-r--r--stacks/lwip_stack/lwip_src/api/spl_api_msg.c11
-rw-r--r--stacks/lwip_stack/lwip_src/api/spl_tcpip.c6
-rw-r--r--stacks/lwip_stack/lwip_src/common/stackx_common_opt.h1
-rw-r--r--stacks/lwip_stack/lwip_src/common/stackx_spl_msg.h2
-rw-r--r--stacks/lwip_stack/lwip_src/include/ip_module/ip_module_api.h1
-rw-r--r--stacks/lwip_stack/lwip_src/include/netif/sharedmemory.h1
-rw-r--r--stacks/lwip_stack/lwip_src/ip_module/container_ip.c2
-rw-r--r--stacks/lwip_stack/lwip_src/ip_module/network.c43
-rw-r--r--stacks/lwip_stack/lwip_src/netif/spl_hal.c21
-rw-r--r--stacks/lwip_stack/lwip_src/socket/stackx_tcp.c12
-rw-r--r--stacks/lwip_stack/lwip_src/socket/stackx_udp.c22
-rw-r--r--stacks/lwip_stack/release/configure/ip_data.json25
-rw-r--r--stacks/lwip_stack/release/configure/network_data_tonStack.json22
-rwxr-xr-xstacks/lwip_stack/release/lwip_helper_files/download_lwip.sh4
-rwxr-xr-xstacks/lwip_stack/release/script/nstack_fun.sh4
-rwxr-xr-xstacks/lwip_stack/release/script/nstack_var.sh4
-rwxr-xr-xstacks/lwip_stack/release/script/run_nstack_main.sh3
-rwxr-xr-xstacks/lwip_stack/release/start_nstack.sh46
-rw-r--r--stacks/lwip_stack/release_tar.sh4
-rw-r--r--stacks/lwip_stack/src/io_adpt/dpdk.c69
-rw-r--r--stacks/lwip_stack/src/nStackMain/main.c2
-rw-r--r--stacks/lwip_stack/src/sbr/CMakeLists.txt6
-rw-r--r--stacks/lwip_stack/src/sbr/sbr_socket.c2
-rwxr-xr-xstacks/lwip_stack/vagrant/start_nstackMain.sh14
30 files changed, 234 insertions, 150 deletions
diff --git a/stacks/lwip_stack/CMakeLists.txt b/stacks/lwip_stack/CMakeLists.txt
index 3992f20..5a5ca94 100644
--- a/stacks/lwip_stack/CMakeLists.txt
+++ b/stacks/lwip_stack/CMakeLists.txt
@@ -65,7 +65,7 @@ execute_process(
COMMAND sh ${CMAKE_CURRENT_LIST_DIR}/release/lwip_helper_files/download_lwip.sh
)
-ADD_DEFINITIONS(-D_GNU_SOURCE -DNSTACK_GETVER_VERSION="18.07")
+ADD_DEFINITIONS(-D_GNU_SOURCE -DNSTACK_GETVER_VERSION="18.10")
SET(JSON_C_SRC ${CMAKE_CURRENT_LIST_DIR}/../../thirdparty/json/json-c-0.12.1)
INCLUDE(ExternalProject)
diff --git a/stacks/lwip_stack/app_conf/module_config.json b/stacks/lwip_stack/app_conf/module_config.json
deleted file mode 100644
index f1b3458..0000000
--- a/stacks/lwip_stack/app_conf/module_config.json
+++ /dev/null
@@ -1,27 +0,0 @@
-{
- "default_stack_name": "kernel",
- "module_list": [
- {
- "stack_name": "kernel",
- "function_name": "kernel_stack_register",
- "libname": "./",
- "loadtype": "static",
- "deploytype": "1",
- "maxfd": "1024",
- "minfd": "0",
- "priorty": "1",
- "stackid": "0",
- },
- {
- "stack_name": "lwip",
- "function_name": "nstack_stack_register",
- "libname": "libnstack.so",
- "loadtype": "dynmic",
- "deploytype": "3",
- "maxfd": "1024",
- "minfd": "0",
- "priorty": "1",
- "stackid": "1",
- },
- ]
-}
diff --git a/stacks/lwip_stack/configure/module_config.json b/stacks/lwip_stack/configure/module_config.json
new file mode 100644
index 0000000..c9c872b
--- /dev/null
+++ b/stacks/lwip_stack/configure/module_config.json
@@ -0,0 +1,17 @@
+{
+ "default_stack_name": "kernel",
+ "module_list": [
+ {
+ "stack_name": "kernel",
+ "libname": "./",
+ "deploytype": "1",
+ "stackid": "0",
+ },
+ {
+ "stack_name": "lwip",
+ "libname": "liblwip_dpdk.so",
+ "deploytype": "3",
+ "stackid": "1",
+ },
+ ]
+}
diff --git a/stacks/lwip_stack/app_conf/nStackConfig.json b/stacks/lwip_stack/configure/nStackConfig.json
index 3cc54c5..3cc54c5 100644
--- a/stacks/lwip_stack/app_conf/nStackConfig.json
+++ b/stacks/lwip_stack/configure/nStackConfig.json
diff --git a/stacks/lwip_stack/app_conf/rd_config.json b/stacks/lwip_stack/configure/rd_config.json
index 3109bcd..3109bcd 100644
--- a/stacks/lwip_stack/app_conf/rd_config.json
+++ b/stacks/lwip_stack/configure/rd_config.json
diff --git a/stacks/lwip_stack/doc/README.md b/stacks/lwip_stack/doc/README.md
index e9bb31e..a76b18a 100644
--- a/stacks/lwip_stack/doc/README.md
+++ b/stacks/lwip_stack/doc/README.md
@@ -32,11 +32,11 @@ a birds eye view of lwip in DMM pipeline mode.
```sh
#export LD_LIBRARY_PATH=${dmm}/stacks/lwip_stack/release/lib64/
#export LD_PRELOAD=${dmm}/release/lib64/libnStackAPI.so
- #export NSTACK_MOD_CFG_FILE=${dmm}/stacks/lwip_stack/app_conf/module_config.json
- #export NSTACK_MOD_CFG_RD=${dmm}/stacks/lwip_stack/app_conf/rd_config.json
+ #export NSTACK_MOD_CFG_FILE=${dmm}/stacks/lwip_stack/configure/module_config.json
+ #export NSTACK_MOD_CFG_RD=${dmm}/stacks/lwip_stack/configure/rd_config.json
#export NSTACK_LOG_ON=DBG (optional enable debug)
```
-- Steps 2: Modify rd_config.json(located at dmm/stacks/lwip_stack/app_config/)
+- Steps 2: Modify rd_config.json(located at dmm/stacks/lwip_stack/configure/)
```sh
#vim rd_config.json
Eg. set "subnet": "192.168.21.1/24"
@@ -67,6 +67,11 @@ Run the process:
#./start_nstack.sh
```
+If you want to run it with vhost-user, you can run the start_nstack.sh with parameters as follow.
+```
+ #./start_nstack.sh --vdev virtio_user,mac=fa:16:3e:5f:b3:08,path=/tmp/unix/sock1.sock,queues=8,queue_size=1024 --no-pci
+```
+
- Steps 4: Communication test between machine A(as server) with machine B
(as client)
diff --git a/stacks/lwip_stack/lwip_src/api/spl_api_msg.c b/stacks/lwip_stack/lwip_src/api/spl_api_msg.c
index 1c9bf92..f437bce 100644
--- a/stacks/lwip_stack/lwip_src/api/spl_api_msg.c
+++ b/stacks/lwip_stack/lwip_src/api/spl_api_msg.c
@@ -22,6 +22,7 @@
//#include "sockets.h"
#include <netinet/in.h>
#include <errno.h>
+#include <netinet/tcp.h>
#include "stackx_prot_com.h"
#include "spl_api.h"
@@ -1572,6 +1573,7 @@ spl_do_connected (void *arg, struct tcp_pcb *pcb, err_t err)
conn->state = SPL_NETCONN_NONE;
SPL_NETCONN_SET_SAFE_ERR (conn, ERR_OK);
+ update_tcp_state (pcb->callback_arg, ESTABLISHED);
SPL_API_EVENT (conn, SPL_NETCONN_EVT_SENDPLUS, 1);
if (was_blocking && m != NULL)
@@ -2523,7 +2525,12 @@ do_get_tcpproto_getsockopt_internal (struct common_pcb *cpcb,
NSPOL_LOGDBG (SOCKETS_DEBUG, "]fd=%d,SPL_TCP_KEEPCNT=%d",
cpcb->socket, *(int *) optval);
break;
-
+ case SPL_TCP_INFO:
+ ((struct tcp_info *) optval)->tcpi_total_retrans = (int) tpcb->nrtx;
+ ((struct tcp_info *) optval)->tcpi_snd_mss = (int) tpcb->mss;
+ ((struct tcp_info *) optval)->tcpi_rtt = (int) tpcb->sa;
+ ((struct tcp_info *) optval)->tcpi_snd_cwnd = (int) tpcb->cwnd;
+ break;
default:
NSPOL_LOGDBG (SOCKETS_DEBUG, "unsupported]optname=%d", optname);
SET_MSG_ERR (m, EOPNOTSUPP);
@@ -3316,5 +3323,7 @@ alloc_common_pcb (enum spl_netconn_type type)
common_pcb_init (cpcb);
cpcb->type = type;
+
+ res_alloc (&cpcb->res_chk);
return cpcb;
}
diff --git a/stacks/lwip_stack/lwip_src/api/spl_tcpip.c b/stacks/lwip_stack/lwip_src/api/spl_tcpip.c
index b627bcf..b0b588a 100644
--- a/stacks/lwip_stack/lwip_src/api/spl_tcpip.c
+++ b/stacks/lwip_stack/lwip_src/api/spl_tcpip.c
@@ -61,7 +61,7 @@
#include "sys.h"
-#define NSTACK_MAIN_MAX_PARA 19
+#define NSTACK_MAIN_MAX_PARA 32
#define NSTACK_MAIN_MIN_PARA 1
#define DPDK_DEFAULT_EAL_MEM_SIZE (1024)
@@ -951,7 +951,7 @@ spl_tcpip_thread (void *arg)
u16 task_loop;
u16 num_recv_task = 0, num_send_timer_task = 0;
u16 index_task = 0;
- int tcpip_thread_sleep_interval = g_tcpip_thread_sleep_time * 1000;
+ //int tcpip_thread_sleep_interval = g_tcpip_thread_sleep_time * 1000;
void *task_queue[TASK_BURST];
data_com_msg *msg;
@@ -981,7 +981,7 @@ spl_tcpip_thread (void *arg)
if (run_count++ > 20)
{
- sys_sleep_ns (0, tcpip_thread_sleep_interval);
+ //sys_sleep_ns (0, tcpip_thread_sleep_interval);
}
continue;
}
diff --git a/stacks/lwip_stack/lwip_src/common/stackx_common_opt.h b/stacks/lwip_stack/lwip_src/common/stackx_common_opt.h
index d2d01e5..feccc3f 100644
--- a/stacks/lwip_stack/lwip_src/common/stackx_common_opt.h
+++ b/stacks/lwip_stack/lwip_src/common/stackx_common_opt.h
@@ -102,6 +102,7 @@ extern "C" {
#define SPL_TCP_KEEPCNT 0x06
#define SPL_TCP_LINGER2 0x08
#define SPL_TCP_DEFER_ACCEPT 0x09
+#define SPL_TCP_INFO 0x0B
typedef enum spl_netconn_type
{
diff --git a/stacks/lwip_stack/lwip_src/common/stackx_spl_msg.h b/stacks/lwip_stack/lwip_src/common/stackx_spl_msg.h
index 119c26a..3088150 100644
--- a/stacks/lwip_stack/lwip_src/common/stackx_spl_msg.h
+++ b/stacks/lwip_stack/lwip_src/common/stackx_spl_msg.h
@@ -21,6 +21,7 @@
#include "stackx_spl_share.h"
#include "stackx_common_opt.h"
#include <sys/socket.h>
+#include <netinet/tcp.h>
#ifdef __cplusplus
/* *INDENT-OFF* */
@@ -207,6 +208,7 @@ typedef struct
//struct in_addr inaddr_optval;
//struct linger _linger;
struct timeval timeval_optval;
+ struct tcp_info tpinfo;
//ipmreq ipmreq_optval; //Multicast support later
} optval;
diff --git a/stacks/lwip_stack/lwip_src/include/ip_module/ip_module_api.h b/stacks/lwip_stack/lwip_src/include/ip_module/ip_module_api.h
index 488e13e..acf5057 100644
--- a/stacks/lwip_stack/lwip_src/include/ip_module/ip_module_api.h
+++ b/stacks/lwip_stack/lwip_src/include/ip_module/ip_module_api.h
@@ -149,6 +149,7 @@ struct network_configuration
struct ip_subnet *ip_subnet;
char network_name[IP_MODULE_MAX_NAME_LEN];
char type_name[IP_MODULE_MAX_NAME_LEN];
+ char nic_type_name[IP_MODULE_MAX_NAME_LEN];
network_buffer *buffer;
};
diff --git a/stacks/lwip_stack/lwip_src/include/netif/sharedmemory.h b/stacks/lwip_stack/lwip_src/include/netif/sharedmemory.h
index 0a92ea0..6230ed8 100644
--- a/stacks/lwip_stack/lwip_src/include/netif/sharedmemory.h
+++ b/stacks/lwip_stack/lwip_src/include/netif/sharedmemory.h
@@ -101,6 +101,7 @@ enum proc_run_type
struct linux_port_info
{
char if_name[HAL_MAX_NIC_NAME_LEN];
+ char if_type[HAL_MAX_NIC_NAME_LEN];
char ip_addr_linux[18]; //uint32_t ip_addr_linux;
char mask_linux[18]; //uint32_t mask_linux;
char bcast_linux[18]; //uint32_t bcast_linux;
diff --git a/stacks/lwip_stack/lwip_src/ip_module/container_ip.c b/stacks/lwip_stack/lwip_src/ip_module/container_ip.c
index decc52c..52f7c64 100644
--- a/stacks/lwip_stack/lwip_src/ip_module/container_ip.c
+++ b/stacks/lwip_stack/lwip_src/ip_module/container_ip.c
@@ -533,7 +533,7 @@ parse_container_ip_json (char *param)
else
{
/* this mandatory parameter */
- goto RETURN_ERROR;
+ NSOPR_LOGWAR ("json_object_object_get_ex containerID failed");
}
json_object_object_get_ex (obj, "ports_list", &ports_list_obj);
diff --git a/stacks/lwip_stack/lwip_src/ip_module/network.c b/stacks/lwip_stack/lwip_src/ip_module/network.c
index ef0d9a7..d7c9630 100644
--- a/stacks/lwip_stack/lwip_src/ip_module/network.c
+++ b/stacks/lwip_stack/lwip_src/ip_module/network.c
@@ -510,7 +510,8 @@ add_network_configuration (struct network_configuration
while (pheader)
{
if (!spl_hal_is_nic_exist (pheader->nic_name)
- && !nic_already_init (pheader->nic_name))
+ && !nic_already_init (pheader->nic_name)
+ && strncmp (tmp->nic_type_name, "vhost", strlen ("vhost")))
{
NSOPR_LOGERR ("Invalid configuration %s not exist Error! ",
pheader->nic_name);
@@ -584,7 +585,7 @@ parse_network_obj (struct json_object *network_obj)
NULL, *type_name_obj = NULL;
struct json_object *ref_nic_list_obj = NULL, *bond_mode_obj =
NULL, *bond_name_obj = NULL, *ipam_obj = NULL;
- struct json_object *subnet_obj = NULL;
+ struct json_object *subnet_obj = NULL, *nic_type_obj = NULL;
if (!network_obj)
{
@@ -687,6 +688,44 @@ parse_network_obj (struct json_object *network_obj)
goto RETURN_ERROR;
}
+ json_object_object_get_ex (phy_obj, "nic_type", &nic_type_obj); /*lint !e534 no need to check return value */
+ if (nic_type_obj)
+ {
+ const char *nic_type_name =
+ json_object_get_string (nic_type_obj);
+ if (strcmp (nic_type_name, "pci") != 0
+ && strcmp (nic_type_name, "vhost") != 0)
+ {
+ NSOPR_LOGERR ("unsupported nic_type]nic_type=%s",
+ nic_type_name);
+ goto RETURN_ERROR;
+ }
+
+ retVal =
+ STRCPY_S (pst_network_configuration->nic_type_name,
+ sizeof (pst_network_configuration->nic_type_name),
+ nic_type_name);
+ if (EOK != retVal)
+ {
+ NSOPR_LOGERR ("strcpy_s failed]ret=%d", retVal);
+ goto RETURN_ERROR;
+ }
+ }
+ else
+ {
+ NSOPR_LOGINF
+ ("nic_type not specified, use default type]defaul nic_type=pci");
+ retVal =
+ STRCPY_S (pst_network_configuration->nic_type_name,
+ sizeof (pst_network_configuration->nic_type_name),
+ "pci");
+ if (EOK != retVal)
+ {
+ NSOPR_LOGERR ("strcpy_s failed]ret=%d", retVal);
+ goto RETURN_ERROR;
+ }
+ }
+
json_object_object_get_ex (phy_obj, "ref_nic", &ref_nic_list_obj);
if (ref_nic_list_obj)
{
diff --git a/stacks/lwip_stack/lwip_src/netif/spl_hal.c b/stacks/lwip_stack/lwip_src/netif/spl_hal.c
index 596962e..db843d4 100644
--- a/stacks/lwip_stack/lwip_src/netif/spl_hal.c
+++ b/stacks/lwip_stack/lwip_src/netif/spl_hal.c
@@ -962,6 +962,23 @@ spl_hal_port_config (unsigned int *port_num)
NSPOL_LOGINF (SC_DPDK_INFO, "if_name %s",
p_stackx_port_zone->
stackx_one_port[port_index].linux_ip.if_name);
+
+ retVal =
+ STRCPY_S (p_stackx_port_zone->
+ stackx_one_port[port_index].linux_ip.if_type,
+ sizeof (p_stackx_port_zone->
+ stackx_one_port[port_index].linux_ip.if_type),
+ network->nic_type_name);
+ if (EOK != retVal)
+ {
+ NSPOL_LOGERR ("strcpy_s failed]ret=%d.", retVal);
+ return -1;
+ }
+
+ NSPOL_LOGINF (SC_DPDK_INFO, "if_type %s",
+ p_stackx_port_zone->
+ stackx_one_port[port_index].linux_ip.if_type);
+
retVal =
STRCPY_S (p_stackx_port_zone->
stackx_one_port[port_index].linux_ip.ip_addr_linux,
@@ -1286,7 +1303,9 @@ spl_hal_port_start (uint16_t nic_id, struct stackx_port_info *p_port_info,
conf.tx.ring_size[q] = HAL_TX_RING_SIZE;
}
- hdl = hal_create (p_port_info->linux_ip.if_name, &conf);
+ hdl =
+ hal_create (p_port_info->linux_ip.if_name, p_port_info->linux_ip.if_type,
+ &conf);
if (!hal_is_valid (hdl))
{
diff --git a/stacks/lwip_stack/lwip_src/socket/stackx_tcp.c b/stacks/lwip_stack/lwip_src/socket/stackx_tcp.c
index 3225c2f..8d57ba0 100644
--- a/stacks/lwip_stack/lwip_src/socket/stackx_tcp.c
+++ b/stacks/lwip_stack/lwip_src/socket/stackx_tcp.c
@@ -403,16 +403,7 @@ sbr_tcp_connect (sbr_socket_t * sk, const struct sockaddr *name,
inet_addr_to_ipaddr (&remote_addr, &addr_in->sin_addr);
u16 remote_port = addr_in->sin_port;
- spl_ip_addr_t local_addr;
- if (IPADDR_ANY == ss_get_local_ip (sbr_get_conn (sk))->addr)
- {
- if (sbr_get_src_ip (remote_addr.addr, &local_addr.addr) != 0)
- {
- sbr_set_sk_errno (sk, EHOSTUNREACH);
- NSSBR_LOGERR ("get src ip failed]fd=%d", sk->fd);
- return -1;
- }
- }
+ spl_ip_addr_t local_addr = { IPADDR_ANY };
if (sbr_handle_connect (sk, &remote_addr, ntohs (remote_port), &local_addr)
!= 0)
@@ -498,6 +489,7 @@ sbr_getsockopt_ipproto_tcp (int optname, void *optval, socklen_t optlen)
case SPL_TCP_KEEPIDLE:
case SPL_TCP_KEEPINTVL:
case SPL_TCP_KEEPCNT:
+ case SPL_TCP_INFO:
break;
default:
err = ENOPROTOOPT;
diff --git a/stacks/lwip_stack/lwip_src/socket/stackx_udp.c b/stacks/lwip_stack/lwip_src/socket/stackx_udp.c
index 69b822b..1f382cf 100644
--- a/stacks/lwip_stack/lwip_src/socket/stackx_udp.c
+++ b/stacks/lwip_stack/lwip_src/socket/stackx_udp.c
@@ -182,16 +182,7 @@ sbr_udp_connect (sbr_socket_t * sk, const struct sockaddr *name,
inet_addr_to_ipaddr (&remote_addr, &addr_in->sin_addr);
u16 remote_port = addr_in->sin_port;
- spl_ip_addr_t local_addr;
- if (IPADDR_ANY == ss_get_local_ip (sbr_get_conn (sk))->addr)
- {
- if (sbr_get_src_ip (remote_addr.addr, &local_addr.addr) != 0)
- {
- sbr_set_sk_errno (sk, EHOSTUNREACH);
- NSSBR_LOGERR ("get src ip failed]fd=%d", sk->fd);
- return -1;
- }
- }
+ spl_ip_addr_t local_addr = { IPADDR_ANY };
return sbr_handle_connect (sk, &remote_addr, ntohs (remote_port),
&local_addr);
@@ -815,16 +806,7 @@ sbr_udp_senddata (sbr_socket_t * sk, const struct iovec *iov, int iovcnt,
netbuf_fromport (&buf) = 0;
}
- spl_ip_addr_t local_ip;
- if (IPADDR_ANY == ss_get_local_ip (sbr_get_conn (sk))->addr)
- {
- if (sbr_get_src_ip (buf.addr.addr, &local_ip.addr) != 0)
- {
- sbr_set_sk_io_errno (sk, EHOSTUNREACH);
- NSSBR_LOGERR ("get src ip failed]fd=%d", sk->fd);
- return -1;
- }
- }
+ spl_ip_addr_t local_ip = { IPADDR_ANY };
int err = ss_get_last_errno (sbr_get_conn (sk));
if (SPL_ERR_IS_FATAL (err))
diff --git a/stacks/lwip_stack/release/configure/ip_data.json b/stacks/lwip_stack/release/configure/ip_data.json
index f29103e..1d52b77 100644
--- a/stacks/lwip_stack/release/configure/ip_data.json
+++ b/stacks/lwip_stack/release/configure/ip_data.json
@@ -1,31 +1,8 @@
{
- "containerID": "9112d2b6aa31",
- "primary_port": "PortA",
"ports_list": [
{
"port_name": "PortA",
- "ref_nic": [
- "eth7"
- ],
- "mac": [
- "00:54:32:19:3d:19"
- ],
- "net_name": "IDX-M",
- "ip_cidr": ["192.168.1.207/24"],
- "multicast_id": [
- {
- "group_id": "cast_group_1",
- "group_ip": "239.0.0.1"
- },
- {
- "group_id": "cast_group_2",
- "group_ip": "239.0.0.2"
- }
- ],
- "vlan_id": 42,
- "vlan_inside": true,
- "vxlan_id": -1,
- "vxlan_inside": false
+ "ip_cidr": ["192.168.1.207/24"]
}
]
}
diff --git a/stacks/lwip_stack/release/configure/network_data_tonStack.json b/stacks/lwip_stack/release/configure/network_data_tonStack.json
index 7c059ef..7b734b0 100644
--- a/stacks/lwip_stack/release/configure/network_data_tonStack.json
+++ b/stacks/lwip_stack/release/configure/network_data_tonStack.json
@@ -1,31 +1,15 @@
[
{
- "cniVersion": "0.2.0",
- "name": "IDX-M",
- "multi_entry": "3",
+ "name": "network1",
"type": "nstack-dpdk",
- "vlanID": 42,
- "vlan_inside": true,
"ipam": {
- "type": "canal-ipam",
- "subnet": "192.168.1.1/24",
- "gateway": "192.168.1.254",
- "range-start": "192.168.1.198",
- "range-end": "192.168.1.209",
- "routes": [
- {
- "dst": "192.168.1.0/24",
- "gw": "192.168.1.254"
- }
- ]
+ "subnet": "192.168.1.1/24"
},
"args": {
"phynet": {
"ref_nic": [
"eth7"
- ],
- "bond_name": "",
- "bond_mode": -1
+ ]
}
}
},
diff --git a/stacks/lwip_stack/release/lwip_helper_files/download_lwip.sh b/stacks/lwip_stack/release/lwip_helper_files/download_lwip.sh
index 316859b..bbb8afb 100755
--- a/stacks/lwip_stack/release/lwip_helper_files/download_lwip.sh
+++ b/stacks/lwip_stack/release/lwip_helper_files/download_lwip.sh
@@ -23,7 +23,7 @@ echo $LWIP_DOWNLOAD_DIR
if [ ! -d "${LWIP_DOWNLOAD_DIR}/lwip/" ]; then
mkdir -p ${LWIP_DOWNLOAD_DIR}/lwip/
cd ${LWIP_DOWNLOAD_DIR}/
- wget -N --no-check-certificate http://download.savannah.nongnu.org/releases/lwip/lwip-2.0.3.zip
+ wget -N --no-check-certificate http://download-mirror.savannah.nongnu.org/releases/lwip/lwip-2.0.3.zip
unzip ${LWIP_DOWNLOAD_DIR}/lwip-2.0.3.zip "lwip-2.0.3/src/*" -d ${LWIP_DOWNLOAD_DIR}/lwip
mv ${LWIP_DOWNLOAD_DIR}/lwip/lwip-2.0.3/src/* ${LWIP_DOWNLOAD_DIR}/lwip/
rm -rf ${LWIP_DOWNLOAD_DIR}/lwip/lwip-2.0.3/
@@ -32,4 +32,4 @@ if [ ! -d "${LWIP_DOWNLOAD_DIR}/lwip/" ]; then
cp -r ${SCRIPT_DIR}/core/* ${LWIP_DOWNLOAD_DIR}/lwip/core/
cp -r ${SCRIPT_DIR}/include/* ${LWIP_DOWNLOAD_DIR}/lwip/include/lwip/
mv ${LWIP_DOWNLOAD_DIR}/lwip/include/lwip/errno.h ${LWIP_DOWNLOAD_DIR}/lwip/include/lwip/lwip_errno.h
-fi \ No newline at end of file
+fi
diff --git a/stacks/lwip_stack/release/script/nstack_fun.sh b/stacks/lwip_stack/release/script/nstack_fun.sh
index 5e16283..fed3588 100755
--- a/stacks/lwip_stack/release/script/nstack_fun.sh
+++ b/stacks/lwip_stack/release/script/nstack_fun.sh
@@ -332,10 +332,10 @@ run_nStackMain()
log $LINENO "$env DPDK_TOOL_DIR=$DPDK_TOOL_DIR"
log $LINENO "$env LD_LIBRARY_PATH=$LD_LIBRARY_PATH"
log $LINENO "$env DPDK_LIB_PATH=$DPDK_LIB_PATH"
- log $LINENO "./nStackMain -c $1 -n 4 --huge-dir=$2 --proc-type=primary --file-prefix nStackMain -m $3 stack -c $4 -sleep $5 -bind_cpu $6"
+ log $LINENO "./nStackMain -c $1 -n 4 --huge-dir=$2 --proc-type=primary --file-prefix nStackMain -m $3 $7 $8 stack -c $4 -sleep $5 -bind_cpu $6"
check_file_size $DPDK_FILE
cd ..; cd bin/
- ./nStackMain -c $1 -n 4 --huge-dir=$2 --proc-type=primary --file-prefix nStackMain -m $3 stack -c $4 -sleep $5 -bind_cpu $6 >> $DPDK_FILE &
+ ./nStackMain -c $1 -n 4 --huge-dir=$2 --proc-type=primary --file-prefix nStackMain -m $3 $7 $8 stack -c $4 -sleep $5 -bind_cpu $6 >> $DPDK_FILE &
}
diff --git a/stacks/lwip_stack/release/script/nstack_var.sh b/stacks/lwip_stack/release/script/nstack_var.sh
index 9a1c612..a654d34 100755
--- a/stacks/lwip_stack/release/script/nstack_var.sh
+++ b/stacks/lwip_stack/release/script/nstack_var.sh
@@ -50,8 +50,10 @@ DPDK_NIC_LIST_FILE=$RUNTIME_DIR/.nstack_dpdk_nic_list
MAX_LOG_FILE_SIZE=52428800
HUGE_PAGES=2048
HUGE_DIR=/mnt/nstackhuge
+
SLEEP_INTERVAL=100 # tcpip thread sleep time, unit: us
-BIND_CPU=0
+BIND_CPU=1
+
MEM_SIZE=3072
RTP_CORE_MASK=2
diff --git a/stacks/lwip_stack/release/script/run_nstack_main.sh b/stacks/lwip_stack/release/script/run_nstack_main.sh
index 2bd9e0d..9d6049a 100755
--- a/stacks/lwip_stack/release/script/run_nstack_main.sh
+++ b/stacks/lwip_stack/release/script/run_nstack_main.sh
@@ -20,7 +20,8 @@ init_network
CORE_MASK=1
log $LINENO "start run nstackmain"
log $LINENO "COREMASK=$CORE_MASK, HUGE_DIR=$1, MEM_SIZE=$2, RTP_CORE_MASK=$RTP_CORE_MASK, SLEEP_INTERVAL=$SLEEP_INTERVAL, BIND_CPU=$BIND_CPU"
+log $LINENO "VDEV=$VDEV, NO_PCI=$NO_PCI"
-run_nStackMain $CORE_MASK $1 $2 $RTP_CORE_MASK $SLEEP_INTERVAL $BIND_CPU
+run_nStackMain $CORE_MASK $1 $2 $RTP_CORE_MASK $SLEEP_INTERVAL $BIND_CPU $3 $4
exit 0
diff --git a/stacks/lwip_stack/release/start_nstack.sh b/stacks/lwip_stack/release/start_nstack.sh
index db0c084..35fe9df 100755
--- a/stacks/lwip_stack/release/start_nstack.sh
+++ b/stacks/lwip_stack/release/start_nstack.sh
@@ -16,16 +16,40 @@ fi
##get the log info from the parameter of ./start -l XXX -a XXX ###
nstack_log_path=""
hostinfo_path=""
-while getopts "l:i:a:" arg
+ARGS=`getopt -o "l:i:a:" -l "vdev:,file-prefix:,no-pci" -n "start_nstack.sh" -- "$@"`
+eval set -- "${ARGS}"
+while true
do
- case $arg in
- l)
- nstack_log_path="$OPTARG"
- ;;
- i)
- hostinfo_path="$OPTARG"
- ;;
- esac
+ case "$1" in
+ -l)
+ nstack_log_path="$2"
+ shift 2
+ ;;
+ -i)
+ hostinfo_path="$2"
+ shift 2
+ ;;
+ --vdev)
+ VDEV="--vdev=$2"
+ shift 2
+ ;;
+ --file-prefix)
+ FILE_PREFIX="--file-prefix=$2"
+ shift 2
+ ;;
+ --no-pci)
+ NO_PCI="--no-pci"
+ shift 1
+ ;;
+ --)
+ shift
+ break
+ ;;
+ *)
+ echo "Option illegal, please check input!"
+ exit 1
+ ;;
+ esac
done
hostinfo_stat=0
@@ -116,8 +140,8 @@ install_config
########################################################
core_mask=1
START_TYPE="primary"
-log $LINENO "./script/run_nstack_main.sh ${core_mask} $HUGE_DIR $MEM_SIZE $START_TYPE"
-${script_path}/script/run_nstack_main.sh $HUGE_DIR $MEM_SIZE
+log $LINENO "./script/run_nstack_main.sh ${core_mask} $HUGE_DIR $MEM_SIZE $START_TYPE $VDEV $NO_PCI"
+${script_path}/script/run_nstack_main.sh $HUGE_DIR $MEM_SIZE $VDEV $NO_PCI
print_pid=$(ps -ux | grep nStackMain | awk '{print $2}' | awk 'NR == 2')
echo "nStackMain PID:$print_pid"
diff --git a/stacks/lwip_stack/release_tar.sh b/stacks/lwip_stack/release_tar.sh
index 6c2928f..d3cfa68 100644
--- a/stacks/lwip_stack/release_tar.sh
+++ b/stacks/lwip_stack/release_tar.sh
@@ -29,7 +29,7 @@ if [ -f "./nStackTools.tar.gz" ]; then
fi
mkdir ./nStackServer/lib64
-cp ./release/lib64/libnstack.so ./release/lib64/libnStackAPI.so ./release/lib64/libnstackcmd.so ./release/lib64/libsecurec.so ./nStackServer/lib64
+cp ./release/lib64/liblwip_dpdk.so ./release/lib64/libnStackAPI.so ./release/lib64/libnstackcmd.so ./release/lib64/libsecurec.so ./nStackServer/lib64
mkdir ./nStackServer/bin
cp ./release/bin/nStackCtrl ./release/bin/nStackMain ./release/bin/nStackMaster ./release/bin/set_permission.sh ./nStackServer/bin
mkdir ./nStackServer/conf
@@ -47,7 +47,7 @@ dos2unix ./nStackServer/*.sh
find ./nStackServer -type f | grep -E "*.sh|*.py" | xargs chmod +x
mkdir ./nStackClient/lib64
-cp ./release/lib64/libnstack.so ./release/lib64/libnStackAPI.so ./release/lib64/libsecurec.so ./nStackClient/lib64
+cp ./release/lib64/liblwip_dpdk.so ./release/lib64/libnStackAPI.so ./release/lib64/libsecurec.so ./nStackClient/lib64
mkdir ./nStackClient/include
cp ./release/include/nstack_custom_api.h ./nStackClient/include
diff --git a/stacks/lwip_stack/src/io_adpt/dpdk.c b/stacks/lwip_stack/src/io_adpt/dpdk.c
index d199513..8518112 100644
--- a/stacks/lwip_stack/src/io_adpt/dpdk.c
+++ b/stacks/lwip_stack/src/io_adpt/dpdk.c
@@ -190,6 +190,13 @@ NSTACK_STATIC struct rte_eth_conf port_conf_default_bond = {
},
};
+NSTACK_STATIC struct rte_eth_conf port_conf_default_vhost = {
+ .rxmode = {
+ .hw_ip_checksum = 0, /* vhost nic doesn't support hw_ip_checksum and hw_vlan_filter */
+ .hw_vlan_filter = 0,
+ }
+};
+
/*****************************************************************************
* Prototype : dpdk_mbuf_to_file
* Description : write the packet data into a file
@@ -700,6 +707,39 @@ dpdk_set_port (netif_inst_t * inst, uint8_t port)
}
/*****************************************************************************
+ Prototype : dpdk_set_nic_type
+ Description : check and save nic type
+ Input : netif_inst_t* inst
+ const char* type
+ Output : None
+ Return Value : NSTACK_STATIC
+ Calls :
+ Called By :
+
+*****************************************************************************/
+NSTACK_STATIC int
+dpdk_set_nic_type (netif_inst_t * inst, const char *type)
+{
+ int ret;
+
+ ret =
+ STRCPY_S (inst->data.dpdk_if.nic_type,
+ sizeof (inst->data.dpdk_if.nic_type), type);
+ if (EOK != ret)
+ {
+ NSHAL_LOGERR ("strcpy_s set nic_type failed]ret=%d", ret);
+ return -1;
+ }
+
+ /*
+ * *nic_type is first checked at read_ipmoduleoperateadd_configuration,
+ * *thus here we dont boring validating it once more and just return.
+ * */
+
+ return 0;
+}
+
+/*****************************************************************************
Prototype : dpdk_set_nic_name
Description : check and save nic name
Input : netif_inst_t* inst
@@ -1433,10 +1473,25 @@ dpdk_probe_pci (netif_inst_t * inst)
*****************************************************************************/
NSTACK_STATIC int
-dpdk_open (netif_inst_t * inst, const char *name)
+dpdk_open (netif_inst_t * inst, const char *name, const char *type)
{
int ret;
+ if ((inst == NULL) || (name == NULL) || (type == NULL))
+ {
+ NSHAL_LOGERR
+ ("invaliad arguments]inst==NULL, nic_type==NULL or type==NULL");
+ return -1;
+ }
+
+ ret = dpdk_set_nic_type (inst, type);
+
+ if (0 != ret)
+ {
+ NSHAL_LOGERR ("dpdk_set_nic_type fail]nic_type=%s, ret=%d", type, ret);
+ return -1;
+ }
+
ret = dpdk_set_nic_name (inst, name);
if (0 != ret)
@@ -1445,6 +1500,13 @@ dpdk_open (netif_inst_t * inst, const char *name)
return -1;
}
+ if (!strncmp (type, "vhost", strlen ("vhost")))
+ {
+ /*for vhost-user device, the remaining steps is unnecessary, y0413485 */
+ NSHAL_LOGERR ("initting vhost device]nic_name=%s type=%s", name, type);
+ return 0;
+ }
+
ret = dpdk_get_driver_name (inst);
if (0 != ret)
@@ -1588,6 +1650,11 @@ dpdk_get_port_conf (netif_inst_t * inst, struct rte_eth_conf **port_conf)
{
*port_conf = &port_conf_default_bond;
}
+ else if (strncmp ("vhost", inst->data.dpdk_if.nic_type, (size_t) 5) == 0)
+ {
+ *port_conf = &port_conf_default_vhost;
+ return;
+ }
else
{
*port_conf = &port_conf_default_normal;
diff --git a/stacks/lwip_stack/src/nStackMain/main.c b/stacks/lwip_stack/src/nStackMain/main.c
index 220d1f1..3bc0a3b 100644
--- a/stacks/lwip_stack/src/nStackMain/main.c
+++ b/stacks/lwip_stack/src/nStackMain/main.c
@@ -42,7 +42,7 @@
#define GlOBAL_HELP "--help"
#define GLOBAL_Dpdk_ARG "dpdk"
#define GLOBAL_STACK_PORT "-port"
-#define NSTACK_MAIN_MAX_PARA 19
+#define NSTACK_MAIN_MAX_PARA 32
#define NSTACK_MAIN_MIN_PARA 1
#define MAX_MASTER_OPEN_FD 1024
diff --git a/stacks/lwip_stack/src/sbr/CMakeLists.txt b/stacks/lwip_stack/src/sbr/CMakeLists.txt
index 42ab4a4..f324e5f 100644
--- a/stacks/lwip_stack/src/sbr/CMakeLists.txt
+++ b/stacks/lwip_stack/src/sbr/CMakeLists.txt
@@ -21,9 +21,9 @@ endif()
FILE(GLOB SBR *.c)
-ADD_LIBRARY(nstack SHARED ${SBR})
-TARGET_LINK_LIBRARIES(nstack -Wl,--whole-archive socket -Wl,--no-whole-archive dmm_api nStackMaintain)
-ADD_DEPENDENCIES(nstack socket DPDK)
+ADD_LIBRARY(lwip_dpdk SHARED ${SBR})
+TARGET_LINK_LIBRARIES(lwip_dpdk -Wl,--whole-archive socket -Wl,--no-whole-archive dmm_api nStackMaintain)
+ADD_DEPENDENCIES(lwip_dpdk socket DPDK)
INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_LIST_DIR}/../include
${PAL_H_DIRECTORIES}
diff --git a/stacks/lwip_stack/src/sbr/sbr_socket.c b/stacks/lwip_stack/src/sbr/sbr_socket.c
index 6f867ab..69481b5 100644
--- a/stacks/lwip_stack/src/sbr/sbr_socket.c
+++ b/stacks/lwip_stack/src/sbr/sbr_socket.c
@@ -1249,7 +1249,7 @@ SBR_INTERCEPT (void, fork_free_fd, (int s, pid_t p, pid_t c))
*
*****************************************************************************/
int
-nstack_stack_register (nstack_proc_cb * ops, nstack_event_cb * val)
+lwip_stack_register (nstack_proc_cb * ops, nstack_event_cb * val)
{
if (!ops || !val || !val->handle)
{
diff --git a/stacks/lwip_stack/vagrant/start_nstackMain.sh b/stacks/lwip_stack/vagrant/start_nstackMain.sh
index 00d4370..674562a 100755
--- a/stacks/lwip_stack/vagrant/start_nstackMain.sh
+++ b/stacks/lwip_stack/vagrant/start_nstackMain.sh
@@ -68,21 +68,9 @@ chmod 775 *
cp ./configure/*.json bin/
cd bin
-if [ "$OS_ID" == "centos" ]; then
- sed -i 's!eth7!'$ifname'!1' ip_data.json
-elif [ "$OS_ID" == "ubuntu" ]; then
- sed -i 's!eth7!'$ifname'!1' ip_data.json
-fi
-
-sed -i 's!00:54:32:19:3d:19!'$ifmac'!1' ip_data.json
sed -i 's!192.168.1.207!'$ifaddress1'!1' ip_data.json
sed -i 's!192.168.1.1!'$ifaddresscut'.0!1' network_data_tonStack.json
-sed -i 's!192.168.1.254!'$ifaddresscut'.1!1' network_data_tonStack.json
-sed -i 's!192.168.1.098!'$ifaddresscut'.5!1' network_data_tonStack.json
-sed -i 's!192.168.1.209!'$ifaddresscut'.254!1' network_data_tonStack.json
-sed -i 's!192.168.1.0!'$ifaddresscut'.0!1' network_data_tonStack.json
-sed -i 's!192.168.1.254!'$ifaddresscut'.1!1' network_data_tonStack.json
if [ "$OS_ID" == "centos" ]; then
sed -i 's!eth7!'$ifname'!1' network_data_tonStack.json
@@ -94,7 +82,7 @@ sed -i 's!eth7!'$ifname'!1' network_data_tonStack.json
cd $DMM_BUILD_SCRIPT_DIR/../release/bin
cp -r . ../../stacks/lwip_stack/app_test
cd $DMM_BUILD_SCRIPT_DIR/../stacks/lwip_stack/app_test
-cp -r ../app_conf/*.json .
+cp -r ../configure/*.json .
sed -i 's!192.168.1.1!'$ifaddresscut'.0!1' rd_config.json