summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri@ouroboros.rocks>2026-01-18 18:50:05 +0100
committerSander Vrijders <sander@ouroboros.rocks>2026-01-19 08:35:10 +0100
commitc20c5bfb40bb65d4196bcf97e80acd97496ddda3 (patch)
tree351b452f55934e8468ddbdb79d16ccb7819eab29 /src
parentc51611c27f766bb4f413485bf8a12bca02e98669 (diff)
downloadouroboros-c20c5bfb40bb65d4196bcf97e80acd97496ddda3.tar.gz
ouroboros-c20c5bfb40bb65d4196bcf97e80acd97496ddda3.zip
build: Add an option for container compatibility
This adds a BUILD_CONTAINER option that disables some features that require elevated privileges like setting thread priorities, which might not be supported in docker environments. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
Diffstat (limited to 'src')
-rw-r--r--src/ipcpd/config.h.in1
-rw-r--r--src/ipcpd/unicast/fa.c6
-rw-r--r--src/ipcpd/unicast/psched.c6
3 files changed, 13 insertions, 0 deletions
diff --git a/src/ipcpd/config.h.in b/src/ipcpd/config.h.in
index a39789a5..e0ca6d89 100644
--- a/src/ipcpd/config.h.in
+++ b/src/ipcpd/config.h.in
@@ -51,6 +51,7 @@
#define CONNMGR_RCV_TIMEOUT @CONNMGR_RCV_TIMEOUT@
#cmakedefine DISABLE_CORE_LOCK
+#cmakedefine BUILD_CONTAINER
#cmakedefine IPCP_FLOW_STATS
#cmakedefine IPCP_DEBUG_LOCAL
#ifdef CONFIG_OUROBOROS_DEBUG
diff --git a/src/ipcpd/unicast/fa.c b/src/ipcpd/unicast/fa.c
index ac168bd9..dc23340c 100644
--- a/src/ipcpd/unicast/fa.c
+++ b/src/ipcpd/unicast/fa.c
@@ -689,9 +689,11 @@ void fa_fini(void)
int fa_start(void)
{
+#ifndef BUILD_CONTAINER
struct sched_param par;
int pol;
int max;
+#endif
fa.psched = psched_create(packet_handler, np1_flow_read);
if (fa.psched == NULL) {
@@ -704,6 +706,7 @@ int fa_start(void)
goto fail_thread;
}
+#ifndef BUILD_CONTAINER
if (pthread_getschedparam(fa.worker, &pol, &par)) {
log_err("Failed to get worker thread scheduling parameters.");
goto fail_sched;
@@ -721,12 +724,15 @@ int fa_start(void)
log_err("Failed to set scheduler priority to maximum.");
goto fail_sched;
}
+#endif
return 0;
+#ifndef BUILD_CONTAINER
fail_sched:
pthread_cancel(fa.worker);
pthread_join(fa.worker, NULL);
+#endif
fail_thread:
psched_destroy(fa.psched);
fail_psched:
diff --git a/src/ipcpd/unicast/psched.c b/src/ipcpd/unicast/psched.c
index 7e12148b..f74b4065 100644
--- a/src/ipcpd/unicast/psched.c
+++ b/src/ipcpd/unicast/psched.c
@@ -41,11 +41,13 @@
#include <stdlib.h>
#include <string.h>
+#ifndef BUILD_CONTAINER
static int qos_prio [] = {
QOS_PRIO_BE,
QOS_PRIO_VIDEO,
QOS_PRIO_VOICE,
};
+#endif
struct psched {
fset_t * set[QOS_CUBE_MAX];
@@ -168,6 +170,7 @@ struct psched * psched_create(next_packet_fn_t callback,
}
}
+#ifndef BUILD_CONTAINER
for (i = 0; i < QOS_CUBE_MAX * IPCP_SCHED_THR_MUL; ++i) {
struct sched_param par;
int pol = SCHED_RR;
@@ -185,14 +188,17 @@ struct psched * psched_create(next_packet_fn_t callback,
if (pthread_setschedparam(psched->readers[i], pol, &par))
goto fail_sched;
}
+#endif
return psched;
+#ifndef BUILD_CONTAINER
fail_sched:
for (j = 0; j < QOS_CUBE_MAX * IPCP_SCHED_THR_MUL; ++j)
pthread_cancel(psched->readers[j]);
for (j = 0; j < QOS_CUBE_MAX * IPCP_SCHED_THR_MUL; ++j)
pthread_join(psched->readers[j], NULL);
+#endif
fail_infos:
for (j = 0; j < QOS_CUBE_MAX; ++j)
fset_destroy(psched->set[j]);