pf-tools/pf-tools: same behaviour for ipv4 than gateway: can tak...

parmelan-guest at users.alioth.debian.org parmelan-guest at users.alioth.debian.org
Wed Sep 24 11:47:45 UTC 2014


details:   http://hg.debian.org/hg/pf-tools/pf-tools/rev/3e6bd2de80a4
changeset: 1336:3e6bd2de80a4
user:      shad
date:      Wed Sep 24 13:47:40 2014 +0200
description:
same behaviour for ipv4 than gateway: can take complete ip or offset

diffstat:

 doc/hostfile-syntax                                                 |   4 +-
 doc/networkfile-syntax                                              |   8 +++---
 lib/PFTools/Conf/Host.pm                                            |  11 ++++++++-
 t/13.conf.cfg1/config-export/SITE/cbv4/CONFIG/hostfile-cbv4-rdeploy |   2 +-
 4 files changed, 16 insertions(+), 9 deletions(-)

diffs (80 lines):

diff -r e9a9a1e54c3f -r 3e6bd2de80a4 doc/hostfile-syntax
--- a/doc/hostfile-syntax	Mon Sep 15 12:58:04 2014 +0200
+++ b/doc/hostfile-syntax	Wed Sep 24 13:47:40 2014 +0200
@@ -5,8 +5,8 @@
 	? slaves[.%HOSTNUM%]		::= comma separated list of <IFACE>, WARNING this directive is mandatory if type[.%HOSTNUM%] is defined
 					    as a bonding interface will be ignored if type[.%HOSTNUM%] is not
 	? options[.%HOSTNUM%]		::= see interfaces docs for misc options
-	! ipv4[.%HOSTNUM%]		::= <IPV4_ADDR> if default is used then act as old ipstart directive
-	? ipv6[.%HOSTNUM%]		::= <IPV6_ADDR> if default is used then act as old ipstart directive
+	! ipv4[.%HOSTNUM%]		::= <IPV4_ADDR> or offset. If default is used then act as old ipstart directive
+	? ipv6[.%HOSTNUM%]		::= <IPV6_ADDR> or offset. If default is used then act as old ipstart directive
 	? iface_opt[%HOSTNUM%]		::= <IFACE_OPT> define here iface options (ip link syntax)
 	? @route[.default|%HOSTNUM%]	::= <SUBNET>/<NETMASK> [via <GATEWAY>] (ip route syntax)
 	? @route6[.default|%HOSTNUM%]	::= <SUBNET>/<NETMASK> [via <GATEWAY>] (ip route syntax)
diff -r e9a9a1e54c3f -r 3e6bd2de80a4 doc/networkfile-syntax
--- a/doc/networkfile-syntax	Mon Sep 15 12:58:04 2014 +0200
+++ b/doc/networkfile-syntax	Wed Sep 24 13:47:40 2014 +0200
@@ -32,9 +32,9 @@
 	! network	::= <NETWORK> define here the network in IPv4 format in CIDR format
 	? network6	::= <NETWORK> define here the prefix in IPv6 format in CIDR format
 	! scope		::= private|public, if private is defined this network will be ONLY added on zone private for site
-	? gateway	::= <IPV4>
+	? gateway	::= <IPV4_ADDR> or offset
 # TODO
-#	? gateway6	::= <IPV4>
+#	? gateway6	::= <IPV6_ADDR> or offset
 
 [<SERVER_NAME>]
 	! type							::= server
@@ -42,8 +42,8 @@
 	! site							::= <STR>
 	! number						::= <INT>
 	? nodes							::= <INT>
-	! ipv4.<VLAN_NAME>[.%HOSTNUM%]	::= <IPV4>
-	? ipv6.<VLAN_NAME>[.%HOSTNUM%]	::= <IPV6>
+	! ipv4.<VLAN_NAME>[.%HOSTNUM%]	::= <IPV4_ADDR>
+	? ipv6.<VLAN_NAME>[.%HOSTNUM%]	::= <IPV6_ADDR>
 	? alias.<NAME>[.%HOSTNUM%]		::= <NETWORK_NAME>
 	? shortname[.%HOSTNUM%]			::= <NETWORK_NAME>
 
diff -r e9a9a1e54c3f -r 3e6bd2de80a4 lib/PFTools/Conf/Host.pm
--- a/lib/PFTools/Conf/Host.pm	Mon Sep 15 12:58:04 2014 +0200
+++ b/lib/PFTools/Conf/Host.pm	Wed Sep 24 13:47:40 2014 +0200
@@ -37,6 +37,7 @@
 use List::MoreUtils qw( any );
 use POSIX qw(ceil floor);
 use Readonly;
+use Regexp::Common;
 
 use PFTools::Conf::Syntax qw( $DEF_SECTIONS );
 use PFTools::Net;
@@ -609,8 +610,14 @@
     # something like '109.3.20.225-255'
     my $prefix = $subnet_ref->prefix();
     $prefix =~ s{ \d+-[\d.]+ }{}xms;
-    my $ip_address
-        = NetAddr::IP->new( $prefix . $ipstart, $subnet_ref->mask() );
+    my $ip_address;
+    if ( $ipstart =~ /\A $RE{net}{IPv4} \Z/xms ) {
+        $ip_address = NetAddr::IP->new( $ipstart, $subnet_ref->mask() );
+    }
+    else {
+        $ip_address
+            = NetAddr::IP->new( $prefix . $ipstart, $subnet_ref->mask() );
+    }
     if ( !$ip_address ) {
         croak
             qq{ERROR: Invalid IP with prefix='$prefix' and ipstart='$ipstart'};
diff -r e9a9a1e54c3f -r 3e6bd2de80a4 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	Mon Sep 15 12:58:04 2014 +0200
+++ b/t/13.conf.cfg1/config-export/SITE/cbv4/CONFIG/hostfile-cbv4-rdeploy	Wed Sep 24 13:47:40 2014 +0200
@@ -6,7 +6,7 @@
 
 [link::vlan-systeme]
 	dev = eth0
-	ipv4 = 167.0
+	ipv4 = 10.1.167.0
 	mac.0 = 00:1e:c9:ff:08:e4
 	mac.1 = 00:1e:c9:ff:42:0b
 



More information about the pf-tools-commits mailing list