Commit 0954c3f6 authored by Jaroslava Fiedlerova's avatar Jaroslava Fiedlerova

Merge remote-tracking branch 'origin/sdap-header-bugfix' into integration_2025_w46 (!3747)

SDAP: guard RX header parsing with enable_sdap and init per-entity

!3519 (merged) refactored the SDAP to use the QFI from the header rather than
pass it to the rx function and got rid of the initialization of QFI to -1.

However, entity roles are stored into the drb2qfi table, and the indexing
implies that the QFI is known.

While in TX it is not an issue since packets are forwarded based on the QFI,
in RX the QFI can only be parsed from the header, therefore if headers are
disabled (--enable_sdap) the QFI is not there and it is wrong to access the
header (buf[0]) and looking for it.

This commit adds enable_sdap to nr_sdap_entity_t and initialize it in
nr_sdap_add_entity() from sdap->role (disabled when NO_SDAP_HEADER).

In nr_sdap_rx_entity(), only parse buf[0] for QFI and derive sdap_ul_rx/
sdap_dl_rx when enable_sdap is true; otherwise, keep offset=0 and forward
payload unchanged.
parents 0d106428 7274e7c4
......@@ -210,15 +210,20 @@ static void nr_sdap_rx_entity(nr_sdap_entity_t *entity,
{
/* The offset of the SDAP header, it might be 0 if has_sdap_rx is not true in the pdcp entity. */
int offset=0;
bool sdap_ul_rx = false;
bool sdap_dl_rx = false;
/* If SDAP header is disabled for this entity, bypass header parsing */
if (entity->enable_sdap) {
uint8_t qfi = buf[0] & 0x3F; // QFI is always the first 6 bits in the first octet
if (qfi >= SDAP_MAX_QFI) {
LOG_E(SDAP, "Invalid QFI %d received in SDAP header\n", qfi);
return;
}
// Fetch entity role from the qfi2drb_table
bool sdap_ul_rx = entity->qfi2drb_table[qfi].entity_role & SDAP_UL_RX; // gNB RX entity
bool sdap_dl_rx = entity->qfi2drb_table[qfi].entity_role & SDAP_DL_RX; // UE RX entity
sdap_ul_rx = entity->qfi2drb_table[qfi].entity_role & SDAP_UL_RX; // gNB RX entity
sdap_dl_rx = entity->qfi2drb_table[qfi].entity_role & SDAP_DL_RX; // UE RX entity
}
if (is_gnb) { // gNB
if (sdap_ul_rx) { // UL Data/Control PDU with SDAP header
......@@ -495,6 +500,7 @@ static void nr_sdap_add_entity(const int is_gnb, const ue_id_t ue_id, const sdap
sdap_entity->ue_id = ue_id;
sdap_entity->pdusession_id = sdap->pdusession_id;
sdap_entity->is_gnb = is_gnb;
sdap_entity->enable_sdap = (sdap->role != NO_SDAP_HEADER);
// rx/tx entities
sdap_entity->tx_entity = nr_sdap_tx_entity;
......
......@@ -99,6 +99,7 @@ typedef struct nr_sdap_entity_s {
/// sdap_tun_read_thread needs to know if we are gNB/UE, so for noS1 mode,
/// store which one we are
bool is_gnb;
bool enable_sdap;
int pdusession_id;
int pdusession_sock;
pthread_t pdusession_thread;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment