Skip to content

Commit ee9eb2e

Browse files
committed
Feat: Multiple DNN Support
Signed-off-by: anaswara <[email protected]>
1 parent 777c06f commit ee9eb2e

File tree

10 files changed

+102
-53
lines changed

10 files changed

+102
-53
lines changed

context/upf.go

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"net"
1414
"reflect"
1515
"strconv"
16+
"strings"
1617
"sync"
1718
"time"
1819

@@ -90,9 +91,9 @@ type UPF struct {
9091

9192
// UPFSelectionParams ... parameters for upf selection
9293
type UPFSelectionParams struct {
93-
Dnn string
94-
SNssai *SNssai
95-
Dnai string
94+
DnnList []string
95+
SNssai *SNssai
96+
Dnai string
9697
}
9798

9899
// UPFInterfaceInfo store the UPF interface information
@@ -163,12 +164,20 @@ func (i *UPFInterfaceInfo) IP(pduSessType uint8) (net.IP, error) {
163164
}
164165

165166
func (upfSelectionParams *UPFSelectionParams) String() string {
167+
if upfSelectionParams == nil {
168+
return "UPFSelectionParams is nil"
169+
}
166170
str := ""
167-
Dnn := upfSelectionParams.Dnn
168-
if Dnn != "" {
169-
str += fmt.Sprintf("Dnn: %s\n", Dnn)
171+
// Handle the DnnList
172+
if len(upfSelectionParams.DnnList) > 0 {
173+
str += "Dnn List: "
174+
for _, dnn := range upfSelectionParams.DnnList {
175+
str += fmt.Sprintf("%s ", dnn)
176+
}
177+
str += "\n"
178+
} else {
179+
str += "Dnn List is empty\n"
170180
}
171-
172181
SNssai := upfSelectionParams.SNssai
173182
if SNssai != nil {
174183
str += fmt.Sprintf("Sst: %d, Sd: %s\n", int(SNssai.Sst), SNssai.Sd)
@@ -249,14 +258,26 @@ func (upf *UPF) GetInterface(interfaceType models.UpInterfaceType, dnn string) *
249258
switch interfaceType {
250259
case models.UpInterfaceType_N3:
251260
for i, iface := range upf.N3Interfaces {
252-
if iface.NetworkInstance == dnn {
253-
return &upf.N3Interfaces[i]
261+
logger.CtxLog.Infof("Checking UPF N3 Interface: %v", iface.NetworkInstance)
262+
263+
// Split multiple DNNs and check if dnn exists
264+
dnnList := strings.Split(iface.NetworkInstance, ",")
265+
for _, d := range dnnList {
266+
if strings.TrimSpace(d) == strings.TrimSpace(dnn) {
267+
return &upf.N3Interfaces[i]
268+
}
254269
}
255270
}
256271
case models.UpInterfaceType_N9:
257272
for i, iface := range upf.N9Interfaces {
258-
if iface.NetworkInstance == dnn {
259-
return &upf.N9Interfaces[i]
273+
logger.CtxLog.Infof("Checking UPF N9 Interface: %v", iface.NetworkInstance)
274+
275+
// Split multiple DNNs and check if dnn exists
276+
dnnList := strings.Split(iface.NetworkInstance, ",")
277+
for _, d := range dnnList {
278+
if strings.TrimSpace(d) == strings.TrimSpace(dnn) {
279+
return &upf.N9Interfaces[i]
280+
}
260281
}
261282
}
262283
}

context/user_plane_information.go

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -184,12 +184,16 @@ func (upi *UserPlaneInformation) GenerateDefaultPath(selection *UPFSelectionPara
184184
destinations = upi.selectMatchUPF(selection)
185185

186186
if len(destinations) == 0 {
187-
logger.CtxLog.Errorf("can not find UPF with DNN[%s] S-NSSAI[sst: %d sd: %s] DNAI[%s]", selection.Dnn,
188-
selection.SNssai.Sst, selection.SNssai.Sd, selection.Dnai)
187+
for _, dnn := range selection.DnnList {
188+
logger.CtxLog.Errorf("Can't find UPF with DNN[%s] S-NSSAI[sst: %d sd: %s] DNAI[%s]\n", dnn,
189+
selection.SNssai.Sst, selection.SNssai.Sd, selection.Dnai)
190+
}
189191
return false
190192
} else {
191-
logger.CtxLog.Debugf("found UPF with DNN[%s] S-NSSAI[sst: %d sd: %s] DNAI[%s]", selection.Dnn,
192-
selection.SNssai.Sst, selection.SNssai.Sd, selection.Dnai)
193+
for _, dnn := range selection.DnnList {
194+
logger.CtxLog.Infof("Found UPF with DNN[%s] S-NSSAI[sst: %d sd: %s] DNAI[%s]\n", dnn,
195+
selection.SNssai.Sst, selection.SNssai.Sd, selection.Dnai)
196+
}
193197
}
194198

195199
// Run DFS
@@ -223,17 +227,20 @@ func (upi *UserPlaneInformation) GenerateDefaultPath(selection *UPFSelectionPara
223227

224228
func (upi *UserPlaneInformation) selectMatchUPF(selection *UPFSelectionParams) []*UPNode {
225229
upList := make([]*UPNode, 0)
226-
230+
logger.CtxLog.Infof("Selecting matching UPFs for DNNs[%v] and S-NSSAI[sst: %d, sd: %s]", selection.DnnList, selection.SNssai.Sst, selection.SNssai.Sd)
227231
for _, upNode := range upi.UPFs {
228232
for _, snssaiInfo := range upNode.UPF.SNssaiInfos {
229233
currentSnssai := &snssaiInfo.SNssai
230234
targetSnssai := selection.SNssai
231235

232236
if currentSnssai.Equal(targetSnssai) {
233237
for _, dnnInfo := range snssaiInfo.DnnList {
234-
if dnnInfo.Dnn == selection.Dnn && dnnInfo.ContainsDNAI(selection.Dnai) {
235-
upList = append(upList, upNode)
236-
break
238+
for _, dnn := range selection.DnnList {
239+
if dnnInfo.Dnn == dnn && dnnInfo.ContainsDNAI(selection.Dnai) {
240+
upList = append(upList, upNode)
241+
logger.CtxLog.Infof("Matching UPF found: %v for DNN[%s] and DNAI[%s]", upNode, dnn, selection.Dnai)
242+
break
243+
}
237244
}
238245
}
239246
}

context/user_plane_information_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ func TestGenerateDefaultPath(t *testing.T) {
160160
Sst: 1,
161161
Sd: "112232",
162162
},
163-
Dnn: "internet",
163+
DnnList: []string{"internet"},
164164
},
165165
expected: true,
166166
},
@@ -171,7 +171,7 @@ func TestGenerateDefaultPath(t *testing.T) {
171171
Sst: 2,
172172
Sd: "112233",
173173
},
174-
Dnn: "internet",
174+
DnnList: []string{"internet"},
175175
},
176176
expected: true,
177177
},
@@ -182,7 +182,7 @@ func TestGenerateDefaultPath(t *testing.T) {
182182
Sst: 3,
183183
Sd: "112234",
184184
},
185-
Dnn: "internet",
185+
DnnList: []string{"internet"},
186186
},
187187
expected: true,
188188
},
@@ -193,7 +193,7 @@ func TestGenerateDefaultPath(t *testing.T) {
193193
Sst: 1,
194194
Sd: "112235",
195195
},
196-
Dnn: "internet",
196+
DnnList: []string{"internet"},
197197
},
198198
expected: true,
199199
},
@@ -204,7 +204,7 @@ func TestGenerateDefaultPath(t *testing.T) {
204204
Sst: 1,
205205
Sd: "010203",
206206
},
207-
Dnn: "internet",
207+
DnnList: []string{"internet"},
208208
},
209209
expected: false,
210210
},

factory/config.go

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
"strings"
1919
"time"
2020

21-
protos "github.com/omec-project/config5g/proto/sdcoreConfig"
21+
protos "github.com/5GC-DEV/config5g-cdac/proto/sdcoreConfig"
2222
"github.com/omec-project/openapi/models"
2323
"github.com/omec-project/smf/logger"
2424
utilLogger "github.com/omec-project/util/logger"
@@ -325,14 +325,16 @@ func (c *Configuration) parseRocConfig(rsp *protos.NetworkSliceResponse) error {
325325
// make DNN Info structure
326326
sNssaiInfoItem.DnnInfos = make([]SnssaiDnnInfoItem, 0)
327327
for _, devGrp := range ns.DeviceGroup {
328-
var dnnInfo SnssaiDnnInfoItem
329-
dnnInfo.Dnn = devGrp.IpDomainDetails.DnnName
330-
dnnInfo.DNS.IPv4Addr = devGrp.IpDomainDetails.DnsPrimary
331-
dnnInfo.UESubnet = devGrp.IpDomainDetails.UePool
332-
dnnInfo.MTU = uint16(devGrp.IpDomainDetails.Mtu)
333-
334-
// update to Slice structure
335-
sNssaiInfoItem.DnnInfos = append(sNssaiInfoItem.DnnInfos, dnnInfo)
328+
for _, ipDomain := range devGrp.IpDomainDetails { // Iterate over IpDomainDetails slice
329+
var dnnInfo SnssaiDnnInfoItem
330+
dnnInfo.Dnn = ipDomain.DnnName
331+
dnnInfo.DNS.IPv4Addr = ipDomain.DnsPrimary
332+
dnnInfo.UESubnet = ipDomain.UePool
333+
dnnInfo.MTU = uint16(ipDomain.Mtu)
334+
335+
// Update to Slice structure
336+
sNssaiInfoItem.DnnInfos = append(sNssaiInfoItem.DnnInfos, dnnInfo)
337+
}
336338
}
337339

338340
// Update to SMF config structure
@@ -376,18 +378,21 @@ func (c *Configuration) parseRocConfig(rsp *protos.NetworkSliceResponse) error {
376378

377379
// Popoulate DNN names per UPF slice Info
378380
for _, devGrp := range ns.DeviceGroup {
379-
// DNN Info in UPF per Slice
380-
var dnnUpfInfo models.DnnUpfInfoItem
381-
dnnUpfInfo.Dnn = devGrp.IpDomainDetails.DnnName
382-
snsUpfInfoItem.DnnUpfInfoList = append(snsUpfInfoItem.DnnUpfInfoList, dnnUpfInfo)
383-
384-
// Populate UPF Interface Info and DNN info in UPF per Interface
385-
intfUpfInfoItem := InterfaceUpfInfoItem{
386-
InterfaceType: models.UpInterfaceType_N3,
387-
Endpoints: make([]string, 0), NetworkInstance: devGrp.IpDomainDetails.DnnName,
381+
for _, ipDomain := range devGrp.IpDomainDetails { // Iterate over IpDomainDetails slice
382+
// DNN Info in UPF per Slice
383+
var dnnUpfInfo models.DnnUpfInfoItem
384+
dnnUpfInfo.Dnn = ipDomain.DnnName
385+
snsUpfInfoItem.DnnUpfInfoList = append(snsUpfInfoItem.DnnUpfInfoList, dnnUpfInfo)
386+
387+
// Populate UPF Interface Info and DNN info in UPF per Interface
388+
intfUpfInfoItem := InterfaceUpfInfoItem{
389+
InterfaceType: models.UpInterfaceType_N3,
390+
Endpoints: make([]string, 0),
391+
NetworkInstance: ipDomain.DnnName,
392+
}
393+
intfUpfInfoItem.Endpoints = append(intfUpfInfoItem.Endpoints, ns.Site.Upf.UpfName)
394+
upf.InterfaceUpfInfoList = append(upf.InterfaceUpfInfoList, intfUpfInfoItem)
388395
}
389-
intfUpfInfoItem.Endpoints = append(intfUpfInfoItem.Endpoints, ns.Site.Upf.UpfName)
390-
upf.InterfaceUpfInfoList = append(upf.InterfaceUpfInfoList, intfUpfInfoItem)
391396
}
392397
upf.SNssaiInfos = append(upf.SNssaiInfos, snsUpfInfoItem)
393398

factory/config_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ package factory
88
import (
99
"testing"
1010

11-
protos "github.com/omec-project/config5g/proto/sdcoreConfig"
11+
protos "github.com/5GC-DEV/config5g-cdac/proto/sdcoreConfig"
1212
"github.com/omec-project/openapi/models"
1313
"github.com/stretchr/testify/assert"
1414
)
@@ -50,7 +50,7 @@ func makeDummyConfig(sst, sd string) *protos.NetworkSliceResponse {
5050

5151
ns.DeviceGroup = make([]*protos.DeviceGroup, 0)
5252
ipDomain := protos.IpDomain{DnnName: "internet", UePool: "60.60.0.0/16", DnsPrimary: "8.8.8.8", Mtu: 1400}
53-
devGrp := protos.DeviceGroup{IpDomainDetails: &ipDomain}
53+
devGrp := protos.DeviceGroup{IpDomainDetails: []*protos.IpDomain{&ipDomain}}
5454
ns.DeviceGroup = append(ns.DeviceGroup, &devGrp)
5555

5656
rsp.NetworkSlice = append(rsp.NetworkSlice, &ns)

go.mod

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ require (
88
github.com/google/uuid v1.6.0
99
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826
1010
github.com/omec-project/aper v1.3.1
11-
github.com/omec-project/config5g v1.6.2
1211
github.com/omec-project/nas v1.6.0
1312
github.com/omec-project/ngap v1.5.0
1413
github.com/omec-project/openapi v1.5.0
@@ -23,6 +22,8 @@ require (
2322
gopkg.in/yaml.v2 v2.4.0
2423
)
2524

25+
require github.com/5GC-DEV/config5g-cdac v0.2.1 // indirect
26+
2627
require (
2728
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
2829
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk=
22
dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
33
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
44
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
5+
github.com/5GC-DEV/config5g-cdac v0.2.1 h1:7Cqwmqh5jqeWtwYTrITflrGotglIRBIb1P3EF2f85OA=
6+
github.com/5GC-DEV/config5g-cdac v0.2.1/go.mod h1:0OEL6UoNKKlx2tlNSoKpRtzckwxR2SL+pRBDAOCT4BU=
57
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25UVaW/CKtUDjefjrs0SPonmDGUVOYP0=
68
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E=
79
github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=
@@ -175,8 +177,6 @@ github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
175177
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
176178
github.com/omec-project/aper v1.3.1 h1:3Vyqn2xQEulzsQ9JganXqxbR1E2IM7oUm4IW1HiPnr0=
177179
github.com/omec-project/aper v1.3.1/go.mod h1:W0i+XhbXHeeLQ4BhMmAS8h83yZ5pnD3w0sdIlnuPS70=
178-
github.com/omec-project/config5g v1.6.2 h1:bfLxwVSt6LAWCQtBmjUuks5CO3qambvcy3VjSVAMHdk=
179-
github.com/omec-project/config5g v1.6.2/go.mod h1:LuaRiJTCJXCkQF7nKB5fOcz6oVMF/8oid+EKCYFAy0E=
180180
github.com/omec-project/nas v1.6.0 h1:Bar13cFszi8l4AStLGRLbznFx93OYNV9n/Ba4A2RN1Y=
181181
github.com/omec-project/nas v1.6.0/go.mod h1:C5mXN3MiZZBF0YRiPkxB2RWc8RvTFb0xWGcUTZ6efng=
182182
github.com/omec-project/ngap v1.5.0 h1:Fu0JIDxDxuNnlz9iomehxn2ZSryqwcY0YS8a73cSIsM=

producer/pdu_session.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ func HandlePDUSessionSMContextCreate(eventData interface{}) error {
226226
smContext.Tunnel = smf_context.NewUPTunnel()
227227
var defaultPath *smf_context.DataPath
228228
upfSelectionParams := &smf_context.UPFSelectionParams{
229-
Dnn: createData.Dnn,
229+
DnnList: []string{createData.Dnn},
230230
SNssai: &smf_context.SNssai{
231231
Sst: createData.SNssai.Sst,
232232
Sd: createData.SNssai.Sd,

qos/qos_flow.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
package qos
66

77
import (
8+
"reflect"
89
"strconv"
910
"strings"
1011

@@ -351,7 +352,21 @@ func GetQosDataChanges(qf1, qf2 *models.QosData) bool {
351352
}
352353

353354
func GetQoSDataFromPolicyDecision(smPolicyDecision *models.SmPolicyDecision, refQosData string) *models.QosData {
354-
return smPolicyDecision.QosDecs[refQosData]
355+
if smPolicyDecision == nil {
356+
logger.PduSessLog.Errorln("smPolicyDecision is nil")
357+
return nil
358+
}
359+
if smPolicyDecision.QosDecs == nil {
360+
logger.PduSessLog.Errorln("QosDecs map is nil")
361+
return nil
362+
}
363+
qos, exists := smPolicyDecision.QosDecs[refQosData]
364+
if !exists {
365+
logger.PduSessLog.Errorf("QoS Data [%s] not found in QosDecs. Available keys: %v", refQosData, reflect.ValueOf(smPolicyDecision.QosDecs).MapKeys())
366+
return nil
367+
}
368+
369+
return qos
355370
}
356371

357372
func (d *QosFlowDescriptionsAuthorized) AddDefaultQosFlowDescription(sessRule *models.SessionRule) {

service/init.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ import (
1818
"syscall"
1919
"time"
2020

21+
grpcClient "github.com/5GC-DEV/config5g-cdac/proto/client"
22+
protos "github.com/5GC-DEV/config5g-cdac/proto/sdcoreConfig"
2123
aperLogger "github.com/omec-project/aper/logger"
22-
grpcClient "github.com/omec-project/config5g/proto/client"
23-
protos "github.com/omec-project/config5g/proto/sdcoreConfig"
2424
nasLogger "github.com/omec-project/nas/logger"
2525
ngapLogger "github.com/omec-project/ngap/logger"
2626
openapiLogger "github.com/omec-project/openapi/logger"

0 commit comments

Comments
 (0)