Skip to content

Commit

Permalink
Refactor UE NAT setup to support dynamic UPF scaling
Browse files Browse the repository at this point in the history
Signed-off-by: hxngillani <h.shabir@studenti.unipi.it>
  • Loading branch information
hxngillani committed Feb 27, 2025
1 parent 56238a8 commit cea71ab
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
5 changes: 5 additions & 0 deletions roles/router/tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@
when: inventory_hostname in groups['master_nodes']
become: true

- name: Disable GRO flag on the {{ core.data_iface }} interface
shell: ethtool -K {{ core.data_iface }} gro off
when: inventory_hostname in groups['master_nodes']
become: true

- name: find {{ core.data_iface }}'s netplan network directory
shell: basename $(find /*/systemd/network -maxdepth 1 -not -type d -name '*{{ core.data_iface }}.network' -print)
register: result
Expand Down
15 changes: 6 additions & 9 deletions roles/router/templates/systemd/aether-ue-nat.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,12 @@ Type=oneshot
ExecStart=/bin/bash -c "\
sudo iptables -t nat -C POSTROUTING -s {{ core.upf.default_upf.ue_ip_pool }} -o {{ core.data_iface }} -j MASQUERADE || \
sudo iptables -t nat -A POSTROUTING -s {{ core.upf.default_upf.ue_ip_pool }} -o {{ core.data_iface }} -j MASQUERADE; \
{% 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 %} \
{% for upf_key, upf_data in core.upf.additional_upfs.items() %} \
sudo iptables -t nat -C POSTROUTING -s {{ upf_data.ue_ip_pool }} -o {{ core.data_iface }} -j MASQUERADE || \
sudo iptables -t nat -A POSTROUTING -s {{ upf_data.ue_ip_pool }} -o {{ core.data_iface }} -j MASQUERADE; \
{% endfor %} \
"

[Install]
WantedBy=multi-user.target
WantedBy=sys-subsystem-net-devices-core.device

0 comments on commit cea71ab

Please sign in to comment.