Skip to content

Commit

Permalink
Fix: PDU Session Establishment panic without DNN for subscription (#28)
Browse files Browse the repository at this point in the history
* Fix: PDU Session Establishment panic without DNN for subscription

Send PDU Session Reject message back.

* update nas and openapi version
  • Loading branch information
matsumu-y authored Sep 13, 2021
1 parent 8597605 commit 46644f0
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 64 deletions.
2 changes: 1 addition & 1 deletion consumer/sm_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func SendSMPolicyAssociationCreate(smContext *smf_context.SMContext) (*models.Sm
var smPolicyDecision *models.SmPolicyDecision
if smPolicyDecisionFromPCF, _, err := smContext.SMPolicyClient.
DefaultApi.SmPoliciesPost(context.Background(), smPolicyData); err != nil {
return nil, fmt.Errorf("setup sm policy association failed: %s", err)
return nil, err
} else {
smPolicyDecision = &smPolicyDecisionFromPCF
}
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ require (
github.com/free5gc/idgenerator v1.0.0
github.com/free5gc/logger_conf v1.0.0
github.com/free5gc/logger_util v1.0.0
github.com/free5gc/nas v1.0.0
github.com/free5gc/nas v1.0.1
github.com/free5gc/ngap v1.0.2
github.com/free5gc/openapi v1.0.0
github.com/free5gc/openapi v1.0.1
github.com/free5gc/path_util v1.0.0
github.com/free5gc/pfcp v1.0.1
github.com/free5gc/util_3gpp v1.0.0
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,15 @@ github.com/free5gc/logger_util v1.0.0 h1:hLTCTnKlEqJURrBwooNFQLavWPdJzS0o9KGIYUN
github.com/free5gc/logger_util v1.0.0/go.mod h1:TK/bAJbm/l2TMNmbsKn83+xUmDNqts69IEir/nCa8w0=
github.com/free5gc/nas v1.0.0 h1:OO4klCGRhflBrOUMyKfFXwxGu5Sz4B8vYrWtIXA1G9Q=
github.com/free5gc/nas v1.0.0/go.mod h1:aZkA9pzIy6D1I4mTYExoUsr1pBwC81+aLvhs382TlD0=
github.com/free5gc/nas v1.0.1 h1:3qOweTX4Ws7y/xKMq7FJ3Is+TlxaXZJCC2qyJ04ITZg=
github.com/free5gc/nas v1.0.1/go.mod h1:XYUq6xLU3iuDxZHZI6vz5MMTBewmOWpJLCtevWW6JfA=
github.com/free5gc/ngap v1.0.0/go.mod h1:FIAFElkAuJzusN2kXrCNJlSuCcQid8RZd5qZaf4N7pI=
github.com/free5gc/ngap v1.0.2 h1:/89OIJVR0AWdMfiUuoe325RnjlF45UvIFdAxWrrbiYU=
github.com/free5gc/ngap v1.0.2/go.mod h1:n9BWKtM58fxSSjvGFbsYlGiB9B3FAqMAi8ckkOP/X4Q=
github.com/free5gc/openapi v1.0.0 h1:DaGVt05b1pSDBOailKAlLj6hAk6vunN0Nhzvl/xcWCY=
github.com/free5gc/openapi v1.0.0/go.mod h1:7OzxoWBj6KQgznMW2ZiUtZdCGY+t89v4wtgKLhluKgU=
github.com/free5gc/openapi v1.0.1 h1:1KwbQ6/D8U3FEwYv3yr4O4PWpHluXRHj2OOg3TK6dG0=
github.com/free5gc/openapi v1.0.1/go.mod h1:oP4YVkZkJ0KrFnaVjT0XfRPBJdD7O6m4/PEyGtt5l1U=
github.com/free5gc/path_util v1.0.0 h1:vJPGTymaWtavz6fJ/7k6WKEYv5BQLAq/O04RP54sab0=
github.com/free5gc/path_util v1.0.0/go.mod h1:OpmcebEKrMPnH7Jg5lZ8y9ZWJNAjQ4l9FGWXUv58Mo0=
github.com/free5gc/pfcp v1.0.1 h1:btAMuCjUqDjQr+5FBv+3+ZbIouKAZkKeh0MF/TdZ1kc=
Expand Down
111 changes: 50 additions & 61 deletions producer/pdu_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,36 +105,8 @@ func HandlePDUSessionSMContextCreate(request models.PostSmContextsRequest) *http
logger.PduSessLog.Warnf("Data Path not found\n")
logger.PduSessLog.Warnln("Selection Parameter: ", upfSelectionParams.String())

var httpResponse *http_wrapper.Response
if buf, err := smf_context.
BuildGSMPDUSessionEstablishmentReject(
smContext,
nasMessage.Cause5GSMInsufficientResourcesForSpecificSliceAndDNN); err != nil {
httpResponse = &http_wrapper.Response{
Header: nil,
Status: http.StatusForbidden,
Body: models.PostSmContextsErrorResponse{
JsonData: &models.SmContextCreateError{
Error: &Nsmf_PDUSession.InsufficientResourceSliceDnn,
N1SmMsg: &models.RefToBinaryData{ContentId: "n1SmMsg"},
},
},
}
} else {
httpResponse = &http_wrapper.Response{
Header: nil,
Status: http.StatusForbidden,
Body: models.PostSmContextsErrorResponse{
JsonData: &models.SmContextCreateError{
Error: &Nsmf_PDUSession.InsufficientResourceSliceDnn,
N1SmMsg: &models.RefToBinaryData{ContentId: "n1SmMsg"},
},
BinaryDataN1SmMessage: buf,
},
}
}

return httpResponse
return makeErrorResponse(smContext, nasMessage.Cause5GSMInsufficientResourcesForSpecificSliceAndDNN,
&Nsmf_PDUSession.InsufficientResourceSliceDnn)
}
smContext.PDUAddress = ip
smContext.SelectedUPF = selectedUPF
Expand Down Expand Up @@ -177,7 +149,18 @@ func HandlePDUSessionSMContextCreate(request models.PostSmContextsRequest) *http

var smPolicyDecision *models.SmPolicyDecision
if smPolicyDecisionRsp, err := consumer.SendSMPolicyAssociationCreate(smContext); err != nil {
logger.PduSessLog.Errorf("")
openapiError := err.(openapi.GenericOpenAPIError)
problemDetails := openapiError.Model().(models.ProblemDetails)
logger.PduSessLog.Errorln("setup sm policy association failed:", err, problemDetails)
smContext.SMContextState = smf_context.InActive
logger.CtxLog.Traceln("SMContextState Change State: ", smContext.SMContextState.String())

if problemDetails.Cause == "USER_UNKNOWN" {
return makeErrorResponse(smContext, nasMessage.Cause5GSMRequestRejectedUnspecified,
&Nsmf_PDUSession.SubscriptionDenied)
} else {
return makeErrorResponse(smContext, nasMessage.Cause5GSMNetworkFailure, &Nsmf_PDUSession.NetworkFailure)
}
} else {
smPolicyDecision = smPolicyDecisionRsp
}
Expand Down Expand Up @@ -217,36 +200,8 @@ func HandlePDUSessionSMContextCreate(request models.PostSmContextsRequest) *http
logger.PduSessLog.Warnf("Data Path not found\n")
logger.PduSessLog.Warnln("Selection Parameter: ", upfSelectionParams.String())

var httpResponse *http_wrapper.Response
if buf, err := smf_context.
BuildGSMPDUSessionEstablishmentReject(
smContext,
nasMessage.Cause5GSMInsufficientResourcesForSpecificSliceAndDNN); err != nil {
httpResponse = &http_wrapper.Response{
Header: nil,
Status: http.StatusForbidden,
Body: models.PostSmContextsErrorResponse{
JsonData: &models.SmContextCreateError{
Error: &Nsmf_PDUSession.InsufficientResourceSliceDnn,
N1SmMsg: &models.RefToBinaryData{ContentId: "n1SmMsg"},
},
},
}
} else {
httpResponse = &http_wrapper.Response{
Header: nil,
Status: http.StatusForbidden,
Body: models.PostSmContextsErrorResponse{
JsonData: &models.SmContextCreateError{
Error: &Nsmf_PDUSession.InsufficientResourceSliceDnn,
N1SmMsg: &models.RefToBinaryData{ContentId: "n1SmMsg"},
},
BinaryDataN1SmMessage: buf,
},
}
}

return httpResponse
return makeErrorResponse(smContext, nasMessage.Cause5GSMInsufficientResourcesForSpecificSliceAndDNN,
&Nsmf_PDUSession.InsufficientResourceSliceDnn)
}

if problemDetails, err := consumer.SendNFDiscoveryServingAMF(smContext); err != nil {
Expand Down Expand Up @@ -946,3 +901,37 @@ func releaseTunnel(smContext *smf_context.SMContext) {
}
}
}

func makeErrorResponse(smContext *smf_context.SMContext, nasErrorCause uint8,
sbiError *models.ProblemDetails) *http_wrapper.Response {
var httpResponse *http_wrapper.Response

if buf, err := smf_context.
BuildGSMPDUSessionEstablishmentReject(
smContext,
nasErrorCause); err != nil {
httpResponse = &http_wrapper.Response{
Header: nil,
Status: int(sbiError.Status),
Body: models.PostSmContextsErrorResponse{
JsonData: &models.SmContextCreateError{
Error: sbiError,
N1SmMsg: &models.RefToBinaryData{ContentId: "n1SmMsg"},
},
},
}
} else {
httpResponse = &http_wrapper.Response{
Header: nil,
Status: int(sbiError.Status),
Body: models.PostSmContextsErrorResponse{
JsonData: &models.SmContextCreateError{
Error: sbiError,
N1SmMsg: &models.RefToBinaryData{ContentId: "n1SmMsg"},
},
BinaryDataN1SmMessage: buf,
},
}
}
return httpResponse
}

0 comments on commit 46644f0

Please sign in to comment.