free5gc / smf

Apache License 2.0
19 stars 95 forks source link

Refactor SMF code for readability, conciseness, and modularity #108

Open LaumiH opened 4 months ago

LaumiH commented 4 months ago

Dear free5gc SMF team!

In the past months, I have been working with the SMF at university. I realized that the code base could be improved with regards to readability, conciseness, and modularity.

So while modifying the code so that it fits my use cases, I ended up refactoring it as well. With this PR, I want to propose my changes to you. Maybe you agree and find the changes worth merging!

There is no new functionality added (besides the session restoration procedure for UPFs, made possible through my refactoring).

The following is a non-complete list of the most important changes I made:

I have tested the code with UERANSIM and performed a session establishment and release procedure with 2 UEs and one sessions each. Please help me to also test additional functionality like handover, UL-CL, ...

Cheers, LaumiH

ianchen0119 commented 4 months ago

Hi @LaumiH

Thanks for your PR. We are currently working on refactoring, so we'll considering merge this patch after the refactoring work is done.

Thanks again.

LaumiH commented 1 month ago

Dear free5gc team,

I just wanted to let you know that I am working on the refactoring, I was on holiday for 3 weeks and I am back just now.

I am rebasing the branch to the main branch, which means that there are many complex conflicts, but I am confident that I will sort things out.

There is one question about the ULCL procedure: Currently, afaik it is started during session modification (in HandlePDUSessionSMContextUpdate -> UpdatePDUSessionAtANUPF), but then it also establishes the uplink tunnels and PDRs etc. for the second PSA and the ULCL. The uplink part could be moved to the session establishment code (in HandlePDUSessionSMContextCreate) to keep the code more aligned with the procedure for a single PSA. Here, only the downlink direction is established during session modification. Is this generally something you find good or bad? I could refactor the ULCL code so that it makes use of existing code instead of having everything in a separate file (internal/sbi/processor/ulcl_procedure.go).

Cheers, LaumiH

andy89923 commented 1 month ago

@LaumiH

Hi,

Thanks for your contribution. We will discuss about this PR and the question you ask, and get back to you tomorrow.

Best, Andy

LaumiH commented 1 month ago

Hi all,

so the branch now contains a conflict-free version of my refactorings that is rebased to the current main branch.

There are a couple of TODOs in the code, mainly with questions I want to ask and SMF logic I am not 100% sure about. I also am not sure that I have tested the code properly, maybe we can cooperate in this?

Cheers, LaumiH

andy89923 commented 3 weeks ago

Hi, sorry for the late reply. I think we should split this PR into multiple. This PR contains too many refactors. In this case, we can verify each functionality and don't have too many conflicts with this PR and other development/fixes on our site.

@ianchen0119

LaumiH commented 3 weeks ago

Hi @andy89923,

I totally agree, this is one huge blob of changes :smile: . However, many refactorings are dependent on each other. I will try to make smaller PRs in the following days, and hope that they can be merged with your help :)

Best, LaumiH