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 <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg
2024-08-08 13:35:27 +02:00
parent c925b2f0a8
commit 959ce88b83
@@ -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"