Blame SOURCES/rh1091296-dispatch-lease-change.patch

d91c12
From 2f18434cef0ab68343ec464159de940a59f02119 Mon Sep 17 00:00:00 2001
d91c12
From: Dan Williams <dcbw@redhat.com>
d91c12
Date: Tue, 29 Apr 2014 16:42:57 -0500
d91c12
Subject: [PATCH] core: emit dhcp4/dhcp6-change dispatcher events if other IP
d91c12
 completes first (rh #1091296)
d91c12
d91c12
If IPv6 completes first it would emit the "up" dispatcher event with IPv6
d91c12
details and move the device to ACTIVATED state.  But if DHCPv4 was still
d91c12
running, no dispatcher event would be emitted with the DHCPv4 information
d91c12
until the first lease renew.  Thus dispatcher scripts would not receive
d91c12
DHCPv4 information for quite some time.
d91c12
d91c12
Ensure that if the other IP version completes first, that when the slower
d91c12
method's DHCP completes, that it emits the appropriate dhcp4-change
d91c12
or dhcp6-change event so that dispatcher scripts get the information
d91c12
as soon as it's available.
d91c12
---
d91c12
 src/devices/nm-device.c | 28 ++++++++++++++++++++++++++++
d91c12
 1 file changed, 28 insertions(+)
d91c12
d91c12
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
d91c12
index 6005072..2043ae3 100644
d91c12
--- a/src/devices/nm-device.c
d91c12
+++ b/src/devices/nm-device.c
d91c12
@@ -4481,14 +4481,28 @@ nm_device_activate_ip4_config_commit (gpointer user_data)
d91c12
 		if (!start_sharing (self, priv->ip4_config)) {
d91c12
 			nm_log_warn (LOGD_SHARING, "Activation (%s) Stage 5 of 5 (IPv4 Commit) start sharing failed.", iface);
d91c12
 			nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_SHARED_START_FAILED);
d91c12
 			goto out;
d91c12
 		}
d91c12
 	}
d91c12
 
d91c12
+	/* If IPv4 wasn't the first to complete, and DHCP was used, then ensure
d91c12
+	 * dispatcher scripts get the DHCP lease information.
d91c12
+	 */
d91c12
+	if (   priv->dhcp4_client
d91c12
+	    && nm_device_activate_ip4_state_in_conf (self)
d91c12
+	    && (nm_device_get_state (self) > NM_DEVICE_STATE_IP_CONFIG)) {
d91c12
+		/* Notify dispatcher scripts of new DHCP4 config */
d91c12
+		nm_dispatcher_call (DISPATCHER_ACTION_DHCP4_CHANGE,
d91c12
+		                    nm_device_get_connection (self),
d91c12
+		                    self,
d91c12
+		                    NULL,
d91c12
+		                    NULL);
d91c12
+	}
d91c12
+
d91c12
 	arp_announce (self);
d91c12
 
d91c12
 	/* Enter the IP_CHECK state if this is the first method to complete */
d91c12
 	priv->ip4_state = IP_DONE;
d91c12
 	if (nm_device_get_state (self) == NM_DEVICE_STATE_IP_CONFIG)
d91c12
 		nm_device_state_changed (self, NM_DEVICE_STATE_IP_CHECK, NM_DEVICE_STATE_REASON_NONE);
d91c12
 
d91c12
@@ -4558,14 +4572,28 @@ nm_device_activate_ip6_config_commit (gpointer user_data)
d91c12
 	g_warn_if_fail (nm_platform_link_is_up (nm_device_get_ip_ifindex (self)));
d91c12
 
d91c12
 	/* Allow setting MTU etc */
d91c12
 	if (NM_DEVICE_GET_CLASS (self)->ip6_config_pre_commit)
d91c12
 		NM_DEVICE_GET_CLASS (self)->ip6_config_pre_commit (self);
d91c12
 
d91c12
 	if (ip6_config_merge_and_apply (self, TRUE, &reason)) {
d91c12
+		/* If IPv6 wasn't the first IP to complete, and DHCP was used,
d91c12
+		 * then ensure dispatcher scripts get the DHCP lease information.
d91c12
+		 */
d91c12
+		if (   priv->dhcp6_client
d91c12
+		    && nm_device_activate_ip6_state_in_conf (self)
d91c12
+		    && (nm_device_get_state (self) > NM_DEVICE_STATE_IP_CONFIG)) {
d91c12
+			/* Notify dispatcher scripts of new DHCP6 config */
d91c12
+			nm_dispatcher_call (DISPATCHER_ACTION_DHCP6_CHANGE,
d91c12
+			                    nm_device_get_connection (self),
d91c12
+			                    self,
d91c12
+			                    NULL,
d91c12
+			                    NULL);
d91c12
+		}
d91c12
+
d91c12
 		/* Enter the IP_CHECK state if this is the first method to complete */
d91c12
 		priv->ip6_state = IP_DONE;
d91c12
 		if (nm_device_get_state (self) == NM_DEVICE_STATE_IP_CONFIG)
d91c12
 			nm_device_state_changed (self, NM_DEVICE_STATE_IP_CHECK, NM_DEVICE_STATE_REASON_NONE);
d91c12
 	} else {
d91c12
 		nm_log_warn (LOGD_DEVICE | LOGD_IP6,
d91c12
 			         "Activation (%s) Stage 5 of 5 (IPv6 Commit) failed",
d91c12
-- 
d91c12
1.9.0
d91c12