]> git.proxmox.com Git - pve-container.git/commitdiff
fix #1134: debian: don't start empty interface sections
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Mon, 3 Oct 2016 07:41:19 +0000 (09:41 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Tue, 4 Oct 2016 09:49:26 +0000 (11:49 +0200)
While a completely unconfigured network interface is
considered manually managed, one that contains an ipv4 _or_
an ipv6 address needs to remove sections with no configured
address rather than printing the 'iface' section header with
no content.

src/PVE/LXC/Setup/Debian.pm
src/test/test-debian-006/config
src/test/test-debian-006/etc/hosts.exp
src/test/test-debian-006/etc/network/interfaces [new file with mode: 0644]
src/test/test-debian-006/etc/network/interfaces.exp [new file with mode: 0644]

index d7e710273f15ddbd97f61066bb8ef3b0316cf883..d529dde14a2762352b0cd9c8fa043a9991285e80 100644 (file)
@@ -209,8 +209,10 @@ sub setup_network {
        if ($section->{type} eq 'ipv4') {
            $done_v4_hash->{$ifname} = 1;
 
-           if (defined($net->{address}) && $net->{address} =~ /^(dhcp|manual)$/) {
-               $interfaces .= "iface $ifname inet $1\n";
+           if (!defined($net->{address})) {
+               # no address => no iface line
+           } elsif ($net->{address} =~ /^(dhcp|manual)$/) {
+               $interfaces .= "iface $ifname inet $1\n\n";
            } else {
                $interfaces .= "iface $ifname inet static\n";
                $interfaces .= "\taddress $net->{address}\n" if defined($net->{address});
@@ -227,15 +229,15 @@ sub setup_network {
                foreach my $attr (@{$section->{attr}}) {
                    $interfaces .= "\t$attr\n";
                }
+               $interfaces .= "\n";
            }
-
-           $interfaces .= "\n";
-
        } elsif ($section->{type} eq 'ipv6') {
            $done_v6_hash->{$ifname} = 1;
 
-           if (defined($net->{address6}) && $net->{address6} =~ /^(auto|dhcp|manual)$/) {
-               $interfaces .= "iface $ifname inet6 $1\n";
+           if (!defined($net->{address6})) {
+               # no address => no iface line
+           } elsif ($net->{address6} =~ /^(auto|dhcp|manual)$/) {
+               $interfaces .= "iface $ifname inet6 $1\n\n";
            } else {
                $interfaces .= "iface $ifname inet6 static\n";
                $interfaces .= "\taddress $net->{address6}\n" if defined($net->{address6});
@@ -251,9 +253,8 @@ sub setup_network {
                foreach my $attr (@{$section->{attr}}) {
                    $interfaces .= "\t$attr\n";
                }
+               $interfaces .= "\n";
            }
-
-           $interfaces .= "\n";
        } else {
            die "unknown section type '$section->{type}'";
        }
index 3ad4192cfd8f1c787ac48f50e1551b9693ad200b..70410539d0a92e594e5c6dd10a906af243e7fdb2 100644 (file)
@@ -1,2 +1,4 @@
 hostname: test1
-tty: 0
\ No newline at end of file
+tty: 0
+net0: bridge=vmbr0,name=eth0,ip=1.2.3.4/24
+net1: bridge=vmbr1,name=eth1,ip6=1234::1/64
index c0dd46e0b6914789f0108e0a105b1812b6be96bc..01ac197e411febf029629edbceb8284d6cb33396 100644 (file)
@@ -1,5 +1,5 @@
 # --- BEGIN PVE ---
 127.0.0.1 localhost.localnet localhost
 ::1 localhost.localnet localhost
-127.0.1.1 test1
+1.2.3.4 test1.proxmox.com test1
 # --- END PVE ---
diff --git a/src/test/test-debian-006/etc/network/interfaces b/src/test/test-debian-006/etc/network/interfaces
new file mode 100644 (file)
index 0000000..d84f213
--- /dev/null
@@ -0,0 +1,23 @@
+# Scenario:
+#  An address was previously configured but then removed.
+
+# ipv6 removed
+auto eth0
+iface eth0 inet static
+       address 1.2.3.4
+       netmask 255.255.255.0
+
+iface eth0 inet6 static
+       address fc00::1
+       netmask 64
+
+# ipv4 removed
+auto eth1
+iface eth1 inet static
+       address 2.3.4.5
+       netmask 255.255.255.0
+
+iface eth1 inet6 static
+       address 1234::1
+       netmask 64
+
diff --git a/src/test/test-debian-006/etc/network/interfaces.exp b/src/test/test-debian-006/etc/network/interfaces.exp
new file mode 100644 (file)
index 0000000..c16c07b
--- /dev/null
@@ -0,0 +1,15 @@
+# Scenario:
+#  An address was previously configured but then removed.
+
+# ipv6 removed
+auto eth0
+iface eth0 inet static
+       address 1.2.3.4
+       netmask 255.255.255.0
+
+# ipv4 removed
+auto eth1
+iface eth1 inet6 static
+       address 1234::1
+       netmask 64
+