[FS#3222] The primary static ip address changes after reloading `/etc/config/network` with a different metric

OpenWrt Bugs openwrt-bugs at lists.openwrt.org
Fri Jul 10 09:35:10 EDT 2020


A new Flyspray task has been opened.  Details are below. 

User who did this - kingarley (kingarley) 

Attached to Project - OpenWrt/LEDE Project
Summary - The primary static ip address changes after reloading `/etc/config/network` with a different metric
Task Type - Bug Report
Category - Base system
Status - Unconfirmed
Assigned To - 
Operating System - All
Severity - Medium
Priority - Very Low
Reported Version - lede-17.01
Due in Version - Undecided
Due Date - Undecided
Details - 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 ''
    option netmask ''
    option metric '1001'
`ip a` gives the ip addresses in this order:,,
change 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:,,

Code (netifd/interface.c) 
in static void
interface_change_config(struct interface *if_old, struct interface *if_new)

	UPDATE(metric, reload_ip);
	UPDATE(proto_ip.no_defaultroute, reload_ip);
	UPDATE(ip4table, reload_ip);
	UPDATE(ip6table, reload_ip);
	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->config_ip, false);
		interface_ip_set_enabled(&if_old->proto_ip, false);
		interface_ip_set_enabled(&if_old->proto_ip, proto_ip_enabled);
		interface_ip_set_enabled(&if_old->config_ip, config_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.

More information can be found at the following URL:

You are receiving this message because you have requested it from the Flyspray bugtracking system.  If you did not expect this message or don't want to receive mails in future, you can change your notification settings at the URL shown above.

More information about the openwrt-bugs mailing list