Change in osmo-gsm-tester[master]: open5gs: Pre-configure tun device for UPF

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

pespin gerrit-no-reply at lists.osmocom.org
Wed May 12 16:41:18 UTC 2021


pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-gsm-tester/+/24220 )


Change subject: open5gs: Pre-configure tun device for UPF
......................................................................

open5gs: Pre-configure tun device for UPF

open5gs requires the tun device to be pre-created and pre-configured
before using it. A ticket was opened in order to allow upfd itself
configuring it in [1]

[1] https://github.com/open5gs/open5gs/issues/899

Change-Id: I3b1857f09017cacee1c86f41dae1463c11b50490
---
M src/osmo_gsm_tester/obj/epc_open5gs.py
M src/osmo_gsm_tester/obj/upf_open5gs.py
M src/osmo_gsm_tester/templates/open5gs-smfd.yaml.tmpl
M src/osmo_gsm_tester/templates/open5gs-upfd.yaml.tmpl
A utils/bin/osmo-gsm-tester_open5gs_tun_setup.sh
A utils/sudoers.d/osmo-gsm-tester_open5gs_tun_setup
6 files changed, 40 insertions(+), 4 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-tester refs/changes/20/24220/1

diff --git a/src/osmo_gsm_tester/obj/epc_open5gs.py b/src/osmo_gsm_tester/obj/epc_open5gs.py
index 6db513b..99849f0 100644
--- a/src/osmo_gsm_tester/obj/epc_open5gs.py
+++ b/src/osmo_gsm_tester/obj/epc_open5gs.py
@@ -61,7 +61,10 @@
         db_host = values['epc']['db_host']
         db_uri = 'mongodb://'+db_host+'/open5gs'
         config.overlay(values, dict(epc=dict(db_uri=db_uri,
+                                             apn_name=self.apn_name(),
+                                             tun_name=self.tun_name(),
                                              tun_addr=self.tun_addr(),
+                                             tun_netmask=self.tun_netmask(),
                                              addr_smf=self.priv_addr_smf(),
                                              addr_upf=self.priv_addr_upf(),
                                              addr_sgwc=self.priv_addr_sgwc(),
@@ -121,6 +124,15 @@
     def priv_addr_sgwu(self):
         return self.gen_priv_addr(4)
 
+    def tun_name(self):
+        return "ogstun"
+
+    def tun_netmask(self):
+        return "16"
+
+    def apn_name(self):
+        return "internet"
+
 ###################
 # PUBLIC (test API included)
 ###################
@@ -170,7 +182,7 @@
                 "default_indicator": True, \
                 "session": [ \
                     { \
-                    "name": "internet", \
+                    "name": self.apn_name(), \
                     "type": 3, "pcc_rule": [], "ambr": {"uplink": {"value": 1, "unit": 0}, "downlink": {"value": 1, "unit": 0}}, \
                     "qos": { "index": 9, "arp": {"priority_level": 8, "pre_emption_capability": 1, "pre_emption_vulnerability": 1} } \
                     } \
@@ -209,7 +221,7 @@
                self.sgwu.running()
 
     def tun_addr(self):
-        return '172.16.0.1'
+        return '10.45.0.1'
 
     def get_kpis(self):
         return {}
diff --git a/src/osmo_gsm_tester/obj/upf_open5gs.py b/src/osmo_gsm_tester/obj/upf_open5gs.py
index 78a520f..344c177 100644
--- a/src/osmo_gsm_tester/obj/upf_open5gs.py
+++ b/src/osmo_gsm_tester/obj/upf_open5gs.py
@@ -34,6 +34,7 @@
     CFGFILE = 'open5gs-upfd.yaml'
     LOGFILE = 'open5gs-upfd.log'
     DIAMETERFILE = 'open5gs-freediameter.conf'
+    O5GS_TUN_SETUP_BIN = 'osmo-gsm-tester_open5gs_tun_setup.sh'
 
     def __init__(self, testenv, o5gs_epc):
         super().__init__(log.C_RUN, 'open5gs-upfd')
@@ -137,6 +138,9 @@
             f.write(r)
 
         if not self._run_node.is_local():
+            self.rem_host.run_remote_sync('tun-setup', ('sudo', Open5gsUPF.O5GS_TUN_SETUP_BIN,
+                                          self.o5gs_epc.tun_name(), self.o5gs_epc.tun_addr(),
+                                          self.o5gs_epc.tun_netmask()))
             self.rem_host.recreate_remote_dir(self.remote_inst)
             self.rem_host.scp('scp-inst-to-remote', str(self.inst), remote_prefix_dir)
             self.rem_host.recreate_remote_dir(remote_run_dir)
diff --git a/src/osmo_gsm_tester/templates/open5gs-smfd.yaml.tmpl b/src/osmo_gsm_tester/templates/open5gs-smfd.yaml.tmpl
index f2bd807..00a0eae 100644
--- a/src/osmo_gsm_tester/templates/open5gs-smfd.yaml.tmpl
+++ b/src/osmo_gsm_tester/templates/open5gs-smfd.yaml.tmpl
@@ -318,7 +318,7 @@
       - addr: ${epc.run_addr}
         port: 2153
     subnet:
-      - addr: ${epc.tun_addr}/16
+      - addr: ${epc.tun_addr}/${epc.tun_netmask}
     dns:
       - 8.8.8.8
       - 8.8.4.4
diff --git a/src/osmo_gsm_tester/templates/open5gs-upfd.yaml.tmpl b/src/osmo_gsm_tester/templates/open5gs-upfd.yaml.tmpl
index 87066d6..757c0ec 100644
--- a/src/osmo_gsm_tester/templates/open5gs-upfd.yaml.tmpl
+++ b/src/osmo_gsm_tester/templates/open5gs-upfd.yaml.tmpl
@@ -110,7 +110,9 @@
       - addr: ${epc.run_addr}
         port: 2154
     subnet:
-      - addr: ${epc.tun_addr}/16
+      - addr: ${epc.tun_addr}/${epc.tun_netmask}
+        dnn: ${epc.apn_name}
+        dev: ${epc.tun_name}
 
 #
 # smf:
diff --git a/utils/bin/osmo-gsm-tester_open5gs_tun_setup.sh b/utils/bin/osmo-gsm-tester_open5gs_tun_setup.sh
new file mode 100755
index 0000000..c9cc28c
--- /dev/null
+++ b/utils/bin/osmo-gsm-tester_open5gs_tun_setup.sh
@@ -0,0 +1,17 @@
+#!/bin/bash -e
+
+ifname="$1"
+ifaddr="$2"
+ifmask="$3"
+
+echo "*** Configuring tun $ifname with addr $ifaddr/$ifmask"
+
+if grep "$ifname" /proc/net/dev > /dev/null; then
+        ip tuntap del name "$ifname" mode tun
+fi
+
+ip tuntap add name "$ifname" mode tun
+
+ip addr add "$ifaddr/$ifmask" dev "$ifname"
+ip link set "$ifname" up
+echo "*** done configuring tun interface $ifname"
diff --git a/utils/sudoers.d/osmo-gsm-tester_open5gs_tun_setup b/utils/sudoers.d/osmo-gsm-tester_open5gs_tun_setup
new file mode 100644
index 0000000..9b8ed83
--- /dev/null
+++ b/utils/sudoers.d/osmo-gsm-tester_open5gs_tun_setup
@@ -0,0 +1 @@
+%osmo-gsm-tester ALL=(root) NOPASSWD: /usr/local/bin/osmo-gsm-tester_open5gs_tun_setup.sh

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-gsm-tester/+/24220
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Change-Id: I3b1857f09017cacee1c86f41dae1463c11b50490
Gerrit-Change-Number: 24220
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210512/c2c03466/attachment.htm>


More information about the gerrit-log mailing list