MOD aaa-12 桥接口自测问题解决,解决重启丢配置的问题
SOL 桥接口自测问题解决,解决重启丢配置的问题 修改人:zhangliang 检视人:zhangliang
This commit is contained in:
parent
9595330e0a
commit
929d8979ed
|
@ -20,7 +20,8 @@ void ip_conf_file_set(char *if_name, char *conf_name, char *conf_buff);
|
||||||
void ip_conf_file_del(char *if_name, char *conf_buff);
|
void ip_conf_file_del(char *if_name, char *conf_buff);
|
||||||
|
|
||||||
ret_code del_sub_string(char *str_in,char *str_sub);
|
ret_code del_sub_string(char *str_in,char *str_sub);
|
||||||
int if_read_from_file(struct ifreq *ifcfg, int max_port);
|
int if_read_dev_file(struct ifreq *ifcfg, int max_port);
|
||||||
ret_code if_conf_file_init();
|
ret_code if_conf_file_init();
|
||||||
|
int if_read_conf_file(struct ifreq *ifcfg, int max_port);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -107,12 +107,16 @@ int br_copy_port_name(const char *b, const char *p, void *arg)
|
||||||
|
|
||||||
ret_code br_name_chk(char *br_name)
|
ret_code br_name_chk(char *br_name)
|
||||||
{
|
{
|
||||||
if(strlen(br_name) == 0
|
if(strlen(br_name) < strlen("br")
|
||||||
|| strlen(br_name) > BR_NAMSIZ - 1
|
|| strlen(br_name) > BR_NAMSIZ - 1
|
||||||
|| strstr(br_name, "br-vl") != NULL)
|
|| strstr(br_name, "br-vl") != NULL)
|
||||||
{
|
{
|
||||||
return RET_BR_INVALID;
|
return RET_BR_INVALID;
|
||||||
}
|
}
|
||||||
|
if(br_name[0] != 'b' || br_name[1] != 'r')
|
||||||
|
{
|
||||||
|
return RET_BR_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
return RET_OK;
|
return RET_OK;
|
||||||
}
|
}
|
||||||
|
@ -189,14 +193,17 @@ ret_code br_if_bridge_check(char **port_list, int cnt, uint config_type)
|
||||||
ret_code br_save_file(BR_EVENT_TYPE event_type,
|
ret_code br_save_file(BR_EVENT_TYPE event_type,
|
||||||
char *br_name, char *port_name)
|
char *br_name, char *port_name)
|
||||||
{
|
{
|
||||||
char *key_str = "bridge_ports";
|
char *key_str = "bridge_ports";
|
||||||
|
char iface_str[IF_BUFF_LEN] = {0};
|
||||||
char config_str[IF_BUFF_LEN] = {0};
|
char config_str[IF_BUFF_LEN] = {0};
|
||||||
ret_code ret;
|
ret_code ret;
|
||||||
|
|
||||||
switch(event_type)
|
switch(event_type)
|
||||||
{
|
{
|
||||||
case BR_CREATE_EVENT:
|
case BR_CREATE_EVENT:
|
||||||
if_conf_file_add(br_name);
|
if_conf_file_add(br_name);
|
||||||
|
sprintf(iface_str, "iface %s inet manual\n", br_name);
|
||||||
|
if_conf_file_set(br_name, "iface", iface_str);
|
||||||
break;
|
break;
|
||||||
case BR_DELETE_EVENT:
|
case BR_DELETE_EVENT:
|
||||||
if_conf_file_del(br_name);
|
if_conf_file_del(br_name);
|
||||||
|
@ -1068,14 +1075,27 @@ ret_code br_fdb_config_get(uint source,
|
||||||
|
|
||||||
ret_code br_bridge_init()
|
ret_code br_bridge_init()
|
||||||
{
|
{
|
||||||
|
struct ifreq ifreq[MAX_IF_NUM];
|
||||||
|
int if_count = 0;
|
||||||
int err;
|
int err;
|
||||||
|
int i;
|
||||||
|
|
||||||
err = br_init();
|
err = br_init();
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
{
|
{
|
||||||
rpc_log_error("bridge init fail:%s\n",strerror(err));
|
rpc_log_error("bridge init fail:%s\n",strerror(err));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
memset(&ifreq, 0, MAX_IF_NUM * sizeof(struct ifreq));
|
||||||
|
|
||||||
|
if_count = if_read_conf_file(ifreq, MAX_IF_NUM);
|
||||||
|
for(i = 0; i < if_count; i++)
|
||||||
|
{
|
||||||
|
if(strstr(ifreq[i].ifr_name, "br"))
|
||||||
|
{
|
||||||
|
br_bridge_add(ifreq[i].ifr_name, &err);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -339,7 +339,7 @@ ret_code if_get_prefix_all(pointer output, int *output_len, int *code)
|
||||||
ifc.ifc_len = MAX_IF_NUM * sizeof(struct ifreq);
|
ifc.ifc_len = MAX_IF_NUM * sizeof(struct ifreq);
|
||||||
ifc.ifc_buf = (char *)ifreq;
|
ifc.ifc_buf = (char *)ifreq;
|
||||||
|
|
||||||
if_count = if_read_from_file(&ifreq, MAX_IF_NUM);
|
if_count = if_read_dev_file(&ifreq, MAX_IF_NUM);
|
||||||
|
|
||||||
if(if_count == 0)
|
if(if_count == 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -39,7 +39,7 @@ static char *if_parse_name(char *name, char *p)
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
int if_read_from_file(struct ifreq *ifcfg, int max_port)
|
int if_read_dev_file(struct ifreq *ifcfg, int max_port)
|
||||||
{
|
{
|
||||||
struct ifreq *ifreq = (struct ifreq *)ifcfg;
|
struct ifreq *ifreq = (struct ifreq *)ifcfg;
|
||||||
char name[128] = {0};
|
char name[128] = {0};
|
||||||
|
@ -72,6 +72,55 @@ int if_read_from_file(struct ifreq *ifcfg, int max_port)
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int if_read_conf_file(struct ifreq *ifcfg, int max_port)
|
||||||
|
{
|
||||||
|
struct ifreq *ifreq = (struct ifreq *)ifcfg;
|
||||||
|
char name[INTERFACE_NAMSIZ] = {0};
|
||||||
|
char buf[512] = {0};
|
||||||
|
char *p = NULL;
|
||||||
|
int i = 0, j = 0;
|
||||||
|
FILE *fh;
|
||||||
|
|
||||||
|
fh = fopen(ETC_NETWORK_IFS, "r");
|
||||||
|
if (!fh) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (fgets(buf, sizeof(buf), fh)) {
|
||||||
|
|
||||||
|
p = NULL;
|
||||||
|
|
||||||
|
if(i >= max_port){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(p = strstr(buf, "iface"))
|
||||||
|
{
|
||||||
|
p += strlen("iface");
|
||||||
|
while (isspace(*p)){
|
||||||
|
p++;
|
||||||
|
}
|
||||||
|
|
||||||
|
j = 0;
|
||||||
|
memset(name, 0, INTERFACE_NAMSIZ);
|
||||||
|
|
||||||
|
while(!isspace(*p)){
|
||||||
|
name[j++] = *p++;
|
||||||
|
if(j >= INTERFACE_NAMSIZ){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
name[INTERFACE_NAMSIZ - 1] = '\0';
|
||||||
|
strncpy(ifreq[i].ifr_name, name, sizeof(ifreq[i].ifr_name));
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose(fh);
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ret_code del_sub_string(char *str_in,char *str_sub)
|
ret_code del_sub_string(char *str_in,char *str_sub)
|
||||||
{
|
{
|
||||||
char* str_out = (char *)malloc(strlen(str_in) + 1);
|
char* str_out = (char *)malloc(strlen(str_in) + 1);
|
||||||
|
@ -644,7 +693,7 @@ next_while:
|
||||||
return conf_file_write(conf_path, sum_buf);
|
return conf_file_write(conf_path, sum_buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
return RET_OK;
|
return RET_EXIST;
|
||||||
}
|
}
|
||||||
|
|
||||||
int conf_value_block_del(char *conf_path, char *start_str, char *end_str)
|
int conf_value_block_del(char *conf_path, char *start_str, char *end_str)
|
||||||
|
@ -833,17 +882,19 @@ ret_code if_role_file_get(char *if_name, char *conf_buff)
|
||||||
|
|
||||||
ret_code if_conf_file_init()
|
ret_code if_conf_file_init()
|
||||||
{
|
{
|
||||||
struct ifreq ifreq[MAX_IF_NUM];
|
/*struct ifreq ifreq[MAX_IF_NUM];
|
||||||
int if_count = 0;
|
int if_count = 0;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
memset(&ifreq, 0, MAX_IF_NUM * sizeof(struct ifreq));
|
memset(&ifreq, 0, MAX_IF_NUM * sizeof(struct ifreq));
|
||||||
|
|
||||||
if_count = if_read_from_file(ifreq, MAX_IF_NUM);
|
if_count = if_read_dev_file(ifreq, MAX_IF_NUM);
|
||||||
for(i = 0; i < if_count; i++)
|
for(i = 0; i < if_count; i++)
|
||||||
{
|
{
|
||||||
if_conf_file_add(ifreq[i].ifr_name);
|
if_conf_file_add(ifreq[i].ifr_name);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue