Skip to content

Commit

Permalink
Remove NodeID from gNB, only use for UPF UPNodes in config; add UPNod…
Browse files Browse the repository at this point in the history
…eConfigInterface 'inheritance' for userplaneInformation config
  • Loading branch information
Laura Henning committed Oct 1, 2024
1 parent 65f6bb0 commit f946aa3
Show file tree
Hide file tree
Showing 13 changed files with 623 additions and 318 deletions.
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ require (
github.com/tim-ywliu/nested-logrus-formatter v1.3.2 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.11 // indirect
go4.org/intern v0.0.0-20211027215823-ae77deb06f29 // indirect
go4.org/unsafe/assume-no-moving-gc v0.0.0-20230525183740-e7c30c78aeb2 // indirect
golang.org/x/arch v0.3.0 // indirect
golang.org/x/crypto v0.21.0 // indirect
golang.org/x/net v0.23.0 // indirect
Expand All @@ -70,4 +72,5 @@ require (
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
inet.af/netaddr v0.0.0-20230525184311-b8eac61e914a // indirect
)
14 changes: 14 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dvyukov/go-fuzz v0.0.0-20210103155950-6a8e9d1f2415/go.mod h1:11Gm+ccJnvAhCNLlf5+cS9KjtbaD5I5zaZpFMsTHWTw=
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
Expand Down Expand Up @@ -235,13 +236,19 @@ github.com/urfave/cli v1.22.5/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtX
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU=
go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc=
go4.org/intern v0.0.0-20211027215823-ae77deb06f29 h1:UXLjNohABv4S58tHmeuIZDO6e3mHpW2Dx33gaNt03LE=
go4.org/intern v0.0.0-20211027215823-ae77deb06f29/go.mod h1:cS2ma+47FKrLPdXFpr7CuxiTW3eyJbWew4qx0qtQWDA=
go4.org/unsafe/assume-no-moving-gc v0.0.0-20211027215541-db492cf91b37/go.mod h1:FftLjUGFEDu5k8lt0ddY+HcrH/qU/0qk+H8j9/nTl3E=
go4.org/unsafe/assume-no-moving-gc v0.0.0-20230525183740-e7c30c78aeb2 h1:WJhcL4p+YeDxmZWg141nRm7XC8IDmhz7lk5GpadO1Sg=
go4.org/unsafe/assume-no-moving-gc v0.0.0-20230525183740-e7c30c78aeb2/go.mod h1:FftLjUGFEDu5k8lt0ddY+HcrH/qU/0qk+H8j9/nTl3E=
golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
golang.org/x/arch v0.3.0 h1:02VY4/ZcO/gBOH6PUaoiptASxtXU10jazRCP865E97k=
golang.org/x/arch v0.3.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
Expand Down Expand Up @@ -308,6 +315,7 @@ golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/
golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs=
golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
Expand All @@ -325,6 +333,7 @@ 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.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
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=
Expand All @@ -351,6 +360,8 @@ golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
Expand Down Expand Up @@ -406,6 +417,7 @@ 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.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
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=
Expand Down Expand Up @@ -507,6 +519,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=
inet.af/netaddr v0.0.0-20230525184311-b8eac61e914a h1:1XCVEdxrvL6c0TGOhecLuB7U9zYNdxZEjvOqJreKZiM=
inet.af/netaddr v0.0.0-20230525184311-b8eac61e914a/go.mod h1:e83i32mAQOW1LAqEIweALsuK2Uw4mhQadA5r7b0Wobo=
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=
Expand Down
2 changes: 1 addition & 1 deletion internal/context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ func InitSmfContext(config *factory.Config) {

smfContext.SupportedPDUSessionType = "IPv4"

smfContext.UserPlaneInformation = NewUserPlaneInformation(&configuration.UserPlaneInformation)
smfContext.UserPlaneInformation = NewUserPlaneInformation(configuration.UserPlaneInformation)

smfContext.ChargingIDGenerator = idgenerator.NewGenerator(1, math.MaxUint32)

Expand Down
32 changes: 3 additions & 29 deletions internal/context/gnb.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,16 @@ package context

import (
"fmt"
"net"

"github.com/google/uuid"

"github.com/free5gc/pfcp/pfcpType"
"github.com/free5gc/smf/internal/logger"
)

// embeds the UPNode struct ("inheritance")
// implements UPNodeInterface
type GNB struct {
UPNode
ANIP net.IP
*UPNode
}

func (gNB *GNB) GetName() string {
Expand All @@ -29,42 +26,19 @@ func (gNB *GNB) GetType() UPNodeType {
return gNB.Type
}

func (gNB *GNB) GetDnn() string {
return gNB.Dnn
}

func (gNB *GNB) String() string {
str := "gNB {\n"
prefix := " "
str += prefix + fmt.Sprintf("Name: %s\n", gNB.Name)
str += prefix + fmt.Sprintf("ANIP: %s\n", gNB.ANIP)
str += prefix + fmt.Sprintf("ID: %s\n", gNB.ID)
str += prefix + fmt.Sprintf("NodeID: %s\n", gNB.GetNodeIDString())
str += prefix + fmt.Sprintf("Dnn: %s\n", gNB.Dnn)
str += prefix + fmt.Sprintln("Links:")
for _, link := range gNB.Links {
str += prefix + fmt.Sprintf("-- %s: %s\n", link.GetName(), link.GetNodeIDString())
str += prefix + fmt.Sprintf("-- %s: %s\n", link.GetName(), link.GetName())
}
str += "}"
return str
}

func (gNB *GNB) GetNodeIDString() string {
switch gNB.NodeID.NodeIdType {
case pfcpType.NodeIdTypeIpv4Address, pfcpType.NodeIdTypeIpv6Address:
return gNB.NodeID.IP.String()
case pfcpType.NodeIdTypeFqdn:
return gNB.NodeID.FQDN
default:
logger.CtxLog.Errorf("nodeID has unknown type %d", gNB.NodeID.NodeIdType)
return ""
}
}

func (gNB *GNB) GetNodeID() pfcpType.NodeID {
return gNB.NodeID
}

func (gNB *GNB) GetLinks() UPPath {
return gNB.Links
}
Expand All @@ -82,7 +56,7 @@ func (gNB *GNB) AddLink(link UPNodeInterface) bool {

func (gNB *GNB) RemoveLink(link UPNodeInterface) bool {
for i, existingLink := range gNB.Links {
if link.GetName() == existingLink.GetName() && existingLink.GetNodeIDString() == link.GetNodeIDString() {
if link.GetName() == existingLink.GetName() && existingLink.GetName() == link.GetName() {
logger.CfgLog.Warningf("Remove UPLink [%s] <=> [%s]\n", existingLink.GetName(), link.GetName())
gNB.Links = append(gNB.Links[:i], gNB.Links[i+1:]...)
return true
Expand Down
8 changes: 4 additions & 4 deletions internal/context/sm_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -474,15 +474,15 @@ func (smContext *SMContext) GetNodeIDByLocalSEID(seid uint64) pfcpType.NodeID {
return pfcpType.NodeID{}
}

func (smContext *SMContext) AllocateLocalSEIDForUPPath(path UPPath) {
for _, upNode := range path {
NodeIDtoIP := upNode.GetNodeIDString()
func (smContext *SMContext) AllocateLocalSEIDForUPPath(path []*UPF) {
for _, upf := range path {
NodeIDtoIP := upf.GetName()
if _, exist := smContext.PFCPContext[NodeIDtoIP]; !exist {
allocatedSEID := AllocateLocalSEID()

smContext.PFCPContext[NodeIDtoIP] = &PFCPSessionContext{
PDRs: make(map[uint16]*PDR),
NodeID: upNode.GetNodeID(),
NodeID: upf.GetNodeID(),
LocalSEID: allocatedSEID,
}

Expand Down
29 changes: 17 additions & 12 deletions internal/context/sm_context_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,17 @@ import (
"github.com/free5gc/smf/pkg/factory"
)

var userPlaneConfig = factory.UserPlaneInformation{
UPNodes: map[string]*factory.UPNode{
"GNodeB": {
Type: "AN",
NodeID: "192.168.1.1",
var userPlaneConfig = &factory.UserPlaneInformation{
UPNodes: map[string]factory.UPNodeConfigInterface{
"GNodeB": &factory.GNBConfig{
UPNodeConfig: &factory.UPNodeConfig{
Type: "AN",
},
},
"UPF1": {
Type: "UPF",
"UPF1": &factory.UPFConfig{
UPNodeConfig: &factory.UPNodeConfig{
Type: "UPF",
},
NodeID: "10.4.0.11",
SNssaiInfos: []*factory.SnssaiUpfInfoItem{
{
Expand All @@ -33,7 +36,7 @@ var userPlaneConfig = factory.UserPlaneInformation{
},
},
},
InterfaceUpfInfoList: []*factory.InterfaceUpfInfoItem{
Interfaces: []*factory.Interface{
{
InterfaceType: "N3",
Endpoints: []string{
Expand All @@ -50,8 +53,10 @@ var userPlaneConfig = factory.UserPlaneInformation{
},
},
},
"UPF2": {
Type: "UPF",
"UPF2": &factory.UPFConfig{
UPNodeConfig: &factory.UPNodeConfig{
Type: "UPF",
},
NodeID: "10.4.0.12",
SNssaiInfos: []*factory.SnssaiUpfInfoItem{
{
Expand All @@ -69,7 +74,7 @@ var userPlaneConfig = factory.UserPlaneInformation{
},
},
},
InterfaceUpfInfoList: []*factory.InterfaceUpfInfoItem{
Interfaces: []*factory.Interface{
{
InterfaceType: "N9",
Endpoints: []string{
Expand Down Expand Up @@ -619,7 +624,7 @@ func TestApplyPccRules(t *testing.T) {
}

smfContext := context.GetSelf()
smfContext.UserPlaneInformation = context.NewUserPlaneInformation(&userPlaneConfig)
smfContext.UserPlaneInformation = context.NewUserPlaneInformation(userPlaneConfig)
for _, n := range smfContext.UserPlaneInformation.UPFs {
n.UPFStatus = context.AssociatedSetUpSuccess
}
Expand Down
18 changes: 8 additions & 10 deletions internal/context/upf.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ const (
type UPF struct {
*UPNode

NodeID pfcpType.NodeID

UPIPInfo pfcpType.UserPlaneIPResourceInformation
UPFStatus UPFStatus
RecoveryTimeStamp time.Time
Expand Down Expand Up @@ -97,10 +99,9 @@ func (upf *UPF) String() string {
str += prefix + fmt.Sprintf("Name: %s\n", upf.Name)
str += prefix + fmt.Sprintf("ID: %s\n", upf.ID)
str += prefix + fmt.Sprintf("NodeID: %s\n", upf.GetNodeIDString())
str += prefix + fmt.Sprintf("Dnn: %s\n", upf.Dnn)
str += prefix + fmt.Sprintln("Links:")
for _, link := range upf.Links {
str += prefix + fmt.Sprintf("-- %s: %s\n", link.GetName(), link.GetNodeIDString())
str += prefix + fmt.Sprintf("-- %s: %s\n", link.GetName(), link.GetName())
}
str += prefix + fmt.Sprintln("N3 interfaces:")
for _, iface := range upf.N3Interfaces {
Expand Down Expand Up @@ -135,7 +136,7 @@ func (upf *UPF) GetNodeID() pfcpType.NodeID {
}

func (upf *UPF) GetName() string {
return upf.Name
return fmt.Sprintf("%s[%s]", upf.Name, upf.GetNodeIDString())
}

func (upf *UPF) GetID() uuid.UUID {
Expand All @@ -146,10 +147,6 @@ func (upf *UPF) GetType() UPNodeType {
return upf.Type
}

func (upf *UPF) GetDnn() string {
return upf.Dnn
}

func (upf *UPF) GetLinks() UPPath {
return upf.Links
}
Expand All @@ -167,7 +164,7 @@ func (upf *UPF) AddLink(link UPNodeInterface) bool {

func (upf *UPF) RemoveLink(link UPNodeInterface) bool {
for i, existingLink := range upf.Links {
if link.GetName() == existingLink.GetName() && existingLink.GetNodeIDString() == link.GetNodeIDString() {
if link.GetName() == existingLink.GetName() && existingLink.GetName() == link.GetName() {
logger.CfgLog.Warningf("Remove UPLink [%s] <=> [%s]\n", existingLink.GetName(), link.GetName())
upf.Links = append(upf.Links[:i], upf.Links[i+1:]...)
return true
Expand Down Expand Up @@ -214,7 +211,7 @@ func GetUpfById(uuid string) *UPF {
}

// NewUPFInterfaceInfo parse the InterfaceUpfInfoItem to generate UPFInterfaceInfo
func NewUPFInterfaceInfo(i *factory.InterfaceUpfInfoItem) *UPFInterfaceInfo {
func NewUPFInterfaceInfo(i *factory.Interface) *UPFInterfaceInfo {
interfaceInfo := new(UPFInterfaceInfo)

interfaceInfo.IPv4EndPointAddresses = make([]net.IP, 0)
Expand Down Expand Up @@ -322,7 +319,8 @@ func (t *UPTunnel) RemoveDataPath(pathID int64) {
// NewUPF returns a new UPF context in SMF
func NewUPF(
upNode *UPNode,
ifaces []*factory.InterfaceUpfInfoItem,
nodeID *pfcpType.NodeID,
ifaces []*factory.Interface,
) (upf *UPF) {
upf = new(UPF)
upf.UPNode = upNode
Expand Down
Loading

0 comments on commit f946aa3

Please sign in to comment.