free5gc / smf

Apache License 2.0
19 stars 93 forks source link

SMF does not properly map default path to UPF destination. #40

Closed aviweit closed 2 years ago

aviweit commented 2 years ago

SMF does not properly map default path to UPF destination.

Environment:

I am using the below uerouting.yaml and can see that SMF states that it builds a datapath to UPF-C1: New default data path (gNB1 to UPF-C1) but the path destination is UPF-C2 and not UPF-C1 as it should be. I validated that the 3rd node ip 10.100.200.6 indicated in the attached logs, is of UPF-C2.

Looking into it more, I can see that the method getAllPathByNodeName uses a recursion in which I suspect that allPaths get changed during the recursion stack even-though it is not being explicitly set.

Please find attached SMF logs. If needed, I can send smfcfg.yaml.

Thanks.

ueRoutingInfo: # the list of UE routing information
  UE-gNB-1-1: # Group Name
    members:
    - imsi-208930000000002 # Subscription Permanent Identifier of the UE
    - imsi-208930000000001 # Subscription Permanent Identifier of the UE
    topology:
    # Network topology for this group (Uplink: A->B, Downlink: B->A)
    # default path derived from this topology
    # node name should be consistent with smfcfg.yaml
      - A: gNB1
        B: UPF-R1

      - A: UPF-R1
        B: UPF-T1

      - A: UPF-R1
        B: UPF-T2

      - A: UPF-T1
        B: UPF-C1

      - A: UPF-T1
        B: UPF-C2

      - A: UPF-T2
        B: UPF-C2

      - A: UPF-T2
        B: UPF-C3

      - A: UPF-T2
        B: UPF-C4

    specificPath:
      - dest: 60.61.0.0/16 # the destination IP address on Data Network (DN)
        # the order of UPF nodes in this path. We use the UPF's name to represent each UPF node.
        # The UPF's name should be consistent with smfcfg.yaml
        path: [UPF-R1, UPF-T1, UPF-C1]
smf       | 2022-01-16T13:58:11Z [DEBU][SMF][Init] gNB1 is AN
smf       | 2022-01-16T13:58:11Z [DEBU][SMF][Init] UPF-C1 is Anchor UPF
smf       | 2022-01-16T13:58:11Z [DEBU][SMF][Init] UPF-C2 is Anchor UPF
smf       | 2022-01-16T13:58:11Z [DEBU][SMF][Init] UPF-C3 is Anchor UPF
smf       | 2022-01-16T13:58:11Z [DEBU][SMF][Init] UPF-C4 is Anchor UPF
smf       | 2022-01-16T13:58:11Z [TRAC][SMF][Init] current path: [gNB1]
smf       | 2022-01-16T13:58:11Z [TRAC][SMF][Init] current path: [gNB1 UPF-R1]
smf       | 2022-01-16T13:58:11Z [TRAC][SMF][Init] current path: [gNB1 UPF-R1 UPF-T1]
smf       | 2022-01-16T13:58:11Z [TRAC][SMF][Init] current path: [gNB1 UPF-R1 UPF-T1 UPF-C1]
smf       | 2022-01-16T13:58:11Z [TRAC][SMF][Init] all path: map[0:[UPF-R1 UPF-T1 UPF-C1]]
smf       | 2022-01-16T13:58:11Z [TRAC][SMF][Init] current path: [gNB1 UPF-R1 UPF-T1 UPF-C2]
smf       | 2022-01-16T13:58:11Z [TRAC][SMF][Init] current path: [gNB1 UPF-R1 UPF-T2]
smf       | 2022-01-16T13:58:11Z [TRAC][SMF][Init] current path: [gNB1 UPF-R1 UPF-T2 UPF-C2]
smf       | 2022-01-16T13:58:11Z [TRAC][SMF][Init] current path: [gNB1 UPF-R1 UPF-T2 UPF-C3]
smf       | 2022-01-16T13:58:11Z [TRAC][SMF][Init] current path: [gNB1 UPF-R1 UPF-T2 UPF-C4]
smf       | 2022-01-16T13:58:11Z [TRAC][SMF][CTX] New default data path (gNB1 to UPF-C1):
smf       | 2022-01-16T13:58:11Z [TRAC][SMF][CTX] DataPath Meta Information
smf       | Activated: false
smf       | IsDefault Path: false
smf       | Has Braching Point: false
smf       | Destination IP:
smf       | Destination Port:
smf       | DataPath Routing Information
smf       | 1th Node in the Path
smf       | Current UPF IP: 10.100.200.5
smf       | Previous UPF IP: None
smf       | Next UPF IP: 10.100.200.8
smf       | 2th Node in the Path
smf       | Current UPF IP: 10.100.200.8
smf       | Previous UPF IP: 10.100.200.5
smf       | Next UPF IP: 10.100.200.6
smf       | 3th Node in the Path
smf       | Current UPF IP: 10.100.200.6
smf       | Previous UPF IP: 10.100.200.8
smf       | Next UPF IP: None
aviweit commented 2 years ago

