From 8bff2cff3e8f5a25fbacab1c56dbd86bdf5158be Mon Sep 17 00:00:00 2001
From: Imad ALAWE <imad.Alawe@b-com.com>
Date: Fri, 1 Jul 2016 15:49:12 +0200
Subject: [PATCH] BUGFIX(GTP-U): Add missing ip rules in order to have point to
point connection
---
cmake_targets/tools/run_enb_ue_virt_s1 | 6 ------
.../ESM/DedicatedEpsBearerContextActivation.c | 2 +-
.../ESM/DefaultEpsBearerContextActivation.c | 2 +-
openair3/NAS/UE/ESM/esm_ebr_context.c | 20 ++++++++++++-------
openair3/NAS/UE/ESM/esm_ebr_context.h | 2 +-
targets/SIMU/USER/oaisim.c | 3 +++
6 files changed, 19 insertions(+), 16 deletions(-)
diff --git a/cmake_targets/tools/run_enb_ue_virt_s1 b/cmake_targets/tools/run_enb_ue_virt_s1
index ecd5993ff4..ff65946803 100755
--- a/cmake_targets/tools/run_enb_ue_virt_s1
+++ b/cmake_targets/tools/run_enb_ue_virt_s1
@@ -247,12 +247,6 @@ function main()
if [ $? -ne 0 ]; then
echo "200 lte " >> /etc/iproute2/rt_tables
fi
- ip rule add fwmark 1 table lte
- ifconfig oip1 up
- ip route add default dev oip1 table lte
- # the actual IP address depends on the EPC/MME config file for address pool
- ip route add from 192.188.0.0/24 table lte
- ip route add to 192.188.0.0/24 table lte
exe_arguments="$exe_arguments -s15 -AAWGN -y1 -b1 -u1 -Q0"
diff --git a/openair3/NAS/UE/ESM/DedicatedEpsBearerContextActivation.c b/openair3/NAS/UE/ESM/DedicatedEpsBearerContextActivation.c
index 3a32d3040d..e213356332 100644
--- a/openair3/NAS/UE/ESM/DedicatedEpsBearerContextActivation.c
+++ b/openair3/NAS/UE/ESM/DedicatedEpsBearerContextActivation.c
@@ -165,7 +165,7 @@ int esm_proc_dedicated_eps_bearer_context_request(nas_user_t *user, int ebi, int
*esm_cause = ESM_CAUSE_SYNTACTICAL_ERROR_IN_PACKET_FILTER;
} else {
/* Create new dedicated EPS bearer context */
- default_ebi = esm_ebr_context_create(esm_data, pid, ebi, FALSE, qos, tft);
+ default_ebi = esm_ebr_context_create(esm_data, user->ueid, pid, ebi, FALSE, qos, tft);
if (default_ebi != ESM_EBI_UNASSIGNED) {
/* Dedicated EPS bearer contextx successfully created */
diff --git a/openair3/NAS/UE/ESM/DefaultEpsBearerContextActivation.c b/openair3/NAS/UE/ESM/DefaultEpsBearerContextActivation.c
index 71421a475d..a438d65ddb 100644
--- a/openair3/NAS/UE/ESM/DefaultEpsBearerContextActivation.c
+++ b/openair3/NAS/UE/ESM/DefaultEpsBearerContextActivation.c
@@ -127,7 +127,7 @@ int esm_proc_default_eps_bearer_context_request(nas_user_t *user, int pid, int e
if (ebi != ESM_EBI_UNASSIGNED) {
/* Create new default EPS bearer context */
- ebi = esm_ebr_context_create(esm_data, pid, ebi, TRUE, qos, NULL);
+ ebi = esm_ebr_context_create(esm_data, user->ueid, pid, ebi, TRUE, qos, NULL);
if (ebi != ESM_EBI_UNASSIGNED) {
/* Default EPS bearer contextx successfully created */
diff --git a/openair3/NAS/UE/ESM/esm_ebr_context.c b/openair3/NAS/UE/ESM/esm_ebr_context.c
index 4ce201260a..bfa4a04cc8 100644
--- a/openair3/NAS/UE/ESM/esm_ebr_context.c
+++ b/openair3/NAS/UE/ESM/esm_ebr_context.c
@@ -98,7 +98,7 @@ static int _esm_ebr_context_check_precedence(const network_tft_t *,
** **
***************************************************************************/
int esm_ebr_context_create(
- esm_data_t *esm_data,
+ esm_data_t *esm_data, int ueid,
int pid, int ebi, int is_default,
const network_qos_t *qos, const network_tft_t *tft)
{
@@ -206,7 +206,7 @@ int esm_ebr_context_create(
char *netmask = NULL;
char broadcast[INET_ADDRSTRLEN];
struct in_addr in_addr;
- char command_line[128];
+ char command_line[500];
int res;
switch (pdn->type) {
@@ -272,11 +272,17 @@ int esm_ebr_context_create(
}
res = sprintf(command_line,
- "ifconfig oip1 %s netmask %s broadcast %s",
- ipv4_addr, netmask, broadcast);
- (void)res; /* avoid gcc warning "set but not used" */
- // AssertFatal((res > 0) && (res < 128),
- // "error in system command line");
+ "ifconfig oip%d %s netmask %s broadcast %s up && "
+ "ip rule add from %s/32 table %d && "
+ "ip rule add to %s/32 table %d && "
+ "ip route add default dev oip%d table %d",
+ ueid + 1, ipv4_addr, netmask, broadcast,
+ ipv4_addr, ueid + 201,
+ ipv4_addr, ueid + 201,
+ ueid + 1, ueid + 201);
+ if ( res<0 ) {
+ LOG_TRACE(WARNING, "ESM-PROC - Failed to system command string");
+ }
LOG_TRACE(INFO, "ESM-PROC - executing %s ",
command_line);
diff --git a/openair3/NAS/UE/ESM/esm_ebr_context.h b/openair3/NAS/UE/ESM/esm_ebr_context.h
index ceb6553846..a0016555a3 100644
--- a/openair3/NAS/UE/ESM/esm_ebr_context.h
+++ b/openair3/NAS/UE/ESM/esm_ebr_context.h
@@ -66,7 +66,7 @@ typedef enum {
/****************** E X P O R T E D F U N C T I O N S ******************/
/****************************************************************************/
-int esm_ebr_context_create(esm_data_t *esm_data, int pid, int ebi, int is_default,
+int esm_ebr_context_create(esm_data_t *esm_data, int ueid, int pid, int ebi, int is_default,
const network_qos_t *qos, const network_tft_t *tft);
int esm_ebr_context_release(nas_user_t *user, int ebi, int *pid, int *bid);
diff --git a/targets/SIMU/USER/oaisim.c b/targets/SIMU/USER/oaisim.c
index 3a06a62780..864ffc720e 100644
--- a/targets/SIMU/USER/oaisim.c
+++ b/targets/SIMU/USER/oaisim.c
@@ -1886,6 +1886,9 @@ oai_shutdown (void)
for (int i = 0; i < NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX; i++)
if (oai_emulation.info.oai_ifup[i] == 1) {
char interfaceName[8];
+ char command_line[100];
+ sprintf(command_line, "while ip rule del table %d; do true; done",i+201);
+ system(command_line);
snprintf (interfaceName, sizeof(interfaceName), "oai%d", i);
bringInterfaceUp (interfaceName, 0);
}
--
GitLab