-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: propagate DG changes to all IMSIs #283
base: main
Are you sure you want to change the base?
Changes from 6 commits
5b6e40b
cca215e
6ca96e2
4e2bb9d
ca19748
4e8982e
ba37e35
91cd6d5
ddff02e
bee58af
42a0eff
efcaa5e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -8,6 +8,7 @@ import ( | |||||||||||||||
"encoding/json" | ||||||||||||||||
"fmt" | ||||||||||||||||
"os/exec" | ||||||||||||||||
"slices" | ||||||||||||||||
"strconv" | ||||||||||||||||
"strings" | ||||||||||||||||
"sync" | ||||||||||||||||
|
@@ -42,14 +43,9 @@ type Update5GSubscriberMsg struct { | |||||||||||||||
|
||||||||||||||||
var ( | ||||||||||||||||
execCommand = exec.Command | ||||||||||||||||
imsiData map[string]*models.AuthenticationSubscription | ||||||||||||||||
rwLock sync.RWMutex | ||||||||||||||||
) | ||||||||||||||||
|
||||||||||||||||
func init() { | ||||||||||||||||
imsiData = make(map[string]*models.AuthenticationSubscription) | ||||||||||||||||
} | ||||||||||||||||
|
||||||||||||||||
func configHandler(configMsgChan chan *configmodels.ConfigMessage, configReceived chan bool) { | ||||||||||||||||
// Start Goroutine which will listens for subscriber config updates | ||||||||||||||||
// and update the mongoDB. Only for 5G | ||||||||||||||||
|
@@ -67,9 +63,6 @@ func configHandler(configMsgChan chan *configmodels.ConfigMessage, configReceive | |||||||||||||||
if configMsg.MsgType == configmodels.Sub_data { | ||||||||||||||||
imsiVal := strings.ReplaceAll(configMsg.Imsi, "imsi-", "") | ||||||||||||||||
logger.ConfigLog.Infoln("received imsi from config channel:", imsiVal) | ||||||||||||||||
rwLock.Lock() | ||||||||||||||||
imsiData[imsiVal] = configMsg.AuthSubData | ||||||||||||||||
rwLock.Unlock() | ||||||||||||||||
logger.ConfigLog.Infof("received Imsi [%v] configuration from config channel", configMsg.Imsi) | ||||||||||||||||
handleSubscriberPost(configMsg) | ||||||||||||||||
if factory.WebUIConfig.Configuration.Mode5G { | ||||||||||||||||
|
@@ -355,9 +348,10 @@ func getAddedImsisList(group, prevGroup *configmodels.DeviceGroups) (aimsis []st | |||||||||||||||
if group == nil { | ||||||||||||||||
return | ||||||||||||||||
} | ||||||||||||||||
provisionedSubscribers := getProvisionedSubscribers() | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i am concerned that here you are using the information in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In |
||||||||||||||||
for _, imsi := range group.Imsis { | ||||||||||||||||
if prevGroup == nil { | ||||||||||||||||
if imsiData[imsi] != nil { | ||||||||||||||||
if slices.Contains(provisionedSubscribers, imsi) { | ||||||||||||||||
aimsis = append(aimsis, imsi) | ||||||||||||||||
} | ||||||||||||||||
} else { | ||||||||||||||||
|
@@ -402,6 +396,36 @@ func getDeletedImsisList(group, prevGroup *configmodels.DeviceGroups) (dimsis [] | |||||||||||||||
return | ||||||||||||||||
} | ||||||||||||||||
|
||||||||||||||||
func getProvisionedSubscribers() []string { | ||||||||||||||||
rawProvisionedSubscribers, errGetMany := dbadapter.AuthDBClient.RestfulAPIGetMany(authSubsDataColl, nil) | ||||||||||||||||
if errGetMany != nil { | ||||||||||||||||
logger.DbLog.Warnln(errGetMany) | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we can inmmediately return here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agree, if we continue There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can return an empty slice. |
||||||||||||||||
} | ||||||||||||||||
var provisionedSubscribers []string | ||||||||||||||||
for _, rawProvisionedSubscriber := range rawProvisionedSubscribers { | ||||||||||||||||
ueId, ok := rawProvisionedSubscriber["ueId"].(string) | ||||||||||||||||
if !ok { | ||||||||||||||||
logger.DbLog.Warnf("cannot retrieve ueId for subscriber: %v", rawProvisionedSubscriber) | ||||||||||||||||
} | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
If we can not get a proper ueId, we can skip it. |
||||||||||||||||
provisionedSubscribers = append(provisionedSubscribers, ueId) | ||||||||||||||||
} | ||||||||||||||||
return provisionedSubscribers | ||||||||||||||||
} | ||||||||||||||||
|
||||||||||||||||
func getSubscriberAuthDataByUeId(ueId string) *models.AuthenticationSubscription { | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i would move this function to clientEvtHandler.go since it is only used there There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In |
||||||||||||||||
filter := bson.M{"ueId": ueId} | ||||||||||||||||
subscriberAuthDataInterface, errGetOne := dbadapter.AuthDBClient.RestfulAPIGetOne(authSubsDataColl, filter) | ||||||||||||||||
if errGetOne != nil { | ||||||||||||||||
logger.DbLog.Warnln(errGetOne) | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we can immediately return here |
||||||||||||||||
} | ||||||||||||||||
var subscriberAuthData models.AuthenticationSubscription | ||||||||||||||||
err := json.Unmarshal(configmodels.MapToByte(subscriberAuthDataInterface), &subscriberAuthData) | ||||||||||||||||
if err != nil { | ||||||||||||||||
logger.DbLog.Errorf("could not unmarshall subscriber %v", subscriberAuthDataInterface) | ||||||||||||||||
} | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
We can return here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see the point of adding There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the project L978 this function is called like below:
They do a nil check to skip or continue to execution. |
||||||||||||||||
return &subscriberAuthData | ||||||||||||||||
} | ||||||||||||||||
|
||||||||||||||||
func updateAmPolicyData(imsi string) { | ||||||||||||||||
// ampolicydata | ||||||||||||||||
var amPolicy models.AmPolicyData | ||||||||||||||||
|
@@ -607,6 +631,7 @@ func Config5GUpdateHandle(confChan chan *Update5GSubscriberMsg) { | |||||||||||||||
/* is this devicegroup part of any existing slice */ | ||||||||||||||||
slice := isDeviceGroupExistInSlice(confData) | ||||||||||||||||
if slice != nil { | ||||||||||||||||
provisionedSubscribers := getProvisionedSubscribers() | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i would make this in line 646: after the if and before the loop. In case of delete operation we would unnecessarily retrieving the list of subscribers |
||||||||||||||||
sVal, err := strconv.ParseUint(slice.SliceId.Sst, 10, 32) | ||||||||||||||||
if err != nil { | ||||||||||||||||
logger.DbLog.Errorf("could not parse SST %v", slice.SliceId.Sst) | ||||||||||||||||
|
@@ -616,14 +641,19 @@ func Config5GUpdateHandle(confChan chan *Update5GSubscriberMsg) { | |||||||||||||||
Sst: int32(sVal), | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We shoud return after line 637. If strconv.ParseUint fails, we can not calculate snssai properly. |
||||||||||||||||
} | ||||||||||||||||
|
||||||||||||||||
aimsis := getAddedImsisList(confData.Msg.DevGroup, confData.PrevDevGroup) | ||||||||||||||||
for _, imsi := range aimsis { | ||||||||||||||||
dnn := confData.Msg.DevGroup.IpDomainExpanded.Dnn | ||||||||||||||||
updateAmPolicyData(imsi) | ||||||||||||||||
updateSmPolicyData(snssai, dnn, imsi) | ||||||||||||||||
updateAmProvisionedData(snssai, confData.Msg.DevGroup.IpDomainExpanded.UeDnnQos, slice.SiteInfo.Plmn.Mcc, slice.SiteInfo.Plmn.Mnc, imsi) | ||||||||||||||||
updateSmProvisionedData(snssai, confData.Msg.DevGroup.IpDomainExpanded.UeDnnQos, slice.SiteInfo.Plmn.Mcc, slice.SiteInfo.Plmn.Mnc, dnn, imsi) | ||||||||||||||||
updateSmfSelectionProviosionedData(snssai, slice.SiteInfo.Plmn.Mcc, slice.SiteInfo.Plmn.Mnc, dnn, imsi) | ||||||||||||||||
/* skip delete case */ | ||||||||||||||||
if confData.Msg.DevGroup != nil { | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can move the first if clause outside of this block to increase readability. if confData.Msg.DevGroup == nil { There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's talk about it. I will ping you. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please disregard my comment. |
||||||||||||||||
for _, imsi := range confData.Msg.DevGroup.Imsis { | ||||||||||||||||
/* update only if the imsi is provisioned */ | ||||||||||||||||
if slices.Contains(provisionedSubscribers, "imsi-" + imsi) { | ||||||||||||||||
dnn := confData.Msg.DevGroup.IpDomainExpanded.Dnn | ||||||||||||||||
updateAmPolicyData(imsi) | ||||||||||||||||
updateSmPolicyData(snssai, dnn, imsi) | ||||||||||||||||
updateAmProvisionedData(snssai, confData.Msg.DevGroup.IpDomainExpanded.UeDnnQos, slice.SiteInfo.Plmn.Mcc, slice.SiteInfo.Plmn.Mnc, imsi) | ||||||||||||||||
updateSmProvisionedData(snssai, confData.Msg.DevGroup.IpDomainExpanded.UeDnnQos, slice.SiteInfo.Plmn.Mcc, slice.SiteInfo.Plmn.Mnc, dnn, imsi) | ||||||||||||||||
updateSmfSelectionProviosionedData(snssai, slice.SiteInfo.Plmn.Mcc, slice.SiteInfo.Plmn.Mnc, dnn, imsi) | ||||||||||||||||
} | ||||||||||||||||
} | ||||||||||||||||
} | ||||||||||||||||
|
||||||||||||||||
dimsis := getDeletedImsisList(confData.Msg.DevGroup, confData.PrevDevGroup) | ||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this piece of code is executed by the 4G configuration , in which case the
authSubsDataColl
used ingetSubscriberAuthDataByUeId
will not be filled andauthSubsData
will be nilAnd it's not 100% clear to me if
getAddedImsisList
if only used by 5G code since the code is shared between both configurations so I wouldn't touch it.please do not merge these changes until thi is fixed