diff options
author | Francesco Giudici <fgiudici@redhat.com> | 2016-09-08 18:12:37 +0200 |
---|---|---|
committer | Francesco Giudici <fgiudici@redhat.com> | 2016-11-22 15:24:47 +0100 |
commit | 61faa5080e47b75d3ca6d93a88afbdb49d2347f8 (patch) | |
tree | 2bd371516679e55fcd9fba3a1711542ac1e5bd72 /src/devices/nm-device-ethernet.c | |
parent | 16fdef33dd4bf37d8b085a2a0c03c12da5dd04b1 (diff) | |
download | NetworkManager-61faa5080e47b75d3ca6d93a88afbdb49d2347f8.tar.gz |
nm-device-ethernet: refactor act_stage1_prepare code
Refactored the code a bit without changing functionality: let the function
immediately return on error.
Diffstat (limited to 'src/devices/nm-device-ethernet.c')
-rw-r--r-- | src/devices/nm-device-ethernet.c | 51 |
1 files changed, 25 insertions, 26 deletions
diff --git a/src/devices/nm-device-ethernet.c b/src/devices/nm-device-ethernet.c index 3e16df9306..d01176b235 100644 --- a/src/devices/nm-device-ethernet.c +++ b/src/devices/nm-device-ethernet.c @@ -799,40 +799,39 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason) { NMDeviceEthernet *self = NM_DEVICE_ETHERNET (dev); NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self); - NMActStageReturn ret = NM_ACT_STAGE_RETURN_SUCCESS; + NMActStageReturn ret; g_return_val_if_fail (reason != NULL, NM_ACT_STAGE_RETURN_FAILURE); ret = NM_DEVICE_CLASS (nm_device_ethernet_parent_class)->act_stage1_prepare (dev, reason); - if (ret == NM_ACT_STAGE_RETURN_SUCCESS) { - if (!nm_device_hw_addr_set_cloned (dev, nm_device_get_applied_connection (dev), FALSE)) - ret = NM_ACT_STAGE_RETURN_FAILURE; - } + if (ret != NM_ACT_STAGE_RETURN_SUCCESS) + return ret; - if (ret == NM_ACT_STAGE_RETURN_SUCCESS) { - /* If we're re-activating a PPPoE connection a short while after - * a previous PPPoE connection was torn down, wait a bit to allow the - * remote side to handle the disconnection. Otherwise the peer may - * get confused and fail to negotiate the new connection. (rh #1023503) - */ - if (priv->last_pppoe_time) { - gint32 delay = nm_utils_get_monotonic_timestamp_s () - priv->last_pppoe_time; - - if ( delay < PPPOE_RECONNECT_DELAY - && nm_device_get_applied_setting (dev, NM_TYPE_SETTING_PPPOE)) { - _LOGI (LOGD_DEVICE, "delaying PPPoE reconnect for %d seconds to ensure peer is ready...", - delay); - g_assert (!priv->pppoe_wait_id); - priv->pppoe_wait_id = g_timeout_add_seconds (delay, - pppoe_reconnect_delay, - self); - ret = NM_ACT_STAGE_RETURN_POSTPONE; - } else - priv->last_pppoe_time = 0; + if (!nm_device_hw_addr_set_cloned (dev, nm_device_get_applied_connection (dev), FALSE)) + return NM_ACT_STAGE_RETURN_FAILURE; + + /* If we're re-activating a PPPoE connection a short while after + * a previous PPPoE connection was torn down, wait a bit to allow the + * remote side to handle the disconnection. Otherwise the peer may + * get confused and fail to negotiate the new connection. (rh #1023503) + */ + if (priv->last_pppoe_time) { + gint32 delay = nm_utils_get_monotonic_timestamp_s () - priv->last_pppoe_time; + + if ( delay < PPPOE_RECONNECT_DELAY + && nm_device_get_applied_setting (dev, NM_TYPE_SETTING_PPPOE)) { + _LOGI (LOGD_DEVICE, "delaying PPPoE reconnect for %d seconds to ensure peer is ready...", + delay); + g_assert (!priv->pppoe_wait_id); + priv->pppoe_wait_id = g_timeout_add_seconds (delay, + pppoe_reconnect_delay, + self); + return NM_ACT_STAGE_RETURN_POSTPONE; } + priv->last_pppoe_time = 0; } - return ret; + return NM_ACT_STAGE_RETURN_SUCCESS; } static NMActStageReturn |