From 7ab81d50641b8bbe3dfb6c58b3dcd832215a81d2 Mon Sep 17 00:00:00 2001 From: Alex Harpin Date: Sun, 15 Feb 2015 13:24:22 +0000 Subject: vyatta-cfg: update is_primary_address for vtun and wan interfaces Expand the matching done in is_primary_address to account for the fact that the output from "ip address show" is different for vtun and wan interfaces; add a separate check for these interfaces. Bug #488 http://bugzilla.vyos.net/show_bug.cgi?id=488 --- lib/Vyatta/Misc.pm | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/Vyatta/Misc.pm b/lib/Vyatta/Misc.pm index 1f5a915..ac1e90b 100755 --- a/lib/Vyatta/Misc.pm +++ b/lib/Vyatta/Misc.pm @@ -109,8 +109,15 @@ sub is_primary_address { my $line = `ip address show $hash{$ip_address} | grep 'inet' | head -n 1`; chomp($line); my $primary_address = undef; - if ($line =~ /inet\s+([0-9.]+)\/.*\s([\w.]+)$/) { - $primary_address = $1; + + if ($line =~ /vtun|wan/) { + if ($line =~ /inet\s+([0-9.]+).*\s([\w.]+)$/) { + $primary_address = $1; + } + } else { + if ($line =~ /inet\s+([0-9.]+)\/.*\s([\w.]+)$/) { + $primary_address = $1; + } } return 1 if ($ip_address eq $primary_address); -- cgit v1.2.3