This patch tests the version of dnsmasq. If (major > 2)
or ((major==2) and (minor >= 63)), then use dnsmasq. Otherwise,
use radvd to provide the RA service.
---
src/conf/network_conf.h | 1 +
src/network/bridge_driver.c | 36 ++++++++++++++++++++++
tests/networkxml2argvdata/dhcp6-network.argv | 1 +
tests/networkxml2argvdata/nat-network-dhcp6.argv | 1 +
.../nat-network-dns-srv-record-minimal.argv | 1 +
.../nat-network-dns-srv-record.argv | 1 +
.../nat-network-dns-txt-record.argv | 1 +
tests/networkxml2argvdata/nat-network.argv | 1 +
.../routed-network-dhcphost.argv | 1 +
tests/networkxml2argvtest.c | 1 +
10 files changed, 45 insertions(+)
diff --git a/src/conf/network_conf.h b/src/conf/network_conf.h
index cfc49af..39fffd7 100644
--- a/src/conf/network_conf.h
+++ b/src/conf/network_conf.h
@@ -220,6 +220,7 @@ struct _virNetworkObj {
unsigned int persistent : 1;
unsigned int dnsmasqMajor;
unsigned int dnsmasqMinor;
+ unsigned int dnsmasqRA;
virNetworkDefPtr def; /* The current definition */
virNetworkDefPtr newDef; /* New definition to activate at shutdown */
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 19610f2..2230268 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -893,6 +893,26 @@ networkDnsmasqConfContents(virNetworkObjPtr network,
virBufferAsprintf(&configbuf, "addn-hosts=%s\n",
dctx->addnhostsfile->path);
+ /* we are doing RA instead of radvd */
+ if (network->dnsmasqRA) {
+ if (dhcp6flag)
+ virBufferAsprintf(&configbuf, "enable-ra\n");
+ else {
+ char *bridgeaddr = NULL;
+ ipdef = virNetworkDefGetIpByIndex(network->def, AF_INET6, 0);
+ if (ipdef) {
+ bridgeaddr = virSocketAddrFormat(&ipdef->address);
+ if (bridgeaddr) {
+ virBufferAsprintf(&configbuf,
+ "dhcp-range=%s,ra-only\n", bridgeaddr);
+ }
+ }
+ if ((!ipdef) || (!bridgeaddr))
+ VIR_WARN("IPv6 invalid configuration for %s",
network->def->name);
+ VIR_FREE(bridgeaddr);
+ }
+ }
+
if (!(*configstr = virBufferContentAndReset(&configbuf))) {
virReportOOMError();
goto cleanup;
@@ -1014,6 +1034,12 @@ networkStartDhcpDaemon(virNetworkObjPtr network)
}
}
+ /* is radvd or dnsmasq to handle RA? */
+ if ((network->dnsmasqMajor > 2) ||
+ ((network->dnsmasqMajor == 2) &&
+ (network->dnsmasqMinor >= 63)))
+ network->dnsmasqRA = 1;
+
if (virFileMakePath(NETWORK_PID_DIR) < 0) {
virReportSystemError(errno,
_("cannot create directory %s"),
@@ -1293,6 +1319,12 @@ networkStartRadvd(virNetworkObjPtr network)
virCommandPtr cmd = NULL;
int ret = -1;
+ /* is dnsmasq handling RA */
+ if (network->dnsmasqRA) {
+ ret = 0;
+ goto cleanup;
+ }
+
network->radvdPid = -1;
if (!virNetworkDefGetIpByIndex(network->def, AF_INET6, 0)) {
@@ -1370,6 +1402,10 @@ cleanup:
static int
networkRefreshRadvd(virNetworkObjPtr network)
{
+ /* is dnsmasq handling RA */
+ if (network->dnsmasqRA)
+ return 0;
+
/* if there's no running radvd, just start it */
if (network->radvdPid <= 0 || (kill(network->radvdPid, 0) < 0))
return networkStartRadvd(network);
diff --git a/tests/networkxml2argvdata/dhcp6-network.argv
b/tests/networkxml2argvdata/dhcp6-network.argv
index 6697833..66ec430 100644
--- a/tests/networkxml2argvdata/dhcp6-network.argv
+++ b/tests/networkxml2argvdata/dhcp6-network.argv
@@ -14,3 +14,4 @@ dhcp-leasefile=/var/lib/libvirt/dnsmasq/default.leases
dhcp-lease-max=240
dhcp-hostsfile=/var/lib/libvirt/dnsmasq/default.hostsfile
addn-hosts=/var/lib/libvirt/dnsmasq/default.addnhosts
+enable-ra
diff --git a/tests/networkxml2argvdata/nat-network-dhcp6.argv
b/tests/networkxml2argvdata/nat-network-dhcp6.argv
index 14256ae..c56fff1 100644
--- a/tests/networkxml2argvdata/nat-network-dhcp6.argv
+++ b/tests/networkxml2argvdata/nat-network-dhcp6.argv
@@ -17,3 +17,4 @@ dhcp-leasefile=/var/lib/libvirt/dnsmasq/default.leases
dhcp-lease-max=493
dhcp-hostsfile=/var/lib/libvirt/dnsmasq/default.hostsfile
addn-hosts=/var/lib/libvirt/dnsmasq/default.addnhosts
+enable-ra
diff --git a/tests/networkxml2argvdata/nat-network-dns-srv-record-minimal.argv
b/tests/networkxml2argvdata/nat-network-dns-srv-record-minimal.argv
index 45a658b..26f283e 100644
--- a/tests/networkxml2argvdata/nat-network-dns-srv-record-minimal.argv
+++ b/tests/networkxml2argvdata/nat-network-dns-srv-record-minimal.argv
@@ -17,3 +17,4 @@ dhcp-leasefile=/var/lib/libvirt/dnsmasq/default.leases
dhcp-lease-max=253
dhcp-hostsfile=/var/lib/libvirt/dnsmasq/default.hostsfile
addn-hosts=/var/lib/libvirt/dnsmasq/default.addnhosts
+dhcp-range=2001:db8:ac10:fe01::1,ra-only
diff --git a/tests/networkxml2argvdata/nat-network-dns-srv-record.argv
b/tests/networkxml2argvdata/nat-network-dns-srv-record.argv
index 13e80b9..1840ae6 100644
--- a/tests/networkxml2argvdata/nat-network-dns-srv-record.argv
+++ b/tests/networkxml2argvdata/nat-network-dns-srv-record.argv
@@ -17,3 +17,4 @@ dhcp-leasefile=/var/lib/libvirt/dnsmasq/default.leases
dhcp-lease-max=253
dhcp-hostsfile=/var/lib/libvirt/dnsmasq/default.hostsfile
addn-hosts=/var/lib/libvirt/dnsmasq/default.addnhosts
+dhcp-range=2001:db8:ac10:fe01::1,ra-only
diff --git a/tests/networkxml2argvdata/nat-network-dns-txt-record.argv
b/tests/networkxml2argvdata/nat-network-dns-txt-record.argv
index 7277132..ecc79e7 100644
--- a/tests/networkxml2argvdata/nat-network-dns-txt-record.argv
+++ b/tests/networkxml2argvdata/nat-network-dns-txt-record.argv
@@ -17,3 +17,4 @@ dhcp-leasefile=/var/lib/libvirt/dnsmasq/default.leases
dhcp-lease-max=253
dhcp-hostsfile=/var/lib/libvirt/dnsmasq/default.hostsfile
addn-hosts=/var/lib/libvirt/dnsmasq/default.addnhosts
+dhcp-range=2001:db8:ac10:fe01::1,ra-only
diff --git a/tests/networkxml2argvdata/nat-network.argv
b/tests/networkxml2argvdata/nat-network.argv
index 6e0161b..74d3c64 100644
--- a/tests/networkxml2argvdata/nat-network.argv
+++ b/tests/networkxml2argvdata/nat-network.argv
@@ -16,3 +16,4 @@ dhcp-leasefile=/var/lib/libvirt/dnsmasq/default.leases
dhcp-lease-max=253
dhcp-hostsfile=/var/lib/libvirt/dnsmasq/default.hostsfile
addn-hosts=/var/lib/libvirt/dnsmasq/default.addnhosts
+dhcp-range=2001:db8:ac10:fe01::1,ra-only
diff --git a/tests/networkxml2argvdata/routed-network-dhcphost.argv
b/tests/networkxml2argvdata/routed-network-dhcphost.argv
index cf38381..744b8f0 100644
--- a/tests/networkxml2argvdata/routed-network-dhcphost.argv
+++ b/tests/networkxml2argvdata/routed-network-dhcphost.argv
@@ -12,3 +12,4 @@ dhcp-no-override
dhcp-range=2001:db8:ac10:fd01::1,static
dhcp-hostsfile=/var/lib/libvirt/dnsmasq/local.hostsfile
addn-hosts=/var/lib/libvirt/dnsmasq/local.addnhosts
+enable-ra
diff --git a/tests/networkxml2argvtest.c b/tests/networkxml2argvtest.c
index ef32aa5..413ba80 100644
--- a/tests/networkxml2argvtest.c
+++ b/tests/networkxml2argvtest.c
@@ -38,6 +38,7 @@ static int testCompareXMLToArgvFiles(const char *inxml, const char
*outargv) {
goto fail;
obj->def = dev;
+ obj->dnsmasqRA = 1;
dctx = dnsmasqContextNew(dev->name, "/var/lib/libvirt/dnsmasq");
if (dctx == NULL)
--
1.7.11.7