[pve-devel] [PATCH pve-container 3/5] setup/debian: guard ipv4 output
Wolfgang Bumiller
w.bumiller at proxmox.com
Fri Oct 16 08:32:00 CEST 2015
When only an ipv6 address was specified we still tried to
print an ipv4 address which warned and caused additional
newlines to be appended to the file on each start.
---
src/PVE/LXC/Setup/Debian.pm | 6 +++---
src/test/test-debian-011/config | 1 +
src/test/test-debian-011/etc/debian_version | 1 +
src/test/test-debian-011/etc/network/interfaces | 2 ++
src/test/test-debian-011/etc/network/interfaces.exp | 8 ++++++++
5 files changed, 15 insertions(+), 3 deletions(-)
create mode 100644 src/test/test-debian-011/config
create mode 100644 src/test/test-debian-011/etc/debian_version
create mode 100644 src/test/test-debian-011/etc/network/interfaces
create mode 100644 src/test/test-debian-011/etc/network/interfaces.exp
diff --git a/src/PVE/LXC/Setup/Debian.pm b/src/PVE/LXC/Setup/Debian.pm
index 07dccfc..44f77dd 100644
--- a/src/PVE/LXC/Setup/Debian.pm
+++ b/src/PVE/LXC/Setup/Debian.pm
@@ -134,7 +134,7 @@ sub setup_network {
if ($net->{address} =~ /^(dhcp|manual)$/) {
$interfaces .= "iface $section->{ifname} inet $1\n";
- } elsif ($net->{address}) {
+ } else {
$interfaces .= "iface $section->{ifname} inet static\n";
$interfaces .= "\taddress $net->{address}\n" if defined($net->{address});
$interfaces .= "\tnetmask $net->{netmask}\n" if defined($net->{netmask});
@@ -151,7 +151,7 @@ sub setup_network {
if ($net->{address6} =~ /^(auto|dhcp|manual)$/) {
$interfaces .= "iface $section->{ifname} inet6 $1\n";
- } elsif ($net->{address6}) {
+ } else {
$interfaces .= "iface $section->{ifname} inet6 static\n";
$interfaces .= "\taddress $net->{address6}\n" if defined($net->{address6});
$interfaces .= "\tnetmask $net->{netmask6}\n" if defined($net->{netmask6});
@@ -244,7 +244,7 @@ sub setup_network {
foreach my $ifname (sort keys %$networks) {
my $net = $networks->{$ifname};
- if (!$done_v4_hash->{$ifname}) {
+ if (!$done_v4_hash->{$ifname} && defined($net->{address})) {
if ($need_separator) { $interfaces .= "\n"; $need_separator = 0; };
$section = { type => 'ipv4', ifname => $ifname, attr => []};
&$print_section(1);
diff --git a/src/test/test-debian-011/config b/src/test/test-debian-011/config
new file mode 100644
index 0000000..63c9ff5
--- /dev/null
+++ b/src/test/test-debian-011/config
@@ -0,0 +1 @@
+net0: name=eth0,hwaddr=46:6B:2E:6F:B1:13,bridge=vmbr0,ip6=fc00::89:c:1/96
diff --git a/src/test/test-debian-011/etc/debian_version b/src/test/test-debian-011/etc/debian_version
new file mode 100644
index 0000000..cc40bca
--- /dev/null
+++ b/src/test/test-debian-011/etc/debian_version
@@ -0,0 +1 @@
+8.0
diff --git a/src/test/test-debian-011/etc/network/interfaces b/src/test/test-debian-011/etc/network/interfaces
new file mode 100644
index 0000000..f1bd92e
--- /dev/null
+++ b/src/test/test-debian-011/etc/network/interfaces
@@ -0,0 +1,2 @@
+auto lo
+iface lo inet loopback
diff --git a/src/test/test-debian-011/etc/network/interfaces.exp b/src/test/test-debian-011/etc/network/interfaces.exp
new file mode 100644
index 0000000..16e619d
--- /dev/null
+++ b/src/test/test-debian-011/etc/network/interfaces.exp
@@ -0,0 +1,8 @@
+auto lo
+iface lo inet loopback
+
+auto eth0
+iface eth0 inet6 static
+ address fc00::89:c:1
+ netmask 96
+
--
2.1.4
More information about the pve-devel
mailing list