mcastmngr: fix ubus call in uci default script

This commit is contained in:
Anatoly Mirin 2023-03-10 01:52:27 +00:00 committed by Rahul Thakur
parent 82fe2012eb
commit cb7256eba9

View file

@ -77,31 +77,32 @@ generate_mcast_config(){
uci commit mcast
}
check_if_upstream_untagged(){
interfaces_ok(){
local section_name=$1
local up_interf=$(uci -q get ${section_name}.upstream_interface)
local up_interf=$(uci -q get ${section_name}.upstream_interface)
[ -z "$up_interf" ] && return 1
local down_interf=$(uci -q get ${section_name}.downstream_interface)
[ -z "$down_interf" ] && return 1
# 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[])
dev_section=$(ubus call uci get '{"config":"network", "type":"device", "match":{"name":"'"$itf"'"}}' | jsonfilter -e @.values | jq keys[])
if [ ! -z "$dev_section" ]; then
continue
fi
# mcast config is outdated, simply generate as per new logic
return
[ -z "$dev_section" ] && return 1
done
return 1
}
if [ -s "/etc/config/mcast" ]; then
if uci -q get mcast.@proxy[0] >/dev/null; then
check_if_upstream_untagged "mcast.@proxy[0]" || exit
interfaces_ok "mcast.@proxy[0]" && exit
elif uci -q get mcast.@snooping[0] >/dev/null; then
# return if there is any valid content
exit