Skip to content

Commit

Permalink
[feg] s8_proxy backport fix mnc 7549 (#7571)
Browse files Browse the repository at this point in the history
  • Loading branch information
uri200 committed Jun 15, 2021
1 parent 23dba39 commit 805c1f3
Show file tree
Hide file tree
Showing 11 changed files with 342 additions and 24 deletions.
4 changes: 2 additions & 2 deletions cwf/gateway/go.mod
Expand Up @@ -43,13 +43,13 @@ require (
github.com/golang/protobuf v1.5.2
github.com/onsi/ginkgo v1.14.0 // indirect
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.5.1
github.com/prometheus/client_golang v1.10.0
github.com/shirou/gopsutil v2.20.3+incompatible
github.com/sparrc/go-ping v0.0.0-20190613174326-4e5b6552494c
github.com/stretchr/testify v1.6.1
github.com/vishvananda/netlink v1.1.0
golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b
golang.org/x/net v0.0.0-20210501142056-aec3718b3fa0
google.golang.org/appengine v1.6.5 // indirect
google.golang.org/grpc v1.33.2
magma/cwf/cloud/go v0.0.0-00010101000000-000000000000
Expand Down
150 changes: 150 additions & 0 deletions cwf/gateway/go.sum

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion cwf/k8s/cwf_operator/go.mod
Expand Up @@ -33,7 +33,6 @@ require (
github.com/garyburd/redigo v1.6.2 // indirect
github.com/go-logr/glogr v0.1.0
github.com/go-redis/redis v6.15.8+incompatible
github.com/gofrs/uuid v3.3.0+incompatible // indirect
github.com/gorilla/mux v1.7.4 // indirect
github.com/operator-framework/operator-sdk v0.16.0
github.com/spf13/pflag v1.0.5
Expand Down
1 change: 1 addition & 0 deletions cwf/k8s/cwf_operator/go.sum
Expand Up @@ -480,6 +480,7 @@ github.com/gofrs/uuid v3.2.0+incompatible h1:y12jRkkFxsd7GpqdSZ+/KCs/fJbqpEXSGd4
github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
github.com/gofrs/uuid v3.3.0+incompatible h1:8K4tyRfvU1CYPgJsveYFQMhpFd/wXNM7iK6rR7UHz84=
github.com/gofrs/uuid v3.3.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
Expand Down
8 changes: 4 additions & 4 deletions feg/gateway/go.mod
Expand Up @@ -33,16 +33,16 @@ require (
github.com/ishidawataru/sctp v0.0.0-20191218070446-00ab2ac2db07
github.com/mitchellh/mapstructure v1.3.3 // indirect
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.5.1
github.com/prometheus/client_golang v1.10.0
github.com/prometheus/client_model v0.2.0
github.com/prometheus/common v0.9.1
github.com/prometheus/common v0.18.0
github.com/shirou/gopsutil v2.20.3+incompatible
github.com/stretchr/objx v0.3.0 // indirect
github.com/stretchr/testify v1.6.1
github.com/thoas/go-funk v0.7.0
github.com/wmnsk/go-gtp v0.7.21
github.com/wmnsk/go-gtp v0.7.25
golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897 // indirect
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b
golang.org/x/net v0.0.0-20210501142056-aec3718b3fa0
google.golang.org/grpc v1.33.2
google.golang.org/protobuf v1.26.0
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 // indirect
Expand Down
148 changes: 148 additions & 0 deletions feg/gateway/go.sum

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions feg/gateway/services/s8_proxy/servicers/ie_conversions.go
Expand Up @@ -69,7 +69,7 @@ func buildCreateSessionRequestMsg(cPgwUDPAddr *net.UDPAddr, apnSuffix string, re
ie.NewIMSI(req.GetImsi()),
bearer,
cFegFTeid,
getUserLocationIndication(req.ServingNetwork.Mcc, req.ServingNetwork.Mcc, req.Uli),
getUserLocationIndication(req.ServingNetwork, req.Uli),
getPdnType(req.PdnType),
getPDNAddressAllocation(req),
getRatType(req.RatType),
Expand Down Expand Up @@ -103,7 +103,7 @@ func buildDeleteSessionRequestMsg(cPgwUDPAddr *net.UDPAddr, req *protos.DeleteSe
ies := []*ie.IE{
ie.NewEPSBearerID(uint8(req.BearerId)),
cFegFTeid,
getUserLocationIndication(req.ServingNetwork.Mcc, req.ServingNetwork.Mcc, req.Uli),
getUserLocationIndication(req.ServingNetwork, req.Uli),
}
return message.NewDeleteSessionRequest(req.CPgwTeid, 0, ies...), nil
}
Expand Down Expand Up @@ -161,7 +161,7 @@ func getPdnType(pdnType protos.PDNType) *ie.IE {
return ie.NewPDNType(res)
}

func getUserLocationIndication(mcc, mnc string, uli *protos.UserLocationInformation) *ie.IE {
func getUserLocationIndication(servingNetwork *protos.ServingNetwork, uli *protos.UserLocationInformation) *ie.IE {
var (
cgi *ie.CGI = nil
sai *ie.SAI = nil
Expand All @@ -173,6 +173,9 @@ func getUserLocationIndication(mcc, mnc string, uli *protos.UserLocationInformat
emenbi *ie.EMENBI = nil
)

mcc := servingNetwork.Mcc
mnc := servingNetwork.Mnc

if uli.Lac != 0 && uli.Ci != 0 {
cgi = ie.NewCGI(mcc, mnc, uint16(uli.Lac), uint16(uli.Ci))
}
Expand Down
8 changes: 8 additions & 0 deletions feg/gateway/services/s8_proxy/servicers/mock_pgw/cs.go
Expand Up @@ -60,6 +60,14 @@ func (mPgw *MockPgw) getHandleCreateSessionRequest() gtpv2.HandlerFunc {
fmt.Println("Missing IE (IMSI) on Create Session Request that PGW received")
return &gtpv2.RequiredIEMissingError{Type: ie.IMSI}
}
if uliIE := csReqFromSGW.ULI; uliIE != nil {
mPgw.LastULI, err = uliIE.UserLocationInformation()
if err != nil {
return err
}
} else {
return &gtpv2.RequiredIEMissingError{Type: ie.UserLocationInformation}
}
if msisdnIE := csReqFromSGW.MSISDN; msisdnIE != nil {
session.MSISDN, err = msisdnIE.MSISDN()
if err != nil {
Expand Down
Expand Up @@ -47,6 +47,7 @@ type LastValues struct {
LastTEIDu uint32
LastTEIDc uint32
LastQos *protos.QosInformation
LastULI *ie.UserLocationInformationFields
}

// CreateSessionOptions to control Create Session Response values to produce errors
Expand Down
14 changes: 14 additions & 0 deletions feg/gateway/services/s8_proxy/servicers/s8_proxy_test.go
Expand Up @@ -113,6 +113,20 @@ func TestS8proxyCreateAndDeleteSession(t *testing.T) {
expectedAPN := fmt.Sprintf("%s%s", "internet", s8p.config.ApnOperatorSuffix)
assert.Equal(t, expectedAPN, bearer.APN)

// check ULI received
require.NotNil(t, mockPgw.LastULI)
assert.Equal(t, csReq.Uli.Ci, uint32(mockPgw.LastULI.CGI.CI))
assert.Equal(t, csReq.ServingNetwork.Mcc, mockPgw.LastULI.CGI.MCC)
assert.Equal(t, csReq.ServingNetwork.Mnc, mockPgw.LastULI.CGI.MNC)

assert.Equal(t, csReq.Uli.Lac, uint32(mockPgw.LastULI.LAI.LAC))
assert.Equal(t, csReq.ServingNetwork.Mcc, mockPgw.LastULI.LAI.MCC)
assert.Equal(t, csReq.ServingNetwork.Mnc, mockPgw.LastULI.LAI.MNC)

assert.Equal(t, csReq.Uli.Eci, mockPgw.LastULI.ECGI.ECI)
assert.Equal(t, csReq.ServingNetwork.Mcc, mockPgw.LastULI.ECGI.MCC)
assert.Equal(t, csReq.ServingNetwork.Mnc, mockPgw.LastULI.ECGI.MNC)

// ------------------------
// ---- Delete Session ----
cdReq := getDeleteSessionRequest(mockPgw.LocalAddr().String(), csRes.CPgwFteid.Teid)
Expand Down
22 changes: 8 additions & 14 deletions feg/gateway/tools/s8_cli/main.go
Expand Up @@ -172,7 +172,7 @@ func createSession(cmd *commands.Command, args []string) int {
CAgwTeid: uint32(AGWTeidC),
ServingNetwork: &protos.ServingNetwork{
Mcc: "310",
Mnc: "14",
Mnc: "010",
},
RatType: protos.RATType_EUTRAN,
BearerContext: &protos.BearerContext{
Expand Down Expand Up @@ -264,19 +264,13 @@ func createSession(cmd *commands.Command, args []string) int {

fmt.Println("\n *** Delete Session Test ***")
dsReq := &protos.DeleteSessionRequestPgw{
PgwAddrs: pgwServerAddr,
Imsi: imsi,
BearerId: bearerId,
CAgwTeid: uint32(AGWTeidC),
CPgwTeid: csRes.CPgwFteid.Teid,
ServingNetwork: &protos.ServingNetwork{
Mcc: "310",
Mnc: "14",
},
Uli: &protos.UserLocationInformation{
Tac: 5,
Eci: 6,
},
PgwAddrs: pgwServerAddr,
Imsi: imsi,
BearerId: bearerId,
CAgwTeid: uint32(AGWTeidC),
CPgwTeid: csRes.CPgwFteid.Teid,
ServingNetwork: csReq.ServingNetwork,
Uli: csReq.Uli,
}
printGRPCMessage("Sending GRPC message: ", dsReq)
dsRes, err := cli.DeleteSession(dsReq)
Expand Down

0 comments on commit 805c1f3

Please sign in to comment.