Skip to content

Commit 2bbcc24

Browse files
brianchennnlinouxis9
authored andcommitted
bugfix: ignore existed TNLA binding & rename amf -> newAmf
Signed-off-by: brianchennn <[email protected]>
1 parent 578563b commit 2bbcc24

File tree

2 files changed

+29
-11
lines changed

2 files changed

+29
-11
lines changed

config/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ amfif:
4141
- ip: "192.168.11.30"
4242
port: 38412
4343
logs:
44-
level: 4
44+
level: 4

internal/control_test_engine/gnb/ngap/handler.go

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)