]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
nss: handle leases with infinite expiry time
authorMichal Privoznik <mprivozn@redhat.com>
Fri, 18 Dec 2020 15:09:16 +0000 (16:09 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 4 Jan 2021 14:33:31 +0000 (15:33 +0100)
After v6.3.0-rc1~64 a lease can have infinite expiry time. This
means that the expiration time will appear as a value of zero.
Do the expiration check only if the expiration time is not zero.

Fixes: 97a0aa246799c97d0a9ca9ecd6b4fd932ae4756c
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
tests/nssdata/virbr0.status
tests/nsstest.c
tools/nss/libvirt_nss_leases.c

index 78afaf6200f933e6007eddf37c767ecf91b0ea52..354715bb1c9d2a604790425726d0ab12805019c7 100644 (file)
         "ip-address": "192.168.122.2",
         "mac-address": "52:54:00:11:22:33",
         "expiry-time": 2000000000
+    },
+    {
+        "ip-address": "192.168.122.3",
+        "mac-address": "52:54:00:a4:6f:91",
+        "hostname": "fedora",
+        "client-id": "01:52:54:00:a4:6f:91",
+        "expiry-time": 0
     }
 ]
index 135f6b6c93951d79d6219e42ed89b9225d7843ff..a4e8a4a37ff24de0b52543d2817bc33e5f48735e 100644 (file)
@@ -173,7 +173,7 @@ mymain(void)
     } while (0)
 
 # if !defined(LIBVIRT_NSS_GUEST)
-    DO_TEST("fedora", AF_INET, "192.168.122.197", "192.168.122.198", "192.168.122.199");
+    DO_TEST("fedora", AF_INET, "192.168.122.197", "192.168.122.198", "192.168.122.199", "192.168.122.3");
     DO_TEST("gentoo", AF_INET, "192.168.122.254");
     DO_TEST("gentoo", AF_INET6, "2001:1234:dead:beef::2");
     DO_TEST("gentoo", AF_UNSPEC, "192.168.122.254");
index 015bbc4ab64458153a362b600367d01591f7b1c7..536fcf8608113d0b74963b34c10d664527ce8c0e 100644 (file)
@@ -276,7 +276,8 @@ findLeasesParserEndMap(void *ctx)
             found = true;
     }
     DEBUG("Found %d", found);
-    if (parser->entry.expiry < parser->now) {
+    if (parser->entry.expiry != 0 &&
+        parser->entry.expiry < parser->now) {
         DEBUG("Entry expired at %llu vs now %llu",
               parser->entry.expiry, parser->now);
         found = false;
@@ -298,6 +299,7 @@ findLeasesParserEndMap(void *ctx)
     free(parser->entry.macaddr);
     free(parser->entry.ipaddr);
     free(parser->entry.hostname);
+    parser->entry.expiry = 0;
     parser->entry.macaddr = NULL;
     parser->entry.ipaddr = NULL;
     parser->entry.hostname = NULL;