[libvirt] [PATCH 6/6] v1: for DHCPv6, add dnsmasq version check

Gene Czarcinski gene at czarc.net
Thu Nov 8 21:13:46 UTC 2012


If dnsmasq version is => 2.64, then IPV6 dhcp-range and
dhcp-host are proccessed/supported.  Otherwise, error out
with message that DHCPv6 range and host not supported by
the installed dnsmasq version.
---
 src/network/bridge_driver.c | 15 ++++++++++++++-
 tests/networkxml2argvtest.c |  2 ++
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 2230268..a0c85b5 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -654,7 +654,7 @@ networkDnsmasqConfContents(virNetworkObjPtr network,
     char *recordWeight = NULL;
     char *recordPriority = NULL;
     virNetworkIpDefPtr tmpipdef, ipdef, ipv4def, ipv6def;
-    bool dhcp4flag, dhcp6flag;
+    bool dhcp4flag, dhcp6flag, dhcp6_OK;
 
     *configstr = NULL;
 
@@ -776,6 +776,13 @@ networkDnsmasqConfContents(virNetworkObjPtr network,
         VIR_FREE(ipaddr);
     }
 
+    /* check to is if dnsmasq version >= 2.64 so that DHCPv6 is OK */
+    dhcp6_OK = false;
+    if (network->dnsmasqMajor > 2)
+        dhcp6_OK = true;
+    if ((network->dnsmasqMajor == 2) && (network->dnsmasqMinor > 63))
+        dhcp6_OK = true;
+
     /* Find the first dhcp for both IPv4 and IPv6 */
     for (ii = 0, ipv4def = NULL, ipv6def = NULL, dhcp4flag = false, dhcp6flag = false;
          (ipdef = virNetworkDefGetIpByIndex(network->def, AF_UNSPEC, ii));
@@ -790,6 +797,12 @@ networkDnsmasqConfContents(virNetworkObjPtr network,
         }
         if (VIR_SOCKET_ADDR_IS_FAMILY(&ipdef->address, AF_INET6)) {
             if (ipdef->nranges || ipdef->nhosts) {
+                if (!dhcp6_OK) {
+                    virReportError(VIR_ERR_XML_ERROR,
+                       _("Invlaid to specify DHCPv6 range or host for dnsmasq version %u.%u"),
+                       network->dnsmasqMajor, network->dnsmasqMinor);
+                    goto cleanup;
+                }
                 if (!ipv6def) {
                     ipv6def = ipdef;
                     dhcp6flag = true;
diff --git a/tests/networkxml2argvtest.c b/tests/networkxml2argvtest.c
index 413ba80..a64da65 100644
--- a/tests/networkxml2argvtest.c
+++ b/tests/networkxml2argvtest.c
@@ -38,6 +38,8 @@ static int testCompareXMLToArgvFiles(const char *inxml, const char *outargv) {
         goto fail;
 
     obj->def = dev;
+    obj->dnsmasqMajor = 2;
+    obj->dnsmasqMinor = 64;
     obj->dnsmasqRA = 1;
     dctx = dnsmasqContextNew(dev->name, "/var/lib/libvirt/dnsmasq");
 
-- 
1.7.11.7




More information about the libvir-list mailing list