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
changes/20/24220/2
Pau Espin 2 years ago
parent 3ccf09f5c0
commit be5156c5c1
  1. 14
      src/osmo_gsm_tester/obj/epc_open5gs.py
  2. 4
      src/osmo_gsm_tester/obj/upf_open5gs.py
  3. 2
      src/osmo_gsm_tester/templates/open5gs-smfd.yaml.tmpl
  4. 4
      src/osmo_gsm_tester/templates/open5gs-upfd.yaml.tmpl
  5. 17
      utils/bin/osmo-gsm-tester_open5gs_tun_setup.sh
  6. 1
      utils/sudoers.d/osmo-gsm-tester_open5gs_tun_setup

@ -61,7 +61,10 @@ class Open5gsEPC(epc.EPC):
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 @@ class Open5gsEPC(epc.EPC):
def priv_addr_sgwu(self):
return self.gen_priv_addr(4)
def tun_name(self):
return "ogstun"
def tun_netmask(self):
return "24"
def apn_name(self):
return "internet"
###################
# PUBLIC (test API included)
###################
@ -170,7 +182,7 @@ class Open5gsEPC(epc.EPC):
"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} } \
} \

@ -34,6 +34,7 @@ class Open5gsUPF(log.Origin):
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 @@ class Open5gsUPF(log.Origin):
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)

@ -318,7 +318,7 @@ smf:
- 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

@ -110,7 +110,9 @@ upf:
- 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:

@ -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"

@ -0,0 +1 @@
%osmo-gsm-tester ALL=(root) NOPASSWD: /usr/local/bin/osmo-gsm-tester_open5gs_tun_setup.sh
Loading…
Cancel
Save