Skip to content

Commit be21356

Browse files
committed
Feat: Multiple DNN
Signed-off-by: anaswara <anaswara.n@cdac.in>
1 parent 029d92d commit be21356

File tree

9 files changed

+77
-28
lines changed

9 files changed

+77
-28
lines changed

conf/upf.jsonc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,12 @@
155155
"cpiface": {
156156
"peers": ["148.162.12.214"],
157157
// [Optional] Below parameters
158-
"dnn": "internet",
158+
"dnn_list": [
159+
{
160+
"dnn": "internet",
161+
"ue_ip_pool": "10.250.0.0/16"
162+
}
163+
],
159164
"http_port": "8080",
160165
"enable_ue_ip_alloc": false,
161166
// "use_fqdn": "true",

pfcpiface/config.go

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,18 @@ type SimModeInfo struct {
8686

8787
// CPIfaceInfo : CPIface interface settings.
8888
type CPIfaceInfo struct {
89-
Peers []string `json:"peers"`
90-
UseFQDN bool `json:"use_fqdn"`
91-
NodeID string `json:"hostname"`
92-
HTTPPort string `json:"http_port"`
93-
Dnn string `json:"dnn"`
94-
EnableUeIPAlloc bool `json:"enable_ue_ip_alloc"`
95-
UEIPPool string `json:"ue_ip_pool"`
89+
Peers []string `json:"peers"`
90+
UseFQDN bool `json:"use_fqdn"`
91+
NodeID string `json:"hostname"`
92+
HTTPPort string `json:"http_port"`
93+
DnnList []DNNInfo `json:"dnn_list"`
94+
EnableUeIPAlloc bool `json:"enable_ue_ip_alloc"`
95+
UEIPPool string `json:"ue_ip_pool"`
96+
}
97+
98+
type DNNInfo struct {
99+
DNN string `json:"dnn"`
100+
UEIPPool string `json:"ue_ip_pool"`
96101
}
97102

98103
// IfaceType : Gateway interface struct.
@@ -118,12 +123,12 @@ func validateConf(conf Conf) error {
118123
if err != nil {
119124
return ErrInvalidArgumentWithReason("conf.P4rtcIface.AccessIP", conf.P4rtcIface.AccessIP, err.Error())
120125
}
121-
122-
_, _, err = net.ParseCIDR(conf.CPIface.UEIPPool)
123-
if err != nil {
124-
return ErrInvalidArgumentWithReason("conf.UEIPPool", conf.CPIface.UEIPPool, err.Error())
126+
for _, dnn := range conf.CPIface.DnnList {
127+
_, _, err := net.ParseCIDR(dnn.UEIPPool)
128+
if err != nil {
129+
return ErrInvalidArgumentWithReason("conf.CPIface.DnnList.UEIPPool", dnn.UEIPPool, err.Error())
130+
}
125131
}
126-
127132
if conf.Mode != "" {
128133
return ErrInvalidArgumentWithReason("conf.Mode", conf.Mode, "mode must not be set for UP4")
129134
}
@@ -140,14 +145,14 @@ func validateConf(conf Conf) error {
140145
return ErrInvalidArgumentWithReason("conf.Mode", conf.Mode, "invalid mode")
141146
}
142147
}
143-
144148
if conf.CPIface.EnableUeIPAlloc {
145-
_, _, err := net.ParseCIDR(conf.CPIface.UEIPPool)
146-
if err != nil {
147-
return ErrInvalidArgumentWithReason("conf.UEIPPool", conf.CPIface.UEIPPool, err.Error())
149+
for _, dnn := range conf.CPIface.DnnList {
150+
_, _, err := net.ParseCIDR(dnn.UEIPPool)
151+
if err != nil {
152+
return ErrInvalidArgumentWithReason("conf.CPIface.DnnList.UEIPPool", dnn.UEIPPool, err.Error())
153+
}
148154
}
149155
}
150-
151156
for _, peer := range conf.CPIface.Peers {
152157
ip := net.ParseIP(peer)
153158
if ip == nil {

pfcpiface/fteid.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ func NewFTEIDGenerator() *FTEIDGenerator {
2929

3030
// Allocate and return an id in range [minValue, maxValue]
3131
func (idGenerator *FTEIDGenerator) Allocate() (uint32, error) {
32+
if idGenerator == nil {
33+
return 0, errors.New("FTEIDGenerator is not initialized")
34+
}
3235
idGenerator.lock.Lock()
3336
defer idGenerator.lock.Unlock()
3437

pfcpiface/messages_conn.go

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

66
import (
77
"errors"
8+
"strings"
89

910
"github.com/omec-project/upf-epc/logger"
1011
"github.com/wmnsk/go-pfcp/ie"
@@ -92,7 +93,7 @@ func (pConn *PFCPConn) handleIncomingResponse(msg message.Message) {
9293

9394
func (pConn *PFCPConn) associationIEs() []*ie.IE {
9495
upf := pConn.upf
95-
networkInstance := string(ie.NewNetworkInstanceFQDN(upf.dnn).Payload)
96+
networkInstance := string(ie.NewNetworkInstanceFQDN(strings.Join(upf.dnn, ",")).Payload)
9697
flags := uint8(0x41)
9798

9899
if len(upf.dnn) != 0 {

pfcpiface/messages_session.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ func (pConn *PFCPConn) handleSessionEstablishmentRequest(msg message.Message) (m
9494

9595
if p.UPAllocateFteid {
9696
var fteid uint32
97+
if pConn.upf.fteidGenerator == nil {
98+
logger.PfcpLog.Warnf("fteid is nill")
99+
pConn.upf.fteidGenerator = NewFTEIDGenerator()
100+
}
97101
fteid, err = pConn.upf.fteidGenerator.Allocate()
98102
if err != nil {
99103
return errProcessReply(err, ie.CauseNoResourcesAvailable)

pfcpiface/up4.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,11 @@ func (up4 *UP4) SetUpfInfo(u *upf, conf *Conf) {
404404

405405
logger.PfcpLog.Infof("AccessIP: %v", up4.accessIP)
406406

407-
up4.ueIPPool = MustParseStrIP(conf.CPIface.UEIPPool)
407+
if len(conf.CPIface.DnnList) > 0 {
408+
up4.ueIPPool = MustParseStrIP(conf.CPIface.DnnList[0].UEIPPool)
409+
} else {
410+
logger.PfcpLog.Fatalln("No UE IP pool configured in DnnList")
411+
}
408412

409413
logger.PfcpLog.Infof("UE IP pool: %v", up4.ueIPPool)
410414

pfcpiface/upf.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ type upf struct {
4848
nodeID string
4949
ippool *IPPool
5050
peers []string
51-
dnn string
51+
dnn []string
5252
reportNotifyChan chan uint64
5353
sliceInfo *SliceInfo
5454
readTimeout time.Duration
@@ -116,17 +116,28 @@ func NewUPF(conf *Conf, fp datapath) *upf {
116116
nodeID = hosts[0]
117117
}
118118

119+
var dnns []string
120+
var ippoolCidr string
121+
122+
// Extract DNN names and UEIPPool from the new DnnList structure
123+
for _, dnnInfo := range conf.CPIface.DnnList {
124+
dnns = append(dnns, dnnInfo.DNN)
125+
if ippoolCidr == "" {
126+
ippoolCidr = dnnInfo.UEIPPool
127+
}
128+
}
129+
119130
u := &upf{
120131
enableUeIPAlloc: conf.CPIface.EnableUeIPAlloc,
121132
enableEndMarker: conf.EnableEndMarker,
122133
enableFlowMeasure: conf.EnableFlowMeasure,
123134
enableGtpuMonitor: conf.EnableGtpuPathMonitoring,
124135
accessIface: conf.AccessIface.IfName,
125136
coreIface: conf.CoreIface.IfName,
126-
ippoolCidr: conf.CPIface.UEIPPool,
137+
ippoolCidr: ippoolCidr,
127138
nodeID: nodeID,
128139
datapath: fp,
129-
dnn: conf.CPIface.Dnn,
140+
dnn: dnns,
130141
peers: conf.CPIface.Peers,
131142
reportNotifyChan: make(chan uint64, 1024),
132143
maxReqRetries: conf.MaxReqRetries,

ptf/config/upf.jsonc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,12 @@
155155
"cpiface": {
156156
"peers": ["148.162.12.214"],
157157
// [Optional] Below parameters
158-
"dnn": "internet",
158+
"dnn_list": [
159+
{
160+
"dnn": "internet",
161+
"ue_ip_pool": "10.250.0.0/16"
162+
}
163+
],
159164
"http_port": "8080",
160165
"enable_ue_ip_alloc": false,
161166
// "use_fqdn": "true",

test/integration/conf.go

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,12 @@ func BESSConfigUPFBasedIPAllocation() pfcpiface.Conf {
5757
config := BESSConfigDefault()
5858
config.CPIface = pfcpiface.CPIfaceInfo{
5959
EnableUeIPAlloc: true,
60-
UEIPPool: UEPoolUPF,
60+
DnnList: []pfcpiface.DNNInfo{
61+
{
62+
UEIPPool: UEPoolUPF,
63+
},
64+
},
6165
}
62-
6366
return config
6467
}
6568

@@ -87,7 +90,11 @@ func UP4ConfigDefault() pfcpiface.Conf {
8790
}
8891

8992
config.CPIface = pfcpiface.CPIfaceInfo{
90-
UEIPPool: UEPoolCP,
93+
DnnList: []pfcpiface.DNNInfo{
94+
{
95+
UEIPPool: UEPoolCP,
96+
},
97+
},
9198
}
9299

93100
return config
@@ -97,7 +104,11 @@ func UP4ConfigUPFBasedIPAllocation() pfcpiface.Conf {
97104
config := UP4ConfigDefault()
98105
config.CPIface = pfcpiface.CPIfaceInfo{
99106
EnableUeIPAlloc: true,
100-
UEIPPool: UEPoolUPF,
107+
DnnList: []pfcpiface.DNNInfo{
108+
{
109+
UEIPPool: UEPoolUPF,
110+
},
111+
},
101112
}
102113

103114
return config

0 commit comments

Comments
 (0)