pf-tools/pf-tools: 2 new changesets

parmelan-guest at users.alioth.debian.org parmelan-guest at users.alioth.debian.org
Thu Dec 18 16:00:42 UTC 2014


details:   http://hg.debian.org/hg/pf-tools/pf-tools/rev/2b137abcb230
changeset: 1408:2b137abcb230
user:      shad
date:      Thu Dec 18 15:03:44 2014 +0100
description:
dont prevent several core site

details:   http://hg.debian.org/hg/pf-tools/pf-tools/rev/18aa85641ba6
changeset: 1409:18aa85641ba6
user:      shad
date:      Thu Dec 18 17:00:33 2014 +0100
description:
merge

diffstat:

 lib/PFTools/Conf/Host.pm    |  61 ++++++++++++++++++++++++++++----------------
 lib/PFTools/Conf/Network.pm |  22 ++-------------
 lib/PFTools/Net.pm          |   4 +-
 t/13.conf.t                 |   6 +++-
 4 files changed, 49 insertions(+), 44 deletions(-)

diffs (212 lines):

diff -r 0bac6a644238 -r 18aa85641ba6 lib/PFTools/Conf/Host.pm
--- a/lib/PFTools/Conf/Host.pm	Thu Dec 18 11:33:34 2014 +0100
+++ b/lib/PFTools/Conf/Host.pm	Thu Dec 18 17:00:33 2014 +0100
@@ -182,7 +182,6 @@
                         hostnum       => $hostnum,
                         hostnode      => $hostnode,
                         host_ref      => $host_ref,
-                        link_list_ref => \@link_list,
                         site_name     => $site,
                         site_ref      => $site_part_ref,
                         pf_config     => $pf_config,
@@ -618,16 +617,30 @@
     my $prefix = $subnet_ref->prefix();
     $prefix =~ s{ \d+-[\d.]+ }{}xms;
     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'};
+    if ($prefix) {
+        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'};
+        }
+    } 
+    elsif ($subnet_ref->{isv6}) {
+        my @subnet_oct = split /:/, $subnet_ref->addr;
+        my @last_oct = split /:/, $ipstart;
+
+        my $index = -1;
+        while (my $oct = pop @last_oct) {
+            $subnet_oct[$index] = $oct;
+            $index --;
+        }
+        my $ip_v6 = join ':', @subnet_oct;
+        $ip_address = NetAddr::IP->new( $ip_v6, $subnet_ref->mask());
     }
 
     if ($hostnum) {
@@ -700,13 +713,10 @@
             next;
         }
 
-        # FIXME this obviously does not handle IPv6
         if ( $key_type =~ m{ \A ipv }xms ) {
             my $suffix = $hostnum ? qq{\.$hostnum} : q{};
-            $result->{qq{link::$spec}}->{qq{dev$suffix}}
-                = qq{eth$iface_index};
-            $result->{qq{link::$spec}}->{qq{ipv4$suffix}}
-                = $server_ref->{$key};
+            $result->{qq{link::$spec}}->{qq{dev$suffix}} = qq{eth$iface_index};
+            $result->{qq{link::$spec}}->{qq{${key_type}${suffix}}} = $server_ref->{$key};
             $iface_index++;
             next;
         }
@@ -759,11 +769,11 @@
 
     my @argument_names = qw(
         link_name   hostname   hostnum
-        hostnode    host_ref   link_list_ref
-        site_name   site_ref   pf_config
+        hostnode    host_ref   site_name
+        site_ref    pf_config
     );
     my ($link_name, $hostname, $hostnum,
-        $hostnode,  $host_ref, $link_list_ref,
+        $hostnode,  $host_ref, 
         $site_name, $site_ref, $pf_config
     ) = @{$arguments_ref}{@argument_names};
 
@@ -869,6 +879,7 @@
         }
     }
 
+    my $ip_found = 0;
     # Check address and route values
     foreach my $ip_type (qw( ipv4 ipv6 )) {
         next if not $pf_config->{'features'}->{$ip_type};
@@ -891,10 +902,10 @@
             );
         };
         if ($EVAL_ERROR) {
-            print $EVAL_ERROR; # not beautiful but we get why ip attribution failed
-            croak
-                qq{ERROR: No $ip_type defined for $hostname on $iface_name (vlan: $vlan_name)};
+            #print $EVAL_ERROR; # not beautiful but we get why ip attribution failed
+            next
         }
+        $ip_found = 1;
 
         my $suffix    = get_suffix_from_ip_type($ip_type);
         my $route_key = '@route' . $suffix;
@@ -924,6 +935,10 @@
         }
     }
 
