aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorrainbow_0206 <jiangwenjiang@huawei.com>2018-09-18 19:39:52 +0800
committerrainbow_0206 <jiangwenjiang@huawei.com>2018-10-09 19:11:54 +0800
commit74d149fea978f0200a1d3af07e0efccaf0ee993a (patch)
treeef4755271258c8409ee6e55f3da76f0a7bc58396 /src
parent2827d26800e19858d4a9856c8a8f977a273f9910 (diff)
Fix: delete g_nstack_plane_info and fix json file
Change-Id: Ib9d92b547af01ee5d46723b15d5aea3fcbe2b989 Signed-off-by: rainbow_0206 <jiangwenjiang@huawei.com>
Diffstat (limited to 'src')
-rw-r--r--src/nSocket/nstack/nstack_info_parse.c14
-rw-r--r--src/nSocket/nstack_rd/nstack_rd.c58
-rw-r--r--src/nSocket/nstack_rd/nstack_rd_init.c41
-rw-r--r--src/nSocket/nstack_rd/nstack_rd_ip.c2
-rw-r--r--src/nSocket/nstack_rd/nstack_rd_priv.h17
5 files changed, 46 insertions, 86 deletions
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_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 */