pf-tools/pf-tools: 4 new changesets

parmelan-guest at users.alioth.debian.org parmelan-guest at users.alioth.debian.org
Mon Jan 5 15:15:32 UTC 2015


details:   http://hg.debian.org/hg/pf-tools/pf-tools/rev/83b155e9c3f9
changeset: 1424:83b155e9c3f9
user:      shad
date:      Mon Jan 05 13:42:31 2015 +0100
description:
fix test

details:   http://hg.debian.org/hg/pf-tools/pf-tools/rev/ae5eeff32d89
changeset: 1425:ae5eeff32d89
user:      shad
date:      Mon Jan 05 14:54:47 2015 +0100
description:
resolv gateway before interting in /etc/networking (the number of parameter become more and more ridiculous)

details:   http://hg.debian.org/hg/pf-tools/pf-tools/rev/ca962feb9df0
changeset: 1426:ca962feb9df0
user:      shad
date:      Mon Jan 05 14:55:52 2015 +0100
description:
add test for non-default routes

details:   http://hg.debian.org/hg/pf-tools/pf-tools/rev/b077d59a9dad
changeset: 1427:b077d59a9dad
user:      shad
date:      Mon Jan 05 16:14:56 2015 +0100
description:
changelog

diffstat:

 debian/changelog                                                       |   1 +
 lib/PFTools/Utils.pm                                                   |  32 ++++++++-
 t/13.conf.cfg1/config-export/SITE/cbv4-pfds/CONFIG/hostfile-cbv4-spawn |   1 +
 t/13.conf.cfg1/config-export/SITE/cbv4/CONFIG/hostfile-cbv4-rdeploy    |   1 -
 t/13.conf.t                                                            |   7 +-
 t/20.files.t                                                           |   3 +-
 6 files changed, 35 insertions(+), 10 deletions(-)

diffs (150 lines):

diff -r 60907fe0b548 -r b077d59a9dad debian/changelog
--- a/debian/changelog	Wed Dec 31 15:35:28 2014 +0100
+++ b/debian/changelog	Mon Jan 05 16:14:56 2015 +0100
@@ -2,6 +2,7 @@
 
   * update templates, default conf
   * pull repository first in case of rspawn
+  * resolve gateway when using named @route
 
  -- Stéphane Pontier <shad at sitadelle.com>  Wed, 31 Dec 2014 13:10:06 +0100
 
diff -r 60907fe0b548 -r b077d59a9dad lib/PFTools/Utils.pm
--- a/lib/PFTools/Utils.pm	Wed Dec 31 15:35:28 2014 +0100
+++ b/lib/PFTools/Utils.pm	Mon Jan 05 16:14:56 2015 +0100
@@ -1399,13 +1399,15 @@
     my $routes     = {};
     foreach my $iface ( 'lo', sort keys %{ $host_ref->{'interfaces'} } ) {
         push @{ $interfaces->{'__order'} }, $iface;
-        $interfaces->{$iface}
-            = __build_interface_lines_ref( $iface, $routes, $host_ref,
-            $pf_config, $domain, @nameservers );
+        $interfaces->{$iface} = __build_interface_lines_ref(
+            $hostname,  $site_name, $global_config,
+            $iface,     $routes,    $host_ref,
+            $pf_config, $domain,    @nameservers
+        );
     }
 
 DESTINATION:
