Save in SDAP context if is UE or gNB
sdap_tun_read_thread needs to know if we are gNB/UE. Previously, we passed this into the thread, but the next commit also needs to for interface termination, where this info is not available. So, for noS1 mode, pass this in.
This commit is contained in:
committed by
francescomani
parent
958b2f3fac
commit
94443aefde
@@ -107,17 +107,10 @@ void sdap_data_ind(rb_id_t pdcp_entity,
|
||||
size);
|
||||
}
|
||||
|
||||
struct thread_args {
|
||||
nr_sdap_entity_t *entity;
|
||||
bool is_gnb;
|
||||
};
|
||||
static void *sdap_tun_read_thread(void *arg)
|
||||
{
|
||||
DevAssert(arg != NULL);
|
||||
struct thread_args *ta = arg;
|
||||
nr_sdap_entity_t *entity = ta->entity;
|
||||
bool is_gnb = ta->is_gnb;
|
||||
free(ta);
|
||||
nr_sdap_entity_t *entity = arg;
|
||||
|
||||
char rx_buf[NL_MAX_PAYLOAD];
|
||||
int len;
|
||||
@@ -134,9 +127,9 @@ static void *sdap_tun_read_thread(void *arg)
|
||||
|
||||
LOG_D(SDAP, "read data of size %d\n", len);
|
||||
|
||||
protocol_ctxt_t ctxt = {.enb_flag = is_gnb, .rntiMaybeUEid = entity->ue_id};
|
||||
protocol_ctxt_t ctxt = {.enb_flag = entity->is_gnb, .rntiMaybeUEid = entity->ue_id};
|
||||
|
||||
bool dc = is_gnb ? false : SDAP_HDR_UL_DATA_PDU;
|
||||
bool dc = entity->is_gnb ? false : SDAP_HDR_UL_DATA_PDU;
|
||||
|
||||
DevAssert(entity != NULL);
|
||||
entity->tx_entity(entity,
|
||||
@@ -161,30 +154,25 @@ void start_sdap_tun_gnb_first_ue_default_pdu_session(ue_id_t ue_id)
|
||||
{
|
||||
nr_sdap_entity_t *entity = nr_sdap_get_entity(ue_id, get_softmodem_params()->default_pdu_session_id);
|
||||
DevAssert(entity != NULL);
|
||||
DevAssert(entity->is_gnb);
|
||||
char *ifprefix = get_softmodem_params()->nsa ? "oaitun_gnb" : "oaitun_enb";
|
||||
char ifname[IFNAMSIZ];
|
||||
tun_generate_ifname(ifname, ifprefix, ue_id - 1);
|
||||
entity->pdusession_sock = tun_alloc(ifname);
|
||||
tun_config(ifname, "10.0.1.1", NULL);
|
||||
struct thread_args *ta = calloc_or_fail(1, sizeof(*ta));
|
||||
ta->entity = entity;
|
||||
ta->is_gnb = true;
|
||||
|
||||
threadCreate(&entity->pdusession_thread, sdap_tun_read_thread, ta, "gnb_tun_read_thread", -1, OAI_PRIORITY_RT_LOW);
|
||||
threadCreate(&entity->pdusession_thread, sdap_tun_read_thread, entity, "gnb_tun_read_thread", -1, OAI_PRIORITY_RT_LOW);
|
||||
}
|
||||
|
||||
void start_sdap_tun_ue(ue_id_t ue_id, int pdu_session_id, int sock)
|
||||
{
|
||||
nr_sdap_entity_t *entity = nr_sdap_get_entity(ue_id, pdu_session_id);
|
||||
DevAssert(entity != NULL);
|
||||
DevAssert(!entity->is_gnb);
|
||||
entity->pdusession_sock = sock;
|
||||
entity->stop_thread = false;
|
||||
char thread_name[64];
|
||||
snprintf(thread_name, sizeof(thread_name), "ue_tun_read_%ld_p%d", ue_id, pdu_session_id);
|
||||
struct thread_args *ta = calloc_or_fail(1, sizeof(*ta));
|
||||
ta->entity = entity;
|
||||
ta->is_gnb = false;
|
||||
threadCreate(&entity->pdusession_thread, sdap_tun_read_thread, ta, thread_name, -1, OAI_PRIORITY_RT_LOW);
|
||||
threadCreate(&entity->pdusession_thread, sdap_tun_read_thread, entity, thread_name, -1, OAI_PRIORITY_RT_LOW);
|
||||
}
|
||||
|
||||
|
||||
@@ -201,7 +189,7 @@ void create_ue_ip_if(const char *ipv4, const char *ipv6, int ue_id, int pdu_sess
|
||||
start_sdap_tun_ue(ue_id, pdu_session_id, sock); // interface name suffix is ue_id+1
|
||||
}
|
||||
|
||||
void remove_ue_ip_if(nr_sdap_entity_t *entity)
|
||||
void remove_ip_if(nr_sdap_entity_t *entity)
|
||||
{
|
||||
DevAssert(entity != NULL);
|
||||
// Stop the read thread
|
||||
@@ -211,6 +199,11 @@ void remove_ue_ip_if(nr_sdap_entity_t *entity)
|
||||
// Bring down the IP interface
|
||||
int default_pdu = get_softmodem_params()->default_pdu_session_id;
|
||||
char ifname[IFNAMSIZ];
|
||||
tun_generate_ue_ifname(ifname, entity->ue_id, entity->pdusession_id != default_pdu ? entity->pdusession_id : -1);
|
||||
if (entity->is_gnb) {
|
||||
char *ifprefix = get_softmodem_params()->nsa ? "oaitun_gnb" : "oaitun_enb";
|
||||
tun_generate_ifname(ifname, ifprefix, entity->ue_id - 1);
|
||||
} else {
|
||||
tun_generate_ue_ifname(ifname, entity->ue_id, entity->pdusession_id != default_pdu ? entity->pdusession_id : -1);
|
||||
}
|
||||
tun_destroy(ifname, entity->pdusession_sock);
|
||||
}
|
||||
|
||||
@@ -502,6 +502,7 @@ nr_sdap_entity_t *new_nr_sdap_entity(int is_gnb,
|
||||
|
||||
sdap_entity->ue_id = ue_id;
|
||||
sdap_entity->pdusession_id = pdusession_id;
|
||||
sdap_entity->is_gnb = is_gnb;
|
||||
|
||||
sdap_entity->tx_entity = nr_sdap_tx_entity;
|
||||
sdap_entity->rx_entity = nr_sdap_rx_entity;
|
||||
@@ -600,8 +601,8 @@ bool nr_sdap_delete_entity(ue_id_t ue_id, int pdusession_id)
|
||||
|
||||
if (entityPtr->ue_id == ue_id && entityPtr->pdusession_id == pdusession_id) {
|
||||
entityPrev->next_entity = entityPtr->next_entity;
|
||||
if (entityPrev->pdusession_sock != -1) {
|
||||
remove_ue_ip_if(entityPrev);
|
||||
if (entityPtr->pdusession_sock != -1) {
|
||||
remove_ip_if(entityPtr);
|
||||
}
|
||||
free(entityPtr);
|
||||
LOG_D(SDAP, "Successfully deleted Entity.\n");
|
||||
|
||||
@@ -80,6 +80,9 @@ void nr_pdcp_submit_sdap_ctrl_pdu(ue_id_t ue_id, rb_id_t sdap_ctrl_pdu_drb, nr_s
|
||||
typedef struct nr_sdap_entity_s {
|
||||
ue_id_t ue_id;
|
||||
rb_id_t default_drb;
|
||||
/// sdap_tun_read_thread needs to know if we are gNB/UE, so for noS1 mode,
|
||||
/// store which one we are
|
||||
bool is_gnb;
|
||||
int pdusession_id;
|
||||
int pdusession_sock;
|
||||
pthread_t pdusession_thread;
|
||||
@@ -218,5 +221,5 @@ bool is_sdap_tx(bool is_gnb, NR_SDAP_Config_t *sdap_config);
|
||||
void nr_reconfigure_sdap_entity(NR_SDAP_Config_t *sdap_config, ue_id_t ue_id, int pdusession_id, int drb_id);
|
||||
|
||||
void set_qfi(uint8_t qfi, uint8_t pduid, ue_id_t ue_id);
|
||||
void remove_ue_ip_if(nr_sdap_entity_t *entity);
|
||||
void remove_ip_if(nr_sdap_entity_t *entity);
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user