From cea71ab8d822b95944d4a87706d8ad1673a6087a Mon Sep 17 00:00:00 2001 From: hxngillani Date: Thu, 27 Feb 2025 00:24:00 +0100 Subject: [PATCH] Refactor UE NAT setup to support dynamic UPF scaling Signed-off-by: hxngillani --- roles/router/tasks/install.yml | 5 +++++ .../templates/systemd/aether-ue-nat.service.j2 | 15 ++++++--------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/roles/router/tasks/install.yml b/roles/router/tasks/install.yml index 16fd52d..e08710c 100644 --- a/roles/router/tasks/install.yml +++ b/roles/router/tasks/install.yml @@ -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 diff --git a/roles/router/templates/systemd/aether-ue-nat.service.j2 b/roles/router/templates/systemd/aether-ue-nat.service.j2 index 235b680..d5f59ec 100644 --- a/roles/router/templates/systemd/aether-ue-nat.service.j2 +++ b/roles/router/templates/systemd/aether-ue-nat.service.j2 @@ -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 +