summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2014-03-11 13:08:42 +0100
committerThomas Haller <thaller@redhat.com>2015-07-07 17:39:46 +0200
commit99908ca68f542313fe07759db6c05fabf4a9bdbb (patch)
tree533dca58be922306f9eba7faf4225b51a28f3b93
parent5b29944b02f2b98a25439653a54e11a7afe4aa6c (diff)
downloadNetworkManager-th/bgo726280_dhcp6_wait_ll.tar.gz
Signed-off-by: Thomas Haller <thaller@redhat.com>
-rw-r--r--src/devices/nm-device.c96
1 files changed, 51 insertions, 45 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index 60050727d3..bb97843d7d 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -362,6 +362,7 @@ static void nm_device_slave_notify_enslave (NMDevice *dev, gboolean success);
static void nm_device_slave_notify_release (NMDevice *dev, NMDeviceStateReason reason);
static void addrconf6_start_with_link_ready (NMDevice *self);
+static gboolean dhcp6_start_with_link_ready (NMDevice *self);
static const char const *platform_ip_signals[] = {
NM_PLATFORM_IP4_ADDRESS_ADDED,
@@ -3194,20 +3195,14 @@ dhcp6_timeout (NMDHCPClient *client, gpointer user_data)
}
}
-static NMActStageReturn
-dhcp6_start (NMDevice *self,
- NMConnection *connection,
- guint32 dhcp_opt,
- NMDeviceStateReason *reason)
+static gboolean
+dhcp6_start (NMDevice *self)
{
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
- NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE;
- GByteArray *tmp = NULL;
+ NMConnection *connection;
- if (!connection) {
- connection = nm_device_get_connection (self);
- g_assert (connection);
- }
+ connection = nm_device_get_connection (self);
+ g_assert (connection);
/* Begin a DHCP transaction on the interface */
@@ -3216,17 +3211,35 @@ dhcp6_start (NMDevice *self,
g_object_unref (priv->dhcp6_config);
priv->dhcp6_config = nm_dhcp6_config_new ();
- g_warn_if_fail (priv->dhcp6_ip6_config == NULL);
if (priv->dhcp6_ip6_config) {
g_object_unref (priv->dhcp6_ip6_config);
priv->dhcp6_ip6_config = NULL;
}
+ /* ensure link local is ready... */
+ ret = linklocal6_start (self);
+ if (ret == NM_ACT_STAGE_RETURN_SUCCESS)
+ return dhcp6_start_with_link_ready (self);
+ else
+ g_return_val_if_fail (ret == NM_ACT_STAGE_RETURN_POSTPONE, TRUE);
+
+ return TRUE;
+}
+
+static gboolean
+dhcp6_start_with_link_ready (NMDevice *self)
+{
+ GByteArray *tmp = NULL;
+ gboolean info_only = FALSE;
+
if (priv->hw_addr_len) {
tmp = g_byte_array_sized_new (priv->hw_addr_len);
g_byte_array_append (tmp, priv->hw_addr, priv->hw_addr_len);
}
+ if (priv->dhcp6_mode == NM_RDISC_DHCP_LEVEL_OTHERCONF)
+ info_only = TRUE;
+
priv->dhcp6_client = nm_dhcp_manager_start_ip6 (priv->dhcp_manager,
nm_device_get_ip_iface (self),
tmp,
@@ -3234,28 +3247,22 @@ dhcp6_start (NMDevice *self,
nm_connection_get_setting_ip6_config (connection),
priv->dhcp_timeout,
priv->dhcp_anycast_address,
- (dhcp_opt == NM_RDISC_DHCP_LEVEL_OTHERCONF) ? TRUE : FALSE);
+ info_only);
if (tmp)
g_byte_array_free (tmp, TRUE);
- if (priv->dhcp6_client) {
- priv->dhcp6_state_sigid = g_signal_connect (priv->dhcp6_client,
- NM_DHCP_CLIENT_SIGNAL_STATE_CHANGED,
- G_CALLBACK (dhcp6_state_changed),
- self);
- priv->dhcp6_timeout_sigid = g_signal_connect (priv->dhcp6_client,
- NM_DHCP_CLIENT_SIGNAL_TIMEOUT,
- G_CALLBACK (dhcp6_timeout),
- self);
-
- /* DHCP devices will be notified by the DHCP manager when stuff happens */
- ret = NM_ACT_STAGE_RETURN_POSTPONE;
- } else {
- *reason = NM_DEVICE_STATE_REASON_DHCP_START_FAILED;
- ret = NM_ACT_STAGE_RETURN_FAILURE;
- }
+ if (!priv->dhcp6_client)
+ return FALSE;
- return ret;
+ priv->dhcp6_state_sigid = g_signal_connect (priv->dhcp6_client,
+ NM_DHCP_CLIENT_SIGNAL_STATE_CHANGED,
+ G_CALLBACK (dhcp6_state_changed),
+ self);
+ priv->dhcp6_timeout_sigid = g_signal_connect (priv->dhcp6_client,
+ NM_DHCP_CLIENT_SIGNAL_TIMEOUT,
+ G_CALLBACK (dhcp6_timeout),
+ self);
+ return TRUE;
}
gboolean
@@ -3351,10 +3358,13 @@ linklocal6_complete (NMDevice *self)
if (strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_AUTO) == 0)
addrconf6_start_with_link_ready (self);
- else if (strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL) == 0)
+ else if (strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_DHCP) == 0) {
+ if (!dhcp6_start_with_link_ready (self))
+ dhcp6_fail (self, FALSE);
+ } else if (strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL) == 0)
nm_device_activate_schedule_ip6_config_result (self);
else
- g_return_if_fail (FALSE);
+ g_return_if_reached ();
}
static NMActStageReturn
@@ -3436,9 +3446,7 @@ static void
rdisc_config_changed (NMRDisc *rdisc, NMRDiscConfigMap changed, NMDevice *device)
{
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device);
- NMConnection *connection;
int i;
- NMDeviceStateReason reason;
static int system_support = -1;
guint ifa_flags = 0x00;
@@ -3464,8 +3472,6 @@ rdisc_config_changed (NMRDisc *rdisc, NMRDiscConfigMap changed, NMDevice *device
}
g_return_if_fail (priv->act_request);
- connection = nm_device_get_connection (device);
- g_assert (connection);
if (!priv->ac_ip6_config)
priv->ac_ip6_config = nm_ip6_config_new ();
@@ -3565,14 +3571,10 @@ rdisc_config_changed (NMRDisc *rdisc, NMRDiscConfigMap changed, NMDevice *device
"Activation (%s) Stage 3 of 5 (IP Configure Start) starting DHCPv6"
" as requested by IPv6 router...",
priv->iface);
- switch (dhcp6_start (device, connection, priv->dhcp6_mode, &reason)) {
- case NM_ACT_STAGE_RETURN_SUCCESS:
- g_warn_if_reached ();
- break;
- case NM_ACT_STAGE_RETURN_POSTPONE:
- return;
- default:
- nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, reason);
+ if (!dhcp6_start (device)) {
+ nm_device_state_changed (device,
+ NM_DEVICE_STATE_FAILED,
+ NM_DEVICE_STATE_REASON_DHCP_START_FAILED);
return;
}
}
@@ -3820,7 +3822,11 @@ act_stage3_ip6_config_start (NMDevice *self,
}
} else if (strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_DHCP) == 0) {
priv->dhcp6_mode = NM_RDISC_DHCP_LEVEL_MANAGED;
- ret = dhcp6_start (self, connection, priv->dhcp6_mode, reason);
+ if (!dhcp6_start (self)) {
+ *reason = NM_DEVICE_STATE_REASON_DHCP_START_FAILED;
+ ret = NM_ACT_STAGE_RETURN_FAILURE;
+ } else
+ ret = NM_ACT_STAGE_RETURN_POSTPONE;
} else if (strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_MANUAL) == 0) {
/* New blank config */
*out_config = nm_ip6_config_new ();