summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--etc/inc/interfaces.inc53
-rw-r--r--usr/local/www/diag_ipsec.php18
2 files changed, 60 insertions, 11 deletions
diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc
index f89257e..0d6a200 100644
--- a/etc/inc/interfaces.inc
+++ b/etc/inc/interfaces.inc
@@ -3846,19 +3846,54 @@ function guess_interface_from_ip($ipaddress) {
/*
* find_ip_interface($ip): return the interface where an ip is defined
+ * (or if $bits is specified, where an IP within the subnet is defined)
*/
-function find_ip_interface($ip)
+function find_ip_interface($ip, $bits = null)
{
- /* if list */
- $ifdescrs = get_configured_interface_list();
+ /* if list */
+ $ifdescrs = get_configured_interface_list();
+
+ foreach ($ifdescrs as $ifdescr => $ifname) {
+ if ($bits === null) {
+ if ($ip == get_interface_ip($ifname)) {
+ $int = get_real_interface($ifname);
+ return $int;
+ }
+ }
+ else {
+ if (ip_in_subnet(get_interface_ip($ifname), $ip . "/" . $bits)) {
+ $int = get_real_interface($ifname);
+ return $int;
+ }
+ }
+ }
+ return false;
+}
- foreach ($ifdescrs as $ifdescr => $ifname) {
- if ($ip == get_interface_ip($ifname)) {
- $int = get_real_interface($ifname);
- return $int;
+/*
+ * find_virtual_ip_alias($ip): return the virtual IP alias where an IP is found
+ * (or if $bits is specified, where an IP within the subnet is found)
+ */
+function find_virtual_ip_alias($ip, $bits = null) {
+ global $config;
+ if (!is_array($config['virtualip']['vip'])) {
+ return false;
+ }
+ foreach ($config['virtualip']['vip'] as $vip) {
+ if ($vip['mode'] === "ipalias") {
+ if ($bits === null) {
+ if (ip_in_subnet($ip, $vip['subnet'] . "/" . $vip['subnet_bits'])) {
+ return $vip;
+ }
+ }
+ else {
+ if (check_subnets_overlap($ip, $bits, $vip['subnet'], $vip['subnet_bits'])) {
+ return $vip;
+ }
+ }
}
- }
- return false;
+ }
+ return false;
}
/*
diff --git a/usr/local/www/diag_ipsec.php b/usr/local/www/diag_ipsec.php
index e682a5f..71f379c 100644
--- a/usr/local/www/diag_ipsec.php
+++ b/usr/local/www/diag_ipsec.php
@@ -128,12 +128,26 @@ $sad = ipsec_dump_sad();
<td class="list">
<?php
$source = "";
+ $ip_interface = null;
+ $ip_alias = null;
if ($ph2ent['localid']['type'] == 'lan') {
$source = get_interface_ip('lan');
+ } else if ($ph2ent['localid']['type'] == 'network') {
+ $ip_interface = find_ip_interface($ph2ent['localid']['address'], $ph2ent['localid']['netbits']);
+ if (!$ip_interface) {
+ $ip_alias = find_virtual_ip_alias($ph2ent['localid']['address'], $ph2ent['localid']['netbits']);
+ }
} else {
- $source = get_interface_ip(find_ip_interface($ph2ent['localid']['address']));
+ $ip_interface = find_ip_interface($ph2ent['localid']['address']);
+ if (!$ip_interface) {
+ $ip_alias = find_virtual_ip_alias($ph2ent['localid']['address']);
+ }
+ }
+ if ($ip_interface) {
+ $source = get_interface_ip($ip_interface);
+ } else if ($ip_alias) {
+ $source = $ip_alias['subnet'];
}
-
?>
<?php if (($ph2ent['remoteid']['type'] != "mobile") && ($icon != "pass") && ($source != "")): ?>
<center>
OpenPOWER on IntegriCloud