How to create two SMF network functions in a Free5gc-compose installation

How to create two SMF network functions in a ffee5gc-compose.

Hello everyone.

I have installed free5gc-compose in a VM with two network slices, and all is working well until here. Now I want to use one SMF network function per each slice. By default, one SMF is installed with free5gc-compose; It means that I have to create another SMF inside a new container. These are the steps that I have done:

  1. I created a copy of nf_smf folder (I named it nf_smf2) to modify the Dockerfile, and use it in the docker-compose file in the context line (context: ./nf_smf2). I only changed the value of the F5GC_MODULE variable to smf2 in the Dockerfile. The rest of the file remains the same as the one used in nf_smf.

  2. I created a copy of the smfcfg.yaml ( I named it smfcfg2.yaml), and I made only the following modification in these lines :
    smfName: SMF2 # the name of this SMF
    registerIPv4: smf2.free5gc.org # IP used to register to NRF
    bindingIPv4: smf2.free5gc.org # IP used to bind the service

  3. In the docker-compose file, I added these lines to create and execute a new container with the image made previously (step 1):

free5gc-smf2:
container_name: smf2
build:
context: ./nf_smf2
args:
DEBUG_TOOLS: “false”
command: ./smf -c ./config/smfcfg2.yaml -u ./config/uerouting.yaml
expose:
- “8000”
volumes:
- ./config/smfcfg2.yaml:/free5gc/config/smfcfg2.yaml
- ./config/uerouting.yaml:/free5gc/config/uerouting.yaml
environment:
GIN_MODE: release
networks:
privnet:
ipv4_address: 10.100.200.15
aliases:
- smf2.free5gc.org
depends_on:
- free5gc-nrf
- free5gc-upf

When I run the containers with the command docker-compose up, the new container (smf2), which has the new SMF network function does not work. It displays the following output:

smf2 | 2022-12-20T14:43:59Z [INFO][LIB][Aper] set log level : info
smf2 | 2022-12-20T14:43:59Z [INFO][LIB][Aper] set report call : false
smf2 | 2022-12-20T14:43:59Z [INFO][LIB][PFCP] set log level : info
smf2 | 2022-12-20T14:43:59Z [INFO][LIB][PFCP] set report call : false
smf2 | 2022-12-20T14:43:59Z [INFO][SMF][App] smf
smf2 | 2022-12-20T14:43:59Z [INFO][SMF][App] SMF version:
smf2 | free5GC version: v3.2.1
smf2 | build time: 2022-11-03T18:08:01Z
smf2 | commit hash: de70bf6c
smf2 | commit time: 2022-06-28T04:52:40Z
smf2 | go version: go1.14.4 linux/amd64
smf2 | 2022-12-20T14:43:59Z [INFO][SMF][CTX] smfconfig Info: Version[1.0.2] Description[SMF initial local configuration]
smf2 | 2022-12-20T14:43:59Z [INFO][SMF][CTX] Endpoints: [129.192.82.238]
smf2 | 2022-12-20T14:43:59Z [INFO][SMF][CTX] Endpoints: [129.192.82.50]
smf2 | 2022-12-20T14:43:59Z [INFO][SMF][Init] Server started
smf2 | 2022-12-20T14:43:59Z [INFO][SMF][Init] SMF Registration to NRF {3397b4e9-566a-45b4-9358-530320aa1316 SMF REGISTERED 0 0xc0000974e0 0xc000097560 [] [] [smf2.free5gc.org] [] [] [] 0 0 0 area1 0xc00007ac80 map[] false 0xc0000972e0 false false []}
smf2 | 2022-12-20T14:43:59Z [ERRO][SMF][PFCP] Failed to listen: listen udp 10.100.200.9:8805: bind: cannot assign requested address
smf2 | 2022-12-20T14:43:59Z [FATA][SMF][App] panic: runtime error: invalid memory address or nil pointer dereference
smf2 | goroutine 1 [running]:
smf2 | runtime/debug.Stack(0xc00058f628, 0xc7b0a0, 0x15067b0)
smf2 | /usr/local/go/src/runtime/debug/stack.go:24 +0x9d
smf2 | main.main.func1()
smf2 | /go/src/free5gc/NFs/smf/cmd/main.go:26 +0x57
smf2 | panic(0xc7b0a0, 0x15067b0)
smf2 | /usr/local/go/src/runtime/panic.go:969 +0x166
smf2 | github.com/free5gc/smf/internal/pfcp/udp.Run(0xdd4700)
smf2 | /go/src/free5gc/NFs/smf/internal/pfcp/udp/udp.go:27 +0x186
smf2 | github.com/free5gc/smf/pkg/service.(*SMF).Start(0x1523eb0)
smf2 | /go/src/free5gc/NFs/smf/pkg/service/init.go:267 +0x2b3
smf2 | main.action(0xc0000ba840, 0x0, 0xc0000a4240)
smf2 | /go/src/free5gc/NFs/smf/cmd/main.go:65 +0x423
smf2 | github.com/urfave/cli.HandleAction(0xc48000, 0xdd65d8, 0xc0000ba840, 0xc0000ba840, 0x0)
smf2 | /go/pkg/mod/github.com/urfave/[email protected]/app.go:524 +0x11a
smf2 | github.com/urfave/cli.(*App).Run(0xc0000d01c0, 0xc00001e140, 0x5, 0x5, 0x0, 0x0)
smf2 | /go/pkg/mod/github.com/urfave/[email protected]/app.go:286 +0x649
smf2 | main.main()
smf2 | /go/src/free5gc/NFs/smf/cmd/main.go:37 +0x188
smf2 exited with code 1

Also, I would like to mention that the SMF network function installed by default has the IP address 10.100.200.9. I mention it because this IP address appears in one smf2’s error line

I would really appreciate if you can help me with this problem.

Hi @rmayalam2022,
I think that in order to create another NF instance (e.g. UPF, SMF) you may not need to duplicate nf_xx folder (its role is for creating the image itself) but rather to duplicate the configuration file and customize it for your needs.
Regarding SMF configuration, you should probably define it with the slice you want it to support (under snssaiInfos:).
Regarding running free5gc compose, please note that the current code supports running it from pre-built images.

I have a forked version, that works for me, with two SMFs each supports a different slice. Please feel free to look: https://github.com/aviweit/free5gc-compose/tree/smf_for_each_slice

Hope it helps.