[libvirt] [PATCHv2 5/7] virSocketAddrGetIpPrefix 0.0.0.0 special case
Laine Stump
laine at laine.org
Thu Jan 15 18:42:18 UTC 2015
On 01/15/2015 04:25 AM, Cédric Bosdonnat wrote:
> If 0.0.0.0 address is provided, then the returned prefix should be 0,
> rather than 8.
> ---
> src/util/virsocketaddr.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/src/util/virsocketaddr.c b/src/util/virsocketaddr.c
> index c5584af..e7870bf 100644
> --- a/src/util/virsocketaddr.c
> +++ b/src/util/virsocketaddr.c
> @@ -832,6 +832,12 @@ virSocketAddrGetIpPrefix(const virSocketAddr *address,
> */
> unsigned char octet
> = ntohl(address->data.inet4.sin_addr.s_addr) >> 24;
> +
> + /* If address is 0.0.0.0, we surely want to have 0 prefix for
> + * the default route. */
> + if (address->data.inet4.sin_addr.s_addr == 0)
> + return 0;
> +
> if ((octet & 0x80) == 0) {
> /* Class A network */
> return 8;
Aha! Now I see that my comments in 3/7 were a bit unneeded. ACK to this,
but do we maybe need it also for IPv6 addresses that are 0?
More information about the libvir-list
mailing list