[lxc-devel] [lxd/master] IPv6 fixes
stgraber on Github
lxc-bot at linuxcontainers.org
Tue Oct 11 16:48:39 UTC 2016
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 301 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20161011/620aaccd/attachment.bin>
-------------- next part --------------
From b922cf1df96e606970ff84763928cb47e9ddcd51 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Tue, 11 Oct 2016 12:21:26 -0400
Subject: [PATCH 1/2] network: Always pass --enable-ra with IPv6
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Closes #2481
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
lxd/networks.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lxd/networks.go b/lxd/networks.go
index 0ec74ab..2dbe53f 100644
--- a/lxd/networks.go
+++ b/lxd/networks.go
@@ -785,7 +785,7 @@ func (n *network) Start() error {
}
// Update the dnsmasq config
- dnsmasqCmd = append(dnsmasqCmd, fmt.Sprintf("--listen-address=%s", ip.String()))
+ dnsmasqCmd = append(dnsmasqCmd, []string{fmt.Sprintf("--listen-address=%s", ip.String()), "--enable-ra"}...)
if n.config["ipv6.dhcp"] == "" || shared.IsTrue(n.config["ipv6.dhcp"]) {
if !shared.StringInSlice("--dhcp-no-override", dnsmasqCmd) {
dnsmasqCmd = append(dnsmasqCmd, []string{"--dhcp-no-override", "--dhcp-authoritative", fmt.Sprintf("--dhcp-leasefile=%s", shared.VarPath("networks", n.name, "dnsmasq.leases")), fmt.Sprintf("--dhcp-hostsfile=%s", shared.VarPath("networks", n.name, "dnsmasq.hosts"))}...)
From 0fa3b9ca39f1b915325ee26121b502a90af036aa Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Tue, 11 Oct 2016 12:46:38 -0400
Subject: [PATCH 2/2] network: Fix IPv6 DHCP logic
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- Re-order the code so that DHCPv6 can actually be turned off.
- Use the ::,constructor= syntax to properly instruct dnsmasq not to do
DHCPv6 when not needed.
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
lxd/networks.go | 25 +++++++++++--------------
1 file changed, 11 insertions(+), 14 deletions(-)
diff --git a/lxd/networks.go b/lxd/networks.go
index 2dbe53f..dc9eded 100644
--- a/lxd/networks.go
+++ b/lxd/networks.go
@@ -791,23 +791,20 @@ func (n *network) Start() error {
dnsmasqCmd = append(dnsmasqCmd, []string{"--dhcp-no-override", "--dhcp-authoritative", fmt.Sprintf("--dhcp-leasefile=%s", shared.VarPath("networks", n.name, "dnsmasq.leases")), fmt.Sprintf("--dhcp-hostsfile=%s", shared.VarPath("networks", n.name, "dnsmasq.hosts"))}...)
}
- flags := ""
- if n.config["ipv6.dhcp"] == "" || shared.IsTrue(n.config["ipv6.dhcp"]) {
- if !shared.IsTrue(n.config["ipv6.dhcp.stateful"]) {
- flags = ",ra-stateless,ra-names"
- }
- } else {
- flags = ",ra-only"
- }
-
- if n.config["ipv6.dhcp.ranges"] != "" {
- for _, dhcpRange := range strings.Split(n.config["ipv6.dhcp.ranges"], ",") {
- dhcpRange = strings.TrimSpace(dhcpRange)
- dnsmasqCmd = append(dnsmasqCmd, []string{"--dhcp-range", fmt.Sprintf("%s%s", strings.Replace(dhcpRange, "-", ",", -1), flags)}...)
+ if shared.IsTrue(n.config["ipv6.dhcp.stateful"]) {
+ if n.config["ipv6.dhcp.ranges"] != "" {
+ for _, dhcpRange := range strings.Split(n.config["ipv6.dhcp.ranges"], ",") {
+ dhcpRange = strings.TrimSpace(dhcpRange)
+ dnsmasqCmd = append(dnsmasqCmd, []string{"--dhcp-range", fmt.Sprintf("%s", strings.Replace(dhcpRange, "-", ",", -1))}...)
+ }
+ } else {
+ dnsmasqCmd = append(dnsmasqCmd, []string{"--dhcp-range", fmt.Sprintf("%s,%s", networkGetIP(subnet, 2), networkGetIP(subnet, -1))}...)
}
} else {
- dnsmasqCmd = append(dnsmasqCmd, []string{"--dhcp-range", fmt.Sprintf("%s,%s%s", networkGetIP(subnet, 2), networkGetIP(subnet, -1), flags)}...)
+ dnsmasqCmd = append(dnsmasqCmd, []string{"--dhcp-range", fmt.Sprintf("::,constructor:%s,ra-stateless,ra-names", n.name)}...)
}
+ } else {
+ dnsmasqCmd = append(dnsmasqCmd, []string{"--dhcp-range", fmt.Sprintf("::,constructor:%s,ra-only", n.name)}...)
}
// Setup basic iptables overrides
More information about the lxc-devel
mailing list