From: Peter Meerwald <p.meerw...@bct-electronic.com>

Connman constantly updates the IP when a lease without gateway is received, e.g.
connmand[7607]: eth0.42 {del} route 0.0.0.0 gw 0.0.0.0 scope 253 <LINK>
connmand[7607]: eth0.42 {add} route 0.0.0.0 gw 0.0.0.0 scope 253 <LINK>
connmand[7607]: eth0.42 {del} route 0.0.0.0 gw 0.0.0.0 scope 253 <LINK>
connmand[7607]: eth0.42 {add} route 0.0.0.0 gw 0.0.0.0 scope 253 <LINK>

the problematic condition in dhcp.c/lease_available_cb() is:
if (!c_address || !c_gateway)
  ip_change = true;
i.e. no address or gateway configured -> IP changed?!

the remaining checks need to be fixed as well, g_strcmp0() already handles
the case when one or both of the strings is NULL

Signed-off-by: Peter Meerwald <pme...@pmeerw.net>
---

v2: fixing g_strcmp0() style

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

diff --git a/src/dhcp.c b/src/dhcp.c
index 4436164..505d9f0 100644
--- a/src/dhcp.c
+++ b/src/dhcp.c
@@ -443,14 +443,12 @@ static void lease_available_cb(GDHCPClient *dhcp_client, 
gpointer user_data)
 
        DBG("c_address %s", c_address);
 
-       if (address && c_address && g_strcmp0(address, c_address) != 0)
+       if (g_strcmp0(address, c_address))
                ip_change = true;
-       else if (gateway && c_gateway && g_strcmp0(gateway, c_gateway) != 0)
+       else if (g_strcmp0(gateway, c_gateway))
                ip_change = true;
        else if (prefixlen != c_prefixlen)
                ip_change = true;
-       else if (!c_address || !c_gateway)
-               ip_change = true;
        else
                ip_change = false;
 
-- 
1.7.9.5

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

Reply via email to