diff options
author | Stephen Hemminger <shemminger@vyatta.com> | 2012-06-22 12:19:08 -0700 |
---|---|---|
committer | Stephen Hemminger <shemminger@vyatta.com> | 2012-06-22 15:51:16 -0700 |
commit | 90b51b30aa19ecdc02b71e5c75f9a5cc4f215756 (patch) | |
tree | 942fbe4b8d8f768d23b7b06946cfe9c2bf236cbc /scripts | |
parent | 72e5d9292cc5e1d31193563f069c88765f422aa1 (diff) | |
download | vyatta-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-x | scripts/vyatta-interfaces.pl | 24 |
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; } |