From 686e5856662de79cd11d63f25f9d57ede579d67d Mon Sep 17 00:00:00 2001
From: Laurent THOMAS <laurent.thomas@open-cells.com>
Date: Tue, 21 Sep 2021 10:30:46 +0200
Subject: [PATCH] replace protobuf in 4G F1 split, first step: UL packets

---
 cmake_targets/CMakeLists.txt                  |   2 +-
 common/utils/LOG/log.c                        |   2 +
 common/utils/LOG/log.h                        |   2 +
 common/utils/T/T_messages.txt                 |  42 ++++
 common/utils/ocp_itti/intertask_interface.cpp |  26 +-
 common/utils/system.c                         |   2 +-
 common/utils/threadPool/thread-pool.h         |   2 +-
 openair2/ENB_APP/enb_config.c                 |   3 +
 openair2/F1AP/f1ap_cu_task.c                  |   4 +-
 openair2/F1AP/f1ap_du_rrc_message_transfer.c  |   3 +-
 openair2/F1AP/f1ap_du_task.c                  |   7 +-
 openair2/F1AP/f1ap_du_ue_context_management.c | 231 ++++++++++--------
 openair2/LAYER2/PDCP_v10.1.0/pdcp.c           |  14 +-
 openair2/LAYER2/PROTO_AGENT/proto_agent.c     |   1 +
 openair2/LAYER2/rlc_v2/rlc_oai_api.c          |  14 ++
 openair2/RRC/LTE/rrc_eNB_S1AP.c               |  58 +++--
 openair2/RRC/NR/rrc_gNB.c                     |  29 +--
 openair3/ocp-gtpu/gtp_itf.cpp                 |   2 +-
 targets/COMMON/create_tasks.c                 |   3 +
 19 files changed, 281 insertions(+), 166 deletions(-)

diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt
index e3843fe2799..2bbe8db1a77 100644
--- a/cmake_targets/CMakeLists.txt
+++ b/cmake_targets/CMakeLists.txt
@@ -2830,7 +2830,7 @@ add_dependencies(lte-softmodem rrc_flag s1ap_flag x2_flag oai_iqplayer)
 
 target_link_libraries (lte-softmodem
   -Wl,--start-group
-  RRC_LIB NR_RRC_LIB S1AP_LIB S1AP_ENB F1AP_LIB F1AP M2AP_LIB M2AP_ENB X2AP_LIB X2AP_ENB M3AP_LIB M3AP_ENB GTPV1U_OCP SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT MME_APP UDP SCHED_LIB SCHED_RU_LIB
+  RRC_LIB NR_RRC_LIB S1AP_LIB S1AP_ENB M2AP_LIB M2AP_ENB X2AP_LIB X2AP_ENB M3AP_LIB M3AP_ENB GTPV1U_OCP F1AP_LIB F1AP SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT MME_APP UDP SCHED_LIB SCHED_RU_LIB
   PHY_COMMON PHY PHY_RU LFDS L2 L2_LTE NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB MISC_NFAPI_LTE_LIB LFDS7
   ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ITTI ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} ${FSPT_MSG_LIB} ${PROTO_AGENT_LIB}
   -Wl,--end-group z dl)
diff --git a/common/utils/LOG/log.c b/common/utils/LOG/log.c
index d0a53a755b2..7b913e6dc91 100644
--- a/common/utils/LOG/log.c
+++ b/common/utils/LOG/log.c
@@ -476,6 +476,8 @@ int logInit (void)
   register_log_component("NR_MAC","log",NR_MAC);
   register_log_component("NR_PHY","log",NR_PHY);
   register_log_component("NGAP","",NGAP);
+  register_log_component("ITTI","log",ITTI);
+  register_log_component("UTIL","log",UTIL);
 
   for (int i=0 ; log_level_names[i].name != NULL ; i++)
     g_log->level2string[i]           = toupper(log_level_names[i].name[0]); // uppercased first letter of level name
diff --git a/common/utils/LOG/log.h b/common/utils/LOG/log.h
index fa95d5a6fee..0acfbca9db7 100644
--- a/common/utils/LOG/log.h
+++ b/common/utils/LOG/log.h
@@ -237,6 +237,8 @@ typedef enum {
   ASN,
   NFAPI_VNF,
   NFAPI_PNF,
+  ITTI,
+  UTIL,
   MAX_LOG_PREDEF_COMPONENTS,
 }
 comp_name_t;
diff --git a/common/utils/T/T_messages.txt b/common/utils/T/T_messages.txt
index cd66be73f5a..a4f76c42adc 100644
--- a/common/utils/T/T_messages.txt
+++ b/common/utils/T/T_messages.txt
@@ -1057,6 +1057,48 @@ ID = LEGACY_NFAPI_PNF_TRACE
     DESC = NFAPI_PNF legacy logs - trace level
     GROUP = ALL:LEGACY_NFAPI_PNF:LEGACY_GROUP_TRACE:LEGACY
     FORMAT = string,log
+
+ID = LEGACY_ITTI_INFO
+    DESC = ITTI legacy logs - info level
+    GROUP = ALL:LEGACY_ITTI:LEGACY_GROUP_INFO:LEGACY
+    FORMAT = string,log
+ID = LEGACY_ITTI_ERROR
+    DESC = ITTI legacy logs - error level
+    GROUP = ALL:LEGACY_ITTI:LEGACY_GROUP_ERROR:LEGACY
+    FORMAT = string,log
+ID = LEGACY_ITTI_WARNING
+    DESC = ITTI legacy logs - warning level
+    GROUP = ALL:LEGACY_ITTI:LEGACY_GROUP_WARNING:LEGACY
+    FORMAT = string,log
+ID = LEGACY_ITTI_DEBUG
+    DESC = ITTI legacy logs - debug level
+    GROUP = ALL:LEGACY_ITTI:LEGACY_GROUP_DEBUG:LEGACY
+    FORMAT = string,log
+ID = LEGACY_ITTI_TRACE
+    DESC = ITTI legacy logs - trace level
+    GROUP = ALL:LEGACY_ITTI:LEGACY_GROUP_TRACE:LEGACY
+    FORMAT = string,log
+
+ID = LEGACY_UTIL_INFO
+    DESC = UTIL legacy logs - info level
+    GROUP = ALL:LEGACY_UTIL:LEGACY_GROUP_INFO:LEGACY
+    FORMAT = string,log
+ID = LEGACY_UTIL_ERROR
+    DESC = UTIL legacy logs - error level
+    GROUP = ALL:LEGACY_UTIL:LEGACY_GROUP_ERROR:LEGACY
+    FORMAT = string,log
+ID = LEGACY_UTIL_WARNING
+    DESC = UTIL legacy logs - warning level
+    GROUP = ALL:LEGACY_UTIL:LEGACY_GROUP_WARNING:LEGACY
+    FORMAT = string,log
+ID = LEGACY_UTIL_DEBUG
+    DESC = UTIL legacy logs - debug level
+    GROUP = ALL:LEGACY_UTIL:LEGACY_GROUP_DEBUG:LEGACY
+    FORMAT = string,log
+ID = LEGACY_UTIL_TRACE
+    DESC = UTIL legacy logs - trace level
+    GROUP = ALL:LEGACY_UTIL:LEGACY_GROUP_TRACE:LEGACY
+    FORMAT = string,log
 # this is a bad hack but I won't fix (function util_print_hex_octets
 # in openairinterface5g/openair2/LAYER2/PDCP_v10.1.0/pdcp_util.c
 # does funky things with the LOG_x macros but we work on the C pre-processor
