diff options
-rwxr-xr-x | scripts/vyatta-interfaces.pl | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/scripts/vyatta-interfaces.pl b/scripts/vyatta-interfaces.pl index 8fc5226..997230d 100755 --- a/scripts/vyatta-interfaces.pl +++ b/scripts/vyatta-interfaces.pl @@ -85,12 +85,8 @@ exit 0; sub is_ip_configured { my ($intf, $ip) = @_; - my $wc = `ip addr show $intf | grep -c $ip`; - if (defined $wc and $wc > 0) { - return 1; - } else { - return 0; - } + my @found = grep $ip, getIP($intf); + return ($#found > 0); } sub is_ip_duplicate { @@ -103,17 +99,12 @@ sub is_ip_duplicate { chomp @ipaddrs; my %ipaddrs_hash = map { $_ => 1 } @ipaddrs; - if (defined $ipaddrs_hash{$ip}) { - # - # allow dup if it's the same interface - # - if (is_ip_configured($intf, $ip)) { - return 0; - } - return 1; - } else { - return 0; - } + return unless($ipaddrs_hash{$ip}); + + # + # allow dup if it's the same interface + # + return is_ip_configured($intf, $ip); } sub touch { |