Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions backend/nfconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,13 +244,15 @@ func extractIpDomains(groupNames []string, deviceGroupMap map[string]configmodel
logger.NfConfigLog.Warnf("Device group %s not found", name)
continue
}
ip := nfConfigApi.NewIpDomain(
dg.IpDomainExpanded.Dnn,
dg.IpDomainExpanded.DnsPrimary,
dg.IpDomainExpanded.UeIpPool,
dg.IpDomainExpanded.Mtu,
)
ipDomains = append(ipDomains, *ip)
for _, ipDomainExp := range dg.IpDomainExpanded {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can no longer preallocate the capacity of ipDomains in line 239

ip := nfConfigApi.NewIpDomain(
ipDomainExp.Dnn,
ipDomainExp.DnsPrimary,
ipDomainExp.UeIpPool, // Now accessing the correct field from the slice element
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does this comment mean ?

ipDomainExp.Mtu,
)
ipDomains = append(ipDomains, *ip)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add a UT that involves multiple ip-domains in a device group

}
return ipDomains
}
Expand Down
12 changes: 7 additions & 5 deletions backend/nfconfig/config_session_management_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,13 @@ type deviceGroupParams struct {

func makeDeviceGroup(p deviceGroupParams) (string, configmodels.DeviceGroups) {
return p.name, configmodels.DeviceGroups{
IpDomainExpanded: configmodels.DeviceGroupsIpDomainExpanded{
Dnn: p.dnn,
DnsPrimary: p.dnsPrimary,
UeIpPool: p.ueIpPool,
Mtu: p.mtu,
IpDomainExpanded: []configmodels.DeviceGroupsIpDomainExpanded{
{
Dnn: p.dnn,
DnsPrimary: p.dnsPrimary,
UeIpPool: p.ueIpPool,
Mtu: p.mtu,
},
},
}
}
Expand Down
2 changes: 1 addition & 1 deletion configapi/api/configapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ components:
ip-domain-name:
example: pool1
type: string
ip-domain-expanded:
ip-domains:
$ref: '#/components/schemas/device_groups_ip_domain_expanded'
type: object
slice:
Expand Down
37 changes: 30 additions & 7 deletions configapi/api_default_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,33 +163,56 @@ func (m *MockMongoClientFoundNetworkSlice) RestfulAPIGetOne(coll string, filter
}

func deviceGroup(name string) configmodels.DeviceGroups {
traffic_class := configmodels.TrafficClassInfo{
traffic_class1 := configmodels.TrafficClassInfo{
Name: "platinum",
Qci: 8,
Arp: 6,
Pdb: 300,
Pelr: 6,
}
qos := configmodels.DeviceGroupsIpDomainExpandedUeDnnQos{
qos1 := configmodels.DeviceGroupsIpDomainExpandedUeDnnQos{
DnnMbrUplink: 10000000,
DnnMbrDownlink: 10000000,
BitrateUnit: "kbps",
TrafficClass: &traffic_class,
TrafficClass: &traffic_class1,
}
ipdomain := configmodels.DeviceGroupsIpDomainExpanded{
ipdomain1 := configmodels.DeviceGroupsIpDomainExpanded{
Dnn: "internet",
UeIpPool: "172.250.1.0/16",
DnsPrimary: "1.1.1.1",
DnsSecondary: "8.8.8.8",
Mtu: 1460,
UeDnnQos: &qos,
UeDnnQos: &qos1,
}

// Define the second traffic class and QoS
traffic_class2 := configmodels.TrafficClassInfo{
Name: "gold",
Qci: 7,
Arp: 5,
Pdb: 150,
Pelr: 5,
}
qos2 := configmodels.DeviceGroupsIpDomainExpandedUeDnnQos{
DnnMbrUplink: 5000000,
DnnMbrDownlink: 5000000,
BitrateUnit: "kbps",
TrafficClass: &traffic_class2,
}
ipdomain2 := configmodels.DeviceGroupsIpDomainExpanded{
Dnn: "ims",
UeIpPool: "172.248.0.0/16",
DnsPrimary: "4.4.4.4",
DnsSecondary: "8.8.4.4",
Mtu: 1400,
UeDnnQos: &qos2,
}
deviceGroup := configmodels.DeviceGroups{
DeviceGroupName: name,
Imsis: []string{"1234", "5678"},
SiteInfo: "demo",
IpDomainName: "pool1",
IpDomainExpanded: ipdomain,
IpDomainExpanded: []configmodels.DeviceGroupsIpDomainExpanded{ipdomain1, ipdomain2},
}
return deviceGroup
}
Expand Down Expand Up @@ -297,7 +320,7 @@ func TestGetDeviceGroupByNameDoesExists(t *testing.T) {
t.Fatalf("failed to read response body: %v", err)
}
body := string(body_bytes)
expected := `{"group-name":"group1","imsis":["1234","5678"],"site-info":"demo","ip-domain-name":"pool1","ip-domain-expanded":{"dnn":"internet","ue-ip-pool":"172.250.1.0/16","dns-primary":"1.1.1.1","dns-secondary":"8.8.8.8","mtu":1460,"ue-dnn-qos":{"dnn-mbr-uplink":10000000,"dnn-mbr-downlink":10000000,"bitrate-unit":"kbps","traffic-class":{"name":"platinum","qci":8,"arp":6,"pdb":300,"pelr":6}}}}`
expected := "{\"group-name\":\"group1\",\"imsis\":[\"1234\",\"5678\"],\"site-info\":\"demo\",\"ip-domain-name\":\"pool1\",\"ip-domains\":[{\"dnn\":\"internet\",\"ue-ip-pool\":\"172.250.1.0/16\",\"dns-primary\":\"1.1.1.1\",\"dns-secondary\":\"8.8.8.8\",\"mtu\":1460,\"ue-dnn-qos\":{\"dnn-mbr-uplink\":10000000,\"dnn-mbr-downlink\":10000000,\"bitrate-unit\":\"kbps\",\"traffic-class\":{\"name\":\"platinum\",\"qci\":8,\"arp\":6,\"pdb\":300,\"pelr\":6}}},{\"dnn\":\"ims\",\"ue-ip-pool\":\"172.248.0.0/16\",\"dns-primary\":\"4.4.4.4\",\"dns-secondary\":\"8.8.4.4\",\"mtu\":1400,\"ue-dnn-qos\":{\"dnn-mbr-uplink\":5000000,\"dnn-mbr-downlink\":5000000,\"bitrate-unit\":\"kbps\",\"traffic-class\":{\"name\":\"gold\",\"qci\":7,\"arp\":5,\"pdb\":150,\"pelr\":5}}}]}"
if body != expected {
t.Errorf("Expected %v, got %v", expected, body)
}
Expand Down
35 changes: 29 additions & 6 deletions configapi/api_subscriber_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -974,33 +974,56 @@ func TestSubscriberDeleteSuccessWithDeviceGroup(t *testing.T) {
}

func deviceGroupWithImsis(name string, imsis []string) configmodels.DeviceGroups {
trafficClass := configmodels.TrafficClassInfo{
traffic_class1 := configmodels.TrafficClassInfo{
Name: "platinum",
Qci: 8,
Arp: 6,
Pdb: 300,
Pelr: 6,
}
qos := configmodels.DeviceGroupsIpDomainExpandedUeDnnQos{
qos1 := configmodels.DeviceGroupsIpDomainExpandedUeDnnQos{
DnnMbrUplink: 10000000,
DnnMbrDownlink: 10000000,
BitrateUnit: "kbps",
TrafficClass: &trafficClass,
TrafficClass: &traffic_class1,
}
ipDomain := configmodels.DeviceGroupsIpDomainExpanded{
ipdomain1 := configmodels.DeviceGroupsIpDomainExpanded{
Dnn: "internet",
UeIpPool: "172.250.1.0/16",
DnsPrimary: "1.1.1.1",
DnsSecondary: "8.8.8.8",
Mtu: 1460,
UeDnnQos: &qos,
UeDnnQos: &qos1,
}

// Define the second traffic class and QoS
traffic_class2 := configmodels.TrafficClassInfo{
Name: "gold",
Qci: 7,
Arp: 5,
Pdb: 150,
Pelr: 5,
}
qos2 := configmodels.DeviceGroupsIpDomainExpandedUeDnnQos{
DnnMbrUplink: 5000000,
DnnMbrDownlink: 5000000,
BitrateUnit: "kbps",
TrafficClass: &traffic_class2,
}
ipdomain2 := configmodels.DeviceGroupsIpDomainExpanded{
Dnn: "ims",
UeIpPool: "172.248.0.0/16",
DnsPrimary: "4.4.4.4",
DnsSecondary: "8.8.4.4",
Mtu: 1400,
UeDnnQos: &qos2,
}
deviceGroup := configmodels.DeviceGroups{
DeviceGroupName: name,
Imsis: imsis,
SiteInfo: "demo",
IpDomainName: "pool1",
IpDomainExpanded: ipDomain,
IpDomainExpanded: []configmodels.DeviceGroupsIpDomainExpanded{ipdomain1, ipdomain2},
}
return deviceGroup
}
Expand Down
52 changes: 29 additions & 23 deletions configapi/device_group_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,28 +89,27 @@ func updateDeviceGroupInNetworkSlices(groupName string) error {
func deviceGroupPostHelper(requestDeviceGroup configmodels.DeviceGroups, msgOp int, groupName string) (int, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to add validation in this function to make sure that the DNN is different than empty string.
Also, should each IP domain should use a different DNN name?
if validation fails, a 400 bad request error should be returned to the user

logger.ConfigLog.Infof("received device group: %s", groupName)

ipdomain := &requestDeviceGroup.IpDomainExpanded
ipdomains := &requestDeviceGroup.IpDomainExpanded
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ipdomains := &requestDeviceGroup.IpDomainExpanded
ipdomains := requestDeviceGroup.IpDomainExpanded

logger.ConfigLog.Infof("imsis.size: %v, Imsis: %s", len(requestDeviceGroup.Imsis), requestDeviceGroup.Imsis)
logger.ConfigLog.Infof("IP Domain Name: %s", requestDeviceGroup.IpDomainName)
logger.ConfigLog.Infof("IP Domain details: %+v", ipdomain)
logger.ConfigLog.Infof("dnn name: %s", ipdomain.Dnn)
logger.ConfigLog.Infof("ue pool: %s", ipdomain.UeIpPool)
logger.ConfigLog.Infof("dns Primary: %s", ipdomain.DnsPrimary)
logger.ConfigLog.Infof("dns Secondary: %s", ipdomain.DnsSecondary)
logger.ConfigLog.Infof("ip mtu: %v", ipdomain.Mtu)
logger.ConfigLog.Infof("device Group Name: %s", groupName)

if ipdomain.UeDnnQos != nil {
ipdomain.UeDnnQos.DnnMbrDownlink = convertToBps(ipdomain.UeDnnQos.DnnMbrDownlink, ipdomain.UeDnnQos.BitrateUnit)
if ipdomain.UeDnnQos.DnnMbrDownlink < 0 {
ipdomain.UeDnnQos.DnnMbrDownlink = math.MaxInt64
}
logger.ConfigLog.Infof("MbrDownLink: %v", ipdomain.UeDnnQos.DnnMbrDownlink)
ipdomain.UeDnnQos.DnnMbrUplink = convertToBps(ipdomain.UeDnnQos.DnnMbrUplink, ipdomain.UeDnnQos.BitrateUnit)
if ipdomain.UeDnnQos.DnnMbrUplink < 0 {
ipdomain.UeDnnQos.DnnMbrUplink = math.MaxInt64
for i, ipdomain := range *ipdomains {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for i, ipdomain := range *ipdomains {
for i, ipdomain := range ipdomains {

logger.ConfigLog.Infof("IP Domain details [%d]: %+v", i, ipdomain)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we are logging 2 times the ip domain details. one in this line and second time in the following lines. We should keep only one

logger.ConfigLog.Infof("DNN Name : %v", ipdomain.Dnn)
logger.ConfigLog.Infof("UE Pool : %v", ipdomain.UeIpPool)
logger.ConfigLog.Infof("DNS Primary : %v", ipdomain.DnsPrimary)
logger.ConfigLog.Infof("DNS Secondary : %v", ipdomain.DnsSecondary)
Comment on lines +96 to +99
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these can stay as %s since they are strings

logger.ConfigLog.Infof("IP MTU : %v", ipdomain.Mtu)
if ipdomain.UeDnnQos != nil {
ipdomain.UeDnnQos.DnnMbrDownlink = convertToBps(ipdomain.UeDnnQos.DnnMbrDownlink, ipdomain.UeDnnQos.BitrateUnit)
if ipdomain.UeDnnQos.DnnMbrDownlink < 0 {
ipdomain.UeDnnQos.DnnMbrDownlink = math.MaxInt64
}
logger.ConfigLog.Infof("MBR DownLink : %v", ipdomain.UeDnnQos.DnnMbrDownlink)
ipdomain.UeDnnQos.DnnMbrUplink = convertToBps(ipdomain.UeDnnQos.DnnMbrUplink, ipdomain.UeDnnQos.BitrateUnit)
if ipdomain.UeDnnQos.DnnMbrUplink < 0 {
ipdomain.UeDnnQos.DnnMbrUplink = math.MaxInt64
}
logger.ConfigLog.Infof("MBR UpLink : %v", ipdomain.UeDnnQos.DnnMbrUplink)
}
logger.ConfigLog.Infof("MbrUpLink: %v", ipdomain.UeDnnQos.DnnMbrUplink)
}

prevDevGroup := getDeviceGroupByName(groupName)
Expand Down Expand Up @@ -214,18 +213,25 @@ func syncDeviceGroupSubscriber(devGroup *configmodels.DeviceGroups, prevDevGroup
Sst: int32(sVal),
}
var errorOccured bool
dnnMap := make(map[string][]configmodels.DeviceGroupsIpDomainExpandedUeDnnQos)
for _, imsi := range devGroup.Imsis {
/* update all current IMSIs */
subscriberAuthData := DatabaseSubscriberAuthenticationData{}
if subscriberAuthData.SubscriberAuthenticationDataGet("imsi-"+imsi) != nil {
dnn := devGroup.IpDomainExpanded.Dnn
for _, ipDomain := range devGroup.IpDomainExpanded {
dnn := ipDomain.Dnn

// Ensure UeDnnQos is not nil before appending
if ipDomain.UeDnnQos != nil {
dnnMap[dnn] = append(dnnMap[dnn], *ipDomain.UeDnnQos) // Directly append the UeDnnQos
}
}
Comment on lines +221 to +228
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be done outside of the loop over devGroup.Imsis

err = updatePolicyAndProvisionedData(
imsi,
slice.SiteInfo.Plmn.Mcc,
slice.SiteInfo.Plmn.Mnc,
snssai,
dnn,
devGroup.IpDomainExpanded.UeDnnQos,
dnnMap,
)
if err != nil {
logger.DbLog.Errorf("updatePolicyAndProvisionedData failed for IMSI %s: %+v", imsi, err)
Expand Down
57 changes: 33 additions & 24 deletions configapi/device_group_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,12 @@ func Test_handleDeviceGroupPost(t *testing.T) {
deviceGroup("group_no_imsis"), deviceGroup("group_no_traf_class"), deviceGroup("group_no_qos"),
}
deviceGroups[2].Imsis = []string{}
deviceGroups[3].IpDomainExpanded.UeDnnQos.TrafficClass = nil
deviceGroups[4].IpDomainExpanded.UeDnnQos = nil
if len(deviceGroups[3].IpDomainExpanded) > 0 {
deviceGroups[3].IpDomainExpanded[0].UeDnnQos.TrafficClass = nil
}
if len(deviceGroups[4].IpDomainExpanded) > 0 {
deviceGroups[4].IpDomainExpanded[0].UeDnnQos = nil
}
factory.WebUIConfig.Configuration.Mode5G = true

for _, testGroup := range deviceGroups {
Expand Down Expand Up @@ -157,9 +161,12 @@ func Test_handleDeviceGroupPost_alreadyExists(t *testing.T) {
deviceGroup("group_no_qos"),
}
deviceGroups[2].Imsis = []string{}
deviceGroups[3].IpDomainExpanded.UeDnnQos.TrafficClass = nil
deviceGroups[4].IpDomainExpanded.UeDnnQos = nil

if len(deviceGroups[3].IpDomainExpanded) > 0 {
deviceGroups[3].IpDomainExpanded[0].UeDnnQos.TrafficClass = nil
}
if len(deviceGroups[4].IpDomainExpanded) > 0 {
deviceGroups[4].IpDomainExpanded[0].UeDnnQos = nil
}
factory.WebUIConfig.Configuration.Mode5G = true

for _, testGroup := range deviceGroups {
Expand Down Expand Up @@ -248,25 +255,27 @@ const DEVICE_GROUP_CONFIG = `{
"imsis": [
"string"
],
"ip-domain-expanded": {
"dnn": "string",
"dns-primary": "string",
"dns-secondary": "string",
"mtu": 0,
"ue-dnn-qos": {
"bitrate-unit": "string",
"dnn-mbr-downlink": 0,
"dnn-mbr-uplink": 0,
"traffic-class": {
"arp": 0,
"name": "string",
"pdb": 0,
"pelr": 0,
"qci": 0
}
},
"ue-ip-pool": "string"
},
"ip-domains": [
{
"dnn": "string",
"dns-primary": "string",
"dns-secondary": "string",
"mtu": 0,
"ue-dnn-qos": {
"bitrate-unit": "string",
"dnn-mbr-downlink": 0,
"dnn-mbr-uplink": 0,
"traffic-class": {
"arp": 0,
"name": "string",
"pdb": 0,
"pelr": 0,
"qci": 0
}
},
"ue-ip-pool": "string"
}
],
"ip-domain-name": "string",
"site-info": "string"
}`
Expand Down
Loading