pf-tools commit: r595 [ccaillet-guest] - in /trunk: TODO lib/PFTools/Bridge.pm

parmelan-guest at users.alioth.debian.org parmelan-guest at users.alioth.debian.org
Fri May 23 10:46:07 UTC 2008


Author: ccaillet-guest
Date: Fri May 23 10:46:07 2008
New Revision: 595

URL: http://svn.debian.org/wsvn/pf-tools/?sc=1&rev=595
Log:
ajout dans le TODO

Modified:
    trunk/TODO
    trunk/lib/PFTools/Bridge.pm

Modified: trunk/TODO
URL: http://svn.debian.org/wsvn/pf-tools/trunk/TODO?rev=595&op=diff
==============================================================================
--- trunk/TODO (original)
+++ trunk/TODO Fri May 23 10:46:07 2008
@@ -1,6 +1,8 @@
 /--Priority: Low/Medium/Urgent
 |/-Difficulty: Easy/Medium/Hard
 ||
+UM Bug lors de la creation de la zone private si multi-site avec IP identique sur chaque site (ANYCAST)
+   alors alias et IP reelle s'ecrase et prise en compte du dernier site
 UM [WIP] convert lib-* to real packages; use strict and use warnings everywhere
 UE check that all mandatory entries are defined (ie: tag)
 UM use Net::IP for ipstart.* and check it is ok wrt the subnet declaration

Modified: trunk/lib/PFTools/Bridge.pm
URL: http://svn.debian.org/wsvn/pf-tools/trunk/lib/PFTools/Bridge.pm?rev=595&op=diff
==============================================================================
--- trunk/lib/PFTools/Bridge.pm (original)
+++ trunk/lib/PFTools/Bridge.pm Fri May 23 10:46:07 2008
@@ -62,6 +62,7 @@
 my $vconf_cmd	= '/sbin/vconfig' ;
 
 my $DEBUG	= 1 ;
+my $IFNAMSIZ	= 16 ;
 my $VLAN_MTU	= 1496 ;
 my $ETHTRUNK	= 'eth1' ;
 my $XEN_CFG_DIR = '' ;
@@ -70,7 +71,7 @@
 sub Sysexec ($) {
 	my ( $cmd ) = @_ ;
 	
-	print "Executing command ".$cmd."\n" ;
+	print "DEBUG --> Executing command ".$cmd."\n" ;
 	system ( $cmd ) if ( ! $DEBUG );
 	if ( $? ) {
 		if ( $? == -1 ) {
@@ -85,6 +86,17 @@
 		}
 	}
 	return 1 ;
+}
+
+sub Sanitize_bridge_name ($) {
+	my ( $br_name ) = @_ ;
+	
+	if ( length ( $br_name ) > $IFNAMSIZ - 1 ) {
+		print "Sanitizing bridge name from ".$br_name." to " if ( $DEBUG ) ;
+		$br_name = substr ( $br_name, length ( $br_name ) - $IFNAMSIZ + 1 );
+		print $br_name."\n" if ( $DEBUG ) ;
+	}
+	return $br_name ;
 }
 
 sub Get_all_bridges () {
@@ -121,7 +133,7 @@
 	my ( $br_name, $br_list ) = @_ ;
 
 	my ( $hostname, $tag ) = split ( /\./, $br_name ) ;
-	return grep /^$br_name$/, @{$br_list->{'br.'.$tag}->{'iface'}} ;
+	return grep /^$br_name$/, @{$br_list->{'br'.$tag}->{'iface'}} ;
 }
 
 sub Mk_primary_bridge ($) {
@@ -130,43 +142,46 @@
 	my $tag		= $1 ;
 
 	# Adding bridge
+	print "Creating primary bridge ".$primary."\n" if ( $DEBUG ) ;
 	my $cmd = $brctl_cmd." addbr ".$primary ;
 	if ( ! Sysexec ( $cmd ) ) {
 		warn "Unable to add primary bridge ".$primary."\n" ;
 		return 0 ;
 	}
 	# Setting spanning tree on bridge off
+	print "Setting up sapnning tree off for primary bridge ".$primary."\n" if ( $DEBUG ) ;
 	if ( ! Sysexec ( $brctl_cmd." stp ".$primary." off " ) ) {
 		warn "Unable to deactivate spanning tree protocol on ".$primary."\n" ;
 	}
 	# Setting some timeout on bridge
+	print "Setting up some timeout on primary bridge ".$primary."\n" if ( $DEBUG ) ;
 	foreach my $act ( 'setfd', 'sethello' ) {
 		if ( ! Sysexec ( $brctl_cmd." ".$act." ".$primary." 1" ) ) {
 			warn "Unablr to set timeout for action ".$act." on bridge ".$primary."\n" ;
 		}
 	}
-	
+	print "Checking if TRUNK is configured for vlan tagged as ".$tag."\n" if ( $DEBUG ) ;
 	if ( ! Sysexec ( $ip_cmd." addr show dev ".$ETHTRUNK.".".$tag ) ) {
-		print "Need to add vlan tagged as ".$tag." on iface ".$ETHTRUNK."\n" ;
 		if ( ! Sysexec ( $vconf_cmd."set_name_type DEV_PLUS_VID_NO_PAD" ) ) {
 			warn "Unable to set_name_type for vconfig creation\n" ;
 		}
+		print "Adding vlan tagged as ".$tag." on trunk interface ".$ETHTRUNK."\n" if ( $DEBUG ) ;
 		if ( ! Sysexec ( $vconf_cmd." add ".$ETHTRUNK." ".$tag ) ) {
 			warn "Unable to add vlan tagged as ".$tag." on ".$ETHTRUNK."\n" ;
 			return 0 ;
 		}
-		print "Activating promiscuous mode for ".$ETHTRUNK.".".$tag."\n" ;
+		print "Activating promiscuous mode for ".$ETHTRUNK.".".$tag."\n" if ( $DEBUG ) ;
 		if ( ! Sysexec ( $ip_cmd." link set ".$ETHTRUNK.".".$tag." up promisc on mtu ".$VLAN_MTU ) ) {
 			warn "Unable to set promiscuous mode and mtu on interface ".$ETHTRUNK.".".$tag."\n" ;
 			return 0 ;
 		}
-		print "Setting ip address for ".$ETHTRUNK.".".$tag."\n" ;
+		print "Setting ip address for ".$ETHTRUNK.".".$tag."\n" if ( $DEBUG ) ;
 		if ( ! Sysexec ( $ip_cmd." addr add 0.0.0.0 dev ".$ETHTRUNK.".".$tag ) ) {
 			warn "Unable to set ip address for ".$ETHTRUNK.".".$tag."\n" ;
 			return 0 ;
 		}
 	}
-	print "Attaching primary bridge ".$primary." to ".$ETHTRUNK.".".$tag."\n" ;
+	print "Attaching primary bridge ".$primary." to ".$ETHTRUNK.".".$tag."\n" if ( $DEBUG ) ;
 	return Sysexec ( $brctl_cmd." addif ".$primary." ".$ETHTRUNK.".".$tag ) ;
 }
 
