From f63fd664720d239e1d253978ea7b614c6b5e5c7b Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Mon, 25 Sep 2023 09:09:25 +0200 Subject: [PATCH] interfaces: for consistency bootstrap the implicit 'none' value --- src/etc/inc/interfaces.inc | 20 +++++++++---------- .../app/library/OPNsense/Routing/Gateways.php | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/etc/inc/interfaces.inc b/src/etc/inc/interfaces.inc index 4a2b0e622..3b3be513a 100644 --- a/src/etc/inc/interfaces.inc +++ b/src/etc/inc/interfaces.inc @@ -2178,7 +2178,7 @@ function interface_configure($verbose = false, $interface = 'wan', $reload = fal $realif = get_real_interface($interface); $realifv6 = get_real_interface($interface, 'inet6'); - switch ($wancfg['ipaddr'] ?? '') { + switch ($wancfg['ipaddr'] ?? 'none') { case 'l2tp': case 'ppp': case 'pppoe': @@ -2272,7 +2272,7 @@ function interface_configure($verbose = false, $interface = 'wan', $reload = fal interface_configure_mtu($realhwif, $wancfg['mtu'], $ifconfig_details); } - switch ($wancfg['ipaddr'] ?? '') { + switch ($wancfg['ipaddr'] ?? 'none') { case 'dhcp': interface_dhcp_configure($interface); break; @@ -2298,7 +2298,7 @@ function interface_configure($verbose = false, $interface = 'wan', $reload = fal $interface_descr = sprintf('%s (%s)', !empty($wancfg['descr']) ? $wancfg['descr'] : strtoupper($interface), $interface); mwexecf('/sbin/ifconfig %s inet6 -accept_rtadv description %s up', [$realif, $interface_descr]); - switch ($wancfg['ipaddrv6'] ?? '') { + switch ($wancfg['ipaddrv6'] ?? 'none') { case 'slaac': case 'dhcp6': /* XXX move these to tunables maybe as they are global anyway */ @@ -3969,15 +3969,15 @@ function get_interfaces_info($include_unlinked = false) $ifinfo['outerrs'] = $ifinfotmp['output errors']; $ifinfo['collisions'] = $ifinfotmp['collisions']; - $link_type = $config['interfaces'][$ifdescr]['ipaddr'] ?? ''; + $link_type = $config['interfaces'][$ifdescr]['ipaddr'] ?? 'none'; switch ($link_type) { case 'dhcp': $ifinfo['dhcplink'] = isvalidpid("/var/run/dhclient.{$ifinfo['if']}.pid") ? 'up' : 'down'; break; /* PPPoE/PPTP/L2TP interface? -> get status from virtual interface */ - case "pppoe": - case "pptp": - case "l2tp": + case 'pppoe': + case 'pptp': + case 'l2tp': if ($ifinfo['status'] == "up") { /* XXX get PPPoE link status for dial on demand */ $ifinfo["{$link_type}link"] = "up"; @@ -3986,7 +3986,7 @@ function get_interfaces_info($include_unlinked = false) } break; /* PPP interface? -> get uptime for this session and cumulative uptime from the persistent log file in conf */ - case "ppp": + case 'ppp': if ($ifinfo['status'] == "up") { $ifinfo['ppplink'] = "up"; } else { @@ -4028,7 +4028,7 @@ function get_interfaces_info($include_unlinked = false) } } - switch ($config['interfaces'][$ifdescr]['ipaddrv6'] ?? '') { + switch ($config['interfaces'][$ifdescr]['ipaddrv6'] ?? 'none') { case 'dhcp6': $ifinfo['dhcp6link'] = isvalidpid('/var/run/dhcp6c.pid') && file_exists("/var/etc/dhcp6c_{$ifdescr}.conf") ? 'up' : 'down'; break; @@ -4371,7 +4371,7 @@ function interfaces_has_prefix_only($interface) $interfaces_a = config_read_array('interfaces'); $ret = false; - switch ($interfaces_a[$interface]['ipaddrv6'] ?? '') { + switch ($interfaces_a[$interface]['ipaddrv6'] ?? 'none') { case 'dhcp6': $ret = empty($interfaces_a[$interface]['adv_dhcp6_config_file_override']) && ((!empty($interfaces_a[$interface]['adv_dhcp6_config_advanced']) && diff --git a/src/opnsense/mvc/app/library/OPNsense/Routing/Gateways.php b/src/opnsense/mvc/app/library/OPNsense/Routing/Gateways.php index c53ca3f67..3b27ed3fa 100644 --- a/src/opnsense/mvc/app/library/OPNsense/Routing/Gateways.php +++ b/src/opnsense/mvc/app/library/OPNsense/Routing/Gateways.php @@ -336,7 +336,7 @@ class Gateways $this->cached_gateways[$gwkey] = $thisconf; } elseif ( $ipproto == 'inet6' - && in_array($ifcfg['ipaddrv6'] ?? null, ['slaac', 'dhcp6', '6to4', '6rd']) + && in_array($ifcfg['ipaddrv6'] ?? 'none', ['slaac', 'dhcp6', '6to4', '6rd']) ) { // Dynamic IPv6 interface, but no router solicit response received using rtsold. $gwkey = $this->newKey($thisconf['priority'], !empty($thisconf['defaultgw']));