diff options
24 files changed, 278 insertions, 142 deletions
@@ -32,15 +32,15 @@ instances and the app/socket-to-stack-mappings, which are provided via the orche different transport layer protocol and also provide the flexibility to choose a protocol stack from manybased on functional/performance requirements. # 3. Quick Start -Refer doc/Build_DMM.md + * [Refer doc/Build_DMM.md.](https://git.fd.io/dmm/plain/doc/Build_DMM.md) # 4. Involved * [Bi-Weekly DMM Metting.](https://wiki.fd.io/view/DMM/Meettng) * [Join the DMM Mailing List.](https://lists.fd.io/g/dmm-dev) * [Join fdio-dmm IRC channel.](https://wiki.fd.io/view/IRC) * [Browse the code.](https://git.fd.io/dmm/tree/) - * [18.07 Release Plan](https://wiki.fd.io/view/Projects/dmm/Release_Plans/Release_Plan_18.07) - + * [18.10 Release Plan](https://wiki.fd.io/view/Projects/dmm/Release_Plans/Release_Plan_18.10) + # 5. More Information - https://wiki.fd.io/view/DMM - https://wiki.fd.io/view/Project_Proposals/DMM diff --git a/doc/Build_DMM.md b/doc/Build_DMM.md index b74d5fb..fb35d2f 100644 --- a/doc/Build_DMM.md +++ b/doc/Build_DMM.md @@ -95,7 +95,7 @@ Check hugepage info sudo mkdir -p /var/run/ip_module ``` -# 6. Biuld and Run the APP +# 6. Build and Run the APP - Link the app with the lib **libnStackAPI.so** first, you can refer to app_example/perf-test diff --git a/release/configure/rd_config.json b/release/configure/rd_config.json index d005569..58a8da9 100644 --- a/release/configure/rd_config.json +++ b/release/configure/rd_config.json @@ -2,25 +2,25 @@ "ip_route": [ { "subnet": "192.168.1.1/24", - "type": "nstack-kernel", + "stack_name": "kernel", }, { "subnet": "192.167.1.1/24", - "type": "nstack-kernel", + "stack_name": "kernel", }, { "subnet": "192.166.1.1/24", - "type": "nstack-kernel", + "stack_name": "kernel", } ], "prot_route": [ { "proto_type": "1", - "type": "nstack-kernel", + "stack_name": "kernel", }, { "proto_type": "2", - "type": "nstack-kernel", + "stack_name": "kernel", } ], } diff --git a/src/framework/common/base/include/common/common_mem_api.h b/src/framework/common/base/include/common/common_mem_api.h index d143732..40b01b9 100644 --- a/src/framework/common/base/include/common/common_mem_api.h +++ b/src/framework/common/base/include/common/common_mem_api.h @@ -90,7 +90,7 @@ get_sys_pid () return g_sys_host_pid; } -pid_t updata_sys_pid (); +pid_t update_sys_pid (); u32_t sys_now (void); #define sys_sem_t sys_sem_t_v2 diff --git a/src/framework/lib_common_mem/common_api.c b/src/framework/lib_common_mem/common_api.c index 566b8be..cfb869d 100644 --- a/src/framework/lib_common_mem/common_api.c +++ b/src/framework/lib_common_mem/common_api.c @@ -275,7 +275,7 @@ sys_get_hostpid_from_file (pid_t pid) } pid_t -updata_sys_pid () +update_sys_pid () { g_sys_host_pid = SYS_HOST_INITIAL_PID; return get_sys_pid (); diff --git a/src/nSocket/nstack/nstack.c b/src/nSocket/nstack/nstack.c index 4198266..225c297 100644 --- a/src/nSocket/nstack/nstack.c +++ b/src/nSocket/nstack/nstack.c @@ -769,7 +769,7 @@ nstack_fw_init () } common_mem_rwlock_read_lock (get_fork_lock ()); - updata_sys_pid (); + update_sys_pid (); u8 proc_type = NSFW_PROC_APP; nsfw_mem_para stinfo = { 0 }; diff --git a/src/nSocket/nstack/nstack_fd_mng.c b/src/nSocket/nstack/nstack_fd_mng.c index ba9b8f1..86e045d 100644 --- a/src/nSocket/nstack/nstack_fd_mng.c +++ b/src/nSocket/nstack/nstack_fd_mng.c @@ -180,7 +180,7 @@ nstack_fork_init_parent (pid_t ppid) void nstack_fork_init_child (pid_t ppid) { - pid_t cpid = updata_sys_pid (); + pid_t cpid = update_sys_pid (); NSSOC_LOGDBG ("parent_pid=%d, child_pid=%d", ppid, cpid); nsfw_mgr_clr_fd_lock (); diff --git a/src/nSocket/nstack/nstack_info_parse.c b/src/nSocket/nstack/nstack_info_parse.c index 989c3b8..04abb4e 100644 --- a/src/nSocket/nstack/nstack_info_parse.c +++ b/src/nSocket/nstack/nstack_info_parse.c @@ -241,7 +241,8 @@ nstack_parse_rd_cfg_json (char *param, rd_route_data ** data, int *num) { rddata = rdtemp + icnt; rddata->type = RD_DATA_TYPE_IP; - (void) json_object_object_get_ex (module_obj, "type", &temp_obj); + (void) json_object_object_get_ex (module_obj, "stack_name", + &temp_obj); if (temp_obj) { temp_value = json_object_get_string (temp_obj); @@ -280,21 +281,21 @@ nstack_parse_rd_cfg_json (char *param, rd_route_data ** data, int *num) } } - for (index = 0; index < ip_list_num; index++) + for (index = 0; index < proto_list_num; index++) { module_obj = json_object_array_get_idx (proto_list_obj, index); if (module_obj) { rddata = rdtemp + icnt; rddata->type = RD_DATA_TYPE_PROTO; - (void) json_object_object_get_ex (module_obj, "type", &temp_obj); + (void) json_object_object_get_ex (module_obj, "stack_name", + &temp_obj); if (temp_obj) { temp_value = json_object_get_string (temp_obj); if (!temp_value) { - NSSOC_LOGERR ("can't get value from subnet index:%d", - index); + NSSOC_LOGERR ("can't get value from proto index:%d", index); goto RETURN_ERROR; } (void) STRNCPY_S (rddata->stack_name, RD_PLANE_NAMELEN, @@ -307,8 +308,7 @@ nstack_parse_rd_cfg_json (char *param, rd_route_data ** data, int *num) temp_value = json_object_get_string (temp_obj); if (!temp_value) { - NSSOC_LOGERR ("can't get value from subnet index:%d", - index); + NSSOC_LOGERR ("can't get value from proto index:%d", index); goto RETURN_ERROR; } rddata->proto_type = atoi (temp_value); diff --git a/src/nSocket/nstack/nstack_socket.c b/src/nSocket/nstack/nstack_socket.c index cd1557b..c967d64 100644 --- a/src/nSocket/nstack/nstack_socket.c +++ b/src/nSocket/nstack/nstack_socket.c @@ -2797,7 +2797,7 @@ nstack_fork (void) pid = nsfw_base_fork (); if (pid == 0) { - updata_sys_pid (); + update_sys_pid (); } NSSOC_LOGERR ("g_nStackInfo has not initialized]parent_pid=%d, pid=%d", parent_pid, pid); diff --git a/src/nSocket/nstack_rd/nstack_rd.c b/src/nSocket/nstack_rd/nstack_rd.c index cdcb92d..650f165 100644 --- a/src/nSocket/nstack_rd/nstack_rd.c +++ b/src/nSocket/nstack_rd/nstack_rd.c @@ -30,19 +30,16 @@ typedef struct __rd_data_defaut_ip { char ip[RD_IP_STR_MAX_LEN]; - char planename[RD_PLANE_NAMELEN]; + char stackname[RD_PLANE_NAMELEN]; int masklent; } rd_data_defaut_ip; typedef struct __rd_data_defaut_protocol { unsigned int proto_type; - char planename[RD_PLANE_NAMELEN]; + char stackname[RD_PLANE_NAMELEN]; } rd_data_defaut_protocol; -extern rd_stack_plane_map g_nstack_plane_info[]; -extern int g_rd_map_num; - rd_data_proc g_rd_cpy[RD_DATA_TYPE_MAX] = { { nstack_rd_ipdata_cpy, @@ -63,12 +60,12 @@ rd_data_proc g_rd_cpy[RD_DATA_TYPE_MAX] = { }; rd_data_defaut_ip g_default_ip_config[] = { - {{"127.0.0.1"}, {RD_LINUX_PLANENAME}, 32}, - {{"0.0.0.0"}, {RD_LINUX_PLANENAME}, 32}, + {{"127.0.0.1"}, {RD_KERNEL}, 32}, + {{"0.0.0.0"}, {RD_KERNEL}, 32}, }; rd_data_defaut_protocol g_default_protcol[] = { - {0xf001, {RD_STACKX_PLANENAME}}, + {0xf001, {RD_LWIP}}, }; /***************************************************************************** @@ -151,6 +148,9 @@ nstack_rd_sys_default () rd_data_defaut_ip *pdata = NULL; rd_data_defaut_protocol *pprotodata = NULL; int icnt = 0, iindex = 0; + int stack_num = 0; + + stack_num = g_rd_local_data->stack_num; /*get the ip default route */ for (icnt = 0; @@ -158,21 +158,21 @@ nstack_rd_sys_default () icnt++) { pdata = &g_default_ip_config[icnt]; - for (iindex = 0; iindex < g_rd_map_num; iindex++) + for (iindex = 0; iindex < stack_num; iindex++) { if (0 == - strcmp (g_nstack_plane_info[iindex].planename, - pdata->planename)) + strcmp (g_rd_local_data->pstack_info[iindex].name, + pdata->stackname)) { - item.stack_id = g_nstack_plane_info[iindex].stackid; + item.stack_id = g_rd_local_data->pstack_info[iindex].stack_id; break; } } - if (iindex >= g_rd_map_num) + if (iindex >= stack_num) { NSSOC_LOGINF - ("default plane name:%s was not fount, ip:%s msklen:%d was dropped", - pdata->planename, pdata->ip, pdata->masklent); + ("default stack name:%s was not fount, ip:%s msklen:%d was dropped", + pdata->stackname, pdata->ip, pdata->masklent); continue; } item.type = RD_DATA_TYPE_IP; @@ -189,24 +189,25 @@ nstack_rd_sys_default () /*get the protocol default route */ (void) MEMSET_S (&item, sizeof (item), 0, sizeof (item)); for (icnt = 0; - icnt < sizeof (g_default_protcol) / sizeof (rd_data_defaut_protocol); icnt++) + icnt < sizeof (g_default_protcol) / sizeof (rd_data_defaut_protocol); + icnt++) { pprotodata = &g_default_protcol[icnt]; - for (iindex = 0; iindex < g_rd_map_num; iindex++) + for (iindex = 0; iindex < stack_num; iindex++) { if (0 == - strcmp (g_nstack_plane_info[iindex].planename, - pprotodata->planename)) + strcmp (g_rd_local_data->pstack_info[iindex].name, + pprotodata->stackname)) { - item.stack_id = g_nstack_plane_info[iindex].stackid; + item.stack_id = g_rd_local_data->pstack_info[iindex].stack_id; break; } } - if (iindex >= g_rd_map_num) + if (iindex >= stack_num) { NSSOC_LOGINF - ("default plane name:%s was not fount, protocoltype:%d was dropped", - pprotodata->planename, pprotodata->proto_type); + ("default stack name:%s was not fount, protocoltype:%d was dropped", + pprotodata->stackname, pprotodata->proto_type); continue; } item.type = RD_DATA_TYPE_PROTO; @@ -233,6 +234,7 @@ nstack_rd_save (rd_route_data * rd_data, int num) { int icnt = 0; int iindex = 0; + int stack_num = 0; rd_data_item item; rd_data_type type = RD_DATA_TYPE_MAX; @@ -243,6 +245,8 @@ nstack_rd_save (rd_route_data * rd_data, int num) return; } + stack_num = g_rd_local_data->stack_num; + for (iindex = 0; iindex < num; iindex++) { if (rd_data[iindex].type >= RD_DATA_TYPE_MAX) @@ -258,17 +262,17 @@ nstack_rd_save (rd_route_data * rd_data, int num) (void *) &rd_data[iindex])) { item.agetime = NSTACK_RD_AGETIME_MAX; - for (icnt = 0; icnt < g_rd_map_num; icnt++) + for (icnt = 0; icnt < stack_num; icnt++) { if (0 == - strcmp (g_nstack_plane_info[icnt].planename, + strcmp (g_rd_local_data->pstack_info[icnt].name, rd_data[iindex].stack_name)) { - item.stack_id = g_nstack_plane_info[icnt].stackid; + item.stack_id = g_rd_local_data->pstack_info[icnt].stack_id; break; } } - if (icnt >= g_rd_map_num) + if (icnt >= stack_num) { NSSOC_LOGINF ("plane name:%s was not fount, protocoltype:%d was dropped", diff --git a/src/nSocket/nstack_rd/nstack_rd_init.c b/src/nSocket/nstack_rd/nstack_rd_init.c index b3d4158..09186ae 100644 --- a/src/nSocket/nstack_rd/nstack_rd_init.c +++ b/src/nSocket/nstack_rd/nstack_rd_init.c @@ -36,17 +36,6 @@ if (!ptr)\ goto lab; \ } -/* *INDENT-OFF* */ -rd_stack_plane_map g_nstack_plane_info[] = { - {{RD_LINUX_NAME}, {RD_LINUX_PLANENAME}, -1}, - {"rsocket", "nstack-rsocket", -1}, - {{RD_STACKX_NAME}, {RD_STACKX_PLANENAME}, -1}, - {"vpp_hoststack", "nstack-vpp", -1}, -}; -/* *INDENT-ON* */ - -int g_rd_map_num = sizeof (g_nstack_plane_info) / sizeof (rd_stack_plane_map); - rd_local_data *g_rd_local_data = NULL; /***************************************************************************** @@ -68,7 +57,6 @@ nstack_rd_init (nstack_stack_info * pstack, int num, nstack_get_route_data * pfun, int fun_num) { int icnt = 0; - int itemp = 0; int hindex = 0; int tindex = num - 1; int iindex = 0; @@ -119,39 +107,18 @@ nstack_rd_init (nstack_stack_info * pstack, int num, /* modify destMax from RD_PLANE_NAMELEN to STACK_NAME_MAX */ ret = - STRCPY_S (ptemstack[iindex].stack.stackname, STACK_NAME_MAX, - pstack[icnt].name); + STRCPY_S (ptemstack[iindex].name, STACK_NAME_MAX, pstack[icnt].name); if (ret != EOK) { NSSOC_LOGERR ("STRCPY_S failed"); goto ERR; } - for (itemp = 0; itemp < g_rd_map_num; itemp++) - { - if (0 == - strcmp (pstack[icnt].name, - g_nstack_plane_info[itemp].stackname)) - { - ret = - STRCPY_S (ptemstack[iindex].stack.planename, RD_PLANE_NAMELEN, - g_nstack_plane_info[itemp].planename); - g_nstack_plane_info[itemp].stackid = pstack[icnt].stack_id; - NSTACK_RD_ERR_CHECK_GOTO (ret, "plane name copy fail", ERR); - break; - } - } - - if (itemp >= g_rd_map_num) - { - NSSOC_LOGERR ("rd route info not found"); - goto ERR; - } ptemstack[iindex].priority = pstack[icnt].priority; ptemstack[iindex].stack_id = pstack[icnt].stack_id; NSSOC_LOGDBG - ("nstack rd init]stackname=%s,planename=%s,priority=%d,stackid=%d was added", - ptemstack[iindex].stack.stackname, ptemstack[iindex].stack.planename, + ("nstack rd init]stackname=%s,priority=%d,stackid=%d was added", + ptemstack[iindex].name, ptemstack[iindex].priority, ptemstack[iindex].stack_id); } @@ -195,7 +162,7 @@ nstack_get_stackid_byname (char *name) for (iindex = 0; iindex < stacknum; iindex++) { pstack = &(g_rd_local_data->pstack_info[iindex]); - if (0 == strcmp (pstack->stack.stackname, name)) + if (0 == strcmp (pstack->name, name)) { return pstack->stack_id; } diff --git a/src/nSocket/nstack_rd/nstack_rd_ip.c b/src/nSocket/nstack_rd/nstack_rd_ip.c index bcbe731..c9246c0 100644 --- a/src/nSocket/nstack_rd/nstack_rd_ip.c +++ b/src/nSocket/nstack_rd/nstack_rd_ip.c @@ -26,7 +26,7 @@ #include "nstack_ip_addr.h" -#define NSTACK_IP_MLSTACKID RD_STACKX_NAME +#define NSTACK_IP_MLSTACKID RD_LWIP #define PP_HTONL(x) ((((x) & 0xff) << 24) | \ (((x) & 0xff00) << 8) | \ diff --git a/src/nSocket/nstack_rd/nstack_rd_priv.h b/src/nSocket/nstack_rd/nstack_rd_priv.h index b3ed9b5..7179364 100644 --- a/src/nSocket/nstack_rd/nstack_rd_priv.h +++ b/src/nSocket/nstack_rd/nstack_rd_priv.h @@ -25,25 +25,14 @@ #define NSTACK_RD_AGETIME_MAX (1) #define NSTACK_SYS_FUN_MAX (16) -#define RD_STACKX_NAME "stackx" -#define RD_LINUX_NAME "kernel" - -#define RD_STACKX_PLANENAME "nstack-dpdk" -#define RD_LINUX_PLANENAME "nstack-kernel" -#define RD_LINUX_PLANENULL "null" +#define RD_LWIP "lwip" +#define RD_KERNEL "kernel" #define NSTACK_RD_INDEX_BYIP(ip) (((ip) & 0xff) \ + (((ip) >> 8)&0xff) \ + (((ip) >> 16)&0xff) \ + (((ip) >> 24)&0xff)) -typedef struct __rd_stack_plane_map -{ - char stackname[STACK_NAME_MAX]; - char planename[RD_PLANE_NAMELEN]; - int stackid; -} rd_stack_plane_map; - /*route data*/ typedef struct __rd_data_item { @@ -73,7 +62,7 @@ typedef struct __nstack_rd_list typedef struct __nstack_rd_stack_info { /*stack name */ - rd_stack_plane_map stack; + char name[STACK_NAME_MAX]; /*stack id */ int stack_id; /*when route info not found, high priority stack was chose, same priority chose fist input one */ diff --git a/stacks/lwip_stack/app_conf/module_config.json b/stacks/lwip_stack/app_conf/module_config.json index a179ad4..f1b3458 100644 --- a/stacks/lwip_stack/app_conf/module_config.json +++ b/stacks/lwip_stack/app_conf/module_config.json @@ -13,7 +13,7 @@ "stackid": "0", }, { - "stack_name": "stackx", + "stack_name": "lwip", "function_name": "nstack_stack_register", "libname": "libnstack.so", "loadtype": "dynmic", diff --git a/stacks/lwip_stack/app_conf/rd_config.json b/stacks/lwip_stack/app_conf/rd_config.json index 38374bc..3109bcd 100644 --- a/stacks/lwip_stack/app_conf/rd_config.json +++ b/stacks/lwip_stack/app_conf/rd_config.json @@ -2,25 +2,25 @@ "ip_route": [ { "subnet": "192.168.1.1/24", - "type": "nstack-dpdk", + "stack_name": "lwip", }, { "subnet": "192.167.1.1/24", - "type": "nstack-kernel", + "stack_name": "kernel", }, { "subnet": "192.166.1.1/24", - "type": "nstack-kernel", + "stack_name": "kernel", } ], "prot_route": [ { "proto_type": "1", - "type": "nstack-dpdk", + "stack_name": "lwip", }, { "proto_type": "2", - "type": "nstack-kernel", + "stack_name": "kernel", } ], } 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 0986ed4..1c9bf92 100644 --- a/stacks/lwip_stack/lwip_src/api/spl_api_msg.c +++ b/stacks/lwip_stack/lwip_src/api/spl_api_msg.c @@ -414,7 +414,7 @@ spl_recv_udp (void *arg, struct udp_pcb *pcb, struct pbuf *p, { struct spl_netbuf *buf; spl_netconn_t *conn = (spl_netconn_t *) arg; - struct spl_pbuf *spb = NULL; //?? + struct spl_pbuf *spl_pb = NULL; //?? if (NULL == pcb) { @@ -432,12 +432,28 @@ spl_recv_udp (void *arg, struct udp_pcb *pcb, struct pbuf *p, /* //@TODO: malloc and Copy splbuf */ struct common_pcb *cpcb = (struct common_pcb *) (conn->comm_pcb_data); - buf = (struct spl_netbuf *) ((char *) p + sizeof (struct spl_pbuf)); - buf->p = spb; + u16_t proc_id = spl_get_lcore_id (); + + spl_pb = spl_pbuf_alloc_hugepage (SPL_PBUF_TRANSPORT, + p->tot_len + + g_offSetArry[SPL_PBUF_TRANSPORT], + SPL_PBUF_HUGE, proc_id, conn); + + if (!spl_pb) + { + NSPOL_LOGINF (TCP_DEBUG, "spl_pbuf_alloc_hugepage Failed!!!"); + return; + } + + pbuf_to_splpbuf_copy (spl_pb, p); + pbuf_free (p); + + buf = (struct spl_netbuf *) ((char *) spl_pb + sizeof (struct spl_pbuf)); + buf->p = spl_pb; spl_ip_addr_set (&buf->addr, ipaddr); buf->port = port; - err_t ret = sp_enqueue (cpcb, (void *) p); + err_t ret = sp_enqueue (cpcb, (void *) spl_pb); if (ret != ERR_OK) { NSPOL_LOGDBG (UDP_DEBUG, "mbox post failed"); @@ -1808,6 +1824,56 @@ do_listen (struct common_pcb *cpcb, msg_listen * lmsg) } /** + * Send some data on UDP pcb contained in a netconn + * Called from do_send + * + * @param msg the api_msg_msg pointing to the connection + */ +void +spl_udp_send (struct common_pcb *cpcb, msg_send_buf * smsg) +{ + struct spl_pbuf *p_from = smsg->p; + spl_netconn_t *conn = cpcb->conn; + struct udp_pcb *upcb = (struct udp_pcb *) (cpcb->conn->private_data); + data_com_msg *m = MSG_ENTRY (smsg, data_com_msg, buffer); + struct pbuf *p_to = NULL; + err_t err = ERR_OK; + + //allocate pbuf and copy spl_pbuf, send , free pbuf and spl_pbuf + do + { + p_to = pbuf_alloc (PBUF_TRANSPORT, p_from->len, PBUF_RAM); + if (NULL == p_to) + { + NSPOL_LOGERR ("pbuf is NULL]conn=%p,pcb=%p", conn, upcb); + return; + } + + err = splpbuf_to_pbuf_transport_copy (p_to, p_from); + if (err != ERR_OK) + { + SET_MSG_ERR (m, conn->last_err); + return; + } + + if (ip_addr_isany (&smsg->addr)) + { + SET_MSG_ERR (m, udp_send (upcb, p_to)); + } + else + { + SET_MSG_ERR (m, + udp_sendto (upcb, p_to, (ip_addr_t *) & smsg->addr, + smsg->port)); + } + + p_from = (struct spl_pbuf *) ADDR_SHTOL (p_from->next_a); + } + while (p_from != NULL); + +} + +/** * Send some data on a RAW or UDP pcb contained in a netconn * Called from netconn_send * @@ -1825,8 +1891,8 @@ do_send (struct common_pcb *cpcb, msg_send_buf * smsg) if (SPL_ERR_IS_FATAL (conn->last_err)) { SET_MSG_ERR (m, conn->last_err); - spl_pbuf_free (p); - return; + NSPOL_LOGERR ("Invalid param]msg->conn=%p", conn); + goto err_return; } switch (SPL_NETCONNTYPE_GROUP (cpcb->type)) @@ -1840,20 +1906,8 @@ do_send (struct common_pcb *cpcb, msg_send_buf * smsg) ss_set_local_ip (conn, smsg->local_ip.addr); } - //spl_ip_addr_t *destIP = &smsg->addr; + spl_udp_send (cpcb, smsg); - //@TODO udp send need to update like TCP. copy pbuf here. Once testing done for TCP we'll update it here. - if (ip_addr_isany (&smsg->addr)) - { - //SET_MSG_ERR(m, udp_send(upcb, p)); - /* destIP.addr == IPADDR_ANY means it is from stackx_send - and the destination is stored in remote_ip and remote port */ - //destIP = &upcb->remote_ip; - } - else - { - //SET_MSG_ERR(m, udp_sendto(upcb, p, &smsg->addr, smsg->port)); - } break; } @@ -1862,6 +1916,10 @@ do_send (struct common_pcb *cpcb, msg_send_buf * smsg) break; } +err_return: + pbuf_free_safe (smsg->p); + ASYNC_MSG_FREE (m); + return; } diff --git a/stacks/lwip_stack/lwip_src/core/spl_pbuf.c b/stacks/lwip_stack/lwip_src/core/spl_pbuf.c index 03e30ed..54589e8 100644 --- a/stacks/lwip_stack/lwip_src/core/spl_pbuf.c +++ b/stacks/lwip_stack/lwip_src/core/spl_pbuf.c @@ -369,6 +369,20 @@ spl_pbuf_copy (struct spl_pbuf * p_to, struct spl_pbuf * p_from) } err_t +splpbuf_to_pbuf_transport_copy (struct pbuf * p_to, struct spl_pbuf * p_from) +{ + if (EOK != MEMMOVE_S ((u8_t *) p_to->payload, + p_to->len, (u8_t *) ADDR_SHTOL (p_from->payload_a), + p_from->len)) + { + NSPOL_LOGERR ("MEMMOVE_S failed"); + return ERR_MEM; + } + + return ERR_OK; +} + +err_t splpbuf_to_pbuf_copy (struct pbuf * p_to, struct spl_pbuf * p_from) { u32_t offset_to = 0; diff --git a/stacks/lwip_stack/lwip_src/include/stackx/spl_pbuf.h b/stacks/lwip_stack/lwip_src/include/stackx/spl_pbuf.h index 01fe242..79deace 100644 --- a/stacks/lwip_stack/lwip_src/include/stackx/spl_pbuf.h +++ b/stacks/lwip_stack/lwip_src/include/stackx/spl_pbuf.h @@ -48,6 +48,9 @@ struct spl_pbuf *spl_pbuf_alloc_hugepage (spl_pbuf_layer l, u16_t length, spl_pbuf_type type, u16_t thread_index, void *net_conn); struct pbuf *spl_convert_spl_pbuf_to_pbuf (struct spl_pbuf *p_from); +err_t +splpbuf_to_pbuf_transport_copy (struct pbuf *p_to, struct spl_pbuf *p_from); + err_t pbuf_to_splpbuf_copy (struct spl_pbuf *p_to, struct pbuf *p_from); err_t splpbuf_to_pbuf_copy (struct pbuf *p_to, struct spl_pbuf *p_from); spl_pbuf_layer get_pbuf_layer_from_pbuf_payload (struct pbuf *buf); diff --git a/stacks/lwip_stack/lwip_src/socket/stackx_event.c b/stacks/lwip_stack/lwip_src/socket/stackx_event.c index 93e47a3..1967ecc 100644 --- a/stacks/lwip_stack/lwip_src/socket/stackx_event.c +++ b/stacks/lwip_stack/lwip_src/socket/stackx_event.c @@ -17,13 +17,112 @@ #include "stackx_spl_share.h" #include "common_pal_bitwide_adjust.h" #include "stackx_event.h" -#include <netinet/in.h> - -#define FREE_FD_SET(readfd, writefd, exceptfd) {\ - if(readfd)\ - free(readfd);\ - if(writefd)\ - free(writefd);\ - if(exceptfd)\ - free(exceptfd);\ + +#define FREE_FD_SET(readfd, writefd, exceptfd) {\ +if(readfd)\ +free(readfd);\ +if(writefd)\ +free(writefd);\ +if(exceptfd)\ +free(exceptfd);\ +} + +int +lwip_try_select (int fdsize, fd_set * fdread, fd_set * fdwrite, + fd_set * fderr, struct timeval *timeout) +{ + int i; + int nready = 0; + nstack_fd_set *read_out; + nstack_fd_set *write_out; + nstack_fd_set *err_out; + nstack_fd_set *readfd = (nstack_fd_set *) fdread; + nstack_fd_set *writefd = (nstack_fd_set *) fdwrite; + nstack_fd_set *exceptfd = (nstack_fd_set *) fderr; + sbr_socket_t *sock; + spl_netconn_t *conn; + + if ((fdsize >= NSTACK_SETSIZE) || (fdsize < 0)) + { + return 0; + } + read_out = malloc (sizeof (nstack_fd_set)); + write_out = malloc (sizeof (nstack_fd_set)); + err_out = malloc (sizeof (nstack_fd_set)); + if ((!read_out) || (!write_out) || (!err_out)) + { + NSPOL_LOGERR ("malloc nstack_fd_set fail"); + FREE_FD_SET (read_out, write_out, err_out); + return -1; + } + int ret = NSTACK_FD_ZERO (read_out); + int ret1 = NSTACK_FD_ZERO (write_out); + int ret2 = NSTACK_FD_ZERO (err_out); + + if ((EOK != ret) || (EOK != ret1) || (EOK != ret2)) + { + NSPOL_LOGERR ("NSTACK_FD_ZERO fail"); + FREE_FD_SET (read_out, write_out, err_out); + return -1; + } + + for (i = 0; i < fdsize; i++) + { + if (!((readfd && NSTACK_FD_ISSET (i, readfd)) + || (writefd && NSTACK_FD_ISSET (i, writefd)) + || (exceptfd && NSTACK_FD_ISSET (i, exceptfd)))) + { + continue; + } + sock = sbr_lookup_sk (i); + if (sock == NULL) + { + errno = EBADF; + FREE_FD_SET (read_out, write_out, err_out); + return -1; + } + conn = sbr_get_conn (sock); + if (!conn) + { + errno = EBADF; + FREE_FD_SET (read_out, write_out, err_out); + return -1; + } + if (readfd && NSTACK_FD_ISSET (i, readfd) && + ((sbr_get_fd_share (sock)->lastdata != NULL) + || (conn->rcvevent > 0))) + { + NSTACK_FD_SET (i, read_out); + nready++; + } + if (writefd && NSTACK_FD_ISSET (i, writefd) && (conn->sendevent != 0)) + { + NSTACK_FD_SET (i, write_out); + nready++; + } + if (exceptfd && NSTACK_FD_ISSET (i, exceptfd) && (conn->errevent != 0)) + { + NSTACK_FD_SET (i, write_out); + nready++; + } + } + + //TODO: need to handle fd_set and nstack_fd_set memory issue + if (readfd) + { + *readfd = *read_out; + } + + if (writefd) + { + *writefd = *write_out; + } + + if (exceptfd) + { + *exceptfd = *err_out; + } + + FREE_FD_SET (read_out, write_out, err_out); + return nready; } diff --git a/stacks/lwip_stack/lwip_src/socket/stackx_protocol_api.c b/stacks/lwip_stack/lwip_src/socket/stackx_protocol_api.c index 920d73d..0be8d7b 100644 --- a/stacks/lwip_stack/lwip_src/socket/stackx_protocol_api.c +++ b/stacks/lwip_stack/lwip_src/socket/stackx_protocol_api.c @@ -56,7 +56,7 @@ sbr_init_protocol () int sbr_fork_protocol () { - pid_t pid = updata_sys_pid (); + pid_t pid = update_sys_pid (); NSSBR_LOGINF ("update pid in child]pid=%d", pid); return sbr_fork_stackx (); diff --git a/stacks/lwip_stack/src/sbr/sbr_protocol_api.h b/stacks/lwip_stack/src/sbr/sbr_protocol_api.h index 0eac1c4..95ca565 100644 --- a/stacks/lwip_stack/src/sbr/sbr_protocol_api.h +++ b/stacks/lwip_stack/src/sbr/sbr_protocol_api.h @@ -91,6 +91,8 @@ int sbr_init_protocol (); int sbr_fork_protocol (); sbr_fdopt *sbr_get_fdopt (int domain, int type, int protocol); void sbr_app_touch_in (void); /*app send its version info to nStackMain */ +int lwip_try_select (int fdsize, fd_set * fdread, fd_set * fdwrite, + fd_set * fderr, struct timeval *timeout); #ifdef __cplusplus /* *INDENT-OFF* */ diff --git a/stacks/lwip_stack/src/sbr/sbr_socket.c b/stacks/lwip_stack/src/sbr/sbr_socket.c index e088224..6f867ab 100644 --- a/stacks/lwip_stack/src/sbr/sbr_socket.c +++ b/stacks/lwip_stack/src/sbr/sbr_socket.c @@ -1065,7 +1065,7 @@ SBR_INTERCEPT (int, select, (int nfds, fd_set * readfd, fd_set * writefd, fd_set * exceptfd, struct timeval * timeout)) { - return -1; + return lwip_try_select (nfds, readfd, writefd, exceptfd, timeout); } SBR_INTERCEPT (unsigned int, ep_getevt, diff --git a/stacks/rsocket/config/rd_config.json b/stacks/rsocket/config/rd_config.json index ea1fc7b..5c6f861 100644 --- a/stacks/rsocket/config/rd_config.json +++ b/stacks/rsocket/config/rd_config.json @@ -2,7 +2,7 @@ "ip_route": [ { "subnet": "192.168.1.1/24", - "type": "nstack-rsocket", + "stack_name": "rsocket", }, ], "prot_route": [ diff --git a/stacks/vpp/configure/rd_config.json b/stacks/vpp/configure/rd_config.json index 2ea10d1..166fbec 100644 --- a/stacks/vpp/configure/rd_config.json +++ b/stacks/vpp/configure/rd_config.json @@ -2,25 +2,25 @@ "ip_route": [ { "subnet": "192.168.1.1/24", - "type": "nstack-vpp", + "stack_name": "vpp_hoststack", }, { "subnet": "10.145.240.1/24", - "type": "nstack-kernel", + "stack_name": "kernel", }, { "subnet": "192.166.1.1/24", - "type": "nstack-kernel", + "stack_name": "kernel", } ], "prot_route": [ { "proto_type": "1", - "type": "nstack-vpp", + "stack_name": "vpp_hoststack", }, { "proto_type": "2", - "type": "nstack-kernel", + "stack_name": "kernel", } ], } |