From 721439469c1146fd283ea219898f4d9b11c0db46 Mon Sep 17 00:00:00 2001 From: An-Cheng Huang Date: Thu, 1 May 2008 14:28:44 -0700 Subject: support "wildcard" ranking at boot time. only VRRP uses this for now. --- scripts/VyattaConfigLoad.pm | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'scripts') diff --git a/scripts/VyattaConfigLoad.pm b/scripts/VyattaConfigLoad.pm index 2efa81e..b69723a 100755 --- a/scripts/VyattaConfigLoad.pm +++ b/scripts/VyattaConfigLoad.pm @@ -44,9 +44,33 @@ my %config_rank = ( 'vpn' => 80, ); +my %wildcard_rank = ( + 'interfaces ethernet * vrrp' => 50, + 'interfaces ethernet * vif * vrrp' => 50, +); + my @all_nodes = (); my @all_naked_nodes = (); +# the wildcard matching could use some serious optimization. but probably +# not when we only have a couple of entries. +sub match_wildcard { + my ($pattern, $str) = @_; + $pattern =~ s/\*/\\S*/g; + $pattern =~ s/^(.*)$/\^$1\$/; + return ($str =~ m/$pattern/) ? 1 : 0; +} + +sub get_wildcard_rank { + my ($str) = @_; + foreach (keys %wildcard_rank) { + if (match_wildcard($_, $str)) { + return $wildcard_rank{$_}; + } + } + return undef; +} + sub get_config_rank { # longest prefix match my @path = @_; @@ -55,6 +79,8 @@ sub get_config_rank { if (defined($config_rank{$path_str})) { return ($config_rank{$path_str}); } + my $wrank = get_wildcard_rank($path_str); + return $wrank if (defined($wrank)); pop @path; } return $default_rank; -- cgit v1.2.3 From 2471813598d00698701b5d6798c0a03d73288488 Mon Sep 17 00:00:00 2001 From: Stig Thormodsrud Date: Mon, 5 May 2008 14:46:30 -0700 Subject: Fix 3233 dhcp client doesn't work on bridge interface --- scripts/vyatta-interfaces.pl | 41 ++++++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 7 deletions(-) (limited to 'scripts') diff --git a/scripts/vyatta-interfaces.pl b/scripts/vyatta-interfaces.pl index aa82b78..020fe28 100755 --- a/scripts/vyatta-interfaces.pl +++ b/scripts/vyatta-interfaces.pl @@ -197,6 +197,21 @@ sub dhcp_get_interfaces { } } } + + $config->setLevel("interfaces bridge"); + my @brs = $config->listNodes(); + foreach my $br (@brs) { + $config->setLevel("interfaces bridge $br"); + if ($config->exists("address")) { + my @addrs = $config->returnValues("address"); + foreach my $addr (@addrs) { + if (defined $addr && $addr eq "dhcp") { + push @dhcp_intfs, $br; + } + } + } + } + return @dhcp_intfs; } @@ -205,10 +220,16 @@ sub is_dhcp_enabled { my $config = new VyattaConfig; - if ($intf =~ m/(\w+)\.(\d)/) { - $config->setLevel("interfaces ethernet $1 vif $2"); + if ($intf =~ m/^eth/) { + if ($intf =~ m/(\w+)\.(\d)/) { + $config->setLevel("interfaces ethernet $1 vif $2"); + } else { + $config->setLevel("interfaces ethernet $intf"); + } + } elsif ($intf =~ m/^br/) { + $config->setLevel("interfaces bridge $intf"); } else { - $config->setLevel("interfaces ethernet $intf"); + die "unsupported dhcp interface [$intf]"; } my @addrs = $config->returnOrigValues("address"); foreach my $addr (@addrs) { @@ -223,11 +244,17 @@ sub is_address_enabled { my $intf = shift; my $config = new VyattaConfig; - - if ($intf =~ m/(\w+)\.(\d)/) { - $config->setLevel("interfaces ethernet $1 vif $2"); + + if ($intf =~ m/^eth/) { + if ($intf =~ m/(\w+)\.(\d)/) { + $config->setLevel("interfaces ethernet $1 vif $2"); + } else { + $config->setLevel("interfaces ethernet $intf"); + } + } elsif ($intf =~ m/^br/) { + $config->setLevel("interfaces bridge $intf"); } else { - $config->setLevel("interfaces ethernet $intf"); + die "unsupported dhcp interface [$intf]"; } my @addrs = $config->returnOrigValues("address"); foreach my $addr (@addrs) { -- cgit v1.2.3 From 762315a293866b7b4c5fc3ca7c7470035a8e3854 Mon Sep 17 00:00:00 2001 From: Stig Thormodsrud Date: Tue, 6 May 2008 14:32:48 -0700 Subject: Only check for dhcp client on eth, vlan, and bridge. --- scripts/vyatta-interfaces.pl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/vyatta-interfaces.pl b/scripts/vyatta-interfaces.pl index 020fe28..ec3a873 100755 --- a/scripts/vyatta-interfaces.pl +++ b/scripts/vyatta-interfaces.pl @@ -229,7 +229,11 @@ sub is_dhcp_enabled { } elsif ($intf =~ m/^br/) { $config->setLevel("interfaces bridge $intf"); } else { - die "unsupported dhcp interface [$intf]"; + # + # currently we only support dhcp on ethernet + # and bridge interfaces. + # + return 0; } my @addrs = $config->returnOrigValues("address"); foreach my $addr (@addrs) { -- cgit v1.2.3 From 07d3641ca62cfede93708d366bb3e5410feba519 Mon Sep 17 00:00:00 2001 From: Stig Thormodsrud Date: Thu, 8 May 2008 17:48:05 -0700 Subject: Add more granularity to config rank (commit rip, ospf, bgp separately). --- scripts/VyattaConfigLoad.pm | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'scripts') diff --git a/scripts/VyattaConfigLoad.pm b/scripts/VyattaConfigLoad.pm index b69723a..a5c5b08 100755 --- a/scripts/VyattaConfigLoad.pm +++ b/scripts/VyattaConfigLoad.pm @@ -23,7 +23,7 @@ package VyattaConfigLoad; use strict; use sort 'stable'; use lib "/opt/vyatta/share/perl5/"; -use XorpConfigParser; +use XorpConfigParser; use VyattaConfig; # configuration ordering. higher rank configured before lower rank. @@ -36,16 +36,22 @@ my %config_rank = ( 'interfaces bridge' => 99, 'interfaces ethernet' => 98, 'interfaces tunnel' => 91, - 'system' => 90, + 'system gateway-address'=> 89, + 'system name-server' => 88, + 'system login user' => 87, + 'system' => 86, 'protocols static' => 85, 'service ssh' => 84, 'service telnet' => 83, 'policy' => 82, - 'vpn' => 80, + 'protocols bgp' => 79, + 'protocols ospf' => 78, + 'protocols rip' => 77, + 'vpn' => 60, ); my %wildcard_rank = ( - 'interfaces ethernet * vrrp' => 50, + 'interfaces ethernet * vrrp' => 50, 'interfaces ethernet * vif * vrrp' => 50, ); -- cgit v1.2.3 From 132e5c7b81bc308bfd66b23a7d619329ded829df Mon Sep 17 00:00:00 2001 From: An-Cheng Huang Date: Thu, 8 May 2008 21:11:13 -0700 Subject: fix for bug 3239: now support regex-based ordering for startup config loading. --- scripts/VyattaConfigLoad.pm | 60 ++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 31 deletions(-) (limited to 'scripts') diff --git a/scripts/VyattaConfigLoad.pm b/scripts/VyattaConfigLoad.pm index a5c5b08..bf86e57 100755 --- a/scripts/VyattaConfigLoad.pm +++ b/scripts/VyattaConfigLoad.pm @@ -29,49 +29,47 @@ use VyattaConfig; # configuration ordering. higher rank configured before lower rank. my $default_rank = 0; my %config_rank = ( - 'qos-policy' => 110, - 'firewall' => 102, - 'service nat' => 101, - 'interfaces' => 100, - 'interfaces bridge' => 99, - 'interfaces ethernet' => 98, - 'interfaces tunnel' => 91, - 'system gateway-address'=> 89, - 'system name-server' => 88, - 'system login user' => 87, - 'system' => 86, - 'protocols static' => 85, - 'service ssh' => 84, - 'service telnet' => 83, - 'policy' => 82, - 'protocols bgp' => 79, - 'protocols ospf' => 78, - 'protocols rip' => 77, - 'vpn' => 60, + 'qos-policy' => 1100, + 'firewall' => 1020, + 'service nat' => 1010, + 'interfaces' => 1000, + 'interfaces bridge' => 990, + 'interfaces ethernet' => 980, + 'interfaces tunnel' => 910, + 'system gateway-address'=> 890, + 'system name-server' => 880, + 'system login user' => 870, + 'system' => 860, + 'protocols static' => 850, + 'service ssh' => 840, + 'service telnet' => 830, + 'policy' => 820, + 'protocols bgp' => 790, + 'protocols ospf' => 780, + 'protocols rip' => 770, + 'vpn' => 600, ); -my %wildcard_rank = ( - 'interfaces ethernet * vrrp' => 50, - 'interfaces ethernet * vif * vrrp' => 50, +my %regex_rank = ( + 'interfaces ethernet \S* vrrp' => 500, + 'interfaces ethernet \S* vif \S* vrrp' => 500, + 'protocols bgp \d+ neighbor \S*[^\d.]\S*' => 800, ); my @all_nodes = (); my @all_naked_nodes = (); -# the wildcard matching could use some serious optimization. but probably -# not when we only have a couple of entries. -sub match_wildcard { +sub match_regex { my ($pattern, $str) = @_; - $pattern =~ s/\*/\\S*/g; $pattern =~ s/^(.*)$/\^$1\$/; return ($str =~ m/$pattern/) ? 1 : 0; } -sub get_wildcard_rank { +sub get_regex_rank { my ($str) = @_; - foreach (keys %wildcard_rank) { - if (match_wildcard($_, $str)) { - return $wildcard_rank{$_}; + foreach (keys %regex_rank) { + if (match_regex($_, $str)) { + return $regex_rank{$_}; } } return undef; @@ -85,7 +83,7 @@ sub get_config_rank { if (defined($config_rank{$path_str})) { return ($config_rank{$path_str}); } - my $wrank = get_wildcard_rank($path_str); + my $wrank = get_regex_rank($path_str); return $wrank if (defined($wrank)); pop @path; } -- cgit v1.2.3 From 04f1b8990af194e436c8581f1ca1a7f60596899c Mon Sep 17 00:00:00 2001 From: Stig Thormodsrud Date: Fri, 9 May 2008 17:50:05 -0700 Subject: Fix vlan regex. --- scripts/vyatta-interfaces.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/vyatta-interfaces.pl b/scripts/vyatta-interfaces.pl index ec3a873..310ee0e 100755 --- a/scripts/vyatta-interfaces.pl +++ b/scripts/vyatta-interfaces.pl @@ -221,7 +221,7 @@ sub is_dhcp_enabled { my $config = new VyattaConfig; if ($intf =~ m/^eth/) { - if ($intf =~ m/(\w+)\.(\d)/) { + if ($intf =~ m/(\w+)\.(\d+)/) { $config->setLevel("interfaces ethernet $1 vif $2"); } else { $config->setLevel("interfaces ethernet $intf"); @@ -250,7 +250,7 @@ sub is_address_enabled { my $config = new VyattaConfig; if ($intf =~ m/^eth/) { - if ($intf =~ m/(\w+)\.(\d)/) { + if ($intf =~ m/(\w+)\.(\d+)/) { $config->setLevel("interfaces ethernet $1 vif $2"); } else { $config->setLevel("interfaces ethernet $intf"); -- cgit v1.2.3