Skip to content

Commit af206e6

Browse files
authored
fix: remove unnecessary mobility registration update rejection (#1378)
Signed-off-by: Guillaume Belanger <guillaume.belanger27@gmail.com>
1 parent dd9a345 commit af206e6

2 files changed

Lines changed: 14 additions & 35 deletions

File tree

internal/amf/nas/gmm/reg_mobility_periodic_registration_updating.go

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,10 @@ func HandleMobilityAndPeriodicRegistrationUpdating(ctx context.Context, amfInsta
5050

5151
ue.Current().AllowedNssai = subscriberProfile.AllowedNssai
5252

53-
if conn.RegistrationRequest.Capability5GMM == nil {
54-
if conn.RegistrationType5GS != nasMessage.RegistrationType5GSPeriodicRegistrationUpdating {
55-
UERegistrationAttempts.WithLabelValues(getRegistrationType5GSName(conn.RegistrationType5GS), RegistrationReject).Inc()
56-
57-
err := message.SendRegistrationReject(ctx, ranUe, nasMessage.Cause5GMMProtocolErrorUnspecified)
58-
if err != nil {
59-
return fmt.Errorf("error sending registration reject: %v", err)
60-
}
61-
62-
return fmt.Errorf("Capability5GMM is nil")
63-
}
64-
}
53+
// The 5GMM capability IE is optional (TS 24.501 Table 8.2.6.1.1) and is
54+
// re-sent only when it changes (§5.5.1.3.2). Its absence is not an error:
55+
// per §7.7.1 the receiver treats a missing optional IE as not present and
56+
// proceeds.
6557

6658
if conn.RegistrationRequest.MICOIndication != nil {
6759
ue.Log.Warn("Receive MICO Indication Not Supported", zap.Uint8("RAAI", conn.RegistrationRequest.GetRAAI()))

internal/amf/nas/gmm/reg_mobility_periodic_registration_updating_test.go

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -182,40 +182,27 @@ func TestMobilityReg_GetOperatorInfoError(t *testing.T) {
182182
}
183183
}
184184

185-
func TestMobilityReg_NilCapability5GMM_Mobility_SendsReject(t *testing.T) {
185+
// A mobility registration update with no 5GMM capability IE is valid: the IE
186+
// is optional and re-sent only on change (TS 24.501 §5.5.1.3.2, §7.7.1), so the
187+
// AMF accepts rather than rejecting.
188+
func TestMobilityReg_NilCapability5GMM_Mobility_Continues(t *testing.T) {
186189
ue, ngapSender, _, amfInstance := buildMobilityRegUeAndAMF(t)
187190

188191
ue.NasConn().RegistrationRequest.Capability5GMM = nil
189192
ue.NasConn().RegistrationType5GS = nasMessage.RegistrationType5GSMobilityRegistrationUpdating
190193

191194
err := HandleMobilityAndPeriodicRegistrationUpdating(context.TODO(), amfInstance, ue)
192-
if err == nil {
193-
t.Fatal("expected error for nil Capability5GMM, got nil")
194-
}
195-
196-
if err.Error() != "Capability5GMM is nil" {
197-
t.Fatalf("unexpected error: %v", err)
195+
if err != nil {
196+
t.Fatalf("expected no error for mobility reg with nil Capability5GMM, got: %v", err)
198197
}
199198

200199
if len(ngapSender.SentDownlinkNASTransport) != 1 {
201-
t.Fatalf("expected 1 DownlinkNASTransport (RegistrationReject), got %d", len(ngapSender.SentDownlinkNASTransport))
202-
}
203-
204-
resp := ngapSender.SentDownlinkNASTransport[0]
205-
nm := new(nas.Message)
206-
nm.SecurityHeaderType = nas.GetSecurityHeaderType(resp.NasPdu) & 0x0f
207-
208-
if nm.SecurityHeaderType != nas.SecurityHeaderTypePlainNas {
209-
t.Fatalf("expected plain NAS, got security header type %d", nm.SecurityHeaderType)
210-
}
211-
212-
err = nm.PlainNasDecode(&resp.NasPdu)
213-
if err != nil {
214-
t.Fatalf("could not decode NAS message: %v", err)
200+
t.Fatalf("expected 1 DownlinkNASTransport, got %d", len(ngapSender.SentDownlinkNASTransport))
215201
}
216202

217-
if nm.GmmHeader.GetMessageType() != nas.MsgTypeRegistrationReject {
218-
t.Fatalf("expected RegistrationReject, got %v", nm.GmmHeader.GetMessageType())
203+
nm := decryptAndDecodeNasPdu(t, ue, ngapSender.SentDownlinkNASTransport[0].NasPdu, 0)
204+
if nm.GmmHeader.GetMessageType() != nas.MsgTypeRegistrationAccept {
205+
t.Fatalf("expected RegistrationAccept, got %v", nm.GmmHeader.GetMessageType())
219206
}
220207
}
221208

0 commit comments

Comments
 (0)