interafces: safe gres/gifs iteration

This commit is contained in:
Franco Fichtner 2026-04-13 15:36:29 +02:00
parent 9cd352e408
commit 3d7cbd8079

View file

@ -401,13 +401,7 @@ function _interfaces_lagg_configure($lagg)
function interfaces_gre_configure($device)
{
global $config;
if (!isset($config['gres']['gre'])) {
return null;
}
foreach ($config['gres']['gre'] as $gre) {
foreach (config_read_array('gres', 'gre', false) as $gre) {
if ($gre['greif'] == $device) {
return _interfaces_gre_configure($gre);
}
@ -483,13 +477,7 @@ function _interfaces_gre_configure($gre)
function interfaces_gif_configure($device)
{
global $config;
if (!isset($config['gifs']['gif'])) {
return null;
}
foreach ($config['gifs']['gif'] as $gif) {
foreach (config_read_array('gifs', 'gif', false) as $gif) {
if ($gif['gifif'] == $device) {
return _interfaces_gif_configure($gif);
}
@ -3683,7 +3671,7 @@ function link_interface_to_gre($interface, $update = false, $family = null)
{
$result = [];
foreach (config_read_array('gres', 'gre') as $gre) {
foreach (config_read_array('gres', 'gre', false) as $gre) {
$parent = explode('_vip', $gre['if'])[0];
if (is_ipaddr($parent)) {
foreach (config_read_array('virtualip', 'vip', false) as $vip) {
@ -3718,7 +3706,7 @@ function link_interface_to_gif($interface, $update = false, $family = null)
{
$result = [];
foreach (config_read_array('gifs', 'gif') as $gif) {
foreach (config_read_array('gifs', 'gif', false) as $gif) {
if (explode('_vip', $gif['if'])[0] != $interface) {
continue;
} elseif ($family == 4 && !is_ipaddrv4($gif['remote-addr'])) {