Skip to content

Commit

Permalink
Prevent duplicated creation of default path
Browse files Browse the repository at this point in the history
  • Loading branch information
louisroyer committed Feb 28, 2025
1 parent e8886ec commit d46f9d5
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions internal/context/sm_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ func (c *SMContext) AllocUeIP() error {
// This function create ULCL data paths.
func (c *SMContext) SelectULCLDataPaths() error {
if c.SelectionParam == nil || c.SelectedUPF == nil {
return fmt.Errorf("SelectDefaultDataPath err: SelectionParam or SelectedUPF is nil")
return fmt.Errorf("SelectULCLDataPath err: SelectionParam or SelectedUPF is nil")
}

if GetSelf().ULCLSupport && CheckUEHasPreConfig(c.Supi) {
Expand All @@ -600,17 +600,19 @@ func (c *SMContext) SelectDefaultDataPath() error {
return fmt.Errorf("SelectDefaultDataPath err: SelectionParam or SelectedUPF is nil")
}

var defaultPath *DataPath
if GetSelf().ULCLSupport && CheckUEHasPreConfig(c.Supi) {
defaultPath := c.Tunnel.DataPathPool.GetDefaultPath()
if defaultPath != nil {
// A default path already exists.
// Use this one.
c.Log.Infof("Has default path")
defaultPath = c.Tunnel.DataPathPool.GetDefaultPath()
} else if GetSelf().ULCLSupport && CheckUEHasPreConfig(c.Supi) {
// Fallback on pre-config default path
c.Log.Infof("Has pre-config default path")
uePreConfigPaths := GetUEPreConfigPaths(c.Supi, c.SelectedUPF.Name)
for _, dp := range uePreConfigPaths.DataPathPool {
if dp.IsDefaultPath {
c.Tunnel.AddDataPath(dp)
}
}
defaultPath = uePreConfigPaths.DataPathPool.GetDefaultPath()
} else if c.Tunnel.DataPathPool.GetDefaultPath() == nil {
c.Tunnel.AddDataPath(defaultPath)
} else {
// UE has no pre-config path and default path
// Use default route
c.Log.Infof("Has no pre-config route. Has no default path")
Expand All @@ -621,9 +623,6 @@ func (c *SMContext) SelectDefaultDataPath() error {
defaultPath.IsDefaultPath = true
c.Tunnel.AddDataPath(defaultPath)
}
} else {
c.Log.Infof("Has no pre-config route. Has default path")
defaultPath = c.Tunnel.DataPathPool.GetDefaultPath()
}

if defaultPath == nil {
Expand Down

0 comments on commit d46f9d5

Please sign in to comment.