When enabling and disabling tethering, the next available class C
IPv4 subnet will be assigned and not the same one as last time.

Fix this by starting with the last allocated block instead of
unconditionally with the next free block. This way the subnet used
for tethering will be the same as the previous time unless the subnet
block is unavailable due to other reasons. Note that even with this
change the subnet user for tethering is not guaranteed to always
stay the same.

Fixes CM-666.
---
 src/ippool.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/ippool.c b/src/ippool.c
index bb8568d..06f3762 100644
--- a/src/ippool.c
+++ b/src/ippool.c
@@ -181,10 +181,10 @@ static uint32_t get_free_block(unsigned int size)
         * To only thing we have to make sure is that we terminated if
         * there is no block left.
         */
-       if (last_block == 0)
-               block = block_16_bits;
+       if (last_block)
+               block = last_block;
        else
-               block = next_block(last_block);
+               block = block_16_bits;
 
        do {
                collision = false;
-- 
2.1.4

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

Reply via email to