dhcpv6: Do not wait answer to RELEASE message
authorJukka Rissanen <jukka.rissanen@linux.intel.com>
Wed, 18 Jan 2012 13:24:56 +0000 (15:24 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Fri, 20 Jan 2012 00:35:24 +0000 (01:35 +0100)
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
src/network.c

index f2c7da6..fe2f0fa 100644 (file)
@@ -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;
 
index d054f34..bd4573b 100644 (file)
@@ -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,