Skip to content

Commit 556ed7d

Browse files
authored
fix: ranUeNgapID reuse (ellanetworks#1187)
Signed-off-by: Guillaume Belanger <guillaume.belanger27@gmail.com>
1 parent f35db77 commit 556ed7d

2 files changed

Lines changed: 13 additions & 5 deletions

File tree

internal/amf/ngap/handle_initial_ue_message.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,18 @@ func HandleInitialUEMessage(ctx context.Context, amfInstance *amf.AMF, ran *amf.
117117
}
118118

119119
ranUe := ran.FindUEByRanUeNgapID(rANUENGAPID.Value)
120-
if ranUe != nil && ranUe.AmfUe() == nil {
120+
if ranUe != nil {
121+
// The gNB reused a RAN UE NGAP ID in a new InitialUEMessage, which
122+
// means the previous RAN-level context for that ID is abandoned
123+
// (e.g. gNB sent a new registration before completing the old
124+
// UEContextRelease). Remove the stale ranUe so a fresh one is
125+
// created below with a new AMF UE NGAP ID — this prevents a
126+
// deferred UEContextReleaseComplete (carrying the old AMF UE NGAP
127+
// ID) from accidentally removing the new context.
128+
logger.WithTrace(ctx, ran.Log).Debug("RAN UE NGAP ID reused in InitialUEMessage, removing stale RanUe",
129+
zap.Int64("RanUeNgapID", ranUe.RanUeNgapID),
130+
zap.Int64("AmfUeNgapID", ranUe.AmfUeNgapID))
131+
121132
err := ranUe.Remove()
122133
if err != nil {
123134
logger.WithTrace(ctx, ran.Log).Error(err.Error())
@@ -176,9 +187,6 @@ func HandleInitialUEMessage(ctx context.Context, amfInstance *amf.AMF, ran *amf.
176187
amfUe.AttachRanUe(ranUe)
177188
}
178189
}
179-
} else {
180-
ranUe.Radio = ran
181-
ranUe.AmfUe().AttachRanUe(ranUe)
182190
}
183191

184192
if userLocationInformation != nil {

observability/grafana/dashboards/deep_dive.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1504,7 +1504,7 @@
15041504
"percentChangeColorMode": "standard",
15051505
"reduceOptions": {
15061506
"calcs": [
1507-
"lastNotNull"
1507+
"max"
15081508
],
15091509
"fields": "",
15101510
"values": false

0 commit comments

Comments
 (0)