Looking into it more and adding traces, I can see that allPaths for UPF-C1, is properly set:

smf | 2022-01-16T14:26:32Z [TRAC][SMF][Init] all path: map[0:[UPF-R1 UPF-T1 UPF-C1]]

However, during the recursion execution, it get changed to: smf | 2022-01-16T14:26:32Z [TRAC][SMF][Init] [WEIT1] all path: map[0:[UPF-R1 UPF-T1 UPF-C2]]

which get returned:

smf | 2022-01-16T14:26:32Z [TRAC][SMF][Init] [WEIT] getAllPathByNodeName EXIT src, dest, allPaths: gNB1 UPF-C1 map[0:[UPF-R1 UPF-T1 UPF-C2]]

smf       | 2022-01-16T14:26:32Z [INFO][SMF][App] SMF version:
smf       |     free5GC version: v3.0.6
smf       |     build time:      2022-01-16T14:24:52Z
smf       |     commit hash:     46644f0a
smf       |     commit time:     2021-09-13T13:23:12Z
smf       |     go version:      go1.14.4 linux/amd64
smf       | 2022-01-16T14:26:32Z [INFO][SMF][Init] SMF Log level is set to [trace] level
smf       | 2022-01-16T14:26:32Z [INFO][LIB][NAS] set log level : trace
smf       | 2022-01-16T14:26:32Z [INFO][LIB][NAS] set report call : false
smf       | 2022-01-16T14:26:32Z [INFO][LIB][NGAP] set log level : trace
smf       | 2022-01-16T14:26:32Z [INFO][LIB][NGAP] set report call : false
smf       | 2022-01-16T14:26:32Z [INFO][LIB][Aper] set log level : info
smf       | 2022-01-16T14:26:32Z [INFO][LIB][Aper] set report call : false
smf       | 2022-01-16T14:26:32Z [INFO][LIB][Path] set log level : debug
smf       | 2022-01-16T14:26:32Z [INFO][LIB][Path] set report call : false
smf       | 2022-01-16T14:26:32Z [INFO][LIB][OAPI] set log level : debug
smf       | 2022-01-16T14:26:32Z [INFO][LIB][OAPI] set report call : false
smf       | 2022-01-16T14:26:32Z [INFO][LIB][PFCP] set log level : trace
smf       | 2022-01-16T14:26:32Z [INFO][LIB][PFCP] set report call : false
smf       | 2022-01-16T14:26:32Z [INFO][SMF][CFG] SMF config version [1.0.2]
smf       | 2022-01-16T14:26:32Z [INFO][SMF][CFG] UE-Routing config version [1.0.1]
smf       | 2022-01-16T14:26:32Z [INFO][SMF][CTX] smfconfig Info: Version[1.0.2] Description[SMF initial local configuration]
smf       | 2022-01-16T14:26:32Z [INFO][SMF][CTX] Endpoints: [172.15.0.7]
smf       | 2022-01-16T14:26:32Z [INFO][SMF][CTX] Endpoints: [172.15.0.8]
smf       | 2022-01-16T14:26:32Z [INFO][SMF][CTX] Endpoints: [172.15.0.9]
smf       | 2022-01-16T14:26:32Z [INFO][SMF][CTX] Endpoints: [172.15.0.10]
smf       | 2022-01-16T14:26:32Z [INFO][SMF][CTX] Endpoints: [172.15.0.11]
smf       | 2022-01-16T14:26:32Z [INFO][SMF][CTX] Endpoints: [172.15.0.12]
smf       | 2022-01-16T14:26:32Z [INFO][SMF][CTX] Endpoints: [172.15.0.6]
smf       | 2022-01-16T14:26:32Z [INFO][SMF][CTX] Endpoints: [172.15.0.6]
smf       | 2022-01-16T14:26:32Z [INFO][SMF][CTX] ue routing config Info: Version[1.0.1] Description[Routing information for UE]
smf       | 2022-01-16T14:26:32Z [DEBU][SMF][CTX] Set context for ULCL group:  UE-gNB-1-1
...

