Files
Gleb Pesin f626f9c502 mwan3: strip dead flag from copied routes
The kernel marks routes using no-carrier devices as dead linkdown. mwan3
strips linkdown but passes dead to ip route, which rejects the copied route
and leaves policy tables incomplete.

Strip both flags, including at end of line, and add a runtime test.

Signed-off-by: Gleb Pesin <dormancygrace@gmail.com>
2026-10-05 11:19:19 +02:00

40 lines
876 B
Bash
Executable File

#!/bin/sh
# shellcheck shell=busybox
IPKG_INSTROOT=${IPKG_INSTROOT:-}
export IPKG_INSTROOT
. /lib/functions.sh
. /lib/mwan3/mwan3.sh
set -e
mwan3_init
sanitize_route()
{
printf '%s\n' "$1" | sed -ne "$MWAN3_ROUTE_LINE_EXP"
}
expected='192.0.2.0/24 dev eth0 scope link src 192.0.2.1 '
for flags in 'dead linkdown' 'linkdown dead' 'dead' 'linkdown'; do
actual=$(sanitize_route "$expected$flags")
[ "$actual" = "$expected" ] || {
echo "failed to sanitize route flags: $flags" >&2
echo "expected: '$expected'" >&2
echo "actual: '$actual'" >&2
exit 1
}
done
ipv6_route='fd00:1::/64 via fe80::dead dev eth0 proto static metric 1024 pref medium'
actual=$(sanitize_route "$ipv6_route")
[ "$actual" = "$ipv6_route" ] || {
echo "failed to preserve an IPv6 address ending in dead" >&2
echo "expected: '$ipv6_route'" >&2
echo "actual: '$actual'" >&2
exit 1
}