diff options
author | Luiz Otavio O Souza <luiz@netgate.com> | 2015-11-27 08:59:21 -0600 |
---|---|---|
committer | Luiz Otavio O Souza <luiz@netgate.com> | 2015-11-27 08:59:21 -0600 |
commit | e686a73f17e94edbdca91b77b03f5ec266ac19ac (patch) | |
tree | 6245856958201ef1821472cf53777f19c9fa88ca /src/etc/inc/pfsense-utils.inc | |
parent | 76153238bde48bba64e460b68d0d29ec8ba764a3 (diff) | |
download | pfsense-e686a73f17e94edbdca91b77b03f5ec266ac19ac.zip pfsense-e686a73f17e94edbdca91b77b03f5ec266ac19ac.tar.gz |
Fix get_carp_interface_status() to work with uniqid notation and also, verify the CARP vhid and not only the interface (when you have more than one CARP IP on the same interface). Ticket #4858
Diffstat (limited to 'src/etc/inc/pfsense-utils.inc')
-rw-r--r-- | src/etc/inc/pfsense-utils.inc | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/src/etc/inc/pfsense-utils.inc b/src/etc/inc/pfsense-utils.inc index b32130a..df2cb32 100644 --- a/src/etc/inc/pfsense-utils.inc +++ b/src/etc/inc/pfsense-utils.inc @@ -405,21 +405,33 @@ function convert_ip_to_network_format($ip, $subnet) { * get_carp_interface_status($carpinterface): returns the status of a carp ip */ function get_carp_interface_status($carpinterface) { + global $config; - $interface = get_real_interface($interface); - $carp_query = ''; - $_gb = exec("/sbin/ifconfig $interface | /usr/bin/grep -v grep | /usr/bin/grep carp: | /usr/bin/head -n 1", $carp_query); - foreach ($carp_query as $int) { - if (stripos($int, "MASTER")) { - return "MASTER"; - } - if (stripos($int, "BACKUP")) { - return "BACKUP"; - } - if (stripos($int, "INIT")) { - return "INIT"; + foreach ($config['virtualip']['vip'] as $carp) { + if ($carp['mode'] != "carp") + continue; + $carpif = "_vip{$carp['uniqid']}"; + if ($carpinterface !== $carpif) + continue; + + $interface = get_real_interface($carp['interface']); + $vhid = $carp['vhid']; + $carp_query = ''; + $_gb = exec("/sbin/ifconfig $interface | /usr/bin/grep carp: | /usr/bin/grep \"vhid $vhid\"", $carp_query); + foreach ($carp_query as $int) { + if (stripos($int, "MASTER")) { + return "MASTER"; + } + if (stripos($int, "BACKUP")) { + return "BACKUP"; + } + if (stripos($int, "INIT")) { + return "INIT"; + } } + break; } + return; } |