From d46f9d547a9d22560ec624ac0ae12c8277d49266 Mon Sep 17 00:00:00 2001 From: Louis Royer Date: Tue, 4 Feb 2025 17:02:07 +0100 Subject: [PATCH] Prevent duplicated creation of default path --- internal/context/sm_context.go | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/internal/context/sm_context.go b/internal/context/sm_context.go index 4dc2783..81246b5 100644 --- a/internal/context/sm_context.go +++ b/internal/context/sm_context.go @@ -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) { @@ -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") @@ -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 {