[pve-devel] [PATCH container] bug #1021: add loopback interface if not network config

Thomas Lamprecht t.lamprecht at proxmox.com
Tue Oct 4 10:50:31 CEST 2016


While loopback is always there it still needs to be in the config in
older Debian versions and Alpine Linux.

Fixes 1021 as the Alpine code uses the debian network code.

Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
 src/PVE/LXC/Setup/Debian.pm                         | 8 ++++++++
 src/test/test-debian-002/etc/network/interfaces.exp | 4 ++++
 2 files changed, 12 insertions(+)

diff --git a/src/PVE/LXC/Setup/Debian.pm b/src/PVE/LXC/Setup/Debian.pm
index e927c37..d7e7102 100644
--- a/src/PVE/LXC/Setup/Debian.pm
+++ b/src/PVE/LXC/Setup/Debian.pm
@@ -353,6 +353,14 @@ sub setup_network {
 	}
     }
 
+    # older templates (< Debian 8) do not configure the loopback interface
+    # if not explicitly told to do so
+    if (!$done_auto->{lo}) {
+	$interfaces = "auto lo\niface lo inet loopback\n" .
+	              "iface lo inet6 loopback\n\n" .
+	              $interfaces;
+    }
+
     $self->ct_file_set_contents($filename, $interfaces);
 }
 
diff --git a/src/test/test-debian-002/etc/network/interfaces.exp b/src/test/test-debian-002/etc/network/interfaces.exp
index 9d9dbcc..0c7dae1 100644
--- a/src/test/test-debian-002/etc/network/interfaces.exp
+++ b/src/test/test-debian-002/etc/network/interfaces.exp
@@ -1,3 +1,7 @@
+auto lo
+iface lo inet loopback
+iface lo inet6 loopback
+
 auto eth0
 iface eth0 inet static
 	address 1.2.3.4
-- 
2.1.4





More information about the pve-devel mailing list