[lxc-devel] [lxd/master] Consider the default port when checking address overlap

freeekanayaka on Github lxc-bot at linuxcontainers.org
Mon Feb 10 09:58:59 UTC 2020


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 361 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200210/c425d8cc/attachment.bin>
-------------- next part --------------
From 29966798bd0a0585939d56f060e348e33e18ddfe Mon Sep 17 00:00:00 2001
From: Free Ekanayaka <free.ekanayaka at canonical.com>
Date: Mon, 10 Feb 2020 09:57:00 +0000
Subject: [PATCH] Consider the default port when checking address overlap

Signed-off-by: Free Ekanayaka <free.ekanayaka at canonical.com>
---
 lxd/util/net.go      | 3 +++
 lxd/util/net_test.go | 1 +
 2 files changed, 4 insertions(+)

diff --git a/lxd/util/net.go b/lxd/util/net.go
index 154a0d98f5..af99fc98cd 100644
--- a/lxd/util/net.go
+++ b/lxd/util/net.go
@@ -138,6 +138,9 @@ func NetworkInterfaceAddress() string {
 // address2, in the sense that they are either the same address or address2 is
 // specified using a wildcard with the same port of address1.
 func IsAddressCovered(address1, address2 string) bool {
+	address1 = CanonicalNetworkAddress(address1)
+	address2 = CanonicalNetworkAddress(address2)
+
 	if address1 == address2 {
 		return true
 	}
diff --git a/lxd/util/net_test.go b/lxd/util/net_test.go
index 6c75a06ed0..e79ace9c3b 100644
--- a/lxd/util/net_test.go
+++ b/lxd/util/net_test.go
@@ -71,6 +71,7 @@ func TestIsAddressCovered(t *testing.T) {
 		{"[::1]:8443", ":8443", true},
 		{":8443", "[::]:8443", true},
 		{"0.0.0.0:8443", "[::]:8443", true},
+		{"10.30.0.8:8443", "[::]", true},
 	}
 
 	// Test some localhost cases too


More information about the lxc-devel mailing list