diff options
author | smos <seth.mos@dds.nl> | 2012-11-19 09:40:17 +0100 |
---|---|---|
committer | smos <seth.mos@dds.nl> | 2012-11-19 09:40:17 +0100 |
commit | 6fb26a17c19d66033320debb863c0a7c9a3499aa (patch) | |
tree | 9130f57c6b9bc179aaaded749f72f775291b4f73 /etc | |
parent | af661ba8b7d8b049ad46f4d44cfd814a5207819f (diff) | |
download | pfsense-6fb26a17c19d66033320debb863c0a7c9a3499aa.zip pfsense-6fb26a17c19d66033320debb863c0a7c9a3499aa.tar.gz |
Add IPv6 support to this function so that IPv6 carp vips can be found
Diffstat (limited to 'etc')
-rw-r--r-- | etc/inc/interfaces.inc | 44 |
1 files changed, 28 insertions, 16 deletions
diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc index d4a4483..a10eacd 100644 --- a/etc/inc/interfaces.inc +++ b/etc/inc/interfaces.inc @@ -3851,28 +3851,40 @@ function find_carp_interface($ip) { } function link_carp_interface_to_parent($interface) { - global $config; + global $config; - if ($interface == "") - return; + if ($interface == "") + return; - $carp_ip = get_interface_ip($interface); - if (!is_ipaddr($carp_ip)) - return; + $carp_ip = get_interface_ip($interface); + $carp_ipv6 = get_interface_ipv6($interface); - /* if list */ - $ifdescrs = get_configured_interface_list(); - foreach ($ifdescrs as $ifdescr => $ifname) { - $interfaceip = get_interface_ip($ifname); - $subnet_bits = get_interface_subnet($ifname); - $subnet_ip = gen_subnet("{$interfaceip}", "{$subnet_bits}"); - if(ip_in_subnet($carp_ip, "{$subnet_ip}/{$subnet_bits}")) - return $ifname; - } + if((!is_ipaddrv4($carp_ip)) && (!is_ipaddrv6($carp_ipv6))) + return; - return ""; + /* if list */ + $ifdescrs = get_configured_interface_list(); + foreach ($ifdescrs as $ifdescr => $ifname) { + /* check IPv4 */ + if(is_ipaddrv4($carp_ip)) { + $interfaceip = get_interface_ip($ifname); + $subnet_bits = get_interface_subnet($ifname); + $subnet_ip = gen_subnet("{$interfaceip}", "{$subnet_bits}"); + if(ip_in_subnet($carp_ip, "{$subnet_ip}/{$subnet_bits}")) + return $ifname; + } + /* Check IPv6 */ + if(is_ipaddrv6($carp_ipv6)) { + $interfaceipv6 = get_interface_ipv6($ifname); + $prefixlen = get_interface_subnetv6($ifname); + if(ip_in_subnet($carp_ipv6, "{$interfaceipv6}/{$prefixlen}")) + return $ifname; + } + } + return ""; } + /****f* interfaces/link_ip_to_carp_interface * NAME * link_ip_to_carp_interface - Find where a CARP interface links to. |