diff --git a/common/utils/ocp_itti/intertask_interface.cpp b/common/utils/ocp_itti/intertask_interface.cpp
index 4e5323aec98..1c9b50d2f2d 100644
--- a/common/utils/ocp_itti/intertask_interface.cpp
+++ b/common/utils/ocp_itti/intertask_interface.cpp
@@ -136,12 +136,12 @@ extern "C" {
       LOG_E(TMR,"Queue for %s task contains %ld messages\n", itti_get_task_name(destination_task_id), s );
 
     if ( s > 50 )
-      LOG_I(TMR,"Queue for %s task size: %ld (last message %s)\n",itti_get_task_name(destination_task_id), s+1,ITTI_MSG_NAME(message));
+      LOG_I(ITTI,"Queue for %s task size: %ld (last message %s)\n",itti_get_task_name(destination_task_id), s+1,ITTI_MSG_NAME(message));
 
     t->message_queue.insert(t->message_queue.begin(), message);
     eventfd_t sem_counter = 1;
     AssertFatal ( sizeof(sem_counter) == write(t->sem_fd, &sem_counter, sizeof(sem_counter)), "");
-    LOG_D(TMR,"sent messages id=%d to %s\n",message_id, t->admin.name);
+    LOG_D(ITTI,"sent messages id=%d to %s\n",message_id, t->admin.name);
     return 0;
   }
 
