From 6b1cb21eb4a05e388463981b5948ddd0b3048c47 Mon Sep 17 00:00:00 2001 From: Yuen Su Date: Mon, 19 Oct 2026 22:19:51 +0800 Subject: [PATCH] mwan3: normalize expanded nexthop routes in 2.12.5 The kernel's nexthop compatibility dump contains both nhid and its expanded via/dev fields. Replaying both makes iproute2 reject the route. Remove the redundant ID from expanded routes, keeping ID-only routes and other attributes intact. Cover the parser cases in the existing package test.sh and bump the package version. Fixes: #27066 Signed-off-by: Yuen Su --- net/mwan3/Makefile | 2 +- net/mwan3/files/lib/mwan3/common.sh | 3 +++ net/mwan3/test.sh | 26 ++++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/net/mwan3/Makefile b/net/mwan3/Makefile index a05c48bacb0b9..3c7d0d1a853d0 100644 --- a/net/mwan3/Makefile +++ b/net/mwan3/Makefile @@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=mwan3 -PKG_VERSION:=2.12.4 +PKG_VERSION:=2.12.5 PKG_RELEASE:=1 PKG_MAINTAINER:=Florian Eckert diff --git a/net/mwan3/files/lib/mwan3/common.sh b/net/mwan3/files/lib/mwan3/common.sh index 67773ec0e2b45..07620d87eb027 100644 --- a/net/mwan3/files/lib/mwan3/common.sh +++ b/net/mwan3/files/lib/mwan3/common.sh @@ -180,6 +180,9 @@ mwan3_init() route_modifiers="$route_modifiers s/ linkdown / /; s/ linkdown$/ /;" route_modifiers="$route_modifiers s/expires [0-9]\+sec//;" route_modifiers="$route_modifiers s/error [0-9]\+//;" + # With nexthop_compat_mode the kernel dumps nhid plus via/dev. Replaying both + # nhid and its expansion is rejected; retain ID-only routes unmodified. + route_modifiers="$route_modifiers / nhid [0-9]\+/ { / via \| dev / s/ nhid [0-9]\+//; };" MWAN3_ROUTE_LINE_EXP="$route_modifiers ${source_routing:+s/default\(.*\) from [^ ]*/default\1/;} p" # mark mask constants diff --git a/net/mwan3/test.sh b/net/mwan3/test.sh index e459111345fe8..ee2382b3ad79d 100755 --- a/net/mwan3/test.sh +++ b/net/mwan3/test.sh @@ -68,3 +68,29 @@ ucode -S "$(dirname "$0")/test-rpcd.uc" done done ) + +# The kernel's expanded nexthop dump must be replayable without nhid. +# These parser checks require no extra tools or changes to the routing tables. +check_nexthop_route() +{ + actual=$(sanitize_route "$1") + [ "$actual" = "$2" ] || { + echo "failed to normalize nexthop route: '$1'" >&2 + echo "expected: '$2'" >&2 + echo "actual: '$actual'" >&2 + exit 1 + } +} + +check_nexthop_route \ + '198.51.100.0/24 nhid 7 via 192.0.2.1 dev eth0 proto static metric 20' \ + '198.51.100.0/24 via 192.0.2.1 dev eth0 proto static metric 20' +check_nexthop_route \ + '2001:db8:2::/64 nhid 8 via fe80::1 dev eth0 proto static metric 30 pref medium' \ + '2001:db8:2::/64 via fe80::1 dev eth0 proto static metric 30 pref medium' +check_nexthop_route '192.0.2.0/24 nhid 9 dev eth0 scope link' \ + '192.0.2.0/24 dev eth0 scope link' +check_nexthop_route '198.51.100.0/24 nhid 7 proto static metric 20' \ + '198.51.100.0/24 nhid 7 proto static metric 20' +check_nexthop_route '198.51.100.0/24 via 192.0.2.1 dev eth0 proto static metric 20' \ + '198.51.100.0/24 via 192.0.2.1 dev eth0 proto static metric 20'