Send connman mailing list submissions to
        connman@lists.01.org

To subscribe or unsubscribe via the World Wide Web, visit
        https://lists.01.org/mailman/listinfo/connman
or, via email, send a message with subject or body 'help' to
        connman-requ...@lists.01.org

You can reach the person managing the list at
        connman-ow...@lists.01.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of connman digest..."


Today's Topics:

   1. [PATCH] Remove old ip/gateway address if different addresses
      are assigned during DHCP renewal to avoid two ip addresses added
      to the interface. (Feng Wang)


----------------------------------------------------------------------

Message: 1
Date: Wed, 20 Apr 2016 11:28:47 -0700
From: Feng Wang <wan...@nestlabs.com>
To: connman@lists.01.org
Subject: [PATCH] Remove old ip/gateway address if different addresses
        are assigned during DHCP renewal to avoid two ip addresses added to
        the interface.
Message-ID: <1461176927-9427-1-git-send-email-wan...@nestlabs.com>

---
 src/dhcp.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/src/dhcp.c b/src/dhcp.c
index 1d2cd48..54d98db 100644
--- a/src/dhcp.c
+++ b/src/dhcp.c
@@ -435,7 +435,7 @@ static void lease_available_cb(GDHCPClient *dhcp_client, 
gpointer user_data)
        char *address, *netmask = NULL, *gateway = NULL;
        const char *c_address, *c_gateway;
        unsigned char prefixlen, c_prefixlen;
-       bool ip_change;
+       bool ip_change = false;
 
        DBG("Lease available");
 
@@ -467,14 +467,21 @@ static void lease_available_cb(GDHCPClient *dhcp_client, 
gpointer user_data)
 
        DBG("c_address %s", c_address);
 
-       if (g_strcmp0(address, c_address))
+       if (g_strcmp0(address, c_address)) {
                ip_change = true;
-       else if (g_strcmp0(gateway, c_gateway))
+               if (c_address) {
+                       /* Remove old ip address */
+                       __connman_ipconfig_address_remove(dhcp->ipconfig);
+               }
+       }
+       if (g_strcmp0(gateway, c_gateway)) {
                ip_change = true;
-       else if (prefixlen != c_prefixlen)
+               if (c_gateway) {
+                       /* Remove gateway ip address */
+                       __connman_ipconfig_gateway_remove(dhcp->ipconfig);
+               }
+       } else if (prefixlen != c_prefixlen)
                ip_change = true;
-       else
-               ip_change = false;
 
        __connman_ipconfig_set_method(dhcp->ipconfig,
                                                CONNMAN_IPCONFIG_METHOD_DHCP);
-- 
2.8.0.rc3.226.g39d4020



------------------------------

Subject: Digest Footer

_______________________________________________
connman mailing list
connman@lists.01.org
https://lists.01.org/mailman/listinfo/connman


------------------------------

End of connman Digest, Vol 6, Issue 15
**************************************

Reply via email to