From 52d4dc91613d8cd6bdb7eca0a26cec2b802a0046 Mon Sep 17 00:00:00 2001 From: Luiz Souza Date: Fri, 30 Mar 2018 15:21:59 -0300 Subject: [PATCH] Fixes a bug where an IP alias on loopback interface is not initialized at boot. A recent change changed the IP alias setup to only happen on enabled interfaces. As the loopback interfaces do not have the enabled flag on config there are being skiped. While here reduce some duplicate code and apply the same rules for VIPs and IP aliases. Ticket: #8393 Github PR: #3920 --- src/etc/inc/interfaces.inc | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/src/etc/inc/interfaces.inc b/src/etc/inc/interfaces.inc index 97d82cd682..4d9cf5b114 100644 --- a/src/etc/inc/interfaces.inc +++ b/src/etc/inc/interfaces.inc @@ -2525,30 +2525,18 @@ function interfaces_vips_configure($interface = "") { $carp_setuped = false; $anyproxyarp = false; foreach ($config['virtualip']['vip'] as $vip) { + if ($interface <> "" && $vip['interface'] <> $interface) { + continue; + } switch ($vip['mode']) { case "proxyarp": /* nothing it is handled on interface_proxyarp_configure() */ - if (($interface <> "" && $vip['interface'] <> $interface) || - !isset($config['interfaces'][$vip['interface']]['enable'])) { - continue; - } $anyproxyarp = true; break; case "ipalias": - $iface = $vip['interface']; - if (substr($iface, 0, 4) == "_vip") - $iface = get_configured_vip_interface($vip['interface']); - if (($interface <> "" && $iface <> $interface) || - !isset($config['interfaces'][$iface]['enable'])) { - continue; - } interface_ipalias_configure($vip); break; case "carp": - if (($interface <> "" && $vip['interface'] <> $interface) || - !isset($config['interfaces'][$vip['interface']]['enable'])) { - continue; - } if ($carp_setuped == false) { $carp_setuped = true; } @@ -2574,12 +2562,8 @@ function interface_ipalias_configure(&$vip) { $realif = get_real_interface("_vip{$vip['uniqid']}"); if ($realif != "lo0") { - $if = convert_real_interface_to_friendly_interface_name($realif); - if (!isset($config['interfaces'][$if])) { - return; - } - - if (!isset($config['interfaces'][$if]['enable'])) { + if (!isset($config['interfaces'][$vip['interface']]) || + !isset($config['interfaces'][$vip['interface']]['enable'])) { return; } } @@ -2610,12 +2594,17 @@ function interface_carp_configure(&$vip) { return; } - /* NOTE: Maybe its useless nowadays */ $realif = get_real_interface($vip['interface']); if (!does_interface_exist($realif)) { file_notice("CARP", sprintf(gettext("Interface specified for the virtual IP address %s does not exist. Skipping this VIP."), $vip['subnet']), "Firewall: Virtual IP", ""); return; } + if ($realif != "lo0") { + if (!isset($config['interfaces'][$vip['interface']]) || + !isset($config['interfaces'][$vip['interface']]['enable'])) { + return; + } + } $vip_password = $vip['password']; $vip_password = escapeshellarg(addslashes(str_replace(" ", "", $vip_password)));