[PATCH v2 1/5] dhcpv6: Do not wait answer to RELEASE message.

Jukka Rissanen jukka.rissanen at linux.intel.com
Tue Jan 17 04:15:14 PST 2012


We do not want to wait the answer to release message that
was sent to the DHCPv6 server because the reply from server
might take some time and we must continue the network
disconnect procedure. So we just inform the server that we
are done with the addresses but ignore server reply as there
is nothing to be done anyway after sending the release.
---
 src/dhcpv6.c  |   21 +++++++--------------
 src/network.c |    5 ++---
 2 files changed, 9 insertions(+), 17 deletions(-)

diff --git a/src/dhcpv6.c b/src/dhcpv6.c
index f2c7da6..fe2f0fa 100644
--- a/src/dhcpv6.c
+++ b/src/dhcpv6.c
@@ -859,18 +859,6 @@ int __connman_dhcpv6_start_renew(struct connman_network *network,
 	return 0;
 }
 
-static void release_cb(GDHCPClient *dhcp_client, gpointer user_data)
-{
-	struct connman_dhcpv6 *dhcp = user_data;
-
-	DBG("dhcpv6 release msg %p", dhcp);
-
-	if (dhcp->callback != NULL) {
-		uint16_t status = g_dhcpv6_client_get_status(dhcp_client);
-		dhcp->callback(dhcp->network, status == 0 ? TRUE : FALSE);
-	}
-}
-
 int __connman_dhcpv6_start_release(struct connman_network *network,
 				dhcp_cb callback)
 {
@@ -909,8 +897,13 @@ int __connman_dhcpv6_start_release(struct connman_network *network,
 
 	clear_callbacks(dhcp_client);
 
-	g_dhcp_client_register_event(dhcp_client, G_DHCP_CLIENT_EVENT_RELEASE,
-					release_cb, dhcp);
+	/*
+	 * We do not register callback here because the answer might take too
+	 * long time and network code might be in the middle of the disconnect.
+	 * So we just inform the server that we are done with the addresses
+	 * but ignore the reply from server. This is allowed by RFC 3315
+	 * chapter 18.1.6.
+	 */
 
 	dhcp->dhcp_client = dhcp_client;
 
diff --git a/src/network.c b/src/network.c
index df9ea47..04e23e6 100644
--- a/src/network.c
+++ b/src/network.c
@@ -984,9 +984,8 @@ static void dhcpv6_release_callback(struct connman_network *network,
 
 static void release_dhcpv6(struct connman_network *network)
 {
-	if (__connman_dhcpv6_start_release(network,
-					dhcpv6_release_callback) < 0)
-		stop_dhcpv6(network);
+	__connman_dhcpv6_start_release(network, dhcpv6_release_callback);
+	stop_dhcpv6(network);
 }
 
 static void dhcpv6_info_callback(struct connman_network *network,
-- 
1.7.1



More information about the connman mailing list