Switch: Fix config defaults saving

This commit is contained in:
RichardG867
2026-01-07 21:51:19 -03:00
parent 0884f9f28b
commit 026ce292fb

View File

@@ -886,18 +886,15 @@ load_network(void)
} else
strcpy(nc->host_dev_name, "none");
sprintf(temp, "net_%02i_switch_group", c + 1);
net_cards_conf[c].switch_group = ini_section_get_int(cat, temp, 0);
sprintf(temp, "net_%02i_switch_group", c + 1);
nc->switch_group = ini_section_get_int(cat, temp, 0);
sprintf(temp, "net_%02i_promisc", c + 1);
net_cards_conf[c].promisc_mode = ini_section_get_int(cat, temp, 0);
sprintf(temp, "net_%02i_promisc", c + 1);
nc->promisc_mode = ini_section_get_int(cat, temp, 0);
sprintf(temp, "net_%02i_nrs_host", c + 1);
p = ini_section_get_string(cat, temp, NULL);
if (p != NULL)
strncpy(net_cards_conf[c].nrs_hostname, p, sizeof(net_cards_conf[c].nrs_hostname) - 1);
else
strncpy(net_cards_conf[c].nrs_hostname, "", sizeof(net_cards_conf[c].nrs_hostname) - 1);
sprintf(temp, "net_%02i_nrs_host", c + 1);
p = ini_section_get_string(cat, temp, NULL);
strncpy(nc->nrs_hostname, p ? p : "", sizeof(nc->nrs_hostname) - 1);
sprintf(temp, "net_%02i_link", c + 1);
nc->link_state = ini_section_get_int(cat, temp,
@@ -2989,26 +2986,22 @@ save_network(void)
ini_section_set_int(cat, temp, nc->link_state);
sprintf(temp, "net_%02i_switch_group", c + 1);
if (nc->device_num == 0)
if (nc->switch_group == 0)
ini_section_delete_var(cat, temp);
else
ini_section_set_int(cat, temp, net_cards_conf[c].switch_group);
ini_section_set_int(cat, temp, nc->switch_group);
sprintf(temp, "net_%02i_promisc", c + 1);
if (nc->device_num == 0)
if (nc->promisc_mode == 0)
ini_section_delete_var(cat, temp);
else
ini_section_set_int(cat, temp, net_cards_conf[c].promisc_mode);
ini_section_set_int(cat, temp, nc->promisc_mode);
sprintf(temp, "net_%02i_nrs_host", c + 1);
if (nc->device_num == 0)
if (nc->nrs_hostname[0] == '\0')
ini_section_delete_var(cat, temp);
else {
if (nc->nrs_hostname[0] != '\0')
ini_section_set_string(cat, temp, net_cards_conf[c].nrs_hostname);
else
ini_section_delete_var(cat, temp);
}
else
ini_section_set_string(cat, temp, net_cards_conf[c].nrs_hostname);
}
ini_delete_section_if_empty(config, cat);