diff --git a/cmd/main.go b/cmd/main.go index 2691fdc8..edd4936d 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -12,8 +12,8 @@ import ( "github.com/free5gc/smf/internal/logger" "github.com/free5gc/smf/pkg/factory" "github.com/free5gc/smf/pkg/service" - logger_util "github.com/free5gc/util/logger" "github.com/free5gc/smf/pkg/utils" + logger_util "github.com/free5gc/util/logger" "github.com/free5gc/util/version" ) diff --git a/go.mod b/go.mod index 0a19c638..09b08452 100644 --- a/go.mod +++ b/go.mod @@ -39,12 +39,13 @@ require ( github.com/goccy/go-json v0.10.2 // indirect github.com/golang-jwt/jwt v3.2.1+incompatible // indirect github.com/golang/protobuf v1.5.0 // indirect + github.com/google/go-cmp v0.6.0 // indirect github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 // indirect github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/jtolds/gls v4.20.0+incompatible // indirect github.com/klauspost/cpuid/v2 v2.2.4 // indirect - github.com/kr/pretty v0.3.0 // indirect + github.com/kr/pretty v0.3.1 // indirect github.com/leodido/go-urn v1.2.4 // indirect github.com/mattn/go-isatty v0.0.19 // indirect github.com/mitchellh/mapstructure v1.4.2 // indirect @@ -52,7 +53,7 @@ require ( github.com/modern-go/reflect2 v1.0.2 // indirect github.com/pelletier/go-toml/v2 v2.0.8 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/rogpeppe/go-internal v1.8.0 // indirect + github.com/rogpeppe/go-internal v1.12.0 // indirect github.com/russross/blackfriday/v2 v2.0.1 // indirect github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d // indirect @@ -61,12 +62,16 @@ require ( github.com/ugorji/go/codec v1.2.11 // indirect golang.org/x/arch v0.3.0 // indirect golang.org/x/crypto v0.21.0 // indirect + golang.org/x/mod v0.14.0 // indirect golang.org/x/net v0.23.0 // indirect golang.org/x/oauth2 v0.0.0-20210810183815-faf39c7919d5 // indirect + golang.org/x/sync v0.6.0 // indirect golang.org/x/sys v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect + golang.org/x/tools v0.17.0 // indirect google.golang.org/appengine v1.6.6 // indirect google.golang.org/protobuf v1.33.0 // indirect gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect gopkg.in/yaml.v3 v3.0.1 // indirect + mvdan.cc/gofumpt v0.6.0 // indirect ) diff --git a/go.sum b/go.sum index d100e243..c23994ef 100644 --- a/go.sum +++ b/go.sum @@ -133,6 +133,8 @@ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= @@ -169,6 +171,8 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -200,6 +204,9 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8= github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE= +github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= +github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= +github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo= @@ -281,6 +288,8 @@ golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzB golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= +golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -324,6 +333,8 @@ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= +golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -405,6 +416,8 @@ golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roY golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.17.0 h1:FvmRgNOcs3kOa+T20R1uhfP9F6HgG2mfxDv1vrx1Htc= +golang.org/x/tools v0.17.0/go.mod h1:xsh6VxdV005rRVaS6SSAf9oiAqljS7UZUacMZ8Bnsps= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -507,6 +520,8 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= +mvdan.cc/gofumpt v0.6.0 h1:G3QvahNDmpD+Aek/bNOLrFR2XC6ZAdo62dZu65gmwGo= +mvdan.cc/gofumpt v0.6.0/go.mod h1:4L0wf+kgIPZtcCWXynNS2e6bhmj73umwnuXSZarixzA= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= diff --git a/internal/context/context.go b/internal/context/context.go index ff489ffe..804aa64f 100644 --- a/internal/context/context.go +++ b/internal/context/context.go @@ -49,7 +49,7 @@ type SMFContext struct { ListenAddr string UDMProfile models.NfProfile - NfProfile NFProfile + NfProfile NFProfile Key string PEM string diff --git a/internal/context/sm_context.go b/internal/context/sm_context.go index 59d49d08..ddba0c13 100644 --- a/internal/context/sm_context.go +++ b/internal/context/sm_context.go @@ -11,6 +11,9 @@ import ( "time" "github.com/antihax/optional" + "github.com/google/uuid" + "github.com/sirupsen/logrus" + "github.com/free5gc/nas/nasConvert" "github.com/free5gc/nas/nasMessage" "github.com/free5gc/ngap/ngapType" @@ -21,10 +24,7 @@ import ( "github.com/free5gc/pfcp/pfcpType" "github.com/free5gc/smf/internal/logger" "github.com/free5gc/smf/pkg/factory" - "github.com/free5gc/util/idgenerator" - "github.com/google/uuid" - "github.com/sirupsen/logrus" ) var ( diff --git a/internal/sbi/consumer/chf_service.go b/internal/sbi/consumer/chf_service.go index 875909d8..ffe8de5e 100644 --- a/internal/sbi/consumer/chf_service.go +++ b/internal/sbi/consumer/chf_service.go @@ -103,8 +103,8 @@ func (s *nchfService) buildConvergedChargingRequest(smContext *smf_context.SMCon return req } -func (s *nchfService) SendConvergedChargingRequest(smContext *smf_context.SMContext, requestType smf_context.RequestType, - multipleUnitUsage []models.MultipleUnitUsage, +func (s *nchfService) SendConvergedChargingRequest(smContext *smf_context.SMContext, + requestType smf_context.RequestType, multipleUnitUsage []models.MultipleUnitUsage, ) (*models.ChargingDataResponse, *models.ProblemDetails, error) { logger.ChargingLog.Info("Handle SendConvergedChargingRequest") diff --git a/internal/sbi/consumer/nrf_service.go b/internal/sbi/consumer/nrf_service.go index bfc6572d..3027dce8 100644 --- a/internal/sbi/consumer/nrf_service.go +++ b/internal/sbi/consumer/nrf_service.go @@ -272,7 +272,9 @@ func (s *nnrfService) SendSearchNFInstances(nrfUri string, targetNfType, request return &result, err } -func (s *nnrfService) NFDiscoveryUDM(ctx context.Context) (result models.SearchResult, httpResp *http.Response, localErr error) { +func (s *nnrfService) NFDiscoveryUDM(ctx context.Context) (result models.SearchResult, + httpResp *http.Response, localErr error, +) { localVarOptionals := Nnrf_NFDiscovery.SearchNFInstancesParamOpts{} smfContext := s.consumer.Context() @@ -284,7 +286,9 @@ func (s *nnrfService) NFDiscoveryUDM(ctx context.Context) (result models.SearchR return result, httpResp, localErr } -func (s *nnrfService) NFDiscoveryPCF(ctx context.Context) (result models.SearchResult, httpResp *http.Response, localErr error) { +func (s *nnrfService) NFDiscoveryPCF(ctx context.Context) ( + result models.SearchResult, httpResp *http.Response, localErr error, +) { localVarOptionals := Nnrf_NFDiscovery.SearchNFInstancesParamOpts{} smfContext := s.consumer.Context() @@ -296,7 +300,9 @@ func (s *nnrfService) NFDiscoveryPCF(ctx context.Context) (result models.SearchR return result, httpResp, localErr } -func (s *nnrfService) NFDiscoveryAMF(smContext *smf_context.SMContext, ctx context.Context) (result models.SearchResult, httpResp *http.Response, localErr error) { +func (s *nnrfService) NFDiscoveryAMF(smContext *smf_context.SMContext, ctx context.Context) ( + result models.SearchResult, httpResp *http.Response, localErr error, +) { localVarOptionals := Nnrf_NFDiscovery.SearchNFInstancesParamOpts{} localVarOptionals.TargetNfInstanceId = optional.NewInterface(smContext.ServingNfId) @@ -326,8 +332,8 @@ func (s *nnrfService) SendNFDiscoveryUDM() (*models.ProblemDetails, error) { for _, service := range *smfContext.UDMProfile.NfServices { if service.ServiceName == models.ServiceName_NUDM_SDM { - smfContext.SubscriberDataManagementClient = - s.consumer.nudmService.getSubscribeDataManagementClient(service.ApiPrefix) + smfContext.SubscriberDataManagementClient = s.consumer.nudmService. + getSubscribeDataManagementClient(service.ApiPrefix) } } diff --git a/internal/sbi/consumer/pcf_service.go b/internal/sbi/consumer/pcf_service.go index 9d867829..8f83af09 100644 --- a/internal/sbi/consumer/pcf_service.go +++ b/internal/sbi/consumer/pcf_service.go @@ -50,7 +50,9 @@ func (s *npcfService) getSMPolicyControlClient(uri string) *Npcf_SMPolicyControl } // SendSMPolicyAssociationCreate create the session management association to the PCF -func (s *npcfService) SendSMPolicyAssociationCreate(smContext *smf_context.SMContext) (string, *models.SmPolicyDecision, error) { +func (s *npcfService) SendSMPolicyAssociationCreate(smContext *smf_context.SMContext) ( + string, *models.SmPolicyDecision, error, +) { var client *Npcf_SMPolicyControl.APIClient // Create SMPolicyControl Client for this SM Context diff --git a/internal/sbi/processor/callback.go b/internal/sbi/processor/callback.go index 7c2a969c..451ce95a 100644 --- a/internal/sbi/processor/callback.go +++ b/internal/sbi/processor/callback.go @@ -27,7 +27,9 @@ func (p *Processor) HandleChargingNotification(chargingNotifyRequest models.Char // While receive Charging Notification from CHF, SMF will send Charging Information to CHF and update UPF // The Charging Notification will be sent when CHF found the changes of the quota file. -func (p *Processor) chargingNotificationProcedure(req models.ChargingNotifyRequest, smContextRef string) *models.ProblemDetails { +func (p *Processor) chargingNotificationProcedure( + req models.ChargingNotifyRequest, smContextRef string, +) *models.ProblemDetails { if smContext := smf_context.GetSMContextByRef(smContextRef); smContext != nil { smContext.SMLock.Lock() defer smContext.SMLock.Unlock() diff --git a/internal/sbi/processor/charging_trigger.go b/internal/sbi/processor/charging_trigger.go index 072ec2d8..7bbb7778 100644 --- a/internal/sbi/processor/charging_trigger.go +++ b/internal/sbi/processor/charging_trigger.go @@ -22,7 +22,9 @@ func (p *Processor) CreateChargingSession(smContext *smf_context.SMContext) { } } -func (p *Processor) UpdateChargingSession(smContext *smf_context.SMContext, urrList []*smf_context.URR, trigger models.Trigger) { +func (p *Processor) UpdateChargingSession( + smContext *smf_context.SMContext, urrList []*smf_context.URR, trigger models.Trigger, +) { var multipleUnitUsage []models.MultipleUnitUsage for _, urr := range urrList { @@ -242,7 +244,9 @@ func getUrrByRg(smContext *smf_context.SMContext, upfId string, rg int32) *smf_c } // Update the urr by the charging information renewed by chf -func (p *Processor) updateGrantedQuota(smContext *smf_context.SMContext, multipleUnitInformation []models.MultipleUnitInformation) { +func (p *Processor) updateGrantedQuota( + smContext *smf_context.SMContext, multipleUnitInformation []models.MultipleUnitInformation, +) { for _, ui := range multipleUnitInformation { trigger := pfcpType.ReportingTriggers{} diff --git a/internal/sbi/processor/pdu_session.go b/internal/sbi/processor/pdu_session.go index 6bfe01a8..e2cb4291 100644 --- a/internal/sbi/processor/pdu_session.go +++ b/internal/sbi/processor/pdu_session.go @@ -247,7 +247,9 @@ func (p *Processor) HandlePDUSessionSMContextCreate(isDone <-chan struct{}, } } -func (p *Processor) HandlePDUSessionSMContextUpdate(smContextRef string, body models.UpdateSmContextRequest) *httpwrapper.Response { +func (p *Processor) HandlePDUSessionSMContextUpdate( + smContextRef string, body models.UpdateSmContextRequest, +) *httpwrapper.Response { // GSM State // PDU Session Modification Reject(Cause Value == 43 || Cause Value != 43)/Complete // PDU Session Release Command/Complete @@ -867,7 +869,9 @@ func (p *Processor) HandlePDUSessionSMContextUpdate(smContextRef string, body mo return httpResponse } -func (p *Processor) HandlePDUSessionSMContextRelease(smContextRef string, body models.ReleaseSmContextRequest) *httpwrapper.Response { +func (p *Processor) HandlePDUSessionSMContextRelease( + smContextRef string, body models.ReleaseSmContextRequest, +) *httpwrapper.Response { logger.PduSessLog.Infoln("In HandlePDUSessionSMContextRelease") smContext := smf_context.GetSMContextByRef(smContextRef) @@ -994,7 +998,9 @@ func (p *Processor) HandlePDUSessionSMContextRelease(smContextRef string, body m return httpResponse } -func (p *Processor) HandlePDUSessionSMContextLocalRelease(smContext *smf_context.SMContext, createData *models.SmContextCreateData) { +func (p *Processor) HandlePDUSessionSMContextLocalRelease( + smContext *smf_context.SMContext, createData *models.SmContextCreateData, +) { smContext.SMLock.Lock() defer smContext.SMLock.Unlock() diff --git a/internal/sbi/processor/pdu_session_test.go b/internal/sbi/processor/pdu_session_test.go index 4cf8256a..3ccf4fe3 100644 --- a/internal/sbi/processor/pdu_session_test.go +++ b/internal/sbi/processor/pdu_session_test.go @@ -576,7 +576,10 @@ func TestHandlePDUSessionSMContextCreate(t *testing.T) { } mockSmf := app.NewMockApp(gomock.NewController(t)) - consumer, _ := consumer.NewConsumer(mockSmf) + consumer, err := consumer.NewConsumer(mockSmf) + if err != nil { + t.Fatalf("Failed to create consumer: %+v", err) + } processor, err := processor.NewProcessor(mockSmf, consumer) if err != nil { t.Fatalf("Failed to create processor: %+v", err) @@ -594,7 +597,8 @@ func TestHandlePDUSessionSMContextCreate(t *testing.T) { createData := tc.request.JsonData if createData != nil { - if ref, err := context.ResolveRef(createData.Supi, + var ref string + if ref, err = context.ResolveRef(createData.Supi, createData.PduSessionId); err == nil { context.RemoveSMContext(ref) } diff --git a/internal/sbi/processor/sm_common.go b/internal/sbi/processor/sm_common.go index 81896bf4..adad74b8 100644 --- a/internal/sbi/processor/sm_common.go +++ b/internal/sbi/processor/sm_common.go @@ -21,7 +21,9 @@ func (p *Processor) RemoveSMContextFromAllNF(smContext *smf_context.SMContext, s go p.sendSMContextStatusNotificationAndRemoveSMContext(smContext, sendNotification) } -func (p *Processor) sendSMContextStatusNotificationAndRemoveSMContext(smContext *smf_context.SMContext, sendNotification bool) { +func (p *Processor) sendSMContextStatusNotificationAndRemoveSMContext( + smContext *smf_context.SMContext, sendNotification bool, +) { smContext.SMLock.Lock() defer smContext.SMLock.Unlock() diff --git a/internal/sbi/server.go b/internal/sbi/server.go index 9d5ecbba..06853bce 100644 --- a/internal/sbi/server.go +++ b/internal/sbi/server.go @@ -3,12 +3,13 @@ package sbi import ( "context" "fmt" - "net/http" "runtime/debug" "sync" "time" + "github.com/gin-gonic/gin" + "github.com/free5gc/openapi/models" smf_context "github.com/free5gc/smf/internal/context" "github.com/free5gc/smf/internal/logger" @@ -19,7 +20,6 @@ import ( "github.com/free5gc/smf/pkg/factory" "github.com/free5gc/util/httpwrapper" logger_util "github.com/free5gc/util/logger" - "github.com/gin-gonic/gin" ) const ( diff --git a/pkg/app/app.go b/pkg/app/app.go index ebcef070..57c00d8b 100644 --- a/pkg/app/app.go +++ b/pkg/app/app.go @@ -10,7 +10,7 @@ type App interface { SetLogLevel(level string) SetReportCaller(reportCaller bool) - Start() error + Start() Terminate() Context() *smf_context.SMFContext diff --git a/pkg/app/mock.go b/pkg/app/mock.go index 77912c11..e82c744c 100644 --- a/pkg/app/mock.go +++ b/pkg/app/mock.go @@ -105,11 +105,9 @@ func (mr *MockAppMockRecorder) SetReportCaller(reportCaller any) *gomock.Call { } // Start mocks base method. -func (m *MockApp) Start() error { +func (m *MockApp) Start() { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Start") - ret0, _ := ret[0].(error) - return ret0 + m.ctrl.Call(m, "Start") } // Start indicates an expected call of Start. diff --git a/pkg/service/init.go b/pkg/service/init.go index 6054bca6..f33cd777 100644 --- a/pkg/service/init.go +++ b/pkg/service/init.go @@ -44,9 +44,9 @@ func NewApp( cfg *factory.Config, tlsKeyLogPath string, pfcpStart func(*SmfApp), pfcpTerminate func(), ) (*SmfApp, error) { smf := &SmfApp{ - cfg: cfg, - wg: sync.WaitGroup{}, - pfcpStart: pfcpStart, + cfg: cfg, + wg: sync.WaitGroup{}, + pfcpStart: pfcpStart, pfcpTerminate: pfcpTerminate, } smf.SetLogEnable(cfg.GetLogEnable()) @@ -144,16 +144,18 @@ func (a *SmfApp) SetReportCaller(reportCaller bool) { logger.Log.SetReportCaller(reportCaller) } -func (a *SmfApp) Start() error { +func (a *SmfApp) Start() { logger.InitLog.Infoln("Server started") - a.sbiServer.Run(context.Background(), &a.wg) + err := a.sbiServer.Run(context.Background(), &a.wg) + if err != nil { + logger.MainLog.Errorf("sbi server run error %+v", err) + } + go a.listenShutDownEvent() // Initialize PFCP server a.pfcpStart(a) - - return nil } func (a *SmfApp) listenShutDownEvent() { diff --git a/pkg/utils/pfcp_util.go b/pkg/utils/pfcp_util.go index 7f6760a6..8059c9ae 100644 --- a/pkg/utils/pfcp_util.go +++ b/pkg/utils/pfcp_util.go @@ -5,6 +5,7 @@ import ( "time" smf_context "github.com/free5gc/smf/internal/context" + "github.com/free5gc/smf/internal/logger" "github.com/free5gc/smf/internal/pfcp" "github.com/free5gc/smf/internal/pfcp/udp" "github.com/free5gc/smf/pkg/association" @@ -34,7 +35,10 @@ func InitPFCPFunc() (func(a *service.SmfApp), func()) { } pfcpStop = func() { - udp.Server.Close() + err := udp.Server.Close() + if err != nil { + logger.Log.Errorf("udp server close failed %+v", err) + } } return pfcpStart, pfcpStop