ippool: Fix endless loop issue with 32 prefix length
authorGuillaume Zajac <guillaume.zajac@linux.intel.com>
Tue, 19 Jun 2012 13:21:24 +0000 (15:21 +0200)
committerPatrik Flykt <patrik.flykt@linux.intel.com>
Wed, 20 Jun 2012 10:13:21 +0000 (13:13 +0300)
While trying to establish a DUN connection with oFono,
an endless loop was found when requesting an IP block.
The problem was on data connection activation its address
with 32 length prefix was notified through ConnMann using
__connman_ippool_newaddr() but mask address shifting with
32 bits was obsolete. So IP pool was considerating block
0.0.0.0 to 255.255.255.255 was in use.

src/ippool.c

index 58a0d28..52446ce 100644 (file)
@@ -258,7 +258,11 @@ void __connman_ippool_newaddr(int index, const char *address,
        if (is_private_address(start) == FALSE)
                return;
 
-       mask = ~(0xffffffff >> prefixlen);
+       if (prefixlen >= 32)
+               mask = 0xffffffff;
+       else
+               mask = ~(0xffffffff >> prefixlen);
+
        start = start & mask;
        end = start | ~mask;