summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJo-Philipp Wich2024-03-15 08:49:33 +0000
committerJo-Philipp Wich2024-05-31 22:13:05 +0000
commite00958884416f59b273595f941d198de63acc1dd (patch)
tree547e7428f5412ca296be5693898e913f33d12e9b
parent4c01d1ebf99e8ecfa69758a9b4f450ecef7b93cd (diff)
downloadfirewall4-e00958884416f59b273595f941d198de63acc1dd.tar.gz
fw4: do not add physical devices for soft offload
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>
-rw-r--r--root/usr/share/ucode/fw4.uc39
1 files changed, 30 insertions, 9 deletions
diff --git a/root/usr/share/ucode/fw4.uc b/root/usr/share/ucode/fw4.uc
index a59eb41..ffea2eb 100644
--- a/root/usr/share/ucode/fw4.uc
+++ b/root/usr/share/ucode/fw4.uc
@@ -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;