From db4769bc359e66083cd38b745e59ae93811ed959 Mon Sep 17 00:00:00 2001 From: Xenofon Foukas Date: Mon, 24 May 2021 16:33:12 +0100 Subject: [PATCH] Fixes to L2NFAPI_NOS1 dataplane traffic forwarding This commit fixes a bug that makes the dataplane traffic of all the emulated UEs to go through the interface of the first UE (oaitun_ue1). The fix uses the last octet of the IP assigned to each UE to map it to its UE_id, which is then used to get its RNTI and the correct PDCP queue. For the emulator to work properly, the routing tables of the emulated UEs must also be set. This patch introduces a script (setup_routes.sh) in cmake_targets/tools that configures the routing tables. This script must be run at the UE host machine once the UEs have successfully attached, passing the number of emulated UEs as the argument. For example, in the case of 16 emulated UEs, one must run "./setup_routes.sh 16". --- cmake_targets/tools/setup_routes.sh | 13 +++++++++++++ openair2/LAYER2/PDCP_v10.1.0/pdcp.c | 8 +++++++- openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c | 7 ++++++- 3 files changed, 26 insertions(+), 2 deletions(-) create mode 100755 cmake_targets/tools/setup_routes.sh diff --git a/cmake_targets/tools/setup_routes.sh b/cmake_targets/tools/setup_routes.sh new file mode 100755 index 0000000000..67fe250be7 --- /dev/null +++ b/cmake_targets/tools/setup_routes.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +for i in $(seq 1 $1); +do + let table=1000+$i + echo "sudo ip route add 10.0.1.0/24 dev oaitun_ue$i table $table" + sudo ip route add 10.0.1.0/24 dev oaitun_ue$i table $table + echo "sudo ip route add default via 10.0.1.1 dev oaitun_ue$i table $table" + sudo ip route add default via 10.0.1.1 dev oaitun_ue$i table $table + let octet=$i+1 + echo "sudo ip rule add from 10.0.1.$octet table $table" + sudo ip rule add from 10.0.1.$octet table $table +done diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c index 51d3cfc8f3..cddb666bfd 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c @@ -1081,7 +1081,13 @@ pdcp_data_ind( pdcpHead->inst = 1; } } // nfapi_mode - } + } else { + if (UE_NAS_USE_TUN) { + pdcpHead->inst = ctxt_pP->module_id; + } else if (ENB_NAS_USE_TUN) { + pdcpHead->inst = 0; + } + } } else { pdcpHead->rb_id = rb_id + (ctxt_pP->module_id * LTE_maxDRB); pdcpHead->inst = ctxt_pP->module_id; diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c index 8ff3c06cd4..cc44572abd 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c @@ -43,6 +43,7 @@ extern int otg_enabled; #include #include #include +#include #define rtf_put write #define rtf_get read @@ -222,7 +223,11 @@ int pdcp_fifo_read_input_sdus_fromtun (const protocol_ctxt_t *const ctxt_pP) { key = PDCP_COLL_KEY_DEFAULT_DRB_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag); h_rc = hashtable_get(pdcp_coll_p, key, (void **)&pdcp_p); } else { // => ENB_NAS_USE_TUN - ctxt.rnti=pdcp_eNB_UE_instance_to_rnti[0]; + /* Get the IP from a packet */ + struct ip *ip_pack = (struct ip *) nl_rx_buf; + /* Use last octet of destination IP to get index of UE */ + int ue_indx = ((ip_pack->ip_dst.s_addr >> 24) - 2) % MAX_MOBILES_PER_ENB; + ctxt.rnti=pdcp_eNB_UE_instance_to_rnti[ue_indx]; ctxt.enb_flag=ENB_FLAG_YES; ctxt.module_id=0; key = PDCP_COLL_KEY_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id, SRB_FLAG_NO);