fw4: do not add physical devices for soft offload master
authorJo-Philipp Wich <jo@mein.io>
Fri, 15 Mar 2024 08:49:33 +0000 (10:49 +0200)
committerJo-Philipp Wich <jo@mein.io>
Fri, 31 May 2024 22:13:05 +0000 (00:13 +0200)
Let kernel heuristics take care of offloading decapsulation.

When software flow offloading is requested, avoid manually resolving and
adding lower physical devices to the flow table in order to let kernel
heuristics deal with the proper offloading en/decapsulation.

Fixes: https://github.com/openwrt/openwrt/issues/13410
Ref: https://github.com/openwrt/openwrt/issues/10224
Submitted-by: Andris PE <neandris@gmail.com>
[refactor code, reword commit message]
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
root/usr/share/ucode/fw4.uc

index a59eb41f8e08a62aee5d28616becee1d2ec22ad7..ffea2ebdd7b5466eceba8ba51b9759b4ca165646 100644 (file)
@@ -505,12 +505,12 @@ return {
                return v;
        },
 
-       resolve_offload_devices: function() {
-               if (!this.default_option("flow_offloading"))
-                       return [];
+       resolve_hw_offload_devices: function() {
+               if (!this.default_option("flow_offloading_hw"))
+                       return null;
 
                let devstatus = null;
-               let devices = [];
+               let devices = null;
                let bus = ubus.connect();
 
                if (bus) {
@@ -520,15 +520,36 @@ return {
 
                for (let zone in this.zones())
                        for (let device in zone.related_physdevs)
-                               push(devices, ...resolve_lower_devices(devstatus, device));
-               devices = sort(uniq(devices));
+                               push(devices ||= [], ...resolve_lower_devices(devstatus, device));
 
-               if (this.default_option("flow_offloading_hw")) {
-                       if (length(devices) && nft_try_hw_offload(devices))
-                               return devices;
+               if (!devices)
+                       return null;
 
+               devices = sort(uniq(devices));
+
+               if (!nft_try_hw_offload(devices)) {
                        this.warn('Hardware flow offloading unavailable, falling back to software offloading');
                        this.state.defaults.flow_offloading_hw = false;
+
+                       return null;
+               }
+
+               return devices;
+       },
+
+       resolve_offload_devices: function() {
+               if (!this.default_option("flow_offloading"))
+                       return [];
+
+               let devices = this.resolve_hw_offload_devices();
+
+               if (!devices) {
+                       devices = [];
+
+                       for (let zone in this.zones())
+                               push(devices, ...zone.related_physdevs);
+
+                       devices = sort(uniq(devices));
                }
 
                return devices;