-    foreach my $dest ( keys %{$routes} ) {
+    foreach my $dest ( sort keys %{$routes} ) {
 
         # Multiple routes
         if ( scalar @{ $routes->{$dest} } > 1 ) {
@@ -1463,7 +1465,10 @@
 =cut
 
 sub __build_interface_lines_ref {
-    my ( $iface, $routes, $host_ref, $pf_config, $domain, @nameservers ) = @_;
+    my ($hostname,  $site_name, $global_config,
+        $iface,     $routes,    $host_ref,
+        $pf_config, $domain,    @nameservers
+    ) = @_;
 
     my @iface_lines;
 
@@ -1490,6 +1495,10 @@
         push @iface_lines, qq{\tslaves\t\t} . $if_part->{'slaves'};
     }
 
+    my $hosttype
+        = get_hosttype_from_hostname( $hostname, $global_config, $site_name );
+    my $subst_ref = init_subst( $hostname, $hosttype, $pf_config );
+    my $site_ref = get_site_config( $site_name, $global_config );
     foreach my $ip_type ( 'ipv4', 'ipv6' ) {
         next if not $pf_config->{'features'}->{$ip_type};
         next if not $if_part->{$ip_type};
@@ -1512,13 +1521,24 @@
         }
 
         # Routes
-        # FIXME add test cases in t/* for non-default routes
         my $suffix = get_suffix_from_ip_type($ip_type);
         foreach my $route ( @{ $if_part->{ '@route' . $suffix } } )
         {    ## no critic(RequireInterpolationOfMetachars);
             if ($route =~ m{ \A \s* (\S+) \s* (?: via \s* \S+ )? \s* \z }xms )
             {
                 my $destination = $1;
+                my @resroute    = __search_and_replace_ip(
+                    {   line          => $route,
+                        hostname      => $hostname,
+                        ip_type       => $ip_type,
+                        site_name     => $site_name,
+                        subst_ref     => $subst_ref,
+                        host_ref      => $host_ref,
+                        site_ref      => $site_ref,
+                        global_config => $global_config,
+                    }
+                );
+                $route = $resroute[0];
                 push @{ $routes->{$destination} }, qq{$iface $route};
             }
         }
diff -r 60907fe0b548 -r b077d59a9dad t/13.conf.cfg1/config-export/SITE/cbv4-pfds/CONFIG/hostfile-cbv4-spawn
--- a/t/13.conf.cfg1/config-export/SITE/cbv4-pfds/CONFIG/hostfile-cbv4-spawn	Wed Dec 31 15:35:28 2014 +0100
+++ b/t/13.conf.cfg1/config-export/SITE/cbv4-pfds/CONFIG/hostfile-cbv4-spawn	Mon Jan 05 16:14:56 2015 +0100
@@ -59,3 +59,4 @@
 #	slaves = eth1,eth2
 #	@route = default via GATEWAY
 #	vlan = vlan-pfds-ext
+	@route = 1.2.3.4 via cbv4-rdeploy00.vlan-public2.private
diff -r 60907fe0b548 -r b077d59a9dad t/13.conf.cfg1/config-export/SITE/cbv4/CONFIG/hostfile-cbv4-rdeploy
--- a/t/13.conf.cfg1/config-export/SITE/cbv4/CONFIG/hostfile-cbv4-rdeploy	Wed Dec 31 15:35:28 2014 +0100
+++ b/t/13.conf.cfg1/config-export/SITE/cbv4/CONFIG/hostfile-cbv4-rdeploy	Mon Jan 05 16:14:56 2015 +0100
@@ -28,4 +28,3 @@
 	dev.0   = eth2
 	dev.1   = NONE
 	ipv4    = 44
-
diff -r 60907fe0b548 -r b077d59a9dad t/13.conf.t
--- a/t/13.conf.t	Wed Dec 31 15:35:28 2014 +0100
+++ b/t/13.conf.t	Mon Jan 05 16:14:56 2015 +0100
@@ -751,6 +751,7 @@
         'type'  => 'bond',
         '@route' => [
             'default via GATEWAY',
+            '1.2.3.4 via cbv4-rdeploy00.vlan-public2.private',
         ],
         'dev'     => 'bond0',
         'ipv4'    => '97',
@@ -991,7 +992,8 @@
                                         'options' => 'miimon=100,mode=active-backup',
                                         'slaves'  => 'eth2 eth3',
                                         '@route'  => [
-                                            'default via 192.168.1.254'
+                                            'default via 192.168.1.254',
+                                            '1.2.3.4/32 via cbv4-rdeploy00.vlan-public2.private',
                                         ],
                                         'vlan' => 'vlan-pfds-ext'
                                     },
@@ -1042,7 +1044,8 @@
                                         'options' => 'miimon=100,mode=active-backup',
                                         'slaves'  => 'eth2 eth3',
                                         '@route'  => [
-                                            'default via 192.168.1.254'
+                                            'default via 192.168.1.254',
+                                            '1.2.3.4/32 via cbv4-rdeploy00.vlan-public2.private',
                                         ],
                                         'vlan' => 'vlan-pfds-ext'
                                     },
diff -r 60907fe0b548 -r b077d59a9dad t/20.files.t
--- a/t/20.files.t	Wed Dec 31 15:35:28 2014 +0100
+++ b/t/20.files.t	Mon Jan 05 16:14:56 2015 +0100
@@ -530,6 +530,7 @@
     qq{\tbroadcast\t192.168.1.255},
     qq{\tup\t\t/sbin/ip link set bond0 miimon=100},
     qq{\tup\t\t/sbin/ip link set bond0 mode=active-backup},
+    qq{\tup\t\t/sbin/ip route add 1.2.3.4/32 via 80.125.164.44 dev bond0},
     qq{\tgateway\t\t192.168.1.254},
     qq{},
     qq{auto eth0},
@@ -963,7 +964,7 @@
 
 LABEL linux
 \tkernel amd64/vmlinuz-2.6.26.5-universal-grm2.1.12
-\tappend vga=normal root=/dev/sda2 -- default pci=bfsort
+\tappend root=/dev/sda2 -- default pci=bfsort
 
 PROMPT 1
 TIMEOUT 100



More information about the pf-tools-commits mailing list