device: add "update_carrier" argument to nm_device_bring_up_full()

In some situations we need to avoid updating the carrier status
synchronously from nm_device_bring_up_full(). Add a flag for that.
This commit is contained in:
Beniamino Galvani 2022-11-14 17:07:42 +01:00
parent 861934a510
commit 9fd9eaf276
3 changed files with 14 additions and 8 deletions

View file

@ -38,7 +38,10 @@ gboolean nm_device_set_ip_ifindex(NMDevice *self, int ifindex);
gboolean nm_device_set_ip_iface(NMDevice *self, const char *iface);
gboolean nm_device_bring_up(NMDevice *self);
gboolean nm_device_bring_up_full(NMDevice *self, gboolean block, gboolean *no_firmware);
gboolean nm_device_bring_up_full(NMDevice *self,
gboolean block,
gboolean update_carrier,
gboolean *no_firmware);
void nm_device_take_down(NMDevice *self, gboolean block);

View file

@ -9752,7 +9752,7 @@ activate_stage2_device_config(NMDevice *self)
_routing_rules_sync(self, NM_TERNARY_TRUE);
if (!nm_device_sys_iface_state_is_external_or_assume(self)) {
if (!nm_device_bring_up_full(self, FALSE, &no_firmware)) {
if (!nm_device_bring_up_full(self, FALSE, TRUE, &no_firmware)) {
nm_device_state_changed(self,
NM_DEVICE_STATE_FAILED,
no_firmware ? NM_DEVICE_STATE_REASON_FIRMWARE_MISSING
@ -14029,7 +14029,10 @@ carrier_detect_wait(NMDevice *self)
}
gboolean
nm_device_bring_up_full(NMDevice *self, gboolean block, gboolean *no_firmware)
nm_device_bring_up_full(NMDevice *self,
gboolean block,
gboolean update_carrier,
gboolean *no_firmware)
{
gboolean device_is_up = FALSE;
NMDeviceCapabilities capabilities;
@ -14056,8 +14059,8 @@ nm_device_bring_up_full(NMDevice *self, gboolean block, gboolean *no_firmware)
return FALSE;
}
/* Store carrier immediately. */
nm_device_set_carrier_from_platform(self);
if (update_carrier)
nm_device_set_carrier_from_platform(self);
device_is_up = nm_device_is_up(self);
if (block && !device_is_up) {
@ -14099,7 +14102,7 @@ nm_device_bring_up_full(NMDevice *self, gboolean block, gboolean *no_firmware)
gboolean
nm_device_bring_up(NMDevice *self)
{
return nm_device_bring_up_full(self, TRUE, NULL);
return nm_device_bring_up_full(self, TRUE, TRUE, NULL);
}
void
@ -15855,7 +15858,7 @@ _set_state_full(NMDevice *self, NMDeviceState state, NMDeviceStateReason reason,
if (priv->sys_iface_state == NM_DEVICE_SYS_IFACE_STATE_MANAGED) {
if (old_state == NM_DEVICE_STATE_UNMANAGED || priv->firmware_missing) {
if (!nm_device_bring_up_full(self, TRUE, &no_firmware) && no_firmware)
if (!nm_device_bring_up_full(self, TRUE, TRUE, &no_firmware) && no_firmware)
_LOGW(LOGD_PLATFORM, "firmware may be missing.");
nm_device_set_firmware_missing(self, no_firmware ? TRUE : FALSE);
}

View file

@ -3591,7 +3591,7 @@ set_enabled(NMDevice *device, gboolean enabled)
if (state != NM_DEVICE_STATE_UNAVAILABLE)
_LOGW(LOGD_CORE, "not in expected unavailable state!");
if (!nm_device_bring_up_full(NM_DEVICE(self), TRUE, &no_firmware)) {
if (!nm_device_bring_up_full(NM_DEVICE(self), TRUE, TRUE, &no_firmware)) {
_LOGD(LOGD_WIFI, "enable blocked by failure to bring device up");
if (no_firmware)