summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorStephen Hemminger <shemminger@vyatta.com>2012-06-22 12:19:08 -0700
committerStephen Hemminger <shemminger@vyatta.com>2012-06-22 15:51:16 -0700
commit90b51b30aa19ecdc02b71e5c75f9a5cc4f215756 (patch)
tree942fbe4b8d8f768d23b7b06946cfe9c2bf236cbc /scripts
parent72e5d9292cc5e1d31193563f069c88765f422aa1 (diff)
downloadvyatta-cfg-system-90b51b30aa19ecdc02b71e5c75f9a5cc4f215756.tar.gz
vyatta-cfg-system-90b51b30aa19ecdc02b71e5c75f9a5cc4f215756.zip
Use hash map of addresses to interfaces
Other part of fix for Bz 8171 Create a hash of address => interfaces in configuration and use it during address commit check. Remove unused creation of list of current addresses. This might speed boot with large number of interfaces. Since the hash is made once per interface rather than multiple times, it might be faster because of that as well.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/vyatta-interfaces.pl24
1 files changed, 14 insertions, 10 deletions
diff --git a/scripts/vyatta-interfaces.pl b/scripts/vyatta-interfaces.pl
index 463139da..c455bb74 100755
--- a/scripts/vyatta-interfaces.pl
+++ b/scripts/vyatta-interfaces.pl
@@ -297,25 +297,29 @@ sub is_valid_addr_commit {
die "Can't configure address on interface that is slaved to bonding interface.\n"
if (defined($bond));
- # Map of all the ip addresses
- my %ipaddr_hash = map { $_ => 1 } getIP();
+ my $addrmap = Vyatta::Interface::get_cfg_addresses();
my ($dhcp, $static_v4);
foreach my $addr (@addrs) {
next if ($addr eq 'dhcpv6');
+
if ($addr eq 'dhcp') {
$dhcp = 1;
- } elsif (!Vyatta::Interface::is_uniq_address($addr)) {
- my $h = Vyatta::Misc::get_ipnet_intf_hash();
- print "Error: duplicate address $addr on $h->{$addr}\n";
- exit 1;
- } elsif ( is_ipv4($addr) ) {
- $static_v4 = 1;
- }
+ next;
+ }
+
+ my $intfs = $addrmap->{$addr};
+ if ($intfs && scalar(@{$intfs}) > 1) {
+ die "Duplicate address $addr used on interfaces: ",
+ join(',', @${intfs}), "\n";
+ }
+
+ $static_v4 = 1
+ if ( is_ipv4($addr) );
}
die "Can't configure static IPv4 address and DHCP on the same interface.\n"
- if ($static_v4 && $dhcp);
+ if ($static_v4 && $dhcp);
exit 0;
}