pf-tools/pf-tools: calculate gateway correctly when declared as ...

parmelan-guest at users.alioth.debian.org parmelan-guest at users.alioth.debian.org
Mon Sep 15 10:56:50 UTC 2014


details:   http://hg.debian.org/hg/pf-tools/pf-tools/rev/0d83e985d181
changeset: 1334:0d83e985d181
user:      shad
date:      Mon Sep 15 11:43:39 2014 +0200
description:
calculate gateway correctly when declared as an IP and not only as an offset

diffstat:

 debian/control                                      |   2 +-
 lib/PFTools/Conf/Network.pm                         |  11 +++++++++--
 t/13.conf.cfg1/config-export/COMMON/private-network |   2 +-
 t/13.conf.t                                         |   2 +-
 4 files changed, 12 insertions(+), 5 deletions(-)

diffs (64 lines):

diff -r d8dd435541a3 -r 0d83e985d181 debian/control
--- a/debian/control	Fri Sep 12 17:31:42 2014 +0200
+++ b/debian/control	Mon Sep 15 11:43:39 2014 +0200
@@ -8,7 +8,7 @@
 
 Package: pf-tools
 Architecture: all
-Depends: perl, perl (>= 5.10.0) | libmd5-perl, libclone-perl, libconfig-inifiles-perl, liblist-moreutils-perl, libhash-merge-simple-perl, libmodule-runtime-perl, libnetaddr-ip-perl, libnet-dns-perl, libproc-reliable-perl, libreadonly-xs-perl, libreadonly-xs-perl, libtemplate-tiny-perl, libtext-diff-perl, mercurial | subversion | cvs , ssh, iproute | iproute2, debconf, psmisc
+Depends: perl, perl (>= 5.10.0) | libmd5-perl, libclone-perl, libconfig-inifiles-perl, liblist-moreutils-perl, libhash-merge-simple-perl, libmodule-runtime-perl, libnetaddr-ip-perl, libnet-dns-perl, libproc-reliable-perl, libreadonly-xs-perl, libreadonly-xs-perl, libregexp-common-perl, libtemplate-tiny-perl, libtext-diff-perl, mercurial | subversion | cvs , ssh, iproute | iproute2, debconf, psmisc
 Description: Outils de gestion de la plateforme
  Mise a jour automatique et generation de conf.
  Deploiement de machines.
diff -r d8dd435541a3 -r 0d83e985d181 lib/PFTools/Conf/Network.pm
--- a/lib/PFTools/Conf/Network.pm	Fri Sep 12 17:31:42 2014 +0200
+++ b/lib/PFTools/Conf/Network.pm	Mon Sep 15 11:43:39 2014 +0200
@@ -37,6 +37,7 @@
 use English qw( -no_match_vars );    # Avoids regex performance penalty
 use List::MoreUtils qw( uniq );
 use Readonly;
+use Regexp::Common;
 
 use PFTools::Logger;
 use PFTools::Net;
@@ -267,8 +268,14 @@
             # something like '109.3.20.225-255'
             my $prefix = $subnet_ref->prefix();
             $prefix =~ s{ \d+-[\d.]+ }{}xms;
-            my $ip_gw
-                = NetAddr::IP->new( $prefix . $gateway, $subnet_ref->mask() );
+            my $ip_gw;
+            if ( $gateway =~ /\A $RE{net}{IPv4} \Z/xms ) {
+                $ip_gw = NetAddr::IP->new( $gateway, $subnet_ref->mask() );
+            }
+            else {
+                $ip_gw = NetAddr::IP->new( $prefix . $gateway,
+                    $subnet_ref->mask() );
+            }
             if ( !$ip_gw ) {
                 croak
                     qq{ERROR: Invalid $ip_type gateway $gateway in $section_name};
diff -r d8dd435541a3 -r 0d83e985d181 t/13.conf.cfg1/config-export/COMMON/private-network
--- a/t/13.conf.cfg1/config-export/COMMON/private-network	Fri Sep 12 17:31:42 2014 +0200
+++ b/t/13.conf.cfg1/config-export/COMMON/private-network	Mon Sep 15 11:43:39 2014 +0200
@@ -89,7 +89,7 @@
     network = 10.3.2.0/24
     tag     = 372
     scope   = private
-    gateway = 254
+    gateway = 10.3.2.254
 
 [admins]
     type    = service
diff -r d8dd435541a3 -r 0d83e985d181 t/13.conf.t
--- a/t/13.conf.t	Fri Sep 12 17:31:42 2014 +0200
+++ b/t/13.conf.t	Mon Sep 15 11:43:39 2014 +0200
@@ -576,7 +576,7 @@
         'type'    => 'network',
     },
     'vlan-middledsi' => {
-        'gateway' => '254',
+        'gateway' => '10.3.2.254',
         'network' => '10.3.2.0/24',
         'scope'   => 'private',
         'site'    => 'cbv4-pfds',



More information about the pf-tools-commits mailing list