@@ -152,7 +152,7 @@ extern "C" {
 
     while ( t->message_queue.size()>0 && t->admin.func != NULL ) {
       if (t->message_queue.size()>1)
-        LOG_W(TMR,"queue in no thread mode is %ld\n", t->message_queue.size());
+        LOG_W(ITTI,"queue in no thread mode is %ld\n", t->message_queue.size());
 
       pthread_mutex_unlock (&t->queue_cond_lock);
       t->admin.func(NULL);
@@ -208,7 +208,7 @@ extern "C" {
               message->ittiMsg.timer_has_expired.arg=it->second.timer_arg;
 
               if (itti_send_msg_to_task_locked(task_id, it->second.instance, message) < 0) {
-                LOG_W(TMR,"Failed to send msg TIMER_HAS_EXPIRED to task %u\n", task_id);
+                LOG_W(ITTI,"Failed to send msg TIMER_HAS_EXPIRED to task %u\n", task_id);
                 free(message);
                 t->timer_map.erase(it);
                 return -1;
@@ -233,7 +233,7 @@ extern "C" {
         epoll_timeout = t->next_timer-current_time;
 
       pthread_mutex_unlock(&t->queue_cond_lock);
-      LOG_D(TMR,"enter blocking wait for %s\n", itti_get_task_name(task_id));
+      LOG_D(ITTI,"enter blocking wait for %s, timeout: %d ms\n", itti_get_task_name(task_id),  epoll_timeout);
       t->nb_events = epoll_wait(t->epoll_fd,t->events,t->nb_fd_epoll, epoll_timeout);
 
       if ( t->nb_events  < 0 && (errno == EINTR || errno == EAGAIN ) )
@@ -243,7 +243,7 @@ extern "C" {
     AssertFatal (t->nb_events >=0,
                  "epoll_wait failed for task %s, nb fds %d, timeout %lu: %s!\n",
                  itti_get_task_name(task_id), t->nb_fd_epoll, t->next_timer != UINT64_MAX ? t->next_timer-current_time : -1, strerror(errno));
-    LOG_D(TMR,"receive on %d descriptors for %s\n", t->nb_events, itti_get_task_name(task_id));
+    LOG_D(ITTI,"receive on %d descriptors for %s\n", t->nb_events, itti_get_task_name(task_id));
 
     if (t->nb_events == 0)
       /* No data to read -> return */
@@ -292,11 +292,11 @@ extern "C" {
     // in this case, *received_msg is NULL
     if (t->message_queue.empty()) {
       *received_msg=NULL;
-      LOG_D(TMR,"task %s received even from other fd (total fds: %d), returning msg NULL\n",t->admin.name, t->nb_fd_epoll);
+      LOG_D(ITTI,"task %s received even from other fd (total fds: %d), returning msg NULL\n",t->admin.name, t->nb_fd_epoll);
     } else {
       *received_msg=t->message_queue.back();
       t->message_queue.pop_back();
-      LOG_D(TMR,"task %s received a message\n",t->admin.name);
+      LOG_D(ITTI,"task %s received a message\n",t->admin.name);
     }
 
     pthread_mutex_unlock (&t->queue_cond_lock);
@@ -308,7 +308,7 @@ extern "C" {
     pthread_mutex_lock(&t->queue_cond_lock);
 
     if (!t->message_queue.empty()) {
-      LOG_D(TMR,"task %s received a message in polling mode\n",t->admin.name);
+      LOG_D(ITTI,"task %s received a message in polling mode\n",t->admin.name);
       *received_msg=t->message_queue.back();
       t->message_queue.pop_back();
     } else
@@ -322,7 +322,7 @@ extern "C" {
                        void *args_p) {
     task_list_t *t=tasks[task_id];
     threadCreate (&t->thread, start_routine, args_p, (char *)itti_get_task_name(task_id),-1,OAI_PRIORITY_RT);
-    LOG_I(TMR,"Created Posix thread %s\n",  itti_get_task_name(task_id) );
+    LOG_I(ITTI,"Created Posix thread %s\n",  itti_get_task_name(task_id) );
     return 0;
   }
 
@@ -344,7 +344,7 @@ extern "C" {
     tasks = new_tasks;
     tasks[newQueue]= new task_list_t;
     pthread_mutex_unlock (&lock_nb_queues);
-    LOG_I(TMR,"Starting itti queue: %s as task %d\n", taskInfo->name, newQueue);
+    LOG_I(ITTI,"Starting itti queue: %s as task %d\n", taskInfo->name, newQueue);
     pthread_mutex_init(&tasks[newQueue]->queue_cond_lock, NULL);
     memcpy(&tasks[newQueue]->admin, taskInfo, sizeof(task_info_t));
     AssertFatal( ( tasks[newQueue]->epoll_fd = epoll_create1(0) ) >=0, "");
@@ -392,7 +392,7 @@ extern "C" {
     clock_gettime(CLOCK_MONOTONIC, &tp);
 
     if (interval_us%1000 != 0)
-      LOG_W(TMR, "Can't set timer precision below 1ms, rounding it\n");
+      LOG_W(ITTI, "Can't set timer precision below 1ms, rounding it\n");
 
     timer.duration  = interval_sec*1000+interval_us/1000;
     timer.timeout= ((uint64_t)tp.tv_sec*1000+tp.tv_nsec/(1000*1000)+timer.duration);
@@ -421,7 +421,7 @@ extern "C" {
     if (ret==1)
       return 0;
     else {
-      LOG_W(TMR, "tried to remove a non existing timer\n");
+      LOG_W(ITTI, "tried to remove a non existing timer\n");
       return 1;
     }
   }
diff --git a/common/utils/system.c b/common/utils/system.c
index 4eb8c8cb197..72b0c71a21a 100644
--- a/common/utils/system.c
+++ b/common/utils/system.c
@@ -236,7 +236,7 @@ void threadCreate(pthread_t* t, void * (*func)(void*), void * param, char* name,
     ret=pthread_attr_setschedpolicy(&attr, SCHED_OAI);
     AssertFatal(ret==0,"ret: %d, errno: %d\n",ret, errno);
     if(priority<sched_get_priority_min(SCHED_OAI) || priority>sched_get_priority_max(SCHED_OAI)) {
-      LOG_E(TMR,"Prio not possible: %d, min is %d, max: %d, forced in the range\n",
+      LOG_E(UTIL,"Prio not possible: %d, min is %d, max: %d, forced in the range\n",
 	    priority,
 	    sched_get_priority_min(SCHED_OAI),
 	    sched_get_priority_max(SCHED_OAI));
diff --git a/common/utils/threadPool/thread-pool.h b/common/utils/threadPool/thread-pool.h
index a32b7c38595..b5e446119ea 100644
--- a/common/utils/threadPool/thread-pool.h
+++ b/common/utils/threadPool/thread-pool.h
@@ -141,7 +141,7 @@ static inline  notifiedFIFO_elt_t *pullNotifiedFIFO_nothreadSafe(notifiedFIFO_t
   notifiedFIFO_elt_t *ret=nf->outF;
 
   if (nf->outF==nf->outF->next)
-    LOG_E(TMR,"Circular list in thread pool: push several times the same buffer is forbidden\n");
+    LOG_E(UTIL,"Circular list in thread pool: push several times the same buffer is forbidden\n");
 
   nf->outF=nf->outF->next;
 
diff --git a/openair2/ENB_APP/enb_config.c b/openair2/ENB_APP/enb_config.c
index 7dc5fb37e50..7b82ec31a12 100644
--- a/openair2/ENB_APP/enb_config.c
+++ b/openair2/ENB_APP/enb_config.c
@@ -1970,8 +1970,11 @@ int RCconfig_DU_F1(MessageDef *msg_p, uint32_t i) {
         LOG_I(ENB_APP,"FIAP: DU_ip4_address in DU %p, strlen %d\n",F1AP_SETUP_REQ (msg_p).DU_f1_ip_address.ipv4_address,(int)strlen(RC.mac[k]->eth_params_n.my_addr));
         F1AP_SETUP_REQ (msg_p).DU_f1_ip_address.ipv6 = 0;
         F1AP_SETUP_REQ (msg_p).DU_f1_ip_address.ipv4 = 1;
+	
         //strcpy(F1AP_SETUP_REQ (msg_p).DU_f1_ip_address.ipv6_address, "");
         strcpy(F1AP_SETUP_REQ (msg_p).DU_f1_ip_address.ipv4_address, RC.mac[k]->eth_params_n.my_addr);
+	F1AP_SETUP_REQ (msg_p).DUport= RC.mac[k]->eth_params_n.my_portd;
+	F1AP_SETUP_REQ (msg_p).CUport= RC.mac[k]->eth_params_n.remote_portd;
         //strcpy(F1AP_SETUP_REQ (msg_p).CU_ip_address[l].ipv6_address,*(F1ParamList.paramarray[l][ENB_CU_IPV6_ADDRESS_IDX].strptr));
         //F1AP_SETUP_REQ (msg_p).CU_port = RC.mac[k]->eth_params_n.remote_portc; // maybe we dont need it
         sprintf(aprefix,"%s.[%i].%s",ENB_CONFIG_STRING_ENB_LIST,k,ENB_CONFIG_STRING_SCTP_CONFIG);
diff --git a/openair2/F1AP/f1ap_cu_task.c b/openair2/F1AP/f1ap_cu_task.c
index 30b15fedadf..fbe0508f600 100644
--- a/openair2/F1AP/f1ap_cu_task.c
+++ b/openair2/F1AP/f1ap_cu_task.c
@@ -45,8 +45,8 @@ static instance_t cu_task_create_gtpu_instance_to_du(eth_params_t *IPaddrs) {
   openAddr_t tmp={0};
   strncpy(tmp.originHost, IPaddrs->my_addr, sizeof(tmp.originHost)-1);
   strncpy(tmp.destinationHost, IPaddrs->remote_addr, sizeof(tmp.destinationHost)-1);
-  sprintf(tmp.originService, "%d", GTPV1U_UDP_PORT);
-  sprintf(tmp.destinationService, "%d", GTPV1U_UDP_PORT);
+  sprintf(tmp.originService, "%d",  IPaddrs->my_portd);
+  sprintf(tmp.destinationService, "%d",  IPaddrs->remote_portd);
   return ocp_gtpv1Init(tmp);
 }
 
diff --git a/openair2/F1AP/f1ap_du_rrc_message_transfer.c b/openair2/F1AP/f1ap_du_rrc_message_transfer.c
index ebdeabb6ce4..adfbff2823f 100644
--- a/openair2/F1AP/f1ap_du_rrc_message_transfer.c
+++ b/openair2/F1AP/f1ap_du_rrc_message_transfer.c
@@ -744,7 +744,6 @@ int DU_send_UL_RRC_MESSAGE_TRANSFER(instance_t instance,
   return 0;
 }
 
-
 /*  UL RRC Message Transfer */
 int DU_send_INITIAL_UL_RRC_MESSAGE_TRANSFER(instance_t     instanceP,
     int             CC_idP,
@@ -764,7 +763,7 @@ int DU_send_INITIAL_UL_RRC_MESSAGE_TRANSFER(instance_t     instanceP,
     LOG_E(F1AP, "Failed to add UE \n");
     return -1;
   }
-
+  
   /* Create */
   /* 0. Message Type */
   pdu.present = F1AP_F1AP_PDU_PR_initiatingMessage;
diff --git a/openair2/F1AP/f1ap_du_task.c b/openair2/F1AP/f1ap_du_task.c
index a6ff3d3211f..6c5094d248b 100644
--- a/openair2/F1AP/f1ap_du_task.c
+++ b/openair2/F1AP/f1ap_du_task.c
@@ -96,10 +96,12 @@ void du_task_handle_sctp_association_resp(instance_t instance, sctp_new_associat
       .remote_ipv4_address = tmp->remote_addr,
       .remote_port         = tmp->remote_portd
     };
-    
+
+  /*
   if (!RC.nrrrc)
     AssertFatal(proto_agent_start(instance, &params) == 0,
               "could not start PROTO_AGENT for F1U on instance %ld!\n", instance);
+  */
   DU_send_F1_SETUP_REQUEST(instance);
 }
 
@@ -149,7 +151,8 @@ void *F1AP_DU_task(void *arg) {
 	AssertFatal(getCxt(DUtype, myInstance)->gtpInst>0,"Failed to create CU F1-U UDP listener");
 	// Fixme: fully inconsistent instances management
 	// dirty global var is a bad fix
-	DUuniqInstance=getCxt(DUtype, myInstance)->gtpInst;
+	extern instance_t legacyInstanceMapping;
+	legacyInstanceMapping =	DUuniqInstance = getCxt(DUtype, myInstance)->gtpInst;
         du_task_send_sctp_association_req(myInstance,msgSetup);
         break;
 
diff --git a/openair2/F1AP/f1ap_du_ue_context_management.c b/openair2/F1AP/f1ap_du_ue_context_management.c
index 05ccc3815b0..33a40bd8ac5 100644
--- a/openair2/F1AP/f1ap_du_ue_context_management.c
+++ b/openair2/F1AP/f1ap_du_ue_context_management.c
@@ -42,6 +42,22 @@
 #include "openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h"
 #include <openair3/ocp-gtpu/gtp_itf.h>
 
+boolean_t lteDURecvCb( protocol_ctxt_t  *ctxt_pP,
+                    const srb_flag_t     srb_flagP,
+                    const rb_id_t        rb_idP,
+                    const mui_t          muiP,
+                    const confirm_t      confirmP,
+                    const sdu_size_t     sdu_buffer_sizeP,
+                    unsigned char *const sdu_buffer_pP,
+                    const pdcp_transmission_mode_t modeP,
+                    const uint32_t *sourceL2Id,
+                    const uint32_t *destinationL2Id) {
+  // The buffer comes from the stack in gtp-u thread, we have a make a separate buffer to enqueue in a inter-thread message queue
+  mem_block_t *sdu=get_free_mem_block(sdu_buffer_sizeP, __func__);
+  memcpy(sdu->data,  sdu_buffer_pP,  sdu_buffer_sizeP);
+  du_rlc_data_req(ctxt_pP,srb_flagP, false,  rb_idP,muiP, confirmP,  sdu_buffer_sizeP, sdu);
+  return true;
+}
 
 int DU_handle_UE_CONTEXT_SETUP_REQUEST(instance_t       instance,
                                        uint32_t         assoc_id,
@@ -111,75 +127,75 @@ int DU_handle_UE_CONTEXT_SETUP_REQUEST(instance_t       instance,
     f1ap_ue_context_setup_req->cellULConfigured = NULL;
   }
 
-  if (RC.nrrrc) {
-    /* RRCContainer */
-    F1AP_UEContextSetupRequestIEs_t *ieDrb;
-    F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextSetupRequestIEs_t, ieDrb, container,
-                               F1AP_ProtocolIE_ID_id_DRBs_ToBeSetup_List, true);
-
-    if(ieDrb!=NULL) {
-      f1ap_ue_context_setup_req->drbs_to_be_setup_length = ieDrb->value.choice.DRBs_ToBeSetup_List.list.count;
-      f1ap_ue_context_setup_req->drbs_to_be_setup = calloc(f1ap_ue_context_setup_req->drbs_to_be_setup_length,
-          sizeof(f1ap_drb_to_be_setup_t));
-      AssertFatal(f1ap_ue_context_setup_req->drbs_to_be_setup,
-                  "could not allocate memory for f1ap_ue_context_setup_req->drbs_to_be_setup\n");
-
-      for (i = 0; i < f1ap_ue_context_setup_req->drbs_to_be_setup_length; ++i) {
-        f1ap_drb_to_be_setup_t *drb_p = &f1ap_ue_context_setup_req->drbs_to_be_setup[i];
-        F1AP_DRBs_ToBeSetup_Item_t *drbs_tobesetup_item_p =
-          &((F1AP_DRBs_ToBeSetup_ItemIEs_t *)ieDrb->value.choice.DRBs_ToBeSetup_List.list.array[i])->value.choice.DRBs_ToBeSetup_Item;
-        drb_p->drb_id = drbs_tobesetup_item_p->dRBID;
-        /* TODO in the following, assume only one UP UL TNL is present.
-        * this matches/assumes OAI CU implementation, can be up to 2! */
-        drb_p->up_ul_tnl_length = 1;
-        AssertFatal(drbs_tobesetup_item_p->uLUPTNLInformation_ToBeSetup_List.list.count > 0,
-                    "no UL UP TNL Information in DRBs to be Setup list\n");
-        F1AP_ULUPTNLInformation_ToBeSetup_Item_t *ul_up_tnl_info_p = (F1AP_ULUPTNLInformation_ToBeSetup_Item_t *)drbs_tobesetup_item_p->uLUPTNLInformation_ToBeSetup_List.list.array[0];
-        F1AP_GTPTunnel_t *ul_up_tnl0 = ul_up_tnl_info_p->uLUPTNLInformation.choice.gTPTunnel;
-        BIT_STRING_TO_TRANSPORT_LAYER_ADDRESS_IPv4(&ul_up_tnl0->transportLayerAddress, drb_p->up_ul_tnl[0].tl_address);
-        OCTET_STRING_TO_INT32(&ul_up_tnl0->gTP_TEID, drb_p->up_ul_tnl[0].teid);
-
-        switch (drbs_tobesetup_item_p->rLCMode) {
-          case F1AP_RLCMode_rlc_am:
-            drb_p->rlc_mode = RLC_MODE_AM;
-            break;
-
-          default:
-            drb_p->rlc_mode = RLC_MODE_TM;
-            break;
-        }
-
-        /*transport_layer_addr_t addr;
+  /* DRB */
+  F1AP_UEContextSetupRequestIEs_t *ieDrb;
+  F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextSetupRequestIEs_t, ieDrb, container,
+			     F1AP_ProtocolIE_ID_id_DRBs_ToBeSetup_List, true);
+  
+  if(ieDrb!=NULL) {
+    f1ap_ue_context_setup_req->drbs_to_be_setup_length = ieDrb->value.choice.DRBs_ToBeSetup_List.list.count;
+    f1ap_ue_context_setup_req->drbs_to_be_setup = calloc(f1ap_ue_context_setup_req->drbs_to_be_setup_length,
+							 sizeof(f1ap_drb_to_be_setup_t));
+    AssertFatal(f1ap_ue_context_setup_req->drbs_to_be_setup,
+		"could not allocate memory for f1ap_ue_context_setup_req->drbs_to_be_setup\n");
+    
+    for (i = 0; i < f1ap_ue_context_setup_req->drbs_to_be_setup_length; ++i) {
+      f1ap_drb_to_be_setup_t *drb_p = &f1ap_ue_context_setup_req->drbs_to_be_setup[i];
+      F1AP_DRBs_ToBeSetup_Item_t *drbs_tobesetup_item_p =
+	&((F1AP_DRBs_ToBeSetup_ItemIEs_t *)ieDrb->value.choice.DRBs_ToBeSetup_List.list.array[i])->value.choice.DRBs_ToBeSetup_Item;
+      drb_p->drb_id = drbs_tobesetup_item_p->dRBID;
+      /* TODO in the following, assume only one UP UL TNL is present.
+       * this matches/assumes OAI CU implementation, can be up to 2! */
+      drb_p->up_ul_tnl_length = 1;
+      AssertFatal(drbs_tobesetup_item_p->uLUPTNLInformation_ToBeSetup_List.list.count > 0,
+		  "no UL UP TNL Information in DRBs to be Setup list\n");
+      F1AP_ULUPTNLInformation_ToBeSetup_Item_t *ul_up_tnl_info_p = (F1AP_ULUPTNLInformation_ToBeSetup_Item_t *)drbs_tobesetup_item_p->uLUPTNLInformation_ToBeSetup_List.list.array[0];
+      F1AP_GTPTunnel_t *ul_up_tnl0 = ul_up_tnl_info_p->uLUPTNLInformation.choice.gTPTunnel;
+      BIT_STRING_TO_TRANSPORT_LAYER_ADDRESS_IPv4(&ul_up_tnl0->transportLayerAddress, drb_p->up_ul_tnl[0].tl_address);
+      OCTET_STRING_TO_INT32(&ul_up_tnl0->gTP_TEID, drb_p->up_ul_tnl[0].teid);
+      
+      switch (drbs_tobesetup_item_p->rLCMode) {
+      case F1AP_RLCMode_rlc_am:
+	drb_p->rlc_mode = RLC_MODE_AM;
+	break;
+	
+      default:
+	drb_p->rlc_mode = RLC_MODE_TM;
+	break;
+      }
+      if (!(RC.nrrrc && RC.nrrrc[instance]->node_type == ngran_gNB_DU)) {
+	transport_layer_addr_t addr;
         memcpy(addr.buffer, &drb_p->up_ul_tnl[0].tl_address, sizeof(drb_p->up_ul_tnl[0].tl_address));
         addr.length=sizeof(drb_p->up_ul_tnl[0].tl_address)*8;
         drb_p->up_dl_tnl[0].teid=newGtpuCreateTunnel(INSTANCE_DEFAULT,
-                                 f1ap_ue_context_setup_req->rnti,
-                                 drb_p->drb_id,
-                                 drb_p->drb_id,
-                                 drb_p->up_ul_tnl[0].teid,
-                                 addr,
-                                 2152,
-                                 DURecvCb);*/
+						     f1ap_ue_context_setup_req->rnti,
+						     drb_p->drb_id,
+						     drb_p->drb_id,
+						     drb_p->up_ul_tnl[0].teid,
+						     addr,
+						     2152,
+						     lteDURecvCb);
       }
     }
+  }
 
-    F1AP_UEContextSetupRequestIEs_t *ieSrb;
-    F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextSetupRequestIEs_t, ieSrb, container,
-                               F1AP_ProtocolIE_ID_id_SRBs_ToBeSetup_List, true);
-
-    if(ieSrb != NULL) {
-      f1ap_ue_context_setup_req->srbs_to_be_setup_length = ieSrb->value.choice.SRBs_ToBeSetup_List.list.count;
-      f1ap_ue_context_setup_req->srbs_to_be_setup = calloc(f1ap_ue_context_setup_req->srbs_to_be_setup_length,
-          sizeof(f1ap_srb_to_be_setup_t));
-      AssertFatal(f1ap_ue_context_setup_req->srbs_to_be_setup,
-                  "could not allocate memory for f1ap_ue_context_setup_req->srbs_to_be_setup\n");
-
-      for (i = 0; i < f1ap_ue_context_setup_req->srbs_to_be_setup_length; ++i) {
-        f1ap_srb_to_be_setup_t *srb_p = &f1ap_ue_context_setup_req->srbs_to_be_setup[i];
-        F1AP_SRBs_ToBeSetup_Item_t *srbs_tobesetup_item_p;
-        srbs_tobesetup_item_p = &((F1AP_SRBs_ToBeSetup_ItemIEs_t *)ieSrb->value.choice.SRBs_ToBeSetup_List.list.array[i])->value.choice.SRBs_ToBeSetup_Item;
-        srb_p->srb_id = srbs_tobesetup_item_p->sRBID;
-      }
+  /* SRB */
+  F1AP_UEContextSetupRequestIEs_t *ieSrb;
+  F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextSetupRequestIEs_t, ieSrb, container,
+			     F1AP_ProtocolIE_ID_id_SRBs_ToBeSetup_List, true);
+  
+  if(ieSrb != NULL) {
+    f1ap_ue_context_setup_req->srbs_to_be_setup_length = ieSrb->value.choice.SRBs_ToBeSetup_List.list.count;
+    f1ap_ue_context_setup_req->srbs_to_be_setup = calloc(f1ap_ue_context_setup_req->srbs_to_be_setup_length,
+							 sizeof(f1ap_srb_to_be_setup_t));
+    AssertFatal(f1ap_ue_context_setup_req->srbs_to_be_setup,
+		"could not allocate memory for f1ap_ue_context_setup_req->srbs_to_be_setup\n");
+    
+    for (i = 0; i < f1ap_ue_context_setup_req->srbs_to_be_setup_length; ++i) {
+      f1ap_srb_to_be_setup_t *srb_p = &f1ap_ue_context_setup_req->srbs_to_be_setup[i];
+      F1AP_SRBs_ToBeSetup_Item_t *srbs_tobesetup_item_p;
+      srbs_tobesetup_item_p = &((F1AP_SRBs_ToBeSetup_ItemIEs_t *)ieSrb->value.choice.SRBs_ToBeSetup_List.list.array[i])->value.choice.SRBs_ToBeSetup_Item;
+      srb_p->srb_id = srbs_tobesetup_item_p->sRBID;
     }
   }
 
@@ -214,7 +230,8 @@ int DU_handle_UE_CONTEXT_SETUP_REQUEST(instance_t       instance,
   }
 
   //DU_send_UE_CONTEXT_SETUP_RESPONSE(instance,  f1ap_ue_context_setup_req);
-  itti_send_msg_to_task(TASK_RRC_GNB, instance, msg_p);
+  if (RC.nrrrc && RC.nrrrc[instance]->node_type == ngran_gNB_DU) 
+    itti_send_msg_to_task(TASK_RRC_GNB, instance, msg_p);
   return 0;
 }
 
@@ -658,9 +675,10 @@ int DU_handle_UE_CONTEXT_RELEASE_COMMAND(instance_t       instance,
   AssertFatal(ctxt.rnti == rnti,
               "RNTI obtained through DU ID (%x) is different from CU ID (%x)\n",
               rnti, ctxt.rnti);
+
   int UE_out_of_sync = 0;
 
-  if (RC.nrrrc[instance]->node_type == ngran_gNB_DU) {
+  if (RC.nrrrc && RC.nrrrc[instance]->node_type == ngran_gNB_DU) {
     for (int n = 0; n < MAX_MOBILES_PER_GNB; ++n) {
       if (RC.nrmac[instance]->UE_info.active[n] == TRUE
           && rnti == RC.nrmac[instance]->UE_info.rnti[n]) {
@@ -724,55 +742,56 @@ int DU_handle_UE_CONTEXT_RELEASE_COMMAND(instance_t       instance,
     }
   }
 
-  if (RC.nrrrc[instance]->node_type == ngran_gNB_DU) {
+  if (RC.nrrrc && RC.nrrrc[instance]->node_type == ngran_gNB_DU) {
     // struct rrc_gNB_ue_context_s *ue_context_p;
     f1ap_ue_context_release_cplt_t cplt;
     cplt.rnti = ctxt.rnti;
     DU_send_UE_CONTEXT_RELEASE_COMPLETE(instance, &cplt);
     return 0;
-  }
-
-  struct rrc_eNB_ue_context_s *ue_context_p;
-
-  ue_context_p = rrc_eNB_get_ue_context(RC.rrc[ctxt.instance], ctxt.rnti);
-
-  if (ue_context_p && !UE_out_of_sync) {
-    /* UE exists and is in sync so we start a timer before releasing the
-     * connection */
-    pthread_mutex_lock(&rrc_release_freelist);
-
-    for (uint16_t release_num = 0; release_num < NUMBER_OF_UE_MAX; release_num++) {
-      if (rrc_release_info.RRC_release_ctrl[release_num].flag == 0) {
-        if (ue_context_p->ue_context.ue_release_timer_s1 > 0)
-          rrc_release_info.RRC_release_ctrl[release_num].flag = 1;
-        else
-          rrc_release_info.RRC_release_ctrl[release_num].flag = 2;
-
-        rrc_release_info.RRC_release_ctrl[release_num].rnti = ctxt.rnti;
-        LOG_D(F1AP, "add rrc_release_info RNTI %x\n", ctxt.rnti);
-        // TODO: how to provide the correct MUI?
-        rrc_release_info.RRC_release_ctrl[release_num].rrc_eNB_mui = 0;
-        rrc_release_info.num_UEs++;
-        LOG_D(RRC,"Generate DLSCH Release send: index %d rnti %x mui %d flag %d \n",release_num,
-              ctxt.rnti, 0, rrc_release_info.RRC_release_ctrl[release_num].flag);
-        break;
+  } else {
+    
+    struct rrc_eNB_ue_context_s *ue_context_p;
+    
+    ue_context_p = rrc_eNB_get_ue_context(RC.rrc[ctxt.instance], ctxt.rnti);
+    
+    if (ue_context_p && !UE_out_of_sync) {
+      /* UE exists and is in sync so we start a timer before releasing the
+       * connection */
+      pthread_mutex_lock(&rrc_release_freelist);
+      
+      for (uint16_t release_num = 0; release_num < NUMBER_OF_UE_MAX; release_num++) {
+	if (rrc_release_info.RRC_release_ctrl[release_num].flag == 0) {
+	  if (ue_context_p->ue_context.ue_release_timer_s1 > 0)
+	    rrc_release_info.RRC_release_ctrl[release_num].flag = 1;
+	  else
+	    rrc_release_info.RRC_release_ctrl[release_num].flag = 2;
+	  
+	  rrc_release_info.RRC_release_ctrl[release_num].rnti = ctxt.rnti;
+	  LOG_D(F1AP, "add rrc_release_info RNTI %x\n", ctxt.rnti);
+	  // TODO: how to provide the correct MUI?
+	  rrc_release_info.RRC_release_ctrl[release_num].rrc_eNB_mui = 0;
+	  rrc_release_info.num_UEs++;
+	  LOG_D(RRC,"Generate DLSCH Release send: index %d rnti %x mui %d flag %d \n",release_num,
+		ctxt.rnti, 0, rrc_release_info.RRC_release_ctrl[release_num].flag);
+	  break;
+	}
       }
+      
+      pthread_mutex_unlock(&rrc_release_freelist);
+      ue_context_p->ue_context.ue_release_timer_s1 = 0;
+    } else if (ue_context_p && UE_out_of_sync) {
+      /* UE exists and is out of sync, drop the connection */
+      mac_eNB_rrc_ul_failure(instance, 0, 0, 0, rnti);
+    } else {
+      LOG_E(F1AP, "no ue_context for RNTI %x, acknowledging release\n", rnti);
     }
-
-    pthread_mutex_unlock(&rrc_release_freelist);
-    ue_context_p->ue_context.ue_release_timer_s1 = 0;
-  } else if (ue_context_p && UE_out_of_sync) {
-    /* UE exists and is out of sync, drop the connection */
-    mac_eNB_rrc_ul_failure(instance, 0, 0, 0, rnti);
-  } else {
-    LOG_E(F1AP, "no ue_context for RNTI %x, acknowledging release\n", rnti);
+    
+    /* TODO send this once the connection has really been released */
+    f1ap_ue_context_release_cplt_t cplt;
+    cplt.rnti = ctxt.rnti;
+    DU_send_UE_CONTEXT_RELEASE_COMPLETE(instance, &cplt);
+    return 0;
   }
-
-  /* TODO send this once the connection has really been released */
-  f1ap_ue_context_release_cplt_t cplt;
-  cplt.rnti = ctxt.rnti;
-  DU_send_UE_CONTEXT_RELEASE_COMPLETE(instance, &cplt);
-  return 0;
 }
 int DU_send_UE_CONTEXT_RELEASE_COMPLETE(instance_t instance,
                                         f1ap_ue_context_release_cplt_t *cplt) {
diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c
index 090cf9531b1..9a57c6f269d 100644
--- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c
+++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c
@@ -154,7 +154,19 @@ boolean_t cu_f1u_data_req(
   const uint32_t *const destinationL2Id
   )
 {
-  return true;
+  mem_block_t *memblock = get_free_mem_block(sdu_buffer_size, __func__);
+  if (memblock == NULL) {
+    LOG_E(RLC, "%s:%d:%s: ERROR: get_free_mem_block failed\n", __FILE__, __LINE__, __FUNCTION__);
+    exit(1);
+  }
+  memcpy(memblock->data,sdu_buffer, sdu_buffer_size);
+  // These -4 are boring
+  int ret=pdcp_data_ind(ctxt_pP,srb_flagP, false, rb_id-4, sdu_buffer_size, memblock);
+  if (!ret) {
+    LOG_E(RLC, "%s:%d:%s: ERROR: pdcp_data_ind failed\n", __FILE__, __LINE__, __FUNCTION__);
+    /* what to do in case of failure? for the moment: nothing */
+  }
+  return ret;
 }
 void *pdcp_stats_thread(void *param) {
 
diff --git a/openair2/LAYER2/PROTO_AGENT/proto_agent.c b/openair2/LAYER2/PROTO_AGENT/proto_agent.c
index 6bf9cdce229..b7844d9b8db 100644
--- a/openair2/LAYER2/PROTO_AGENT/proto_agent.c
+++ b/openair2/LAYER2/PROTO_AGENT/proto_agent.c
@@ -192,6 +192,7 @@ error:
 
 
 boolean_t
+
 proto_agent_send_pdcp_data_ind(const protocol_ctxt_t *const ctxt_pP, const srb_flag_t srb_flagP,
                                const MBMS_flag_t MBMS_flagP, const rb_id_t rb_idP, sdu_size_t sdu_sizeP, mem_block_t *sdu_pP) {
   uint8_t *msg = NULL;
diff --git a/openair2/LAYER2/rlc_v2/rlc_oai_api.c b/openair2/LAYER2/rlc_v2/rlc_oai_api.c
index 24e36ec03d8..b31393d67f8 100644
--- a/openair2/LAYER2/rlc_v2/rlc_oai_api.c
+++ b/openair2/LAYER2/rlc_v2/rlc_oai_api.c
@@ -427,6 +427,20 @@ rb_found:
       F1AP_UL_RRC_MESSAGE(msg).rrc_container_length = size;
       itti_send_msg_to_task(TASK_DU_F1, ENB_MODULE_ID_TO_INSTANCE(0 /*ctxt_pP->module_id*/), msg);
       return;
+    }  else {
+      // Fixme: very dirty workaround of incomplete F1-U implementation
+      instance_t DUuniqInstance=0;
+      MessageDef *msg = itti_alloc_new_message(TASK_RLC_ENB, 0, GTPV1U_ENB_TUNNEL_DATA_REQ);
+      gtpv1u_enb_tunnel_data_req_t *req=&GTPV1U_ENB_TUNNEL_DATA_REQ(msg);
+      req->buffer=malloc(size);
+      memcpy(req->buffer,buf,size);
+      req->length=size;
+      req->offset=0;
+      req->rnti=ue->rnti;
+      req->rab_id=rb_id+4;
+      LOG_D(RLC, "Received uplink user-plane traffic at RLC-DU to be sent to the CU, size %d \n", size);
+      itti_send_msg_to_task(OCP_GTPV1_U, DUuniqInstance, msg);      
+      return;
     }
   }
   
diff --git a/openair2/RRC/LTE/rrc_eNB_S1AP.c b/openair2/RRC/LTE/rrc_eNB_S1AP.c
index 1cb575d1ddb..4a472c88410 100644
--- a/openair2/RRC/LTE/rrc_eNB_S1AP.c
+++ b/openair2/RRC/LTE/rrc_eNB_S1AP.c
@@ -1078,29 +1078,43 @@ int rrc_eNB_process_S1AP_INITIAL_CONTEXT_SETUP_REQ(MessageDef *msg_p, const char
       rrc_eNB_send_S1AP_INITIAL_CONTEXT_SETUP_RESP(&ctxt,ue_context_p);
     }
 
-    /*
-        if ((RC.rrc[ctxt.module_id]->node_type == ngran_eNB_CU) ||
-            (RC.rrc[ctxt.module_id]->node_type == ngran_ng_eNB_CU) ||
-            (RC.rrc[ctxt.module_id]->node_type == ngran_gNB_CU) ){
-
-          message_p = itti_alloc_new_message (TASK_RRC_ENB, 0, F1AP_UE_CONTEXT_SETUP_REQ);
-          F1AP_UE_CONTEXT_SETUP_REQ (message_p).rrc_container =  ue_p->Srb0.Tx_buffer.Payload;
-
-          F1AP_UE_CONTEXT_SETUP_REQ (message_p).rrc_container_length = ue_p->Srb0.Tx_buffer.payload_size;
-          F1AP_UE_CONTEXT_SETUP_REQ (message_p).gNB_CU_ue_id     = 0;
-          F1AP_UE_CONTEXT_SETUP_REQ (message_p).gNB_DU_ue_id = 0;
-          F1AP_UE_CONTEXT_SETUP_REQ (message_p).old_gNB_DU_ue_id  = 0xFFFFFFFF; // unknown
-          F1AP_UE_CONTEXT_SETUP_REQ (message_p).rnti = ue_p->rnti;
-          F1AP_UE_CONTEXT_SETUP_REQ (message_p).srb_id = CCCH;
-          F1AP_UE_CONTEXT_SETUP_REQ (message_p).execute_duplication      = 1;
-          F1AP_UE_CONTEXT_SETUP_REQ (message_p).RAT_frequency_priority_information.en_dc      = 0;
-          itti_send_msg_to_task (TASK_CU_F1, ctxt_pP->module_id, message_p);
-          LOG_D(RRC, "Send F1AP_UE_CONTEXT_SETUP_REQ with ITTI\n");
-
-        }
-    */
-    return (0);
+    
+    if ((RC.rrc[ctxt.module_id]->node_type == ngran_eNB_CU) ||
+	(RC.rrc[ctxt.module_id]->node_type == ngran_ng_eNB_CU) ||
+	(RC.rrc[ctxt.module_id]->node_type == ngran_gNB_CU) ){
+      struct eNB_RRC_INST_s *rrc= RC.rrc[0];
+      MessageDef *message_p = itti_alloc_new_message (TASK_RRC_ENB, 0, F1AP_UE_CONTEXT_SETUP_REQ);
+      f1ap_ue_context_setup_t *req=&F1AP_UE_CONTEXT_SETUP_REQ (message_p);
+      req->gNB_CU_ue_id     = 0;
+      req->gNB_DU_ue_id = 0;
+      req->rnti = ue_context_p->ue_context.rnti;
+      req->mcc  = rrc->configuration.mcc[0];
+      req->mnc  = rrc->configuration.mnc[0];
+      req->mnc_digit_length = rrc->configuration.mnc_digit_length[0];
+      req->nr_cellid        = rrc->nr_cellid;
+      req->srbs_to_be_setup = malloc(sizeof(f1ap_srb_to_be_setup_t));
+      req->srbs_to_be_setup_length = 1;
+      f1ap_srb_to_be_setup_t *SRBs=req->srbs_to_be_setup;
+      SRBs[0].srb_id=CCCH;
+      req->drbs_to_be_setup_length = S1AP_INITIAL_CONTEXT_SETUP_REQ (msg_p).nb_of_e_rabs;
+      req->drbs_to_be_setup = malloc(req->drbs_to_be_setup_length * sizeof(f1ap_drb_to_be_setup_t));
+      f1ap_drb_to_be_setup_t *DRBs=req->drbs_to_be_setup;
+      for (int i = 0; i < req->drbs_to_be_setup_length ; i++) {
+	DRBs[i].drb_id=S1AP_INITIAL_CONTEXT_SETUP_REQ (msg_p).e_rab_param[i].e_rab_id;
+	DRBs[i].rlc_mode = RLC_MODE_AM;
+	DRBs[i].up_ul_tnl[0].tl_address = inet_addr(rrc->eth_params_s.my_addr);
+	DRBs[i].up_ul_tnl[0].port=rrc->eth_params_s.my_portd;
+	DRBs[i].up_ul_tnl_length = 1;
+	DRBs[i].up_dl_tnl[0].tl_address = inet_addr(rrc->eth_params_s.remote_addr);
+	DRBs[i].up_dl_tnl[0].port=rrc->eth_params_s.remote_portd;
+	DRBs[i].up_dl_tnl_length = 1;
+      }
+      LOG_I(RRC, "Send F1AP_UE_CONTEXT_SETUP_REQ with ITTI\n");
+      itti_send_msg_to_task (TASK_CU_F1, 0, message_p);
+    }
   }
+  
+  return (0);
 }
 
 /*------------------------------------------------------------------------------*/
diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c
index 1f0f0be9235..8fd2be14f41 100755
--- a/openair2/RRC/NR/rrc_gNB.c
+++ b/openair2/RRC/NR/rrc_gNB.c
@@ -1370,17 +1370,18 @@ rrc_gNB_process_RRCReconfigurationComplete(
   else if(SRB_configList!=NULL || DRB_configList!=NULL){
     MessageDef *message_p;
     message_p = itti_alloc_new_message (TASK_RRC_GNB, 0, F1AP_UE_CONTEXT_SETUP_REQ);
-    F1AP_UE_CONTEXT_SETUP_REQ (message_p).gNB_CU_ue_id     = 0;
-    F1AP_UE_CONTEXT_SETUP_REQ (message_p).gNB_DU_ue_id = 0;
-    F1AP_UE_CONTEXT_SETUP_REQ (message_p).rnti = ue_context_pP->ue_context.rnti;
-    F1AP_UE_CONTEXT_SETUP_REQ (message_p).mcc              = RC.nrrrc[0]->configuration.mcc[0];
-    F1AP_UE_CONTEXT_SETUP_REQ (message_p).mnc              = RC.nrrrc[0]->configuration.mnc[0];
-    F1AP_UE_CONTEXT_SETUP_REQ (message_p).mnc_digit_length = RC.nrrrc[0]->configuration.mnc_digit_length[0];
-    F1AP_UE_CONTEXT_SETUP_REQ (message_p).nr_cellid        = RC.nrrrc[0]->nr_cellid;
+    f1ap_ue_context_setup_t *req=&F1AP_UE_CONTEXT_SETUP_REQ (message_p);
+    req->gNB_CU_ue_id     = 0;
+    req->gNB_DU_ue_id = 0;
+    req->rnti = ue_context_pP->ue_context.rnti;
+    req->mcc              = RC.nrrrc[0]->configuration.mcc[0];
+    req->mnc              = RC.nrrrc[0]->configuration.mnc[0];
+    req->mnc_digit_length = RC.nrrrc[0]->configuration.mnc_digit_length[0];
+    req->nr_cellid        = RC.nrrrc[0]->nr_cellid;
     if(SRB_configList!=NULL){
-      F1AP_UE_CONTEXT_SETUP_REQ (message_p).srbs_to_be_setup = malloc(SRB_configList->list.count*sizeof(f1ap_srb_to_be_setup_t));
-      F1AP_UE_CONTEXT_SETUP_REQ (message_p).srbs_to_be_setup_length = SRB_configList->list.count;
-      f1ap_srb_to_be_setup_t *SRBs=F1AP_UE_CONTEXT_SETUP_REQ (message_p).srbs_to_be_setup;
+      req->srbs_to_be_setup = malloc(SRB_configList->list.count*sizeof(f1ap_srb_to_be_setup_t));
+      req->srbs_to_be_setup_length = SRB_configList->list.count;
+      f1ap_srb_to_be_setup_t *SRBs=req->srbs_to_be_setup;
       for (int i = 0; i < SRB_configList->list.count; i++){
         if(SRB_configList->list.array[i]->srb_Identity > 1){
           SRBs[i].srb_id = SRB_configList->list.array[i]->srb_Identity;
@@ -1391,10 +1392,10 @@ rrc_gNB_process_RRCReconfigurationComplete(
     if(DRB_configList!=NULL){
       gtpv1u_gnb_create_tunnel_req_t  create_tunnel_req;
       memset(&create_tunnel_req, 0, sizeof(gtpv1u_gnb_create_tunnel_req_t));
-      F1AP_UE_CONTEXT_SETUP_REQ (message_p).drbs_to_be_setup = malloc(DRB_configList->list.count*sizeof(f1ap_drb_to_be_setup_t));
-      F1AP_UE_CONTEXT_SETUP_REQ (message_p).drbs_to_be_setup_length = DRB_configList->list.count;
-      f1ap_drb_to_be_setup_t *DRBs=F1AP_UE_CONTEXT_SETUP_REQ (message_p).drbs_to_be_setup;
-      LOG_I(RRC, "Length of DRB list:%d, %d \n", DRB_configList->list.count, F1AP_UE_CONTEXT_SETUP_REQ (message_p).drbs_to_be_setup_length);
+      req->drbs_to_be_setup = malloc(DRB_configList->list.count*sizeof(f1ap_drb_to_be_setup_t));
+      req->drbs_to_be_setup_length = DRB_configList->list.count;
+      f1ap_drb_to_be_setup_t *DRBs=req->drbs_to_be_setup;
+      LOG_I(RRC, "Length of DRB list:%d, %d \n", DRB_configList->list.count, req->drbs_to_be_setup_length);
       for (int i = 0; i < DRB_configList->list.count; i++){
         DRBs[i].drb_id = DRB_configList->list.array[i]->drb_Identity;
         DRBs[i].rlc_mode = RLC_MODE_AM;
diff --git a/openair3/ocp-gtpu/gtp_itf.cpp b/openair3/ocp-gtpu/gtp_itf.cpp
index b6d093d1afd..b90b89b21ac 100644
--- a/openair3/ocp-gtpu/gtp_itf.cpp
+++ b/openair3/ocp-gtpu/gtp_itf.cpp
@@ -95,7 +95,7 @@ static  teid_t gtpv1uNewTeid(void) {
 #endif
 }
 
-static instance_t legacyInstanceMapping=0;
+instance_t legacyInstanceMapping=0;
 #define compatInst(a) ((a)==0 || (a)==INSTANCE_DEFAULT?legacyInstanceMapping:a)
 
 #define GTPV1U_HEADER_SIZE                                  (8)
diff --git a/targets/COMMON/create_tasks.c b/targets/COMMON/create_tasks.c
index 3e0d97f60a0..d302b418c51 100644
--- a/targets/COMMON/create_tasks.c
+++ b/targets/COMMON/create_tasks.c
@@ -91,6 +91,9 @@ int create_tasks(uint32_t enb_nb) {
   if (NODE_IS_DU(type)) {
     rc = itti_create_task(TASK_DU_F1, F1AP_DU_task, NULL);
     AssertFatal(rc >= 0, "Create task for DU F1AP failed\n");
+    // DU is now GTP-U instead of protobuf
+    rc = itti_create_task(TASK_GTPV1_U, gtpv1u_eNB_task, NULL);
+    AssertFatal(rc >= 0, "Create task for GTPV1U failed\n");
   }
 
   if (!NODE_IS_CU(type)) {
-- 
GitLab