From b7f00aa24041bf9185eb40a5b3e621df6f684e9e Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Fri, 6 Jun 2025 07:53:49 +0200 Subject: [PATCH 1/6] SCTP: Provide more info on getaddrinfo() fail Upon failure, the error message was saying that something failed (i.e., the reason), but not parameters of the getaddrinfo(). Simplify root cause analysis by providing the parameters for the attempted getaddrinfo() call. --- openair3/SCTP/sctp_eNB_task.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair3/SCTP/sctp_eNB_task.c b/openair3/SCTP/sctp_eNB_task.c index 6b83a7df6d..82afa451c0 100644 --- a/openair3/SCTP/sctp_eNB_task.c +++ b/openair3/SCTP/sctp_eNB_task.c @@ -464,7 +464,7 @@ static void sctp_handle_new_association_req(const instance_t instance, char port[12]; snprintf(port, sizeof(port), "%d", req->port); int status = getaddrinfo(remote, port, &hints, &serv); - AssertFatal(status == 0, "getaddrinfo() failed: %s\n", gai_strerror(status)); + AssertFatal(status == 0, "getaddrinfo(node %s service %s) failed: %s\n", remote, port, gai_strerror(status)); struct addrinfo *p = NULL; for (p = serv; p != NULL; p = p->ai_next) { From 842ab32c91a530bc4e5d8f82ab2d3cb196a067f5 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Fri, 6 Jun 2025 08:14:12 +0200 Subject: [PATCH 2/6] ITTI: remove useless log_scheduler() function The primary motivation here is to remove a VLA, as in the parent commits. Closer inspection revealed that (1) it is only used by the LTE UE, and (2) it only logs some data which we likely don't need. So I simply removed this function. --- common/utils/ocp_itti/intertask_interface.cpp | 36 ------------------- common/utils/ocp_itti/intertask_interface.h | 1 - executables/lte-ue.c | 2 -- 3 files changed, 39 deletions(-) diff --git a/common/utils/ocp_itti/intertask_interface.cpp b/common/utils/ocp_itti/intertask_interface.cpp index faf510712b..8ad5f63a50 100644 --- a/common/utils/ocp_itti/intertask_interface.cpp +++ b/common/utils/ocp_itti/intertask_interface.cpp @@ -475,41 +475,5 @@ typedef struct timer_elm_s { return 0; } -void log_scheduler(const char* label) -{ - int policy = sched_getscheduler(0); - struct sched_param param; - if (sched_getparam(0, ¶m) == -1) - { - LOG_E(HW, "sched_getparam: %s\n", strerror(errno)); - abort(); - } - - cpu_set_t cpu_set; - if (sched_getaffinity(0, sizeof(cpu_set), &cpu_set) == -1) - { - LOG_E(HW, "sched_getaffinity: %s\n", strerror(errno)); - abort(); - } - int num_cpus = sysconf(_SC_NPROCESSORS_ONLN); - if (num_cpus < 1) - { - LOG_E(HW, "sysconf(_SC_NPROCESSORS_ONLN): %s\n", strerror(errno)); - abort(); - } - char buffer[num_cpus]; - for (int i = 0; i < num_cpus; i++) - { - buffer[i] = CPU_ISSET(i, &cpu_set) ? 'Y' : '-'; - } - - LOG_A(HW, "Scheduler policy=%d priority=%d affinity=[%d]%.*s label=%s\n", - policy, - param.sched_priority, - num_cpus, - num_cpus, - buffer, - label); -} } // extern "C" diff --git a/common/utils/ocp_itti/intertask_interface.h b/common/utils/ocp_itti/intertask_interface.h index 2f2ad54174..84dbd15365 100644 --- a/common/utils/ocp_itti/intertask_interface.h +++ b/common/utils/ocp_itti/intertask_interface.h @@ -566,7 +566,6 @@ int timer_remove(long timer_id); int signal_handle(int *end); int signal_mask(void); -void log_scheduler(const char *label); #ifdef __cplusplus } #endif diff --git a/executables/lte-ue.c b/executables/lte-ue.c index e941690f26..2d7338c410 100644 --- a/executables/lte-ue.c +++ b/executables/lte-ue.c @@ -1740,8 +1740,6 @@ void *UE_thread(void *arg) { oai_exit=1; } - log_scheduler(__func__); - while (!oai_exit) { AssertFatal ( 0== pthread_mutex_lock(&UE->proc.mutex_synch), ""); int instance_cnt_synch = UE->proc.instance_cnt_synch; From 405d12293735db582c20b08ac306435a7c556d32 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Fri, 6 Jun 2025 18:28:57 +0200 Subject: [PATCH 3/6] GTP: check that packets are not larger than max UDP size --- openair3/ocp-gtpu/gtp_itf.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/openair3/ocp-gtpu/gtp_itf.cpp b/openair3/ocp-gtpu/gtp_itf.cpp index 3036565fad..0ac9f95fa1 100644 --- a/openair3/ocp-gtpu/gtp_itf.cpp +++ b/openair3/ocp-gtpu/gtp_itf.cpp @@ -224,6 +224,7 @@ static int gtpv1uCreateAndSendMsg(int h, uint8_t extensionHeader_length) { LOG_D(GTPU, "Peer IP:%u peer port:%u outgoing teid:%u \n", peerIp, peerPort, teid); + DevAssert(msgLen + HDR_MAX < 65536); // maximum size of UDP packet uint8_t buffer[msgLen+HDR_MAX]; uint8_t *curPtr=buffer; Gtpv1uMsgHeaderT *msgHdr = (Gtpv1uMsgHeaderT *)buffer ; From 0f78aade97667073c588dd0131490a9bef3f896b Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Fri, 6 Jun 2025 08:22:52 +0200 Subject: [PATCH 4/6] Remove useless printf in config reading This printf just shows which config sections are being read, but this has no useful information for a user. It was introduced in 7731f5bd2d8 but was not present prior to this commit, either. --- common/config/config_paramdesc.h | 1 - 1 file changed, 1 deletion(-) diff --git a/common/config/config_paramdesc.h b/common/config/config_paramdesc.h index 6947f6531d..3341162da7 100644 --- a/common/config/config_paramdesc.h +++ b/common/config/config_paramdesc.h @@ -169,7 +169,6 @@ typedef struct paramlist_def { /* Macros to get parameters with the config module API */ #define GET_PARAMS(param_def, param_desc, prefix) \ - printf("Reading '%s' section from the config file\n", #param_def); \ paramdef_t param_def[] = param_desc; \ config_get(config_get_if(), param_def, sizeofArray(param_def), prefix); From 986b212fe905f0983d5ae36b380e02458bce1383 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Fri, 6 Jun 2025 08:22:02 +0200 Subject: [PATCH 5/6] GTP: fix memory leak when socket binding fails Avoid leaking memory upon failed socket binding by calling freeaddrinfo() before exiting in error cases. Fixes leak: Direct leak of 64 byte(s) in 1 object(s) allocated from: #0 0x0000004ac038 in malloc (/home/richie/oai/cmake_targets/ran_build/build/nr-softmodem+0x4ac038) (BuildId: 875d6e5bc54d7c89bdcf151452f12703cb6fd110) #1 0x7f0fdd92e2a6 in getaddrinfo (/lib64/libc.so.6+0x1202a6) (BuildId: 2b3c02fe7e4d3811767175b6f323692a10a4e116) #2 0x00000043d7ad in getaddrinfo (/home/richie/oai/cmake_targets/ran_build/build/nr-softmodem+0x43d7ad) (BuildId: 875d6e5bc54d7c89bdcf151452f12703cb6fd110) #3 0x000000700c73 in udpServerSocket(openAddr_s) /home/richie/oai/openair3/ocp-gtpu/gtp_itf.cpp:486:17 #4 0x000000700c73 in gtpv1Init /home/richie/oai/openair3/ocp-gtpu/gtp_itf.cpp:546:10 #5 0x000000c692b8 in cuup_init_n3 /home/richie/oai/openair2/E1AP/e1ap.c:744:61 #6 0x000000549ea1 in create_gNB_tasks /home/richie/oai/executables/nr-softmodem.c:320:7 #7 0x000000549ea1 in main /home/richie/oai/executables/nr-softmodem.c:619:15 #8 0x7f0fdd8115f4 in __libc_start_call_main (/lib64/libc.so.6+0x35f4) (BuildId: 2b3c02fe7e4d3811767175b6f323692a10a4e116) #9 0x7f0fdd8116a7 in __libc_start_main@GLIBC_2.2.5 (/lib64/libc.so.6+0x36a7) (BuildId: 2b3c02fe7e4d3811767175b6f323692a10a4e116) #10 0x000000408524 in _start (/home/richie/oai/cmake_targets/ran_build/build/nr-softmodem+0x408524) (BuildId: 875d6e5bc54d7c89bdcf151452f12703cb6fd110) --- openair3/ocp-gtpu/gtp_itf.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openair3/ocp-gtpu/gtp_itf.cpp b/openair3/ocp-gtpu/gtp_itf.cpp index 0ac9f95fa1..fd571e8d0e 100644 --- a/openair3/ocp-gtpu/gtp_itf.cpp +++ b/openair3/ocp-gtpu/gtp_itf.cpp @@ -526,14 +526,14 @@ static int udpServerSocket(openAddr_s addr) { break; // if we get here, we must have connected successfully } + freeaddrinfo(servinfo); // all done with this structure + if (p == NULL) { // looped off the end of the list with no successful bind LOG_E(GTPU,"failed to bind socket: %s %s \n", addr.originHost, addr.originService); return -1; } - freeaddrinfo(servinfo); // all done with this structure - int sendbuff = 1000*1000*10; AssertFatal(0==setsockopt(sockfd, SOL_SOCKET, SO_SNDBUF, &sendbuff, sizeof(sendbuff)),""); LOG_D(GTPU,"[%d] Created listener for paquets to: %s:%s, send buffer size: %d\n", sockfd, addr.originHost, addr.originService,sendbuff); From f0ca66adcddcc71b9a02175d306146fff6b2d1fb Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Fri, 6 Jun 2025 08:58:05 +0200 Subject: [PATCH 6/6] Remove unused MAC types and includes Using the USIM interface in the MAC is non-sensical (violates layer separation). Add header include in nr-softmodem.c, which previously came through nr_mac_gNB.h -> usim_interface.h. --- executables/nr-softmodem.c | 1 + openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 8 -------- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/executables/nr-softmodem.c b/executables/nr-softmodem.c index b9302392ab..332e06e7af 100644 --- a/executables/nr-softmodem.c +++ b/executables/nr-softmodem.c @@ -23,6 +23,7 @@ #define _GNU_SOURCE /* See feature_test_macros(7) */ #include "common/config/config_userapi.h" +#include "common/utils/load_module_shlib.h" #include "RRC/LTE/rrc_vars.h" #ifdef SMBV #include "PHY/TOOLS/smbv.h" diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index d97783604f..8d42b7cc02 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -89,9 +89,6 @@ #include "LAYER2/NR_MAC_COMMON/nr_mac_common.h" #include "NR_TAG.h" -#include - - /* Defs */ #define MAX_NUM_BWP 5 #define MAX_NUM_CORESET 12 @@ -100,7 +97,6 @@ #define NR_NB_RA_PROC_MAX 4 #define MAX_NUM_OF_SSB 64 #define MAX_NUM_NR_PRACH_PREAMBLES 64 -#define MIN_NUM_PRBS_TO_SCHEDULE 5 uint8_t nr_get_rv(int rel_round); @@ -677,10 +673,6 @@ typedef struct { float pdcch_cl_adjust; } NR_UE_sched_ctrl_t; -typedef struct { - uicc_t *uicc; -} NRUEcontext_t; - typedef struct NR_mac_dir_stats { uint64_t lc_bytes[64]; uint64_t rounds[8];