diff options
author | Feng Wang <wangfe@nestlabs.com> | 2016-04-29 14:37:29 -0700 |
---|---|---|
committer | Patrik Flykt <patrik.flykt@linux.intel.com> | 2016-05-19 16:16:03 +0300 |
commit | d593e995c7c75b9d74e411bf3691b5adb6c56179 (patch) | |
tree | 49476f9ad6b844c8b5042c6bf80c21c431a93c24 | |
parent | 57a31db51504f52a83b004dc3c2d3e012731b841 (diff) | |
download | connman-d593e995c7c75b9d74e411bf3691b5adb6c56179.tar.gz |
dhcp: Remove old IP and gateway address
Remove old IP and gateway address if different addresses are assigned
during DHCP renewal to avoid two IP addresses or gateways added for the
interface.
-rw-r--r-- | src/dhcp.c | 19 |
1 files changed, 13 insertions, 6 deletions
@@ -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); |