diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2022-11-14 17:07:42 +0100 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2022-12-05 17:14:49 +0100 |
commit | 54170fdfb04954da6c941d5edd603cf2c2b99f5f (patch) | |
tree | fcb33febcee0c471cb3461635d78bee5ac33e8f8 | |
parent | 738e41cd3e7f3bcdb2c026475b0caae5f1c6ab76 (diff) |
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.
(cherry picked from commit 9fd9eaf27619375a24f87dab36fee0f2ecae6629)
-rw-r--r-- | src/core/devices/nm-device-private.h | 5 | ||||
-rw-r--r-- | src/core/devices/nm-device.c | 15 | ||||
-rw-r--r-- | src/core/devices/wifi/nm-device-wifi.c | 2 |
3 files changed, 14 insertions, 8 deletions
diff --git a/src/core/devices/nm-device-private.h b/src/core/devices/nm-device-private.h index eaf03392c9..c597e05260 100644 --- a/src/core/devices/nm-device-private.h +++ b/src/core/devices/nm-device-private.h @@ -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); diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c index 01409c783b..956303244c 100644 --- a/src/core/devices/nm-device.c +++ b/src/core/devices/nm-device.c @@ -9719,7 +9719,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 @@ -13994,7 +13994,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; @@ -14021,8 +14024,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) { @@ -14064,7 +14067,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 @@ -15820,7 +15823,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); } diff --git a/src/core/devices/wifi/nm-device-wifi.c b/src/core/devices/wifi/nm-device-wifi.c index fb13c421fa..8af974d0f6 100644 --- a/src/core/devices/wifi/nm-device-wifi.c +++ b/src/core/devices/wifi/nm-device-wifi.c @@ -3586,7 +3586,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) |