[lxc-devel] [lxd/master] Network: Exclude /32 underlay addresses from fan overlay address generation

tomponline on Github lxc-bot at linuxcontainers.org
Wed Sep 2 10:07:00 UTC 2020


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 641 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200902/dc1d6e36/attachment.bin>
-------------- next part --------------
From 602ecadd3c7a1286bf2d1245394f06824c712394 Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Wed, 2 Sep 2020 11:04:54 +0100
Subject: [PATCH] lxd/network/driver/bridge: Exclude /32 underlay addresses
 from overlay address generation

Avoids detecting the incorrect fan underlay address when /32 VIPs from the underlay subnet are added to a different interface than the underlay subnet is being used on.

Fixes https://discuss.linuxcontainers.org/t/delete-a-stopped-container-bring-down-the-fan-interface/8803

Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
 lxd/network/driver_bridge.go | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/lxd/network/driver_bridge.go b/lxd/network/driver_bridge.go
index 8ef1e612e4..9d04ba123b 100644
--- a/lxd/network/driver_bridge.go
+++ b/lxd/network/driver_bridge.go
@@ -1819,11 +1819,18 @@ func (n *bridge) addressForSubnet(subnet *net.IPNet) (net.IP, string, error) {
 		}
 
 		for _, addr := range addrs {
-			ip, _, err := net.ParseCIDR(addr.String())
+			ip, network, err := net.ParseCIDR(addr.String())
 			if err != nil {
 				continue
 			}
 
+			// Skip /32 addresses on interfaces in case VIPs are being used on a different interface
+			// than the intended underlay subnet interface.
+			maskOnes, maskSize := network.Mask.Size()
+			if maskOnes == 32 && maskSize == 32 {
+				continue
+			}
+
 			if subnet.Contains(ip) {
 				return ip, iface.Name, nil
 			}


More information about the lxc-devel mailing list