[lxc-devel] [lxd/master] lxd/containers: Fix lxc.net check
stgraber on Github
lxc-bot at linuxcontainers.org
Tue Apr 17 15:27:12 UTC 2018
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 370 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180417/d49cbf97/attachment.bin>
-------------- next part --------------
From adb04ba36aa74c70a1ca6fcce9e2e1d730e0ecc7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Tue, 17 Apr 2018 11:25:21 -0400
Subject: [PATCH] lxd/containers: Fix lxc.net check
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Closes #4466
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
lxd/container_lxc.go | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)
diff --git a/lxd/container_lxc.go b/lxd/container_lxc.go
index b40eb99f3..8dffa50fd 100644
--- a/lxd/container_lxc.go
+++ b/lxd/container_lxc.go
@@ -234,17 +234,26 @@ func lxcValidConfig(rawLxc string) error {
if strings.HasPrefix(key, networkKeyPrefix) {
fields := strings.Split(key, ".")
- allowedIPKeys := []string{"ipv4.address", "ipv6.address"}
if !util.RuntimeLiblxcVersionAtLeast(2, 1, 0) {
- allowedIPKeys = []string{"ipv4", "ipv6"}
- }
+ // lxc.network.X.ipv4 or lxc.network.X.ipv6
+ if len(fields) == 4 && shared.StringInSlice(fields[3], []string{"ipv4", "ipv6"}) {
+ continue
+ }
- if len(fields) == 4 && shared.StringInSlice(fields[3], allowedIPKeys) {
- continue
- }
+ // lxc.network.X.ipv4.gateway or lxc.network.X.ipv6.gateway
+ if len(fields) == 5 && shared.StringInSlice(fields[3], []string{"ipv4", "ipv6"}) && fields[4] == "gateway" {
+ continue
+ }
+ } else {
+ // lxc.net.X.ipv4.address or lxc.net.X.ipv6.address
+ if len(fields) == 5 && shared.StringInSlice(fields[3], []string{"ipv4", "ipv6"}) && fields[4] == "address" {
+ continue
+ }
- if len(fields) == 5 && shared.StringInSlice(fields[3], allowedIPKeys) && fields[4] == "gateway" {
- continue
+ // lxc.net.X.ipv4.gateway or lxc.net.X.ipv6.gateway
+ if len(fields) == 5 && shared.StringInSlice(fields[3], []string{"ipv4", "ipv6"}) && fields[4] == "gateway" {
+ continue
+ }
}
return fmt.Errorf("Only interface-specific ipv4/ipv6 %s keys are allowed", networkKeyPrefix)
More information about the lxc-devel
mailing list