smf       | 2022-01-16T14:26:32Z [DEBU][SMF][Init] gNB1 is AN
smf       | 2022-01-16T14:26:32Z [DEBU][SMF][Init] UPF-C1 is Anchor UPF
smf       | 2022-01-16T14:26:32Z [DEBU][SMF][Init] UPF-C2 is Anchor UPF
smf       | 2022-01-16T14:26:32Z [DEBU][SMF][Init] UPF-C3 is Anchor UPF
smf       | 2022-01-16T14:26:32Z [DEBU][SMF][Init] UPF-C4 is Anchor UPF
smf       | 2022-01-16T14:26:32Z [TRAC][SMF][Init] [WEIT] findPath: src, dest, currentPath, allPaths: gNB1 UPF-C1 [] map[]
smf       | 2022-01-16T14:26:32Z [TRAC][SMF][Init] current path: [gNB1]
smf       | 2022-01-16T14:26:32Z [TRAC][SMF][Init] [WEIT1] all path: map[]
smf       | 2022-01-16T14:26:32Z [TRAC][SMF][Init] [WEIT] findPath: src, dest, currentPath, allPaths: UPF-R1 UPF-C1 [gNB1] map[]
smf       | 2022-01-16T14:26:32Z [TRAC][SMF][Init] current path: [gNB1 UPF-R1]
smf       | 2022-01-16T14:26:32Z [TRAC][SMF][Init] [WEIT1] all path: map[]
smf       | 2022-01-16T14:26:32Z [TRAC][SMF][Init] [WEIT] findPath: src, dest, currentPath, allPaths: UPF-T1 UPF-C1 [gNB1 UPF-R1] map[]
smf       | 2022-01-16T14:26:32Z [TRAC][SMF][Init] current path: [gNB1 UPF-R1 UPF-T1]
smf       | 2022-01-16T14:26:32Z [TRAC][SMF][Init] [WEIT1] all path: map[]
smf       | 2022-01-16T14:26:32Z [TRAC][SMF][Init] [WEIT] findPath: src, dest, currentPath, allPaths: UPF-C1 UPF-C1 [gNB1 UPF-R1 UPF-T1] map[]
smf       | 2022-01-16T14:26:32Z [TRAC][SMF][Init] current path: [gNB1 UPF-R1 UPF-T1 UPF-C1]
smf       | 2022-01-16T14:26:32Z [TRAC][SMF][Init] [WEIT1] all path: map[]
smf       | 2022-01-16T14:26:32Z [TRAC][SMF][Init] all path: map[0:[UPF-R1 UPF-T1 UPF-C1]]
smf       | 2022-01-16T14:26:32Z [TRAC][SMF][Init] [WEIT] findPath: src, dest, currentPath, allPaths: UPF-C2 UPF-C1 [gNB1 UPF-R1 UPF-T1] map[0:[UPF-R1 UPF-T1 UPF-C1]]
smf       | 2022-01-16T14:26:32Z [TRAC][SMF][Init] current path: [gNB1 UPF-R1 UPF-T1 UPF-C2]
smf       | 2022-01-16T14:26:32Z [TRAC][SMF][Init] [WEIT1] all path: map[0:[UPF-R1 UPF-T1 UPF-C2]]
smf       | 2022-01-16T14:26:32Z [TRAC][SMF][Init] [WEIT] findPath: src, dest, currentPath, allPaths: UPF-T2 UPF-C1 [gNB1 UPF-R1] map[0:[UPF-R1 UPF-T1 UPF-C2]]
smf       | 2022-01-16T14:26:32Z [TRAC][SMF][Init] current path: [gNB1 UPF-R1 UPF-T2]
smf       | 2022-01-16T14:26:32Z [TRAC][SMF][Init] [WEIT1] all path: map[0:[UPF-R1 UPF-T1 UPF-C2]]
smf       | 2022-01-16T14:26:32Z [TRAC][SMF][Init] [WEIT] findPath: src, dest, currentPath, allPaths: UPF-C2 UPF-C1 [gNB1 UPF-R1 UPF-T2] map[0:[UPF-R1 UPF-T1 UPF-C2]]
smf       | 2022-01-16T14:26:32Z [TRAC][SMF][Init] current path: [gNB1 UPF-R1 UPF-T2 UPF-C2]
smf       | 2022-01-16T14:26:32Z [TRAC][SMF][Init] [WEIT1] all path: map[0:[UPF-R1 UPF-T1 UPF-C2]]
smf       | 2022-01-16T14:26:32Z [TRAC][SMF][Init] [WEIT] findPath: src, dest, currentPath, allPaths: UPF-C3 UPF-C1 [gNB1 UPF-R1 UPF-T2] map[0:[UPF-R1 UPF-T1 UPF-C2]]
smf       | 2022-01-16T14:26:32Z [TRAC][SMF][Init] current path: [gNB1 UPF-R1 UPF-T2 UPF-C3]
smf       | 2022-01-16T14:26:32Z [TRAC][SMF][Init] [WEIT1] all path: map[0:[UPF-R1 UPF-T1 UPF-C2]]
smf       | 2022-01-16T14:26:32Z [TRAC][SMF][Init] [WEIT] findPath: src, dest, currentPath, allPaths: UPF-C4 UPF-C1 [gNB1 UPF-R1 UPF-T2] map[0:[UPF-R1 UPF-T1 UPF-C2]]
smf       | 2022-01-16T14:26:32Z [TRAC][SMF][Init] current path: [gNB1 UPF-R1 UPF-T2 UPF-C4]
smf       | 2022-01-16T14:26:32Z [TRAC][SMF][Init] [WEIT1] all path: map[0:[UPF-R1 UPF-T1 UPF-C2]]
smf       | 2022-01-16T14:26:32Z [TRAC][SMF][Init] [WEIT] getAllPathByNodeName EXIT src, dest, allPaths: gNB1 UPF-C1 map[0:[UPF-R1 UPF-T1 UPF-C2]]
smf       | 2022-01-16T14:26:32Z [TRAC][SMF][CTX] [WEIT] generateDefaultDataPath: nodeName: [UPF-R1]
smf       | 2022-01-16T14:26:32Z [TRAC][SMF][CTX] [WEIT] generateDefaultDataPath: nodeName: [UPF-T1]
smf       | 2022-01-16T14:26:32Z [TRAC][SMF][CTX] [WEIT] generateDefaultDataPath: nodeName: [UPF-C2]
smf       | 2022-01-16T14:26:32Z [TRAC][SMF][CTX] New default data path (gNB1 to UPF-C1):
smf       | 2022-01-16T14:26:32Z [TRAC][SMF][CTX] DataPath Meta Information
smf       | Activated: false
smf       | IsDefault Path: false
smf       | Has Braching Point: false
smf       | Destination IP:
smf       | Destination Port:
smf       | DataPath Routing Information
smf       | 1th Node in the Path
smf       | Current UPF IP: 10.100.200.8
smf       | Previous UPF IP: None
smf       | Next UPF IP: 10.100.200.2
smf       | 2th Node in the Path
smf       | Current UPF IP: 10.100.200.2
smf       | Previous UPF IP: 10.100.200.8
smf       | Next UPF IP: 10.100.200.6
smf       | 3th Node in the Path
smf       | Current UPF IP: 10.100.200.6
smf       | Previous UPF IP: 10.100.200.2
smf       | Next UPF IP: None
smf       | 2022-01-16T14:26:32Z [TRAC][SMF][Init] [WEIT] NewUEDefaultPaths: destination: [UPF-C1]
smf       | 2022-01-16T14:26:32Z [TRAC][SMF][Init] [WEIT] NewUEDefaultPaths: Current DP Node IP: [10.100.200.8], currently DP Node Type: [%!s(uint8=2)], node Value: [upf-r1.free5gc.org]
smf       | 2022-01-16T14:26:32Z [TRAC][SMF][Init] [WEIT] NewUEDefaultPaths: Current DP Node IP: [10.100.200.2], currently DP Node Type: [%!s(uint8=2)], node Value: [upf-t1.free5gc.org]
smf       | 2022-01-16T14:26:32Z [TRAC][SMF][Init] [WEIT] NewUEDefaultPaths: Current DP Node IP: [10.100.200.6], currently DP Node Type: [%!s(uint8=2)], node Value: [upf-c2.free5gc.org]
...
aviweit commented 2 years ago

Hi,

Modifying getAllPathByNodeName to perform a deep copy of currentPath to allPaths, seems to fix this issue where allPaths does not get changed once it is getting set.

Please find code snippet below.

...
                if src == dest {
                        cpy := make([]string, len(currentPath))
                        copy(cpy, currentPath)
                        allPaths[count] = cpy[1:]
                        count++
                        logger.InitLog.Traceln("all path:", allPaths)
                        visited[src] = false
                        return
                }
...

What do you think ?

Thanks.

louisroyer commented 2 years ago

Hi @aviweit, I have a related issue where if you specify multiple specificPaths only the PFCP rule for 1 of them is send (see https://forum.free5gc.org/t/issues-with-ueroutinginfo/1214 for details). I found out that using your fix, PFCP rules are well send. I have submitted PR #53 with your fix, with the hope it will be integrated.