From 57097e20acdcdd09818275f3f0bc0ca7bd855bc8 Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Mon, 28 Mar 2022 09:21:47 +0200 Subject: [PATCH] interfaces: according to #5646 VIP reassignment enforces "order" This is strange, but no the strangest thing to happen. Partially restore the old functionality but this time make sure we only flip IPv4 on IPv4 and IPv6 on IPv6 changes instead of everything all the time. --- src/etc/inc/interfaces.inc | 38 ++++++++++++++++++++++---------------- src/etc/rc.newwanip | 2 ++ src/etc/rc.newwanipv6 | 2 ++ 3 files changed, 26 insertions(+), 16 deletions(-) diff --git a/src/etc/inc/interfaces.inc b/src/etc/inc/interfaces.inc index bf37ea02a..f28e41926 100644 --- a/src/etc/inc/interfaces.inc +++ b/src/etc/inc/interfaces.inc @@ -1395,7 +1395,7 @@ function interface_proxyarp_configure($interface = '') } } -function interfaces_vips_configure($interface) +function interfaces_vips_configure($interface, $family = null) { global $config; @@ -1407,21 +1407,27 @@ function interfaces_vips_configure($interface) $anyproxyarp = false; foreach ($config['virtualip']['vip'] as $vip) { - if ($vip['interface'] == $interface) { - switch ($vip['mode']) { - case 'proxyarp': - $anyproxyarp = true; - break; - case 'ipalias': - interface_ipalias_configure($vip); - break; - case 'carp': - if (!$carp_setup) { - $carp_setup = true; - } - interface_carp_configure($vip); - break; - } + if ($vip['interface'] != $interface) { + continue; + } + + if ($family === 4 && strpos($vip['subnet'], ':') !== false) { + continue; + } elseif ($family === 6 && strpos($vip['subnet'], ':') === false) { + continue; + } + + switch ($vip['mode']) { + case 'proxyarp': + $anyproxyarp = true; + break; + case 'ipalias': + interface_ipalias_configure($vip); + break; + case 'carp': + $carp_setup = true; + interface_carp_configure($vip); + break; } } diff --git a/src/etc/rc.newwanip b/src/etc/rc.newwanip index d245927e3..640897352 100755 --- a/src/etc/rc.newwanip +++ b/src/etc/rc.newwanip @@ -75,6 +75,8 @@ if (!is_ipaddr($ip) && substr($interface_real, 0, 4) != 'ovpn') { return; } +interfaces_vips_configure($interface, 4); + $gres = link_interface_to_gre($interface); foreach ($gres as $gre) { _interfaces_gre_configure($gre); diff --git a/src/etc/rc.newwanipv6 b/src/etc/rc.newwanipv6 index c9fbd49a7..a03c8a7c7 100755 --- a/src/etc/rc.newwanipv6 +++ b/src/etc/rc.newwanipv6 @@ -75,6 +75,8 @@ if (!is_ipaddr($ip) && substr($interface_real, 0, 4) != 'ovpn') { return; } +interfaces_vips_configure($interface, 6); + if (count(link_interface_to_track6($interface, true))) { plugins_configure('dhcp', false, array('inet6')); }