@@ -174,7 +189,7 @@
 	my ( $primary, $ref_brlist ) = @_ ;
 	
 	if ( ! defined $ref_brlist ) {
-		print "Need to retrive bridges configuration on host\n" ;
+		print "Need to retrieve bridges configuration on host\n" if ( $DEBUG ) ;
 		$ref_brlist = Get_all_bridges () ;
 		if ( ! defined $ref_brlist ) {
 			warn "Unable to retrieve briges list : unable to remove primary bridge ".$primary."\n" ;
@@ -197,6 +212,7 @@
 sub Detach_host_bridge ($$) {
 	my ( $br_name, $primary ) = @_ ;
 	
+	print "Detaching bridge ".$br_name." from primary ".$primary."\n" if ( $DEBUG ) ;
 	my $cmd = $brctl_cmd." delif ".$primary." ".$br_name ;
 	return Sysexec ( $cmd ) ;
 }
@@ -204,6 +220,7 @@
 sub Attach_host_bridge ($$) {
 	my ( $br_name, $primary ) = @_ ;
 	
+	print "Attaching bridge ".$br_name." to primary bridge ".$primary."\n" if ( $DEBUG ) ;
 	my $cmd = $brctl_cmd." addif ".$primary." ".$br_name ;
 	return Sysexec ( $cmd ) ;
 }
@@ -212,31 +229,31 @@
 	my ( $hostname, $tag ) = @_ ;
 	my $primary = "br".$tag ;
 
-	my $cmd = $tunctl_cmd." -b -u ".$XEN_USER." -t ".$hostname.".".$tag ;
+	my $br_name = Sanitize_bridge_name ( $hostname.".".$tag ) ;
+	my $cmd = $tunctl_cmd." -b -u ".$XEN_USER." -t ".$br_name ;
 	if ( ! Bridge_primary_exist ( $primary ) ) {
-		print "Need to create primary bridge ".$primary."\n" if ( $DEBUG ) ;
 		if ( ! Mk_primary_bridge ( $primary ) ) {
 			warn "Unable to create primary bridge ".$primary."\n" ;
-			return 0 ;
-		}
-	}
+			return undef ;
+		}
+	}
+	print "Adding host TUN/TAP interface ".$br_name."\n" if ( $DEBUG ) ;
 	if ( ! Sysexec ( $cmd ) ) {
-		warn "Unable to add host bridge ".$hostname.".".$tag."\n" ;
-		return 0 ;
-	}
-	print "Attaching new TUN/TAP ".$hostname.".".$tag." to primary bridge ".$primary."\n" ;
-	return Attach_host_bridge ( $primary, $hostname.".".$tag ) ;
+		warn "Unable to add host bridge ".$br_name."\n" ;
+		return undef ;
+	}
+	return $br_name ;
 }
 
 sub Del_host_bridge ($$) {
 	my ( $hostname, $tag ) = @_ ;
 	my $primary = "br".$tag ;
 
-	print "Need to detach ".$hostname.".".$tag." from the primary bridge\n" ;
 	if ( ! Detach_host_bridge ( $hostname.".".$tag, $primary ) ) {
 		warn "Unable to detach ".$hostname.".".$tag." from ".$primary."\n" ;
 		return 0 ;
 	}
+	print "Deleting host bridge ".$hostname.".".$tag."\n" if ( $DEBUG ) ;
 	return Sysexec ( $tunctl_cmd." -b -d ".$hostname.".".$tag ) ;
 }
 
@@ -258,6 +275,7 @@
 		if ( ! Bridge_exist ( $hostname.'.'.$tag, $ref_brlist ) ) {
 			print "Need to create bridge ".$hostname.".".$tag."\n" ;
 			Add_host_bridge ( $hostname, $tag ) ;
+			Attach_host_bridge ( 'br'.$tag, $hostname.".".$tag ) ;
 		} else {
 			print "Bridge ".$hostname.".".$tag." already exists\n" ;
 		}




More information about the pf-tools-commits mailing list