mcastmngr: fix uci-default script to not overwrite on upgrade

This commit fixes the bug in the uci-default script due to which
the upstream interface in the proxy section was getting overwritten
on sysupgrades.

The uci-default scripts now validates that if the interface that
is set as the upstream_interface is a valid interface in the network
uci file, then config does not need to be updated.
This commit is contained in:
Rahul Thakur 2023-12-13 10:55:28 +05:30
parent bb9b397caa
commit 55e87e47f1

View file

@ -89,15 +89,24 @@ interfaces_ok(){
# check if upstream untagged
IFS=" "
for itf in $up_interf; do
# check if there exist a device section for this upstream interface, if yes the
# do nothing, if no then split the it at . and use the native interface as
# upstream interface
dev_section=$(ubus call uci get '{"config":"network", "type":"device", "match":{"name":"'"$itf"'"}}' | jsonfilter -e @.values | jq keys[])
# check if there exist a interface section for this upstream interface, if yes the
# do nothing, if no then generate config as mcast config is outdated
local dev_section=$(uci show network | grep -E "\.device=\'$itf\'" | cut -d'.' -f2)
# mcast config is outdated, simply generate as per new logic
if [ -z "$dev_section" ]; then
# check if the itf is a native interface && return 1
[ -f "/proc/net/vlan/$itf" ] || return 1
return 1
else
section_type=$(uci get network.$dev_section)
if [ "$section_type" == "interface" ]; then
# interface section exits, hence, sync has already happened
# nothing to do further, just return
return 0
else
# mcast config is outdated
return 1
fi
fi
done
return 0