[libvirt] [PATCH 4/6] leaseshelper: remove useless comparison

Ján Tomko jtomko at redhat.com
Tue Jan 19 09:54:03 UTC 2016


We do not care if the mac was specified in the delete section,
we are going to delete the record anyway.

Also move the comment about adding ipv6 leases to the ADD case.
---
 src/network/leaseshelper.c | 34 +++++++++++++++-------------------
 1 file changed, 15 insertions(+), 19 deletions(-)

diff --git a/src/network/leaseshelper.c b/src/network/leaseshelper.c
index 94686ee..eb1c0c7 100644
--- a/src/network/leaseshelper.c
+++ b/src/network/leaseshelper.c
@@ -401,9 +401,21 @@ main(int argc, char **argv)
     switch ((enum virLeaseActionFlags) action) {
     case VIR_LEASE_ACTION_ADD:
     case VIR_LEASE_ACTION_OLD:
+        /* Custom ipv6 leases *will not* be created if the env-var DNSMASQ_MAC
+         * is not set. In the special case, when the $(interface).status file
+         * is not already present and dnsmasq is (re)started, the corresponding
+         * ipv6 custom lease will be created only when the guest sends the
+         * 'old' action for its existing ipv6 interfaces.
+         *
+         * According to rfc3315, the combination of DUID and IAID can be used
+         * to uniquely identify each ipv6 guest interface. So, in future, if
+         * we introduce virNetworkGetDHCPLeaseBy(IAID|DUID|IAID+DUID) for ipv6
+         * interfaces, then, the following if condition won't be required, as
+         * the new lease will be created irrespective of whether the MACID is
+         * known or not.
+         */
         if (!mac)
             break;
-        delete = true;
 
         /* Create new lease */
         if (!(lease_new = virJSONValueNewObject())) {
@@ -435,27 +447,11 @@ main(int argc, char **argv)
         if (expirytime && virJSONValueObjectAppendNumberLong(lease_new, "expiry-time", expirytime) < 0)
             goto cleanup;
 
-        break;
 
+        /* fallthrough */
     case VIR_LEASE_ACTION_DEL:
+        /* Delete the corresponding lease, if it already exists */
         delete = true;
-        /* Custom ipv6 leases *will not* be created if the env-var DNSMASQ_MAC
-         * is not set. In the special case, when the $(interface).status file
-         * is not already present and dnsmasq is (re)started, the corresponding
-         * ipv6 custom lease will be created only when the guest sends the
-         * 'old' action for its existing ipv6 interfaces.
-         *
-         * According to rfc3315, the combination of DUID and IAID can be used
-         * to uniquely identify each ipv6 guest interface. So, in future, if
-         * we introduce virNetworkGetDHCPLeaseBy(IAID|DUID|IAID+DUID) for ipv6
-         * interfaces, then, the following if condition won't be required, as
-         * the new lease will be created irrespective of whether the MACID is
-         * known or not.
-         */
-        if (mac) {
-            /* Delete the corresponding lease, if it already exists */
-            delete = true;
-        }
         break;
 
     case VIR_LEASE_ACTION_INIT:
-- 
2.4.6




More information about the libvir-list mailing list