FS#3222 - The primary static ip address changes after reloading /etc/config/network
with a different metric
#8099
Labels
/etc/config/network
with a different metric
#8099
kingarley:
Device: tested with x86
Software version: found in lede, don't think it's fixed in the later versions
netifd version: netifd-2017-01-25
Reproduce (/etc/config/network):
config interface 'eth0_1'
option ifname 'eth0'
option proto 'static'
option ipaddr '1.1.1.3 1.1.1.2 1.1.1.1'
option netmask '255.255.255.0'
option metric '1001'
ip a
gives the ip addresses in this order: 1.1.1.3, 1.1.1.2, 1.1.1.1change the metric from '1001' to '1002' in
/etc/config/network
call
/etc/init.d/network reload
ip a
gives the ip addresses in this order: 1.1.1.1, 1.1.1.2, 1.1.1.3Code (netifd/interface.c)
in static void
interface_change_config(struct interface *if_old, struct interface *if_new)
...
...
if (reload_ip) {
bool config_ip_enabled = if_old->config_ip.enabled;
bool proto_ip_enabled = if_old->proto_ip.enabled;
interface_ip_set_enabled(&if_old->proto_ip, false);
interface_ip_set_enabled(&if_old->proto_ip, proto_ip_enabled);
The call to interface_ip_set_enabled with 'true' iterates the if_old_proto_ip vlist:
vlist_for_each_element(&ip->addr, addr, node)
which doesn't retain the original order of the static ip addresses in the /etc/config/network, which means the ip addresses are added in a different order, thus changing the primary ip address.
The text was updated successfully, but these errors were encountered: