From 959ce88b839afa33fb3ffaf6604e735330a1d741 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Sun, 7 Jul 2024 13:28:05 +0200 Subject: [PATCH] board/common: fix bogus syslog warnings When syncing interface defaults at boot, some settings are read-only and some are write-only. Filter these out so sysctl does not log any bogus Permission Denied messages. Signed-off-by: Joachim Wiberg --- .../infix/init.d/10-sysctl-sync-ip-conf | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/board/common/rootfs/libexec/infix/init.d/10-sysctl-sync-ip-conf b/board/common/rootfs/libexec/infix/init.d/10-sysctl-sync-ip-conf index 5120fb8a..d2bcd2fa 100755 --- a/board/common/rootfs/libexec/infix/init.d/10-sysctl-sync-ip-conf +++ b/board/common/rootfs/libexec/infix/init.d/10-sysctl-sync-ip-conf @@ -5,12 +5,24 @@ # interfaces at boot, such that physical interfaces will start from # the same point as virtual ones. tmp=$(mktemp) +fil=$(mktemp) -sysctl net.ipv4.conf.default >$tmp -sysctl net.ipv6.conf.default >>$tmp +# Ignore unreadable entries, like net.ipv6.conf.default.stable_secret +sysctl net.ipv4.conf.default >"$tmp" 2>/dev/null +sysctl net.ipv6.conf.default >>"$tmp" 2>/dev/null + +# Filter out read-only entries like net.ipv4.conf.default.mc_forwarding +# to prevent misleading error messages in syslog +while IFS= read -r line; do + entry=$(echo "$line" | awk '{print $1}') + path="/proc/sys/$(echo "$entry" | tr . /)" + if [ -w "$path" ]; then + echo "$line" >> "$fil" + fi +done < "$tmp" for iface in $(ip -j link show | jq -r .[].ifname); do - sed -e "s/.default./.${iface}./g" $tmp | sysctl -q -p - + sed -e "s/.default./.${iface}./g" "$fil" | sysctl -q -p - done -rm $tmp +rm "$tmp" "$fil"