summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2009-04-28 23:01:47 -0700
committerStephen Hemminger <stephen.hemminger@vyatta.com>2009-04-28 23:01:47 -0700
commit4bb05740120a92338d081bd3f2a2993b87ce3909 (patch)
tree06c45a5b925457354545796a884ca8101dd21716 /scripts
parent5e7cbd98a5f76adf37f15020b1a9375e388ba37a (diff)
parentcb8a0c4dd7f3ebb47bbda57edb528c1cda278578 (diff)
downloadvyatta-cfg-4bb05740120a92338d081bd3f2a2993b87ce3909.tar.gz
vyatta-cfg-4bb05740120a92338d081bd3f2a2993b87ce3909.zip
Merge branch 'jenner' of 192.168.100.1:git/vyatta-cfg into jenner
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/vyatta-interfaces.pl25
1 files changed, 9 insertions, 16 deletions
diff --git a/scripts/vyatta-interfaces.pl b/scripts/vyatta-interfaces.pl
index 25fefc9..d0d8fa1 100755
--- a/scripts/vyatta-interfaces.pl
+++ b/scripts/vyatta-interfaces.pl
@@ -90,25 +90,19 @@ exit 0;
sub is_ip_configured {
my ($intf, $ip) = @_;
- my @found = grep $ip, Vyatta::Misc::getIP($intf);
- return ($#found > 0);
+ my $found = grep { $_ eq $ip } Vyatta::Misc::getIP($intf);
+ return ($found > 0);
}
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);
}
@@ -233,9 +227,8 @@ sub update_eth_addrs {
return;
}
my $version = is_ip_v4_or_v6($addr);
- if (!defined $version) {
- exit 1;
- }
+ die "Unknown address not IPV4 or IPV6" unless $version;
+
if (is_ip_configured($intf, $addr)) {
#
# treat this as informational, don't fail
@@ -250,8 +243,7 @@ sub update_eth_addrs {
if ($version == 6) {
return system("ip -6 addr add $addr dev $intf");
}
- print "Error: Invalid address/prefix [$addr] for interface $intf\n";
- exit 1;
+ die "Error: Invalid address/prefix [$addr] for interface $intf\n";
}
sub delete_eth_addrs {
@@ -380,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;