Skip to content

Commit

Permalink
bugfix: ignore existed TNLA binding & rename amf -> newAmf
Browse files Browse the repository at this point in the history
Signed-off-by: brianchennn <[email protected]>
  • Loading branch information
brianchennn committed May 19, 2024
1 parent 578563b commit 6b53ae0
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 11 deletions.
2 changes: 1 addition & 1 deletion config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ amfif:
- ip: "192.168.11.30"
port: 38412
logs:
level: 4
level: 4
38 changes: 28 additions & 10 deletions internal/control_test_engine/gnb/ngap/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

}

Expand Down

0 comments on commit 6b53ae0

Please sign in to comment.