+    if (!$ip_found) {
+        croak qq{ERROR: No ip defined for $hostname on $iface_name (vlan: $vlan_name)};
+    }
+
     return $result;
 }
 
@@ -979,7 +994,7 @@
         = $link_section_ref->{$ip_type_dot_host_number} ? 0 : $nodes;
 
     if ( !defined $ipstart ) {
-        croak qq{ERROR: No $ip_type defined};
+        return;
     }
     my $params_ref = {
         ip_type    => $ip_type,
diff -r 0bac6a644238 -r 18aa85641ba6 lib/PFTools/Conf/Network.pm
--- a/lib/PFTools/Conf/Network.pm	Thu Dec 18 11:33:34 2014 +0100
+++ b/lib/PFTools/Conf/Network.pm	Thu Dec 18 17:00:33 2014 +0100
@@ -143,13 +143,7 @@
     }
 
     if ( $section_ref->{'state'} eq 'ROOT' ) {
-        if ( $global_config->{'SITE'}->{'ROOT'} ) {
-            carp
-                qq{WARNING: ROOT site is already defined: skipping $section_name};
-            return;
-        }
-
-        $global_config->{'SITE'}->{'ROOT'} = $section_name;
+        push @{ $global_config->{'SITE'}->{'ROOT'} }, $section_name;
     }
     else {
         push @{ $global_config->{'SITE'}->{'EDGE'} }, $section_name;
@@ -253,8 +247,8 @@
     foreach my $ip_type (qw( ipv4 ipv6 )) {
         next if not $pf_config->{'features'}->{$ip_type};
 
-        my $suffix      = get_suffix_from_ip_type($ip_type);
-        my $subnet_ref  = get_subnet_from_vlan( $ip_type, $section_ref );
+        my $suffix = get_suffix_from_ip_type($ip_type);
+        my $subnet_ref = get_subnet_from_vlan( $ip_type, $section_ref );
 
         next if !$subnet_ref;
 
@@ -293,15 +287,7 @@
 
         foreach my $site ( @{$site_list} ) {
             my $net_part = $site_part->{'BY_NAME'}->{$site}->{'NETWORK'};
-            if ( $net_part->{'BY_NAME'}->{$section_name} ) {
-
-                # FIXME is this not a fatal error?
-                carp
-                    qq{WARNING: file $start_file section $section_name: already defined};
-                next;
-            }
-
-            if ( $tag and $net_part->{'BY_TAG'}->{$tag} ) {
+            if ( $tag and $net_part->{'BY_TAG'}->{$tag} and $net_part->{'BY_TAG'}->{$tag} ne $section_name ) {
                 croak
                     qq{ERROR: File $start_file section $section_name: duplicate tag $tag};
             }
diff -r 0bac6a644238 -r 18aa85641ba6 lib/PFTools/Net.pm
--- a/lib/PFTools/Net.pm	Thu Dec 18 11:33:34 2014 +0100
+++ b/lib/PFTools/Net.pm	Thu Dec 18 17:00:33 2014 +0100
@@ -83,9 +83,9 @@
         $subnet_ref = NetAddr::IP->new($net_def);
     }
     else {
-        my $netmask = $net_hash->{'netmask'};
+        my $netmask = $net_hash->{qq{netmask$suffix}};
         if ( !$netmask ) {
-            croak q{ERROR: Unable to retrieve netmask};
+            croak qq{ERROR: Unable to retrieve netmask$suffix};
         }
         $subnet_ref = NetAddr::IP->new( $net_def, $netmask );
     }
diff -r 0bac6a644238 -r 18aa85641ba6 t/13.conf.t
--- a/t/13.conf.t	Thu Dec 18 11:33:34 2014 +0100
+++ b/t/13.conf.t	Thu Dec 18 17:00:33 2014 +0100
@@ -872,9 +872,11 @@
 qr{ \A ERROR: [ ] Invalid [ ] non-hashref [ ] 'pf_config' }xms
     => q{Dies if non-hashref $pf_config};
 
+print "lala\n";
 $parsed_configuration
     = init_global_netconfig( q{COMMON:private-network}, $test_hash_subst,
     $test_pf_config );
+print "lala\n";
 
 $expected_configuration = {
     'DHCP' => {
@@ -929,7 +931,9 @@
         'EDGE' => [
             'cbv4'
         ],
-        'ROOT'    => 'cbv4-pfds',
+        'ROOT'    => [
+            'cbv4-pfds',
+        ],
         'BY_NAME' => {
             'cbv4-pfds' => {
                 'HOST' => {



More information about the pf-tools-commits mailing list