Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SMF crash fix & log cleanup #177

Merged
merged 8 commits into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion callback/api_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func SmPolicyControlTerminationRequestNotification(c *gin.Context) {
}

func N1N2FailureNotification(c *gin.Context) {
logger.PduSessLog.Info("Recieve N1N2 Failure Notification")
logger.PduSessLog.Info("Receive N1N2 Failure Notification")
stats.IncrementN11MsgStats(smf_context.SMF_Self().NfInstanceID, string(svcmsgtypes.N1N2MessageTransferFailureNotification), "In", "", "")

var request models.N1N2MsgTxfrFailureNotification
Expand Down
13 changes: 7 additions & 6 deletions context/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func SetupSmfCollection() {
}

smfCount := MongoDBLibrary.GetUniqueIdentity("smfCount")
logger.CtxLog.Infof("unique id - init smfCount %+v\n", smfCount)
logger.CtxLog.Infof("unique id - init smfCount %d", smfCount)

// set os env
os.Setenv("SMF_COUNT", strconv.Itoa(int(smfCount)))
Expand Down Expand Up @@ -248,7 +248,7 @@ func StoreSmContextInDB(smContext *SMContext) {
defer smContext.SMLock.Unlock()
smContextBsonA := ToBsonM(smContext)
filter := bson.M{"ref": smContext.Ref}
logger.CtxLog.Infof("filter : %+v\n", filter)
logger.CtxLog.Infof("filter: %+v", filter)

MongoDBLibrary.RestfulAPIPost(SmContextDataColl, filter, smContextBsonA)

Expand All @@ -273,7 +273,7 @@ func StoreSeidContextInDB(seidUint uint64, smContext *SMContext) {
}
itemBsonA := ToBsonMSeidRef(item)
filter := bson.M{"seid": seid}
logger.CtxLog.Infof("filter : %+v\n", filter)
logger.CtxLog.Infof("filter: %+v", filter)

MongoDBLibrary.RestfulAPIPost(SeidSmContextCol, filter, itemBsonA)
}
Expand All @@ -287,7 +287,7 @@ func StoreRefToSeidInDB(seidUint uint64, smContext *SMContext) {
}
itemBsonA := ToBsonMSeidRef(item)
filter := bson.M{"ref": smContext.Ref}
logger.CtxLog.Infof("filter : %+v\n", filter)
logger.CtxLog.Infof("filter: %+v", filter)

MongoDBLibrary.RestfulAPIPost(RefSeidCol, filter, itemBsonA)
}
Expand Down Expand Up @@ -349,7 +349,7 @@ func DeleteSmContextInDBBySEID(seidUint uint64) {
seid := SeidConv(seidUint)
fmt.Println("db - delete SMContext In DB by seid")
filter := bson.M{"seid": seid}
logger.CtxLog.Infof("filter : %+v\n", filter)
logger.CtxLog.Infof("filter: %+v", filter)

result := MongoDBLibrary.RestfulAPIGetOne(SeidSmContextCol, filter)
if result != nil {
Expand All @@ -367,7 +367,8 @@ func DeleteSmContextInDBBySEID(seidUint uint64) {
func DeleteSmContextInDBByRef(ref string) {
fmt.Println("db - delete SMContext In DB w ref")
filter := bson.M{"ref": ref}
logger.CtxLog.Infof("filter : %+v\n", filter)
logger.CtxLog.Infof("filter: %+v", filter)

MongoDBLibrary.RestfulAPIDeleteOne(SmContextDataColl, filter)
}

Expand Down
2 changes: 1 addition & 1 deletion context/db_uptunnel.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ func ToBsonMNodeInDB(data *DataPathNodeInDB) (ret bson.M) {
func StoreNodeInDB(nodeInDB *DataPathNodeInDB) {
itemBsonA := ToBsonMNodeInDB(nodeInDB)
filter := bson.M{"nodeIDInDB": nodeInDB.DataPathNodeUPFNodeID}
logger.CtxLog.Infof("filter : %+v\n", filter)
logger.CtxLog.Infof("filter: %+v", filter)

MongoDBLibrary.RestfulAPIPost(NodeInDBCol, filter, itemBsonA)
}
Expand Down
4 changes: 3 additions & 1 deletion context/sm_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,9 @@ func (smContext *SMContext) PublishSmCtxtInfo() {

//Populate kafka sm ctxt struct
kafkaSmCtxt.Imsi = smContext.Supi
kafkaSmCtxt.IPAddress = smContext.PDUAddress.Ip.String()
if smContext.PDUAddress != nil && smContext.PDUAddress.Ip != nil {
kafkaSmCtxt.IPAddress = smContext.PDUAddress.Ip.String()
thakurajayL marked this conversation as resolved.
Show resolved Hide resolved
}
kafkaSmCtxt.SmfSubState, op = mapPduSessStateToMetricStateAndOp(smContext.SMContextState)
kafkaSmCtxt.SmfId = smContext.Ref
kafkaSmCtxt.Slice = "sd:" + smContext.Snssai.Sd + " sst:" + strconv.Itoa(int(smContext.Snssai.Sst))
Expand Down
8 changes: 8 additions & 0 deletions fsm/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ package fsm
import (
"fmt"

mi "github.com/omec-project/metricfunc/pkg/metricinfo"
smf_context "github.com/omec-project/smf/context"
stats "github.com/omec-project/smf/metrics"
"github.com/omec-project/smf/producer"
"github.com/omec-project/smf/transaction"
)
Expand Down Expand Up @@ -94,11 +96,13 @@ func EmptyEventHandler(event SmEvent, eventData *SmEventData) (smf_context.SMCon
func HandleStateInitEventPduSessCreate(event SmEvent, eventData *SmEventData) (smf_context.SMContextState, error) {

if err := producer.HandlePDUSessionSMContextCreate(eventData.Txn); err != nil {
stats.PublishMsgEvent(mi.Smf_msg_type_pdu_sess_create_req_failure)
txn := eventData.Txn.(*transaction.Transaction)
txn.Err = err
return smf_context.SmStateInit, fmt.Errorf("pdu session create error, %v ", err.Error())
}

stats.PublishMsgEvent(mi.Smf_msg_type_pdu_sess_create_rsp_success)
return smf_context.SmStatePfcpCreatePending, nil
}

Expand Down Expand Up @@ -127,9 +131,11 @@ func HandleStateN1N2TransferPendingEventN1N2Transfer(event SmEvent, eventData *S
smCtxt := txn.Ctxt.(*smf_context.SMContext)

if err := producer.SendPduSessN1N2Transfer(smCtxt, true); err != nil {
stats.PublishMsgEvent(mi.Smf_msg_type_pdu_sess_update_req_failure)
smCtxt.SubFsmLog.Errorf("N1N2 transfer failure error, %v ", err.Error())
return smf_context.SmStateN1N2TransferPending, fmt.Errorf("N1N2 Transfer failure error, %v ", err.Error())
}
stats.PublishMsgEvent(mi.Smf_msg_type_pdu_sess_update_rsp_success)
return smf_context.SmStateActive, nil
}

Expand Down Expand Up @@ -170,9 +176,11 @@ func HandleStateActiveEventPduSessRelease(event SmEvent, eventData *SmEventData)
smCtxt := txn.Ctxt.(*smf_context.SMContext)

if err := producer.HandlePDUSessionSMContextRelease(eventData.Txn); err != nil {
stats.PublishMsgEvent(mi.Smf_msg_type_pdu_sess_release_req_failure)
smCtxt.SubFsmLog.Errorf("sm context release error, %v ", err.Error())
return smf_context.SmStateInit, err
}
stats.PublishMsgEvent(mi.Smf_msg_type_pdu_sess_release_rsp_success)
return smf_context.SmStateInit, nil
}

Expand Down
4 changes: 2 additions & 2 deletions pdusession/api_individual_sm_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import (

// HTTPReleaseSmContext - Release SM Context
func HTTPReleaseSmContext(c *gin.Context) {
logger.PduSessLog.Info("Recieve Release SM Context Request")
logger.PduSessLog.Info("Receive Release SM Context Request")
stats.IncrementN11MsgStats(smf_context.SMF_Self().NfInstanceID, string(svcmsgtypes.ReleaseSmContext), "In", "", "")
stats.PublishMsgEvent(mi.Smf_msg_type_pdu_sess_release_req)

Expand Down Expand Up @@ -87,7 +87,7 @@ func RetrieveSmContext(c *gin.Context) {

// HTTPUpdateSmContext - Update SM Context
func HTTPUpdateSmContext(c *gin.Context) {
logger.PduSessLog.Info("Recieve Update SM Context Request")
logger.PduSessLog.Info("Receive Update SM Context Request")
stats.IncrementN11MsgStats(smf_context.SMF_Self().NfInstanceID, string(svcmsgtypes.UpdateSmContext), "In", "", "")
stats.PublishMsgEvent(mi.Smf_msg_type_pdu_sess_update_req)

Expand Down
2 changes: 1 addition & 1 deletion pdusession/api_sm_contexts_collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import (

// HTTPPostSmContexts - Create SM Context
func HTTPPostSmContexts(c *gin.Context) {
logger.PduSessLog.Info("Recieve Create SM Context Request")
logger.PduSessLog.Info("Receive Create SM Context Request")
var request models.PostSmContextsRequest
stats.IncrementN11MsgStats(smf_context.SMF_Self().NfInstanceID, string(svcmsgtypes.CreateSmContext), "In", "", "")
stats.PublishMsgEvent(mi.Smf_msg_type_pdu_sess_create_req)
Expand Down
10 changes: 5 additions & 5 deletions pfcp/adapter/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ func HandlePfcpSessionEstablishmentResponse(msg *pfcpUdp.Message) {
}
}
smContext := smf_context.GetSMContextBySEID(SEID)
logger.PfcpLog.Infoln("In HandlePfcpSessionEstablishmentResponse SEID ", SEID)
logger.PfcpLog.Infof("In HandlePfcpSessionEstablishmentResponse smContext %+v\n", smContext)
logger.PfcpLog.Infof("In HandlePfcpSessionEstablishmentResponse SEID %v", SEID)
logger.PfcpLog.Infof("In HandlePfcpSessionEstablishmentResponse smContext %+v", smContext)

//Get NodeId from Seq:NodeId Map
seq := msg.PfcpMessage.Header.SequenceNumber
Expand Down Expand Up @@ -235,13 +235,13 @@ func HandlePfcpSessionModificationResponse(msg *pfcpUdp.Message) {
logger.PfcpLog.Infoln("In HandlePfcpSessionModificationResponse")

pfcpRsp := msg.PfcpMessage.Body.(pfcp.PFCPSessionModificationResponse)
logger.PfcpLog.Infof("In HandlePfcpSessionModificationResponse pfcpRsp.Cause.CauseValue = [%+v], accepted?? %+v\n", pfcpRsp.Cause.CauseValue, pfcpRsp.Cause.CauseValue == pfcpType.CauseRequestAccepted)
logger.PfcpLog.Infof("In HandlePfcpSessionModificationResponse pfcpRsp.Cause.CauseValue = [%v], accepted?? %v", pfcpRsp.Cause.CauseValue, pfcpRsp.Cause.CauseValue == pfcpType.CauseRequestAccepted)

SEID := msg.PfcpMessage.Header.SEID
logger.PfcpLog.Infof("In HandlePfcpSessionModificationResponse SEID %+v\n", SEID)
logger.PfcpLog.Infof("In HandlePfcpSessionModificationResponse SEID %v", SEID)

smContext := smf_context.GetSMContextBySEID(SEID)
logger.PfcpLog.Infof("In HandlePfcpSessionModificationResponse smContext found by SEID %+v\n", smContext)
logger.PfcpLog.Infof("In HandlePfcpSessionModificationResponse smContext found by SEID %v", smContext)
thakurajayL marked this conversation as resolved.
Show resolved Hide resolved

if SEID == 0 {
if eventData, ok := msg.EventData.(pfcpUdp.PfcpEventData); !ok {
Expand Down
11 changes: 6 additions & 5 deletions pfcp/message/send.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ func SendHeartbeatRequest(upNodeID pfcpType.NodeID, upfPort uint16) error {
logger.PfcpLog.Fatalln(err)
}
pfcpMsgString := string(pfcpMsgBytes)
logger.PfcpLog.Debugf("pfcp rsp status ok, %+v\n", pfcpMsgString)
logger.PfcpLog.Debugf("pfcp rsp status ok, %s", pfcpMsgString)

pfcpRspMsg := pfcp.Message{}
json.Unmarshal(pfcpMsgBytes, &pfcpRspMsg)
adapter.HandleAdapterPfcpRsp(pfcpRspMsg, nil)
Expand Down Expand Up @@ -182,7 +183,7 @@ func SendPfcpAssociationSetupRequest(upNodeID pfcpType.NodeID, upfPort uint16) {
logger.PfcpLog.Fatalln(err)
}
pfcpMsgString := string(pfcpMsgBytes)
logger.PfcpLog.Debugf("pfcp rsp status ok, %+v\n", pfcpMsgString)
logger.PfcpLog.Debugf("pfcp rsp status ok, %s", pfcpMsgString)
pfcpRspMsg := pfcp.Message{}
json.Unmarshal(pfcpMsgBytes, &pfcpRspMsg)
adapter.HandleAdapterPfcpRsp(pfcpRspMsg, nil)
Expand Down Expand Up @@ -322,7 +323,7 @@ func SendPfcpSessionEstablishmentRequest(
logger.PfcpLog.Fatalln(err)
}
pfcpMsgString := string(pfcpMsgBytes)
logger.PfcpLog.Debugf("pfcp rsp status ok, %+v", pfcpMsgString)
logger.PfcpLog.Debugf("pfcp rsp status ok, %s", pfcpMsgString)
pfcpRspMsg := pfcp.Message{}
json.Unmarshal(pfcpMsgBytes, &pfcpRspMsg)
eventData := pfcpUdp.PfcpEventData{LSEID: ctx.PFCPContext[ip.String()].LocalSEID, ErrHandler: HandlePfcpSendError}
Expand Down Expand Up @@ -406,7 +407,7 @@ func SendPfcpSessionModificationRequest(upNodeID pfcpType.NodeID,
logger.PfcpLog.Fatalln(err)
}
pfcpMsgString := string(pfcpMsgBytes)
logger.PfcpLog.Debugf("pfcp rsp status ok, %+v\n", pfcpMsgString)
logger.PfcpLog.Debugf("pfcp rsp status ok, %s", pfcpMsgString)
pfcpRspMsg := pfcp.Message{}
json.Unmarshal(pfcpMsgBytes, &pfcpRspMsg)
eventData := pfcpUdp.PfcpEventData{LSEID: ctx.PFCPContext[nodeIDtoIP].LocalSEID, ErrHandler: HandlePfcpSendError}
Expand Down Expand Up @@ -487,7 +488,7 @@ func SendPfcpSessionDeletionRequest(upNodeID pfcpType.NodeID, ctx *smf_context.S
logger.PfcpLog.Fatalln(err)
}
pfcpMsgString := string(pfcpMsgBytes)
logger.PfcpLog.Debugf("pfcp rsp status ok, %+v\n", pfcpMsgString)
logger.PfcpLog.Debugf("pfcp rsp status ok, %s", pfcpMsgString)
pfcpRspMsg := pfcp.Message{}
json.Unmarshal(pfcpMsgBytes, &pfcpRspMsg)
eventData := pfcpUdp.PfcpEventData{LSEID: ctx.PFCPContext[nodeIDtoIP].LocalSEID, ErrHandler: HandlePfcpSendError}
Expand Down
37 changes: 20 additions & 17 deletions qos/qos_rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,12 @@ func TestBuildQosRules(t *testing.T) {
fmt.Printf("Marshal Error : %v", err.Error())
} else {
fmt.Printf("Encoded Bytes: %v", bytes)
expectedBytes := []byte{0x1, 0x0, 0x37, 0x32, 0x31, 0x18, 0x10, 0x1, 0x1,
0x1, 0x1, 0xff, 0xff, 0xff, 0xff, 0x50, 0x3, 0xe8, 0x11, 0x2, 0x2, 0x2,
0x2, 0xff, 0xff, 0xff, 0xff, 0x40, 0x7, 0xd0, 0x32, 0x18, 0x10, 0x3, 0x3,
0x3, 0x3, 0xff, 0xff, 0xff, 0xff, 0x50, 0xb, 0xb8, 0x11, 0x4, 0x4, 0x4,
0x4, 0xff, 0xff, 0xff, 0xff, 0x40, 0xf, 0xa0, 0xc8, 0x1}
expectedBytes := []byte{0x1, 0x0, 0x37, 0x32, 0x31, 0x18, 0x10,
0x1, 0x1, 0x1, 0x1, 0xff, 0xff, 0xff, 0xff, 0x50, 0x3, 0xe8,
0x11, 0x2, 0x2, 0x2, 0x2, 0xff, 0xff, 0xff, 0xff, 0x40, 0x7,
0xd0, 0x32, 0x18, 0x10, 0x3, 0x3, 0x3, 0x3, 0xff, 0xff, 0xff,
0xff, 0x50, 0xb, 0xb8, 0x11, 0x4, 0x4, 0x4, 0x4, 0xff, 0xff,
0xff, 0xff, 0x40, 0xf, 0xa0, 0xc8, 0x5}
require.Equal(t, expectedBytes, bytes)
}

Expand Down Expand Up @@ -100,7 +101,7 @@ func makeSamplePccRules() map[string]*models.PccRule {

func makeSampleQosData() map[string]*models.QosData {
qosData1 := models.QosData{
QosId: "1",
QosId: "5",
Var5qi: 5,
MaxbrUl: "101 Mbps",
MaxbrDl: "201 Mbps",
Expand All @@ -110,20 +111,22 @@ func makeSampleQosData() map[string]*models.QosData {
DefQosFlowIndication: true,
}

qosData2 := models.QosData{
QosId: "2",
Var5qi: 3,
MaxbrUl: "301 Mbps",
MaxbrDl: "401 Mbps",
GbrUl: "31 Mbps",
GbrDl: "41 Mbps",
PriorityLevel: 3,
DefQosFlowIndication: false,
}
/*
qosData2 := models.QosData{
QosId: "QosData2",
Var5qi: 3,
MaxbrUl: "301 Mbps",
MaxbrDl: "401 Mbps",
GbrUl: "31 Mbps",
GbrDl: "41 Mbps",
PriorityLevel: 3,
DefQosFlowIndication: false,
}
*/

return map[string]*models.QosData{
"QosData1": &qosData1,
"QosData2": &qosData2,
// "QosData2": &qosData2,
}
}

Expand Down
Loading