OPNSense 22.7_4 - Fatal error: Uncaught TypeError while setting WAN properties

Started by diedenieded, July 30, 2022, 06:28:50 AM

Previous topic - Next topic
Hello. I'm trying to save my changes to the WAN Interface, but the following error keeps popping up. This error also happens if I'm not changing anything and just pressing the Save button. Any clue why this happens?

Fatal error: Uncaught TypeError: Cannot access offset of type string on string in /usr/local/www/interfaces.php:931 Stack trace: #0 {main} thrown in /usr/local/www/interfaces.php on line 931

My WAN interface is an AX200 loaded by iwlwifi if that matters. Please do tell me if there's any extra info I can provide. I'm quite new to this.


Hello, thank you for replying.

I'm not too clear on what I'm supposed to do. I'm using English, not French, and I do have a 'Save' button.

I've ran the commands anyways, and I still have the same issues.

Seems like it is a problem if WLAN is selected as a WAN device. The php tries to access:
$a_interfaces["wireless"]["mode"] but the wireless element is not an object, it is an empty string.

As a workaround I tried setting the mode in /config/config.xml  i.e. find the line in the right interface block which shows:
   <wireless/>
and use "vi" change it to
   <wireless><mode>bss</mode></wireless>
this suppresses the error and allows further configuration.
After this I a was able to see that the wlan associated.

(all done via a shell from the console)

I also found that NAT is not working using WIFI as a WAN

in ifconfig the interface appears as iwm0_wlan0 but the NAT does not see this, so no automatic rules are generated.
Adding manual rules looks like
rdr nat on iwm0 inet ...
manually change rules to change to iwmo_wlan0 appears to work

so fix is to edit /conf/config.xml from:
    <wan><if>iwm0</if>
to be
    <wan><if>iwm0_wlan0</if>

Next disable outbound NAT, save, apply.
Finally re enable automatic Nat, save, apply.
Now have working NAT with WIFI WAN.


@diedenieded

This is easy to work around as hsw suggests but a fix is much harder. This could break in a number of code lines with the way that legacy code stores empty nodes and PHP 8 refusing to cast it to an array for reading (missing) elements.

I added an issue to track via https://github.com/opnsense/core/issues/5939

@hsw

The second one is easier to fix for console port assignment use:

https://github.com/opnsense/core/commit/47bff6840df


Cheers,
Franco



Quote from: franco on August 11, 2022, 11:45:10 AM
Anyone with the original issue here to try https://github.com/opnsense/core/commit/475cb8ec7f  ?

# opnsense-patch 475cb8ec7f


Thanks,
Franco

I can confirm this is partially working.
The error is gone but the name of the interface in the configuration is still wrong.

In my case, the name of the wireless lan connection is run0_wlan0, but the WAN interface has only run0.

I had to do as hsw suggested here:

Quote from: hsw on August 09, 2022, 12:50:19 PM
I also found that NAT is not working using WIFI as a WAN

in ifconfig the interface appears as iwm0_wlan0 but the NAT does not see this, so no automatic rules are generated.
Adding manual rules looks like
rdr nat on iwm0 inet ...
manually change rules to change to iwmo_wlan0 appears to work

so fix is to edit /conf/config.xml from:
    <wan><if>iwm0</if>
to be
    <wan><if>iwm0_wlan0</if>

Next disable outbound NAT, save, apply.
Finally re enable automatic Nat, save, apply.
Now have working NAT with WIFI WAN.

Although it seems like I didn't need to disable outbound NAT and re-enable it.

EDIT: I just discovered that when I reboot the wireless doesn't autoconnect, I have to go back to the WAN page on the webGUI and click save and then it will connect.

EDIT 2: nevermind! Did an update and everything is now working correctly!

There are a lot more patches in the pipe for wireless, but I think the bulk will hit in 23.1 to keep impact on 22.7.x low.


Cheers,
Franco