Interface stays in disabled state after link connectivity loss is restored

I have a wan interface which is set as a DHCP client and the issue is that if the modem restarts and there is a link loss, udhcpc gets a SIGTERM and exits, but the interface remains in an inactive or disabled state unless I restart the entire network ie through /etc/init.d/network restart.

Even if I try the restart option in Luci for that specific interface, it makes no difference, neither does ifup <interface name>

I've been noticing this issue only in OpenWRT 19.07.2, it's been working stable in 19.07.0 without issues.

Below shows an example of an occurrence that happened last night. As you can see the interface stays in a disabled state.

2020 Apr 20 03:06:14 bumblebee notice netifd[]: Interface 'wan2' has link connectivity loss
2020 Apr 20 03:06:14 bumblebee notice netifd[]: wan2 (30260): udhcpc: received SIGTERM
2020 Apr 20 03:06:14 bumblebee notice netifd[]: Interface 'wan2' is now down
2020 Apr 20 03:06:14 bumblebee notice netifd[]: Interface 'wan2' is disabled
2020 Apr 20 03:06:14 bumblebee notice mwan3[3392]: Execute ifdown event on interface wan2 (unknown)
2020 Apr 20 03:06:14 bumblebee info mwan3track[15914]: Detect ifdown event on interface wan2 (eth2)
2020 Apr 20 03:06:14 bumblebee notice mwan3track[15914]: Interface wan2 (eth2) is offline
2020 Apr 20 03:06:16 bumblebee notice netifd[]: Interface 'wan2' has link connectivity
2020 Apr 20 03:06:18 bumblebee notice netifd[]: Interface 'wan2' has link connectivity loss
2020 Apr 20 03:06:19 bumblebee notice netifd[]: Interface 'wan2' has link connectivity
2020 Apr 20 03:06:35 bumblebee notice netifd[]: Interface 'wan2' has link connectivity loss
2020 Apr 20 03:06:37 bumblebee notice netifd[]: Interface 'wan2' has link connectivity
2020 Apr 20 03:06:40 bumblebee notice netifd[]: Interface 'wan2' has link connectivity loss
2020 Apr 20 03:06:41 bumblebee notice netifd[]: Interface 'wan2' has link connectivity
2020 Apr 20 03:06:43 bumblebee notice netifd[]: Interface 'wan2' has link connectivity loss
2020 Apr 20 03:06:45 bumblebee notice netifd[]: Interface 'wan2' has link connectivity

Now if I do a network restart, the logs are different as you can see the interface is now enabled and udhcpc is started.

2020 Apr 20 13:12:04 bumblebee notice netifd[]: Interface 'wan2' has link connectivity loss
2020 Apr 20 13:12:06 bumblebee notice netifd[]: Interface 'wan2' is enabled
2020 Apr 20 13:12:08 bumblebee notice netifd[]: Interface 'wan2' has link connectivity
2020 Apr 20 13:12:08 bumblebee notice netifd[]: Interface 'wan2' is setting up now
2020 Apr 20 13:12:08 bumblebee notice netifd[]: wan2 (32300): udhcpc: started, v1.30.1
2020 Apr 20 13:12:08 bumblebee notice netifd[]: wan2 (32300): udhcpc: sending discover
2020 Apr 20 13:12:08 bumblebee notice netifd[]: wan2 (32300): udhcpc: sending select for 56.81.103.21
2020 Apr 20 13:12:08 bumblebee notice netifd[]: wan2 (32300): udhcpc: lease of 56.81.103.21 obtained, lease time 7200
2020 Apr 20 13:12:08 bumblebee notice netifd[]: Interface 'wan2' is now up

So I have three interfaces which all start with wan2 ie wan2, wan2_6 and wan2_cpe. First two are IPv4 and IPv6 respectively, and the third is an alias interface so that I can access the modems management UI. This is set with a static IP address.

If I do a ifup wan2 I see that all three interfaces get restarted if they are already running and up. It appears some component is not looking for an exact name match and that is causing a race condition of some sort.

After this issue repeating couple of times, noticed that this happens only the first time the modem restarts post my OpenWRT router starting up.

Whenever this happens, running ifdown wan2_cpe && ifup wan2 && ifup wan2_cpe brings it back up. After this even if the modem gets restarted, connectivity is restored without an issue (provided my router hasn't restarted)

So I added the following to /etc/rc.local to workaround the issue, by proactively restarting the interface before the issue manifests. This appears to be work alright for now.

sleep 120 && ifdown wan2_cpe && ifup wan2 && ifup wan2_cpe
logger -t wan2_fix "Restarted wan2 interfaces to workaround a possible bug"

Again, I am no where close to why this happens in the first place.