From bf854ebaca9bfbe22f438799a3911f5f441e0829 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Fri, 25 Feb 2011 11:28:08 -0600 Subject: [PATCH] ip6: fail activation if addrconf fails to start Like if the IP interface doesn't have an ifindex yet. Previously the connection would just go merrily along and wait for IPv6 to complete even though it had already failed. Happens if you try to do IPv6 on mobile broadband connections, which we'll add support for later. --- src/ip6-manager/nm-ip6-manager.c | 17 ++++++++++------- src/ip6-manager/nm-ip6-manager.h | 2 +- src/nm-device.c | 14 ++++++++------ 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/ip6-manager/nm-ip6-manager.c b/src/ip6-manager/nm-ip6-manager.c index ea93f02c02..7ffa2d1f57 100644 --- a/src/ip6-manager/nm-ip6-manager.c +++ b/src/ip6-manager/nm-ip6-manager.c @@ -1051,7 +1051,7 @@ netlink_notification (NMNetlinkMonitor *monitor, struct nl_msg *msg, gpointer us } } -void +gboolean nm_ip6_manager_prepare_interface (NMIP6Manager *manager, int ifindex, NMSettingIP6Config *s_ip6, @@ -1061,16 +1061,17 @@ nm_ip6_manager_prepare_interface (NMIP6Manager *manager, NMIP6Device *device; const char *method = NULL; - g_return_if_fail (NM_IS_IP6_MANAGER (manager)); - g_return_if_fail (ifindex > 0); + g_return_val_if_fail (NM_IS_IP6_MANAGER (manager), FALSE); + g_return_val_if_fail (ifindex > 0, FALSE); priv = NM_IP6_MANAGER_GET_PRIVATE (manager); device = nm_ip6_device_new (manager, ifindex); - g_return_if_fail (device != NULL); - g_return_if_fail ( strchr (device->iface, '/') == NULL - && strcmp (device->iface, "all") != 0 - && strcmp (device->iface, "default") != 0); + g_return_val_if_fail (device != NULL, FALSE); + g_return_val_if_fail ( strchr (device->iface, '/') == NULL + && strcmp (device->iface, "all") != 0 + && strcmp (device->iface, "default") != 0, + FALSE); if (s_ip6) method = nm_setting_ip6_config_get_method (s_ip6); @@ -1085,6 +1086,8 @@ nm_ip6_manager_prepare_interface (NMIP6Manager *manager, device->target_state = NM_IP6_DEVICE_GOT_ADDRESS; nm_utils_do_sysctl (accept_ra_path, "1\n"); } + + return TRUE; } static gboolean diff --git a/src/ip6-manager/nm-ip6-manager.h b/src/ip6-manager/nm-ip6-manager.h index 77c1106841..2732c63ec2 100644 --- a/src/ip6-manager/nm-ip6-manager.h +++ b/src/ip6-manager/nm-ip6-manager.h @@ -71,7 +71,7 @@ typedef struct { GType nm_ip6_manager_get_type (void); NMIP6Manager *nm_ip6_manager_get (void); -void nm_ip6_manager_prepare_interface (NMIP6Manager *manager, +gboolean nm_ip6_manager_prepare_interface (NMIP6Manager *manager, int ifindex, NMSettingIP6Config *s_ip6, const char *accept_ra_path); diff --git a/src/nm-device.c b/src/nm-device.c index 3036b7e16c..8be4a859a9 100644 --- a/src/nm-device.c +++ b/src/nm-device.c @@ -822,6 +822,7 @@ addrconf6_setup (NMDevice *self) NMActRequest *req; NMConnection *connection; NMSettingIP6Config *s_ip6; + gboolean success; req = nm_device_get_act_request (self); g_assert (req); @@ -841,13 +842,14 @@ addrconf6_setup (NMDevice *self) } s_ip6 = (NMSettingIP6Config *) nm_connection_get_setting (connection, NM_TYPE_SETTING_IP6_CONFIG); - nm_ip6_manager_prepare_interface (priv->ip6_manager, - nm_device_get_ip_ifindex (self), - s_ip6, - priv->ip6_accept_ra_path); - priv->ip6_waiting_for_config = TRUE; + success = nm_ip6_manager_prepare_interface (priv->ip6_manager, + nm_device_get_ip_ifindex (self), + s_ip6, + priv->ip6_accept_ra_path); + if (success) + priv->ip6_waiting_for_config = TRUE; - return TRUE; + return success; } static void