diff options
author | Ermal Luçi <ermal.luci@gmail.com> | 2012-12-19 12:46:27 -0800 |
---|---|---|
committer | Ermal Luçi <ermal.luci@gmail.com> | 2012-12-19 12:46:27 -0800 |
commit | a33b69dbd9a6682c452ef509a30340ca4e69646b (patch) | |
tree | be9e3817a0085b9166cbf84a6abfd62f309fdb36 | |
parent | 15fc311fc4236bdcf618e93a74bd606e293a2e01 (diff) | |
parent | 13b31977f7268517c5e53dc4cd768c477c98786f (diff) | |
download | pfsense-a33b69dbd9a6682c452ef509a30340ca4e69646b.zip pfsense-a33b69dbd9a6682c452ef509a30340ca4e69646b.tar.gz |
Merge pull request #287 from bcyrill/alias_gif
Add IP alias support to GIF interfaces
-rw-r--r-- | etc/inc/interfaces.inc | 16 | ||||
-rw-r--r-- | usr/local/www/interfaces_gif_edit.php | 21 |
2 files changed, 27 insertions, 10 deletions
diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc index d30b137..55ca41f 100644 --- a/etc/inc/interfaces.inc +++ b/etc/inc/interfaces.inc @@ -834,13 +834,19 @@ function interface_gif_configure(&$gif, $gifkey = "") { return -1; $realif = get_real_interface($gif['if']); + $ipaddr = $gif['ipaddr']; - if(is_ipaddrv4($gif['remote-addr'])) { - $realifip = get_interface_ip($gif['if']); + if (is_ipaddrv4($gif['remote-addr'])) { + if (is_ipaddrv4($ipaddr)) + $realifip = $ipaddr; + else + $realifip = get_interface_ip($gif['if']); $realifgw = get_interface_gateway($gif['if']); - } - if(is_ipaddrv6($gif['remote-addr'])) { - $realifip = get_interface_ipv6($gif['if']); + } else if (is_ipaddrv6($gif['remote-addr'])) { + if (is_ipaddrv6($ipaddr)) + $realifip = $ipaddr; + else + $realifip = get_interface_ipv6($gif['if']); $realifgw = get_interface_gatewayv6($gif['if']); } /* make sure the parent interface is up */ diff --git a/usr/local/www/interfaces_gif_edit.php b/usr/local/www/interfaces_gif_edit.php index 7421f8d..ea1d3d3 100644 --- a/usr/local/www/interfaces_gif_edit.php +++ b/usr/local/www/interfaces_gif_edit.php @@ -52,6 +52,9 @@ if (isset($_POST['id'])) if (isset($id) && $a_gifs[$id]) { $pconfig['if'] = $a_gifs[$id]['if']; + if (!empty($a_gifs[$id]['ipaddr'])) { + $pconfig['if'] = $pconfig['if'] . '|' . $a_gifs[$id]['ipaddr']; + } $pconfig['gifif'] = $a_gifs[$id]['gifif']; $pconfig['remote-addr'] = $a_gifs[$id]['remote-addr']; $pconfig['tunnel-remote-net'] = $a_gifs[$id]['tunnel-remote-net']; @@ -77,13 +80,18 @@ if ($_POST) { (!is_ipaddr($_POST['remote-addr']))) { $input_errors[] = gettext("The tunnel local and tunnel remote fields must have valid IP addresses."); } + + $alias = strstr($_POST['if'],'|'); + if ((is_ipaddrv4($alias) && !is_ipaddrv4($_POST['remote-addr'])) || + (is_ipaddrv6($alias) && !is_ipaddrv6($_POST['remote-addr']))) + $input_errors[] = gettext("The alias IP address family has to match the family of the remote peer address."); foreach ($a_gifs as $gif) { if (isset($id) && ($a_gifs[$id]) && ($a_gifs[$id] === $gif)) continue; /* FIXME: needs to perform proper subnet checks in the feature */ - if (($gif['if'] == $_POST['if']) && ($gif['tunnel-remote-addr'] == $_POST['tunnel-remote-addr'])) { + if (($gif['if'] == strtok($_POST['if'],'|')) && ($gif['tunnel-remote-addr'] == $_POST['tunnel-remote-addr'])) { $input_errors[] = sprintf(gettext("A gif with the network %s is already defined."), $gif['tunnel-remote-addr']); break; } @@ -91,7 +99,7 @@ if ($_POST) { if (!$input_errors) { $gif = array(); - $gif['if'] = $_POST['if']; + list($gif['if'], $gif['ipaddr']) = explode("|",$_POST['if']); $gif['tunnel-local-addr'] = $_POST['tunnel-local-addr']; $gif['tunnel-remote-addr'] = $_POST['tunnel-remote-addr']; $gif['tunnel-remote-net'] = $_POST['tunnel-remote-net']; @@ -144,9 +152,12 @@ include("head.inc"); <?php $portlist = get_configured_interface_with_descr(); $carplist = get_configured_carp_interface_list(); - foreach ($carplist as $cif => $carpip) - $portlist[$cif] = $carpip." (".get_vip_descr($carpip).")"; - foreach ($portlist as $ifn => $ifinfo) { + foreach ($carplist as $cif => $carpip) + $portlist[$cif] = $carpip." (".get_vip_descr($carpip).")"; + $aliaslist = get_configured_ip_aliases_list(); + foreach ($aliaslist as $aliasip => $aliasif) + $portlist[$aliasif.'|'.$aliasip] = $aliasip." (".get_vip_descr($aliasip).")"; + foreach ($portlist as $ifn => $ifinfo) { echo "<option value=\"{$ifn}\""; if ($ifn == $pconfig['if']) echo "selected"; |