Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: Improved UPF routing and NAT handling #38

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

hxngillani
Copy link

@hxngillani hxngillani commented Feb 26, 2025

Enhancement: Dynamic UPF Routing and NAT Handling

Changes Made:

  • Replaced static aether-ue-nat.service with aether-ue-nat.service.j2 for dynamic NAT configuration..
  • Updated install.yaml to generate the NAT service dynamically based on UPF configuration.
  • Improved 20-aether-core.network to dynamically add routes for additional UPFs.
  • Modified the UPF module to check for existing routes before adding, preventing duplicate route errors.
  • Ensured a consistent and streamlined route management approach between the core network and UPF installation.

Why This Change?

  • The original aether-ue-nat.service was static, meaning new UPFs required manual modifications.
  • Using Jinja2 templating allows the NAT service to automatically adapt to new UPFs.
  • Previously, additional UPFs required route configuration, which is being done in UPF role in install task which near me should be part of router role.
  • The new approach automates UPF routing in router role section
  • Ensures that UPF routes do not fail with RTNETLINK answers: File exists when adding new UPFs.

Testing & Validation:

  • Successfully deployed Aether 5GC with multiple UPFs without issues.
  • Verified dynamic generation of NAT service using Jinja2.
  • Ensured UPF routing was correctly applied without requiring manual intervention.
  • No duplicate route errors occurred when adding multiple UPFs.

Notes for Reviewers:

  • Please verify if moving route handling to the router section aligns with project best practices.
  • Open to feedback on improving the logic for route management.

- Replaced static aether-ue-nat.service with dynamic aether-ue-nat.service.j2
- Updated install.yaml to use Jinja2 templating for NAT service
- Improved 20-aether-core.network to dynamically add routes for additional UPFs
- Modified add UPF module to check for existing routes before adding
- Ensured consistent route management between core network and UPF installation

Signed-off-by: hxngillani <h.shabir@studenti.unipi.it>
@hxngillani hxngillani force-pushed the upf-routing-improvements branch from 081a98a to fd8760a Compare February 26, 2025 23:26
@gab-arrobo
Copy link
Contributor

Hi @hxngillani, thanks for your contribution

Hi @llpeterson, @mbilal92, can you please review this PR? Thanks!

Comment on lines 13 to 20
{% if '1' in core.upf.additional_upfs %} \
sudo iptables -t nat -C POSTROUTING -s {{ core.upf.additional_upfs['1'].ue_ip_pool }} -o {{ core.data_iface }} -j MASQUERADE || \
sudo iptables -t nat -A POSTROUTING -s {{ core.upf.additional_upfs['1'].ue_ip_pool }} -o {{ core.data_iface }} -j MASQUERADE; \
{% endif %} \
{% if '2' in core.upf.additional_upfs %} \
sudo iptables -t nat -C POSTROUTING -s {{ core.upf.additional_upfs['2'].ue_ip_pool }} -o {{ core.data_iface }} -j MASQUERADE || \
sudo iptables -t nat -A POSTROUTING -s {{ core.upf.additional_upfs['2'].ue_ip_pool }} -o {{ core.data_iface }} -j MASQUERADE; \
{% endif %} \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if someone wants to deploy more than 2 additional UPFs? Would it be better to replace these if statements by a for loop?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for review great idea let me do that and test if it works will then amend in PR

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i have updated and tested it is working now for multiple UPFs use case.

Screenshot from 2025-02-27 20-43-52

Signed-off-by: hxngillani <h.shabir@studenti.unipi.it>
@hxngillani hxngillani force-pushed the upf-routing-improvements branch from fd8760a to cea71ab Compare February 27, 2025 19:40
Comment on lines +62 to 63

# ignore_errors: yes
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If ignore_errors is not used, I think it is better to just remove it

Suggested change
# ignore_errors: yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants