From 4ab7d8b28a19ee2cd11cf9f88e98d4367dfb4a7c Mon Sep 17 00:00:00 2001 From: Maxim Mikityanskiy Date: Tue, 2 Apr 2024 01:01:48 +0300 Subject: [PATCH] mwan3: Fix awk expression in mwan3_delete_iface_rules The awk expression in mwan3_delete_iface_rules splits the `ip rule list` output by spaces, therefore $1 contains the trailing colon (e.g., "1:", "1000:"). The < and > operators compare such values as strings instead of numbers, producing unexpected results (for example, "1:" > "1000"). Change the field separator to ":" for correct number comparison, so that the right rules are removed. An example error message that may appear before the fix: Error: argument "1:" is wrong: preference value is invalid It happens because `substr($1,0,4)` selects short numbers along with the colon. In other cases wrong rules may be removed, for example, if there is rule 10051, then rule 1005 will be removed. Signed-off-by: Maxim Mikityanskiy --- net/mwan3/Makefile | 2 +- net/mwan3/files/lib/mwan3/mwan3.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/net/mwan3/Makefile b/net/mwan3/Makefile index 3d4dd36a14..9743edcb92 100644 --- a/net/mwan3/Makefile +++ b/net/mwan3/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=mwan3 PKG_VERSION:=2.11.13 -PKG_RELEASE:=2 +PKG_RELEASE:=3 PKG_MAINTAINER:=Florian Eckert , \ Aaron Goodman PKG_LICENSE:=GPL-2.0 diff --git a/net/mwan3/files/lib/mwan3/mwan3.sh b/net/mwan3/files/lib/mwan3/mwan3.sh index c69f381ea8..475d1a0733 100644 --- a/net/mwan3/files/lib/mwan3/mwan3.sh +++ b/net/mwan3/files/lib/mwan3/mwan3.sh @@ -549,7 +549,7 @@ mwan3_delete_iface_rules() return fi - for rule_id in $(ip rule list | awk '$1 % 1000 == '$id' && $1 > 1000 && $1 < 4000 {print substr($1,0,4)}'); do + for rule_id in $(ip rule list | awk -F : '$1 % 1000 == '$id' && $1 > 1000 && $1 < 4000 {print $1}'); do $IP rule del pref $rule_id done }