ip6: fail activation if addrconf fails to start
authorDan Williams <dcbw@redhat.com>
Fri, 25 Feb 2011 17:28:08 +0000 (11:28 -0600)
committerDan Williams <dcbw@redhat.com>
Fri, 25 Feb 2011 17:28:08 +0000 (11:28 -0600)
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
src/ip6-manager/nm-ip6-manager.h
src/nm-device.c

index ea93f02..7ffa2d1 100644 (file)
@@ -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
index 77c1106..2732c63 100644 (file)
@@ -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);
index 3036b7e..8be4a85 100644 (file)
@@ -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