[pve-devel] [PATCH container 3/3] centos: fixup ipv6 out-of-subnet route

Wolfgang Bumiller w.bumiller at proxmox.com
Mon Apr 25 16:20:43 CEST 2016


Centos needs these in route6-$iface, not route-$iface.
It also seems to make sense to not include the
IPV6_DEFAULTGW when a route6-$iface file is used containing
the default gateway.

Also adding the device to the routes.
---
 src/PVE/LXC/Setup/CentOS.pm                                  | 12 ++++++++----
 src/test/run_setup_tests.pl                                  |  4 ++++
 .../etc/sysconfig/network-scripts/ifcfg-eth0.exp             |  1 -
 .../etc/sysconfig/network-scripts/route-eth0.exp             |  4 +---
 .../etc/sysconfig/network-scripts/route6-eth0.exp            |  4 ++++
 5 files changed, 17 insertions(+), 8 deletions(-)
 create mode 100644 src/test/test-centos6-002/etc/sysconfig/network-scripts/route6-eth0.exp

diff --git a/src/PVE/LXC/Setup/CentOS.pm b/src/PVE/LXC/Setup/CentOS.pm
index c0330c2..2becc35 100644
--- a/src/PVE/LXC/Setup/CentOS.pm
+++ b/src/PVE/LXC/Setup/CentOS.pm
@@ -177,7 +177,9 @@ sub setup_network {
 
 	my $filename = "/etc/sysconfig/network-scripts/ifcfg-$d->{name}";
 	my $routefile = "/etc/sysconfig/network-scripts/route-$d->{name}";
+	my $route6file = "/etc/sysconfig/network-scripts/route6-$d->{name}";
 	my $routes = '';
+	my $routes6 = '';
 
 	my $header = "DEVICE=$d->{name}\nONBOOT=yes\n";
 	my $data = '';
@@ -195,7 +197,7 @@ sub setup_network {
 		    $data .= "GATEWAY=$d->{gw}\n";
 		    if (!PVE::Network::is_ip_in_cidr($d->{gw}, $d->{ip}, 4)) {
 			$routes .= "$d->{gw} dev $d->{name}\n";
-			$routes .= "default via $d->{gw}\n";
+			$routes .= "default via $d->{gw} dev $d->{name}\n";
 		    }
 		}
 	    }
@@ -214,11 +216,12 @@ sub setup_network {
 	    } else {
 		$data .= "IPV6ADDR=$d->{ip6}\n";
 		if (defined($d->{gw6})) {
-		    $data .= "IPV6_DEFAULTGW=$d->{gw6}\n";
 		    if (!PVE::Network::is_ip_in_cidr($d->{gw6}, $d->{ip6}, 6) &&
 			!PVE::Network::is_ip_in_cidr($d->{gw6}, 'fe80::/10', 6)) {
-			$routes .= "$d->{gw6} dev $d->{name}\n";
-			$routes .= "default via $d->{gw6}\n";
+			$routes6 .= "$d->{gw6} dev $d->{name}\n";
+			$routes6 .= "default via $d->{gw6} dev $d->{name}\n";
+		    } else {
+			$data .= "IPV6_DEFAULTGW=$d->{gw6}\n";
 		    }
 		}
 	    }
@@ -228,6 +231,7 @@ sub setup_network {
 	$header .= "BOOTPROTO=$bootproto\n";
 	$self->ct_file_set_contents($filename, $header . $data);
 	$self->ct_modify_file($routefile, $routes, delete => 1, prepend => 1);
+	$self->ct_modify_file($route6file, $routes6, delete => 1, prepend => 1);
     }
 
     my $sysconfig_network = "/etc/sysconfig/network";
diff --git a/src/test/run_setup_tests.pl b/src/test/run_setup_tests.pl
index fc92dbb..b103cfa 100755
--- a/src/test/run_setup_tests.pl
+++ b/src/test/run_setup_tests.pl
@@ -53,12 +53,16 @@ sub run_test {
 	                   /etc/sysconfig/network
 	                   /etc/sysconfig/network-scripts/ifcfg-eth0
 	                   /etc/sysconfig/network-scripts/route-eth0
+	                   /etc/sysconfig/network-scripts/route6-eth0
 	                   /etc/sysconfig/network-scripts/ifcfg-eth1
 	                   /etc/sysconfig/network-scripts/route-eth1
+	                   /etc/sysconfig/network-scripts/route6-eth1
 	                   /etc/sysconfig/network-scripts/ifcfg-eth2
 	                   /etc/sysconfig/network-scripts/route-eth2
+	                   /etc/sysconfig/network-scripts/route6-eth2
 	                   /etc/sysconfig/network-scripts/ifcfg-eth3
 	                   /etc/sysconfig/network-scripts/route-eth3
+	                   /etc/sysconfig/network-scripts/route6-eth3
 	                   /etc/sysconfig/network/ifcfg-eth0
 	                   /etc/sysconfig/network/ifroute-eth0
 	                   /etc/sysconfig/network/ifcfg-eth1
diff --git a/src/test/test-centos6-002/etc/sysconfig/network-scripts/ifcfg-eth0.exp b/src/test/test-centos6-002/etc/sysconfig/network-scripts/ifcfg-eth0.exp
index 1935e20..a6cc799 100644
--- a/src/test/test-centos6-002/etc/sysconfig/network-scripts/ifcfg-eth0.exp
+++ b/src/test/test-centos6-002/etc/sysconfig/network-scripts/ifcfg-eth0.exp
@@ -7,4 +7,3 @@ GATEWAY=4.3.2.1
 IPV6INIT=yes
 IPV6_AUTOCONF=no
 IPV6ADDR=2000::1/64
-IPV6_DEFAULTGW=20ff::1
diff --git a/src/test/test-centos6-002/etc/sysconfig/network-scripts/route-eth0.exp b/src/test/test-centos6-002/etc/sysconfig/network-scripts/route-eth0.exp
index 6bf6cbb..144a9c1 100644
--- a/src/test/test-centos6-002/etc/sysconfig/network-scripts/route-eth0.exp
+++ b/src/test/test-centos6-002/etc/sysconfig/network-scripts/route-eth0.exp
@@ -1,6 +1,4 @@
 # --- BEGIN PVE ---
 4.3.2.1 dev eth0
-default via 4.3.2.1
-20ff::1 dev eth0
-default via 20ff::1
+default via 4.3.2.1 dev eth0
 # --- END PVE ---
diff --git a/src/test/test-centos6-002/etc/sysconfig/network-scripts/route6-eth0.exp b/src/test/test-centos6-002/etc/sysconfig/network-scripts/route6-eth0.exp
new file mode 100644
index 0000000..e11687a
--- /dev/null
+++ b/src/test/test-centos6-002/etc/sysconfig/network-scripts/route6-eth0.exp
@@ -0,0 +1,4 @@
+# --- BEGIN PVE ---
+20ff::1 dev eth0
+default via 20ff::1 dev eth0
+# --- END PVE ---
-- 
2.1.4





More information about the pve-devel mailing list