File 3993c2f9-virSocketAddrGetIpPrefix-0-special-cases.patch of Package libvirt.11695

From 3993c2f91cbaab94ceb65557fd1c54dff01d24cc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?C=C3=A9dric=20Bosdonnat?= <cbosdonnat@suse.com>
Date: Thu, 15 Jan 2015 09:13:09 +0100
Subject: [PATCH 5/7] virSocketAddrGetIpPrefix 0.0.0.0 and :: special cases

If 0.0.0.0  or :: address is provided, then the returned prefix should
be 0, for the default address.

Squashed in bug fix commit '981f0cda4'
---
 src/util/virsocketaddr.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Index: libvirt-1.2.5/src/util/virsocketaddr.c
===================================================================
--- libvirt-1.2.5.orig/src/util/virsocketaddr.c
+++ libvirt-1.2.5/src/util/virsocketaddr.c
@@ -832,6 +832,12 @@ virSocketAddrGetIpPrefix(const virSocket
          */
         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;
@@ -844,6 +850,8 @@ virSocketAddrGetIpPrefix(const virSocket
         }
         return -1;
     } else if (VIR_SOCKET_ADDR_IS_FAMILY(address, AF_INET6)) {
+        if (virSocketAddrIsWildcard(address))
+            return 0;
         return 64;
     }
 
openSUSE Build Service is sponsored by