From c70aa4c43a14aa0bdee525055194885308be1931 Mon Sep 17 00:00:00 2001 From: Raphael Defosseux Date: Fri, 13 Aug 2021 14:21:50 +0200 Subject: [PATCH] fix(nr-ue): apply ip rules/route Signed-off-by: Raphael Defosseux --- ci-scripts/cls_containerize.py | 18 +-- ci-scripts/xml_files/container_4g_rfsim.xml | 130 ++++++++++++++++++ .../xml_files/container_4g_rfsim_down.xml | 38 +++++ ci-scripts/xml_files/container_5g_rfsim.xml | 1 + .../yaml_files/5g_rfsimulator/README.md | 28 ---- openair2/RRC/NAS/nas_config.c | 13 ++ 6 files changed, 185 insertions(+), 43 deletions(-) create mode 100644 ci-scripts/xml_files/container_4g_rfsim.xml create mode 100644 ci-scripts/xml_files/container_4g_rfsim_down.xml diff --git a/ci-scripts/cls_containerize.py b/ci-scripts/cls_containerize.py index 63b707aa74..3e65f83e06 100644 --- a/ci-scripts/cls_containerize.py +++ b/ci-scripts/cls_containerize.py @@ -596,20 +596,6 @@ class Containerize(): else: time.sleep(10) - # HACK TO REMOVE LATER WHEN FIX - res = re.search('oai-nr-ue', self.services[0]) - if res is not None: - cmd = 'docker exec rfsim5g-oai-nr-ue /bin/bash -c "ip route del default"' - logging.debug(cmd) - deployStatus = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT, universal_newlines=True, timeout=10) - cmd = 'docker exec rfsim5g-oai-nr-ue /bin/bash -c "ip route del 12.1.1.0/24"' - logging.debug(cmd) - deployStatus = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT, universal_newlines=True, timeout=10) - cmd = 'docker exec rfsim5g-oai-nr-ue /bin/bash -c "ip route add default via 12.1.1.2 dev oaitun_ue1"' - logging.debug(cmd) - deployStatus = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT, universal_newlines=True, timeout=10) - # END OF HACK TO REMOVE LATER WHEN FIX - if count == 100 and healthy == self.nb_healthy[0]: HTML.CreateHtmlTestRow('n/a', 'OK', CONST.ALL_PROCESSES_OK) logging.info('\u001B[1m Deploying OAI Object(s) PASS\u001B[0m') @@ -628,7 +614,7 @@ class Containerize(): logging.debug(cmd) subprocess.run(cmd, shell=True) -# if the containers are running, recover the logs! + # if the containers are running, recover the logs! cmd = 'cd ' + self.yamlPath[0] + ' && docker-compose -f docker-compose-ci.yml ps --all' logging.debug(cmd) deployStatus = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT, universal_newlines=True, timeout=10) @@ -831,7 +817,9 @@ class Containerize(): logging.debug('\u001B[1;34m Jitter : ' + jitter + '\u001B[0m') self.IperfExit(HTML, iperfStatus, msg) else: + iperfStatus = False logging.error('problem?') + self.IperfExit(HTML, iperfStatus, 'problem?') if iperfStatus: logging.info('\u001B[1m Iperf Test PASS\u001B[0m') diff --git a/ci-scripts/xml_files/container_4g_rfsim.xml b/ci-scripts/xml_files/container_4g_rfsim.xml new file mode 100644 index 0000000000..f342c3f5ce --- /dev/null +++ b/ci-scripts/xml_files/container_4g_rfsim.xml @@ -0,0 +1,130 @@ + + + rfsim-4gnr + Testing 4G NR RF sim in containers + wrench + 4 + + 100011 + 000011 + 000001 + 000012 + 000002 + 000013 + 000001 + 000014 + 000002 + 020011 + 020012 + 030011 + 030012 + 100011 + + + + + DeployGenObject + Deploy Cassandra Database + yaml_files/4g_rfsimulator + cassandra db_init + 1 + + + + IdleSleep + Sleep + 30 + + + + IdleSleep + Sleep + 10 + + + + DeployGenObject + Deploy OAI 4G CoreNetwork + yaml_files/4g_rfsimulator + oai_hss oai_mme oai_spgwc oai_spgwu trf_gen + 6 + + + + DeployGenObject + Deploy OAI 4G eNB RF sim + yaml_files/4g_rfsimulator + enb + 7 + + + + DeployGenObject + Deploy OAI 4G NR-UE RF sim + yaml_files/4g_rfsimulator + oai_ue0 + 8 + + + + PingFromContainer + Ping Traffic-Gen from LTE-UE + rfsim4g-oai-lte-ue0 + -I oaitun_ue1 -c 20 192.168.61.11 + 5 + + + + PingFromContainer + Ping LTE-UE from Traffic-Gen + rfsim4g-trf-gen + -c 20 12.0.0.2 + 5 + + + + IperfFromContainer + Iperf UDP Downlink + rfsim4g-oai-lte-ue0 + rfsim4g-trf-gen + -B 12.0.0.2 -u -i 1 -s + -c 12.0.0.2 -u -i 1 -t 30 -b 4M + + + + IperfFromContainer + Iperf UDP Uplink + rfsim4g-trf-gen + rfsim4g-oai-lte-ue0 + -u -i 1 -s + -B 12.0.0.2 -c 192.168.61.11 -u -i 1 -t 30 -b 2M + + + + UndeployGenObject + Undeploy all OAI 4G stack + yaml_files/4g_rfsimulator + + + diff --git a/ci-scripts/xml_files/container_4g_rfsim_down.xml b/ci-scripts/xml_files/container_4g_rfsim_down.xml new file mode 100644 index 0000000000..cce2b32cf3 --- /dev/null +++ b/ci-scripts/xml_files/container_4g_rfsim_down.xml @@ -0,0 +1,38 @@ + + + rfsim-4gnr + Testing 4G NR RF sim in containers + wrench + + 100011 + + + + + UndeployGenObject + Undeploy all OAI 4G stack + yaml_files/4g_rfsimulator + + + diff --git a/ci-scripts/xml_files/container_5g_rfsim.xml b/ci-scripts/xml_files/container_5g_rfsim.xml index 8847c11894..660cd7cde8 100644 --- a/ci-scripts/xml_files/container_5g_rfsim.xml +++ b/ci-scripts/xml_files/container_5g_rfsim.xml @@ -25,6 +25,7 @@ Testing 5G NR RF sim in containers wrench + 100001 000001 000002 000003 diff --git a/ci-scripts/yaml_files/5g_rfsimulator/README.md b/ci-scripts/yaml_files/5g_rfsimulator/README.md index 807f1b47c5..1351d6742b 100644 --- a/ci-scripts/yaml_files/5g_rfsimulator/README.md +++ b/ci-scripts/yaml_files/5g_rfsimulator/README.md @@ -218,34 +218,6 @@ oaitun_ue1: flags=4305 mtu 1500 TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 ``` -**CAUTION: THESE NEXT FEW COMMANDS ARE A HACK. RAN developers SHALL FIX THIS!** - -```bash -$ docker exec -it rfsim5g-oai-nr-ue /bin/bash - -# Check the current routes - -root@bb4d400a832d:/opt/oai-nr-ue# ip route -default via 192.168.71.129 dev eth0 -12.1.1.0/24 dev oaitun_ue1 proto kernel scope link src 12.1.1.2 -192.168.71.128/26 dev eth0 proto kernel scope link src 192.168.71.137 - -# Remove the default and PDN routes - -root@bb4d400a832d:/opt/oai-nr-ue# ip route del default -root@bb4d400a832d:/opt/oai-nr-ue# ip route del 12.1.1.0/24 - -# Force the default route through oaitun_ue1 tunnel - -root@bb4d400a832d:/opt/oai-nr-ue# ip route add default via 12.1.1.2 dev oaitun_ue1 - -# Check the new routes - -root@bb4d400a832d:/opt/oai-nr-ue# ip route -default via 12.1.1.2 dev oaitun_ue1 -192.168.71.128/26 dev eth0 proto kernel scope link src 192.168.71.137 -``` - # 3. Check traffic # ## 3.1. Check your Internet connectivity ## diff --git a/openair2/RRC/NAS/nas_config.c b/openair2/RRC/NAS/nas_config.c index 2eb439b9e9..22a7ef2711 100644 --- a/openair2/RRC/NAS/nas_config.c +++ b/openair2/RRC/NAS/nas_config.c @@ -344,6 +344,19 @@ int nas_config(int interface_id, int thirdOctet, int fourthOctet, char *ifname) LOG_E(OIP,"Interface %s couldn't be configured (ip address %s, mask %s broadcast address %s)\n", interfaceName, ipAddress, netMask, broadcastAddress); + int res; + char command_line[500]; + res = sprintf(command_line, + "ip rule add from %s/32 table %d && " + "ip rule add to %s/32 table %d && " + "ip route add default dev %s%d table %d", + ipAddress, interface_id - 1 + 10000, + ipAddress, interface_id - 1 + 10000, + UE_NAS_USE_TUN ? "oaitun_ue" : "oip", + interface_id, interface_id - 1 + 10000); + + background_system(command_line); + return returnValue; }