diff options
author | Lubomir Rintel <lkundrak@v3.sk> | 2014-12-11 10:13:59 +0100 |
---|---|---|
committer | Lubomir Rintel <lkundrak@v3.sk> | 2014-12-11 11:46:42 +0100 |
commit | 063ab8da5cb50fbca9f134aa15c7927035b5036c (patch) | |
tree | d4fd13d2009b45d13751c95ae6cf1dadd32d049a | |
parent | d19770102e8e231888f10e3a4e45bbd9491fe802 (diff) | |
download | NetworkManager-063ab8da5cb50fbca9f134aa15c7927035b5036c.tar.gz |
device: turn nm_d_ip_config_should_fail to get_ip_config_may_fail
Has a cleaner semantics and will be useful later on. Also, make it static --
it's not used outside nm-device.c.
-rw-r--r-- | src/devices/nm-device-private.h | 2 | ||||
-rw-r--r-- | src/devices/nm-device.c | 29 |
2 files changed, 15 insertions, 16 deletions
diff --git a/src/devices/nm-device-private.h b/src/devices/nm-device-private.h index fd87fd77a1..65a9a71af4 100644 --- a/src/devices/nm-device-private.h +++ b/src/devices/nm-device-private.h @@ -56,8 +56,6 @@ void nm_device_take_down (NMDevice *self, gboolean block); gboolean nm_device_set_hw_addr (NMDevice *device, const char *addr, const char *detail, guint64 hw_log_domain); -gboolean nm_device_ip_config_should_fail (NMDevice *self, gboolean ip6); - void nm_device_set_firmware_missing (NMDevice *self, gboolean missing); void nm_device_activate_schedule_stage1_device_prepare (NMDevice *device); diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 169db19dfb..e366e1dec9 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -2215,11 +2215,11 @@ activation_source_schedule (NMDevice *self, GSourceFunc func, int family) } } -gboolean -nm_device_ip_config_should_fail (NMDevice *self, gboolean ip6) +static gboolean +get_ip_config_may_fail (NMDevice *self, int family) { NMConnection *connection; - NMSettingIPConfig *s_ip4, *s_ip6; + NMSettingIPConfig *s_ip = NULL; g_return_val_if_fail (self != NULL, TRUE); @@ -2227,17 +2227,18 @@ nm_device_ip_config_should_fail (NMDevice *self, gboolean ip6) g_assert (connection); /* Fail the connection if the failed IP method is required to complete */ - if (ip6) { - s_ip6 = nm_connection_get_setting_ip6_config (connection); - if (!nm_setting_ip_config_get_may_fail (s_ip6)) - return TRUE; - } else { - s_ip4 = nm_connection_get_setting_ip4_config (connection); - if (!nm_setting_ip_config_get_may_fail (s_ip4)) - return TRUE; + switch (family) { + case AF_INET: + s_ip = nm_connection_get_setting_ip4_config (connection); + break; + case AF_INET6: + s_ip = nm_connection_get_setting_ip6_config (connection); + break; + default: + g_assert_not_reached (); } - return FALSE; + return nm_setting_ip_config_get_may_fail (s_ip); } static void @@ -4668,7 +4669,7 @@ nm_device_activate_schedule_stage3_ip_config_start (NMDevice *self) static NMActStageReturn act_stage4_ip4_config_timeout (NMDevice *self, NMDeviceStateReason *reason) { - if (nm_device_ip_config_should_fail (self, FALSE)) { + if (!get_ip_config_may_fail (self, AF_INET)) { *reason = NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE; return NM_ACT_STAGE_RETURN_FAILURE; } @@ -4746,7 +4747,7 @@ nm_device_activate_schedule_ip4_config_timeout (NMDevice *self) static NMActStageReturn act_stage4_ip6_config_timeout (NMDevice *self, NMDeviceStateReason *reason) { - if (nm_device_ip_config_should_fail (self, TRUE)) { + if (!get_ip_config_may_fail (self, AF_INET6)) { *reason = NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE; return NM_ACT_STAGE_RETURN_FAILURE; } |