[th/act-stage2-re-entrant]
NMDevice has stages (states) during activations. In fact, it has very few of them.
Sometimes, a stage cannot be completed right away, and the completion gets postponed (by returning NM_ACT_STAGE_RETURN_POSTPONE
from act_stage2_config()
). Afterwards, when the device is ready to proceed, it currently schedules the next stage with nm_device_activate_schedule_stage3_ip_config_start()
. That is wrong, because NMDevice
's activate_stage2_device_config()
still does some actions that will be skipped (for example, lldp_init()
).
Instead, when something happens that a stage might now be completed, we must enter the same stage again (calling nm_device_activate_schedule_stage2_device_config()
) and do all the steps that are necessary for completion. That requires that stage2 is re-entrant.
The problem is that stage2 does a lot of things, and the state handling in NMDeviceEthernet, NMDeviceMacsec, NMDeviceWifi is utterly complicated. These should be simplified, and possibly we should have more, and smaller stages.
For now, here is a first branch that tries to cleanup the code a bit and solve some of the problems. Other problems are still not addresses (e.g. some devices still proceed to the next stage by scheduling it directly). More patches will come later.
This is also a continuation of 397b05e8 (!245 (closed)).