diff options
author | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2009-04-28 23:00:59 -0700 |
---|---|---|
committer | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2009-04-28 23:00:59 -0700 |
commit | cb8a0c4dd7f3ebb47bbda57edb528c1cda278578 (patch) | |
tree | 86d624852bfc6a241625476761df89a1cd99a010 /scripts/vyatta-interfaces.pl | |
parent | e4e05713a76c31ba4edbb252e6f5fa0f59b13837 (diff) | |
download | vyatta-cfg-cb8a0c4dd7f3ebb47bbda57edb528c1cda278578.tar.gz vyatta-cfg-cb8a0c4dd7f3ebb47bbda57edb528c1cda278578.zip |
Use getIP() to check for duplicates
Simpler to use new getIP() for all address fetching
Diffstat (limited to 'scripts/vyatta-interfaces.pl')
-rwxr-xr-x | scripts/vyatta-interfaces.pl | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/scripts/vyatta-interfaces.pl b/scripts/vyatta-interfaces.pl index 5574462..d0d8fa1 100755 --- a/scripts/vyatta-interfaces.pl +++ b/scripts/vyatta-interfaces.pl @@ -97,18 +97,12 @@ sub is_ip_configured { sub is_ip_duplicate { my ($intf, $ip) = @_; - # - # get a list of all ipv4 and ipv6 addresses - # - my @ipaddrs = `ip addr show | grep inet | cut -d" " -f6`; - chomp @ipaddrs; - my %ipaddrs_hash = map { $_ => 1 } @ipaddrs; + # get a map of all ipv4 and ipv6 addresses + my %ipaddrs_hash = map { $_ => 1 } getIP(); return unless($ipaddrs_hash{$ip}); - # - # allow dup if it's the same interface - # + # if ip exists but on another interface, that is okay return is_ip_configured($intf, $ip); } @@ -378,6 +372,7 @@ sub is_valid_addr { print "Error: remove dhcp before adding static addresses for $intf\n"; exit 1; } + if (is_ip_duplicate($intf, $addr_net)) { print "Error: duplicate address/prefix [$addr_net]\n"; exit 1; |