Commit d93251fa authored by wangyongshou's avatar wangyongshou

modify error of config interfce state/ip, ip route

parent f922788c
...@@ -80,6 +80,7 @@ void upf_create_gtpu_tunnel(const u32 n3_local_ip, const u32 n3_remote_ip, const ...@@ -80,6 +80,7 @@ void upf_create_gtpu_tunnel(const u32 n3_local_ip, const u32 n3_remote_ip, const
{ {
u8 *buf = NULL; u8 *buf = NULL;
char cmd[UPF_BUF] = {0} ;
char n3_local[UPF_BUF] = {0}; char n3_local[UPF_BUF] = {0};
char n3_remote[UPF_BUF] = {0}; char n3_remote[UPF_BUF] = {0};
vlib_main_t * vm = &vlib_global_main; vlib_main_t * vm = &vlib_global_main;
...@@ -87,15 +88,16 @@ void upf_create_gtpu_tunnel(const u32 n3_local_ip, const u32 n3_remote_ip, const ...@@ -87,15 +88,16 @@ void upf_create_gtpu_tunnel(const u32 n3_local_ip, const u32 n3_remote_ip, const
upf_ip4_to_str(n3_local_ip, n3_local, UPF_BUF); upf_ip4_to_str(n3_local_ip, n3_local, UPF_BUF);
upf_ip4_to_str(n3_remote_ip, n3_remote, UPF_BUF); upf_ip4_to_str(n3_remote_ip, n3_remote, UPF_BUF);
char cmd[UPF_BUF] = {0} ; int len = snprintf(cmd, UPF_BUF, GTPU_TUNNEL, n3_local, n3_remote, teid);
snprintf(cmd, UPF_BUF, GTPU_TUNNEL, n3_local, n3_remote, teid);
unformat_input_t sub_input; unformat_input_t sub_input;
vec_resize (buf, UPF_BUF);
//vec_copy(buf, cmd);
vec_resize (buf, strlen(cmd));
strncpy((char *)buf, cmd, strlen(cmd)); strncpy((char *)buf, cmd, strlen(cmd));
clib_upf_debug(um->log_fd,"len:%u, strlen:%u", len, strlen(cmd));
clib_upf_debug(um->log_fd, "\n\n***** Startup Config *****\n\n%s\n***** End Startup Config *****\n\n",cmd); clib_upf_debug(um->log_fd, "\n\n***** Startup Config *****\n\n%s\n***** End Startup Config *****\n\n",cmd);
if(vec_len (buf)) if(vec_len (buf))
...@@ -123,7 +125,8 @@ void upf_create_ip_route(const u32 ue_ip, const char *gtpu_name) ...@@ -123,7 +125,8 @@ void upf_create_ip_route(const u32 ue_ip, const char *gtpu_name)
snprintf(cmd, UPF_BUF, IP_ROUTE, ueaddr, gtpu_name); snprintf(cmd, UPF_BUF, IP_ROUTE, ueaddr, gtpu_name);
unformat_input_t sub_input; unformat_input_t sub_input;
vec_resize (buf, UPF_BUF);
vec_resize (buf, strlen(cmd));
strncpy((char *)buf, cmd, strlen(cmd)); strncpy((char *)buf, cmd, strlen(cmd));
clib_upf_debug(um->log_fd, "\n\n***** Startup Config *****\n\n%s\n***** End Startup Config *****\n\n",cmd); clib_upf_debug(um->log_fd, "\n\n***** Startup Config *****\n\n%s\n***** End Startup Config *****\n\n",cmd);
......
...@@ -375,44 +375,45 @@ startup_config_process (vlib_main_t * vm, ...@@ -375,44 +375,45 @@ startup_config_process (vlib_main_t * vm,
close (fd); close (fd);
} }
else else
{ {
//add it to inif config in 20210311 //add it to inif config in 20210311
{ {
#define BUF_LEN 1024 #define BUF_LEN 1024
#define IF_UP_IPADDR "set interface state %s up\nset interface ip address %s %s/%d\n\n" #define IF_UP_IPADDR "set interface state %s up\nset interface ip address %s %s/%d\n\n"
u8 *buf = NULL; u8 *buf = NULL;
char cmd[BUF_LEN] = {0}; char cmd[BUF_LEN] = {0};
char if_cmd[BUF_LEN] = {0}; char if_cmd[BUF_LEN] = {0};
strcat(if_cmd, IF_UP_IPADDR); strcat(if_cmd, IF_UP_IPADDR);
strcat(if_cmd, IF_UP_IPADDR); strcat(if_cmd, IF_UP_IPADDR);
strcat(if_cmd, "ip route add 0.0.0.0/0 via %s %s\n\n"); strcat(if_cmd, "ip route add 0.0.0.0/0 via %s %s\n\n");
vec_resize (buf, BUF_LEN);
snprintf(cmd, BUF_LEN, if_cmd,
snprintf(cmd, BUF_LEN, if_cmd, if_info->if_n3.name, if_info->if_n3.name,if_info->if_n3.ipaddr, if_info->if_n3.netmask,
if_info->if_n3.name, if_info->if_n3.name,if_info->if_n3.ipaddr, if_info->if_n3.netmask, if_info->if_n6.name, if_info->if_n6.name,if_info->if_n6.ipaddr, if_info->if_n6.netmask,
if_info->if_n6.name, if_info->if_n6.name,if_info->if_n6.ipaddr, if_info->if_n6.netmask, if_info->if_n6.name, if_info->if_n6.gateway);
if_info->if_n6.name, if_info->if_n6.gateway);
vec_resize (buf, strlen(cmd));
vec_copy(buf, cmd); strncpy((char *)buf, cmd,strlen(cmd));
clib_upf_debug(um->log_fd, "\n\n***** Startup Config *****\n\n%s\n***** End Startup Config *****\n\n",cmd); clib_upf_debug(um->log_fd, "\n\n***** Startup Config *****\n\n%s\n***** End Startup Config *****\n\n",cmd);
if(vec_len (buf)) if(vec_len (buf))
{ {
unformat_input_t sub_input; unformat_input_t sub_input;
unformat_init_vector (&sub_input, buf); unformat_init_vector (&sub_input, buf);
vlib_cli_input (vm, &sub_input, 0, 0); vlib_cli_input (vm, &sub_input, 0, 0);
/* frees buf for us */ /* frees buf for us */
unformat_free (&sub_input); unformat_free (&sub_input);
} }
} }
} }
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment