From e87bcbb819237de27bbb718272c785782f66d7d8 Mon Sep 17 00:00:00 2001 From: Amin Ben Romdhane Date: Tue, 18 Mar 2025 14:45:14 +0000 Subject: [PATCH] map-agent: hotplug: map-dynamic-backhaul: Refactor port filtering and bridge detection logic --- .../etc/hotplug.d/ethernet/map-dynamic-backhaul | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/map-agent/files/etc/hotplug.d/ethernet/map-dynamic-backhaul b/map-agent/files/etc/hotplug.d/ethernet/map-dynamic-backhaul index ab196c314..02b09eb6b 100755 --- a/map-agent/files/etc/hotplug.d/ethernet/map-dynamic-backhaul +++ b/map-agent/files/etc/hotplug.d/ethernet/map-dynamic-backhaul @@ -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