]> git.ipfire.org Git - location/libloc.git/commitdiff
network: Fix bit length check when merging networks
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 17 Feb 2024 21:12:32 +0000 (21:12 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 17 Feb 2024 21:12:32 +0000 (21:12 +0000)
The check was incorrect as it only expected perfect matches, but we can
of course also merge subnets that don't necessarily require the entire
prefix length for the start address.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/network.c

index 47fe73503acdd80900a23d05ed0ba8353d88e9fe..07da2b0dbef87dab7ee93dca9c3c1058459b3edc 100644 (file)
@@ -602,7 +602,7 @@ static int loc_network_merge(struct loc_network** n,
        const size_t bitlength = loc_address_bit_length(&n1->first_address) - 1;
 
        // We cannot shorten this any more
-       if (bitlength == prefix)
+       if (bitlength < prefix)
                return 0;
 
        // Increment the last address of the first network