From 2bbcc24fa2ebf14335d6eec8737291f2205b91a1 Mon Sep 17 00:00:00 2001 From: brianchennn Date: Sun, 19 May 2024 15:24:39 +0000 Subject: [PATCH] bugfix: ignore existed TNLA binding & rename amf -> newAmf Signed-off-by: brianchennn --- config/config.yml | 2 +- .../control_test_engine/gnb/ngap/handler.go | 38 ++++++++++++++----- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/config/config.yml b/config/config.yml index 58bdcc70..9c1e2cf0 100644 --- a/config/config.yml +++ b/config/config.yml @@ -41,4 +41,4 @@ amfif: - ip: "192.168.11.30" port: 38412 logs: - level: 4 \ No newline at end of file + level: 4 diff --git a/internal/control_test_engine/gnb/ngap/handler.go b/internal/control_test_engine/gnb/ngap/handler.go index 76589cac..42196240 100644 --- a/internal/control_test_engine/gnb/ngap/handler.go +++ b/internal/control_test_engine/gnb/ngap/handler.go @@ -719,25 +719,43 @@ func HandlerAmfConfigurationUpdate(amf *context.GNBAmf, gnb *context.GNBContext, ipv4String, _ = ngapConvert.IPAddressToString(*toAddItem.AMFTNLAssociationAddress.EndpointIPAddress) } + amfPool := gnb.GetAmfPool() + amfExisted := false + amfPool.Range(func(key, value any) bool { + gnbAmf, ok := value.(*context.GNBAmf) + if !ok { + return true + } + if gnbAmf.GetAmfIp() == ipv4String { + log.Info("[GNB] SCTP/NGAP service exists") + amfExisted = true + return false + } + return true + }) + if amfExisted { + continue + } + port := 38412 // default sctp port - amf := gnb.NewGnBAmf(ipv4String, port) - amf.SetAmfName(amfName) - amf.SetAmfCapacity(amfCapacity) - amf.SetRegionId(amfRegionId) - amf.SetSetId(amfSetId) - amf.SetPointer(amfPointer) - amf.SetTNLAUsage(toAddItem.TNLAssociationUsage.Value) - amf.SetTNLAWeight(toAddItem.TNLAddressWeightFactor.Value) + newAmf := gnb.NewGnBAmf(ipv4String, port) + newAmf.SetAmfName(amfName) + newAmf.SetAmfCapacity(amfCapacity) + newAmf.SetRegionId(amfRegionId) + newAmf.SetSetId(amfSetId) + newAmf.SetPointer(amfPointer) + newAmf.SetTNLAUsage(toAddItem.TNLAssociationUsage.Value) + newAmf.SetTNLAWeight(toAddItem.TNLAddressWeightFactor.Value) // start communication with AMF(SCTP). - if err := InitConn(amf, gnb); err != nil { + if err := InitConn(newAmf, gnb); err != nil { log.Fatal("Error in", err) } else { log.Info("[GNB] SCTP/NGAP service is running") // wg.Add(1) } - trigger.SendNgSetupRequest(gnb, amf) + trigger.SendNgSetupRequest(gnb, newAmf) }