From ede79668090e89ad6ed657bfc3ab3d5bb4c5db20 Mon Sep 17 00:00:00 2001 From: Sukru Senli Date: Thu, 2 Oct 2025 17:10:13 +0200 Subject: [PATCH] sulu-vendorext: ap_to_mld_creds_sync: do no hardcode mld_id to 1 set it only if there are unused mld sections --- .../files/etc/init.d/hmg_ap_to_mld_creds_sync | 45 ++++++++++++++++--- 1 file changed, 40 insertions(+), 5 deletions(-) diff --git a/sulu/sulu-vendorext/files/etc/init.d/hmg_ap_to_mld_creds_sync b/sulu/sulu-vendorext/files/etc/init.d/hmg_ap_to_mld_creds_sync index f31a1f3b8..7e0c72d0e 100755 --- a/sulu/sulu-vendorext/files/etc/init.d/hmg_ap_to_mld_creds_sync +++ b/sulu/sulu-vendorext/files/etc/init.d/hmg_ap_to_mld_creds_sync @@ -1,8 +1,35 @@ #!/bin/sh /etc/rc.common - START=97 USE_PROCD=1 +# Function to find the first available MLD ID +find_available_mld_id() { + # Get all MLD sections and their IDs + for mld in $(uci show mapcontroller | grep "^mapcontroller.@mld\[" | cut -d'=' -f1); do + mld_id=$(uci -q get "$mld.id") + [ -z "$mld_id" ] && continue + + # Check if any AP is using this MLD ID + mld_in_use=0 + for ap in $(uci show mapcontroller | grep "^mapcontroller.@ap\[" | cut -d'=' -f1); do + ap_mld_id=$(uci -q get "$ap.mld_id") + if [ "$ap_mld_id" = "$mld_id" ]; then + mld_in_use=1 + break + fi + done + + # If no AP is using this MLD ID, it's available + if [ "$mld_in_use" -eq 0 ]; then + echo "$mld_id" + return 0 + fi + done + + # If we get here, no available MLD ID was found + return 1 +} + start_service() { # --- STEP 1: process fronthaul APs with mld_id --- mld_ids=$(uci show mapcontroller | grep "^mapcontroller.@ap\[" | cut -d'=' -f1 | while read -r ap; do @@ -24,7 +51,6 @@ start_service() { cur_ssid=$(uci -q get "$ap.ssid") cur_key=$(uci -q get "$ap.key") - ap_list="$ap_list $ap" if [ -z "$ssid_ref" ]; then @@ -71,13 +97,22 @@ start_service() { [ "$count" -lt 2 ] && continue + # Find first available MLD ID + available_mld_id=$(find_available_mld_id) + if [ -z "$available_mld_id" ]; then + logger -t mldsync "Warning: No available MLD ID found for SSID group: $ssid" + continue + fi + + # Assign the available MLD ID to all APs in the group for ap in $ap_group; do - logger -t mldsync "Assigning mld_id=1 to $ap (ssid=$ssid)" - uci -q set "$ap.mld_id=1" + logger -t mldsync "Assigning mld_id=$available_mld_id to $ap (ssid=$ssid)" + uci -q set "$ap.mld_id=$available_mld_id" done + # Update the corresponding MLD section for mld in $(uci show mapcontroller | grep "^mapcontroller.@mld\[" | cut -d'=' -f1); do - [ "$(uci -q get "$mld.id")" = "1" ] || continue + [ "$(uci -q get "$mld.id")" = "$available_mld_id" ] || continue logger -t mldsync "Updating $mld with ssid=$ssid and key=$key_ref (from unassigned group)" uci -q set "$mld.ssid=$ssid" uci -q set "$mld.key=$key_ref"