free5gc / smf

Apache License 2.0
19 stars 93 forks source link

Fix NewUEPreConfigPaths when there is only one UPF in path list #10

Closed zhonglin6666 closed 3 years ago

zhonglin6666 commented 3 years ago

1. uerouting config as follows:

DestinationIP: 60.60.0.200 only one UPF

info:
  version: 1.0.0
  description: Routing information for UE

ueRoutingInfo:
  - SUPI: imsi-2089300007487
    AN: 10.200.200.101
    PathList:
      - DestinationIP: 60.60.0.101
        UPF: !!seq
          - BranchingUPF
          - AnchorUPF1

      - DestinationIP: 60.60.0.103
        UPF: !!seq
          - BranchingUPF
          - AnchorUPF2

      - DestinationIP: 60.60.0.200
        UPF: !!seq
          - AnchorUPF1

2. Run ./test_ulcl.sh TestRegistration, panic as this:

Activated: false
IsDefault Path: false
Has Braching Point: false
Destination IP: 60.60.0.103
Destination Port: 
DataPath Routing Information
1th Node in the Path
Current UPF IP: 10.200.200.102
Previous UPF IP: None
Next UPF IP: 10.200.200.103
2th Node in the Path
Current UPF IP: 10.200.200.103
Previous UPF IP: 10.200.200.102
Next UPF IP: None
panic: runtime error: index out of range [1] with length 1

goroutine 40 [running]:
free5gc/src/smf/context.NewUEPreConfigPaths(0xc00040c5c0, 0x12, 0xc00009d8c0, 0x3, 0x3, 0x2, 0x2, 0xc00031b380)
    /root/go/src/free5gc/src/smf/context/ue_datapath.go:71 +0x906
free5gc/src/smf/context.InitSMFUERouting(0x2116100)
    /root/go/src/free5gc/src/smf/context/smf_context.go:199 +0x1c4
free5gc/src/smf/service.(*SMF).Start(0x266cfa0)
    /root/go/src/free5gc/src/smf/service/init.go:124 +0x57
created by free5gc/src/test_test.init.0
    /root/go/src/free5gc/src/test/ngsetup_test.go:65 +0x22a
exit status 2

3. If only one UPF in path list, will panic

smf/context/ue_datapath.go

            switch idx {
            case lowerBound:
                childName := path.UPF[idx+1]