@@ -719,25 +719,43 @@ func HandlerAmfConfigurationUpdate(amf *context.GNBAmf, gnb *context.GNBContext,
719719 ipv4String , _ = ngapConvert .IPAddressToString (* toAddItem .AMFTNLAssociationAddress .EndpointIPAddress )
720720 }
721721
722+ amfPool := gnb .GetAmfPool ()
723+ amfExisted := false
724+ amfPool .Range (func (key , value any ) bool {
725+ gnbAmf , ok := value .(* context.GNBAmf )
726+ if ! ok {
727+ return true
728+ }
729+ if gnbAmf .GetAmfIp () == ipv4String {
730+ log .Info ("[GNB] SCTP/NGAP service exists" )
731+ amfExisted = true
732+ return false
733+ }
734+ return true
735+ })
736+ if amfExisted {
737+ continue
738+ }
739+
722740 port := 38412 // default sctp port
723- amf := gnb .NewGnBAmf (ipv4String , port )
724- amf .SetAmfName (amfName )
725- amf .SetAmfCapacity (amfCapacity )
726- amf .SetRegionId (amfRegionId )
727- amf .SetSetId (amfSetId )
728- amf .SetPointer (amfPointer )
729- amf .SetTNLAUsage (toAddItem .TNLAssociationUsage .Value )
730- amf .SetTNLAWeight (toAddItem .TNLAddressWeightFactor .Value )
741+ newAmf := gnb .NewGnBAmf (ipv4String , port )
742+ newAmf .SetAmfName (amfName )
743+ newAmf .SetAmfCapacity (amfCapacity )
744+ newAmf .SetRegionId (amfRegionId )
745+ newAmf .SetSetId (amfSetId )
746+ newAmf .SetPointer (amfPointer )
747+ newAmf .SetTNLAUsage (toAddItem .TNLAssociationUsage .Value )
748+ newAmf .SetTNLAWeight (toAddItem .TNLAddressWeightFactor .Value )
731749
732750 // start communication with AMF(SCTP).
733- if err := InitConn (amf , gnb ); err != nil {
751+ if err := InitConn (newAmf , gnb ); err != nil {
734752 log .Fatal ("Error in" , err )
735753 } else {
736754 log .Info ("[GNB] SCTP/NGAP service is running" )
737755 // wg.Add(1)
738756 }
739757
740- trigger .SendNgSetupRequest (gnb , amf )
758+ trigger .SendNgSetupRequest (gnb , newAmf )
741759
742760 }
743761
0 commit comments