Skip to content

Commit

Permalink
Fixing crash when multiple instances of AMF are run (#126)
Browse files Browse the repository at this point in the history
* Fixing crash when multiple instances of AMF are run

Delaying the null reference set to make sure there is no
inflight packet in the pipeline

* Reset security context available flag
  • Loading branch information
thakurajayL authored Sep 28, 2023
1 parent 418527a commit e4d4f47
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 5 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ FROM golang:1.18.3-stretch AS builder
LABEL maintainer="ONF <[email protected]>"

#RUN apt remove cmdtest yarn
RUN echo "deb http://archive.debian.org/debian stretch main" > /etc/apt/sources.list
RUN apt-get update
RUN apt-get -y install apt-transport-https ca-certificates
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg > pubkey.gpg
Expand Down
12 changes: 8 additions & 4 deletions context/amf_ue.go
Original file line number Diff line number Diff line change
Expand Up @@ -507,13 +507,17 @@ func (ue *AmfUe) DetachRanUe(anType models.AccessType) {
func (ue *AmfUe) AttachRanUe(ranUe *RanUe) {
/* detach any RanUe associated to it */
oldRanUe := ue.RanUe[ranUe.Ran.AnType]
if oldRanUe != nil {
oldRanUe.Log.Infof("Detached UeContext from OldRanUe")
ue.RanUe[ranUe.Ran.AnType].AmfUe = nil
}
ue.RanUe[ranUe.Ran.AnType] = ranUe
ranUe.AmfUe = ue

go func() {
time.Sleep(time.Second * 2)
if oldRanUe != nil {
oldRanUe.Log.Infof("Detached UeContext from OldRanUe")
oldRanUe.AmfUe = nil
}
}()

// set log information
ue.NASLog = logger.NasLog.WithField(logger.FieldAmfUeNgapID, fmt.Sprintf("AMF_UE_NGAP_ID:%d", ranUe.AmfUeNgapId))
ue.GmmLog = logger.GmmLog.WithField(logger.FieldAmfUeNgapID, fmt.Sprintf("AMF_UE_NGAP_ID:%d", ranUe.AmfUeNgapId))
Expand Down
1 change: 1 addition & 0 deletions context/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ func DbFetch(collName string, filter bson.M) *AmfUe {
ue.ProducerLog = logger.ProducerLog.WithField(logger.FieldSupi, fmt.Sprintf("SUPI:%s", ue.Supi))
ue.AmfInstanceName = os.Getenv("HOSTNAME")
ue.AmfInstanceIp = os.Getenv("POD_IP")
ue.TxLog.Errorln("amfue fetched")
return ue
}

Expand Down
1 change: 1 addition & 0 deletions nas/nas_security/security.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ func Decode(ue *context.AmfUe, accessType models.AccessType, payload []byte) (*n
if ue.SecurityContextAvailable && ue.RanUe[accessType].RRCEstablishmentCause != "0" {
ue.NASLog.Warnln("Received Plain NAS message")
ue.MacFailed = false
ue.SecurityContextAvailable = false
if err := msg.PlainNasDecode(&payload); err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion ngap/dispatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func DispatchLb(sctplbMsg *sdcoreAmfServer.SctplbMessage, Amf2RanMsgChan chan *s
/* uecontext is found, submit the message to transaction queue*/
if ranUe != nil && ranUe.AmfUe != nil {
ranUe.AmfUe.SetEventChannel(NgapMsgHandler)
ranUe.AmfUe.TxLog.Infof("Uecontext found. queuing ngap message to uechannel")
//ranUe.AmfUe.TxLog.Infof("Uecontext found. queuing ngap message to uechannel")
ranUe.AmfUe.EventChannel.UpdateNgapHandler(NgapMsgHandler)
ngapMsg := context.NgapMsg{
Ran: ran,
Expand Down

0 comments on commit e4d4f47

Please sign in to comment.