]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
util: fix equivalence of AF_UNSPEC virSocketAddrs
authorLaine Stump <laine@redhat.com>
Tue, 13 Jan 2026 06:03:23 +0000 (01:03 -0500)
committerLaine Stump <laine@redhat.com>
Fri, 16 Jan 2026 17:14:34 +0000 (12:14 -0500)
If a virSocketAddr has family AF_UNSPEC that means it is
unspecified/empty. If two virSocketAddrs are AF_UNSPEC then they are
equal, but virSocketAddrEqual() was countint that as *not* equal. This
doesn't make a difference for current uses of the function since they
all check that at least one of the virSocketAddrs is *not* AF_UNSPEC
before calling virSocketAddrEqual(), but an upcoming patch using
virSocketAddrEqual() will not be making that check, so let's fix the
utility function.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/util/virsocketaddr.c

index f53768878ed6247e5f1b9df53775173be645679d..4d4a6b2a0f52a2756e6b9f01c9776bfb78a85f87 100644 (file)
@@ -369,6 +369,8 @@ virSocketAddrEqual(const virSocketAddr *s1, const virSocketAddr *s2)
         return false;
 
     switch (s1->data.stor.ss_family) {
+    case AF_UNSPEC:
+        return true;
     case AF_INET:
         return (memcmp(&s1->data.inet4.sin_addr.s_addr,
                        &s2->data.inet4.sin_addr.s_addr,