summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuiz Otavio O Souza <luiz@netgate.com>2016-02-09 09:30:24 -0600
committerLuiz Otavio O Souza <luiz@netgate.com>2016-02-09 15:58:43 -0600
commit5420820f8bd504e2d886fe40796d2b3f7ec6778a (patch)
tree90cddf399646675700e98756520abe821ec1b8a1
parent2a5960b07bb2a40aeaf81423b0c52d5629e87e49 (diff)
downloadpfsense-5420820f8bd504e2d886fe40796d2b3f7ec6778a.zip
pfsense-5420820f8bd504e2d886fe40796d2b3f7ec6778a.tar.gz
Fix get_interface_ip[v6]() to try first the IP from our configuration before ask the kernel. The OS will return the first IP it find for the interface and not necessarily the main IP address.
This can cause conflicts where get_interface_ip[v6]() returns a CARP or IP alias for the interface (missing the real IP and generating a duplicated IP address).
-rw-r--r--src/etc/inc/interfaces.inc17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/etc/inc/interfaces.inc b/src/etc/inc/interfaces.inc
index dc984fd..05945d3 100644
--- a/src/etc/inc/interfaces.inc
+++ b/src/etc/inc/interfaces.inc
@@ -5312,6 +5312,16 @@ function get_interface_ip($interface = "wan") {
return null;
}
+ if (is_array($config['interfaces'][$interface]) &&
+ is_ipaddr($config['interfaces'][$interface]['ipaddr'])) {
+ return ($config['interfaces'][$interface]['ipaddr']);
+ }
+
+ /*
+ * Beaware that find_interface_ip() is our last option, it will
+ * return the first IP it find on interface, not necessarily the
+ * main IP address.
+ */
$curip = find_interface_ip($realif);
if ($curip && is_ipaddr($curip) && ($curip != "0.0.0.0")) {
return $curip;
@@ -5351,8 +5361,15 @@ function get_interface_ipv6($interface = "wan", $flush = false) {
}
break;
}
+ if (is_ipaddrv6($config['interfaces'][$interface]['ipaddrv6']))
+ return ($config['interfaces'][$interface]['ipaddrv6']);
}
+ /*
+ * Beaware that find_interface_ip() is our last option, it will
+ * return the first IP it find on interface, not necessarily the
+ * main IP address.
+ */
$curip = find_interface_ipv6($realif, $flush);
if ($curip && is_ipaddrv6($curip) && ($curip != "::")) {
return $curip;
OpenPOWER on IntegriCloud