map-agent: hotplug: map-dynamic-backhaul: Refactor port filtering and bridge detection logic

This commit is contained in:
Amin Ben Romdhane 2025-03-18 14:45:14 +00:00 committed by IOPSYS Dev
parent f8561996ab
commit e87bcbb819
No known key found for this signature in database

View file

@ -7,9 +7,21 @@ map_bh_file="/var/run/multiap/multiap.backhaul"
al_bridge="$(uci -q get mapagent.agent.al_bridge)"
[ "${al_bridge:0:3}" = "br-" ] || exit 0
# Get all sections where the port appears in 'ports' list
port_bridge_sec_list="$(uci show network | grep -w $PORT | grep '\.ports' | cut -d'.' -f2)"
# Find the first section with type='bridge' and get its name
for port_bridge_sec in $port_bridge_sec_list; do
if [ "$(uci -q get network.$port_bridge_sec.type)" = "bridge" ]; then
port_bridge_name="$(uci -q get network.$port_bridge_sec.name)"
break
fi
done
# Exit if the PORT Bridge Name is empty
[ -z "$port_bridge_name" ] && exit 0
# Exit if the PORT is not member of the AL Bridge
port_bridge_sec="$(uci show network | grep -w $PORT | grep '\.ports' | cut -d'.' -f2)"
port_bridge_name="$(uci -q get network.$port_bridge_sec.name)"
[ "$port_bridge_name" = "$al_bridge" ] || exit 0
# Exit if the device is not operating in extender/repeater mode