From 55e87e47f1928c38b519577b60d3d21e0a31b4ee Mon Sep 17 00:00:00 2001 From: Rahul Thakur Date: Wed, 13 Dec 2023 10:55:28 +0530 Subject: [PATCH] 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. --- .../etc/uci-defaults/61-mcast_config_generate | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/mcastmngr/files/common/etc/uci-defaults/61-mcast_config_generate b/mcastmngr/files/common/etc/uci-defaults/61-mcast_config_generate index 3c8c14824..089c5f230 100644 --- a/mcastmngr/files/common/etc/uci-defaults/61-mcast_config_generate +++ b/mcastmngr/files/common/etc/uci-defaults/61-mcast_config_generate @@ -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