diff options
Diffstat (limited to 'cmake/config')
| -rw-r--r-- | cmake/config/global.cmake | 47 | ||||
| -rw-r--r-- | cmake/config/ipcp/broadcast.cmake | 9 | ||||
| -rw-r--r-- | cmake/config/ipcp/common.cmake | 58 | ||||
| -rw-r--r-- | cmake/config/ipcp/eth.cmake | 22 | ||||
| -rw-r--r-- | cmake/config/ipcp/local.cmake | 39 | ||||
| -rw-r--r-- | cmake/config/ipcp/udp.cmake | 16 | ||||
| -rw-r--r-- | cmake/config/ipcp/unicast.cmake | 35 | ||||
| -rw-r--r-- | cmake/config/irmd.cmake | 46 | ||||
| -rw-r--r-- | cmake/config/lib.cmake | 139 | ||||
| -rw-r--r-- | cmake/config/ssm.cmake | 168 | ||||
| -rw-r--r-- | cmake/config/tests.cmake | 17 |
11 files changed, 596 insertions, 0 deletions
diff --git a/cmake/config/global.cmake b/cmake/config/global.cmake new file mode 100644 index 00000000..1e172724 --- /dev/null +++ b/cmake/config/global.cmake @@ -0,0 +1,47 @@ +# Global configuration options for Ouroboros +# These options affect the entire framework + +# Installation directories +set(OUROBOROS_CONFIG_DIR "${CMAKE_INSTALL_FULL_SYSCONFDIR}/ouroboros" CACHE PATH + "Configuration directory") + +# Security directories +set(OUROBOROS_SECURITY_DIR "${OUROBOROS_CONFIG_DIR}/security" CACHE PATH + "Security directory holding authentication information") +set(OUROBOROS_CA_CRT_DIR "${OUROBOROS_SECURITY_DIR}/cacert" CACHE PATH + "Directory holding trusted CA certificates") +set(OUROBOROS_SRV_CRT_DIR "${OUROBOROS_SECURITY_DIR}/server" CACHE PATH + "Directory holding server certificates") +set(OUROBOROS_CLI_CRT_DIR "${OUROBOROS_SECURITY_DIR}/client" CACHE PATH + "Directory holding client certificates") +set(OUROBOROS_UNTRUSTED_DIR "${OUROBOROS_SECURITY_DIR}/untrusted" CACHE PATH + "Directory holding untrusted intermediate certificates") + +# Shared memory naming +set(SHM_PREFIX "ouroboros" CACHE STRING + "String to prepend to POSIX shared memory filenames") +set(SHM_LOCKFILE_NAME "/${SHM_PREFIX}.lockfile" CACHE INTERNAL + "Filename for the POSIX shared memory lockfile") + +# Secure memory configuration +set(IRMD_SECMEM_MAX 1048576 CACHE STRING "IRMd secure heap size") +# ~8 KiB secure heap per encrypted flow (cur+prev node slabs); the total +# is rounded up to a power of two for the OpenSSL secure-heap allocator. +set(PROC_SECMEM_FLOWS 512 CACHE STRING + "Max concurrent encrypted flows the per-process secure heap is sized for") +math(EXPR PROC_SECMEM_NEED "${PROC_SECMEM_FLOWS} * 8192") +set(PROC_SECMEM_MAX 4096) +while(PROC_SECMEM_MAX LESS PROC_SECMEM_NEED) + math(EXPR PROC_SECMEM_MAX "${PROC_SECMEM_MAX} * 2") +endwhile() +set(SECMEM_MINSIZE 32 CACHE STRING "Secure heap min alloc size") + +# Container/deployment options +set(BUILD_CONTAINER FALSE CACHE BOOL + "Disable thread priority setting for container compatibility") +set(DISABLE_CORE_LOCK TRUE CACHE BOOL + "Disable locking performance threads to a core") + +# IPC socket configuration +set(SOCK_BUF_SIZE 10240 CACHE STRING + "Size of the buffer used by the UNIX sockets for local IPC") diff --git a/cmake/config/ipcp/broadcast.cmake b/cmake/config/ipcp/broadcast.cmake new file mode 100644 index 00000000..f521ed8e --- /dev/null +++ b/cmake/config/ipcp/broadcast.cmake @@ -0,0 +1,9 @@ +# Broadcast IPCP configuration options for Ouroboros + +set(IPCP_BROADCAST_TARGET ipcpd-broadcast) + +set(IPCP_BROADCAST_MPL 100 CACHE STRING + "Default maximum packet lifetime for the Broadcast IPCP, in ms") + +set(IPCP_BROADCAST_MTU 1400 CACHE STRING + "Layer MTU advertised by the Broadcast IPCP, in bytes") diff --git a/cmake/config/ipcp/common.cmake b/cmake/config/ipcp/common.cmake new file mode 100644 index 00000000..7dbc252b --- /dev/null +++ b/cmake/config/ipcp/common.cmake @@ -0,0 +1,58 @@ +# Common IPCP configuration options for Ouroboros +# Options affecting all IPC Process types + +# Connection manager +set(CONNMGR_RCV_TIMEOUT 1000 CACHE STRING + "Timeout for the connection manager to wait for OCEP info (ms).") + +# Debugging +set(IPCP_DEBUG_LOCAL FALSE CACHE BOOL + "Use PID as address for local debugging") + +# QoS cube priorities (0-99, higher = more priority) +set(IPCP_QOS_CUBE_BE_PRIO 50 CACHE STRING + "Priority for best effort QoS cube (0-99)") +set(IPCP_QOS_CUBE_VIDEO_PRIO 90 CACHE STRING + "Priority for video QoS cube (0-99)") +set(IPCP_QOS_CUBE_VOICE_PRIO 99 CACHE STRING + "Priority for voice QoS cube (0-99)") + +# Validate QoS cube priorities +if((IPCP_QOS_CUBE_BE_PRIO LESS 0) OR (IPCP_QOS_CUBE_BE_PRIO GREATER 99)) + message(FATAL_ERROR "Invalid priority for best effort QoS cube (must be 0-99)") +endif() +if((IPCP_QOS_CUBE_VIDEO_PRIO LESS 0) OR (IPCP_QOS_CUBE_VIDEO_PRIO GREATER 99)) + message(FATAL_ERROR "Invalid priority for video QoS cube (must be 0-99)") +endif() +if((IPCP_QOS_CUBE_VOICE_PRIO LESS 0) OR (IPCP_QOS_CUBE_VOICE_PRIO GREATER 99)) + message(FATAL_ERROR "Invalid priority for voice QoS cube (must be 0-99)") +endif() + +# Threading +set(IPCP_MIN_THREADS 4 CACHE STRING + "Minimum number of worker threads in the IPCP") +set(IPCP_ADD_THREADS 4 CACHE STRING + "Number of extra threads to start when an IPCP faces thread starvation") +set(IPCP_SCHED_THR_MUL 2 CACHE STRING + "Number of scheduler threads per QoS cube") + +# Linux-specific +if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + set(IPCP_LINUX_TIMERSLACK_NS 100 CACHE STRING + "Slack value for high resolution timers on Linux systems.") +endif() + +# Per-flow statistics exposed via the RIB (requires FUSE). +if(HAVE_FUSE) + set(IPCP_FLOW_STATS TRUE CACHE BOOL + "Enable per-flow statistics via the RIB") + if(IPCP_FLOW_STATS) + message(STATUS "IPCP flow statistics enabled") + endif() + + set(IPCP_ETH_FLOW_STATS FALSE CACHE BOOL + "Enable ipcpd-eth flow statistics via RIB") + if(IPCP_ETH_FLOW_STATS) + message(STATUS "ipcpd-eth flow statistics enabled") + endif() +endif() diff --git a/cmake/config/ipcp/eth.cmake b/cmake/config/ipcp/eth.cmake new file mode 100644 index 00000000..6a044d4b --- /dev/null +++ b/cmake/config/ipcp/eth.cmake @@ -0,0 +1,22 @@ +# Ethernet IPCP configuration options for Ouroboros +# Options for eth-llc and eth-dix IPCPs + +set(IPCP_ETH_LLC_TARGET ipcpd-eth-llc) +set(IPCP_ETH_DIX_TARGET ipcpd-eth-dix) + +set(IPCP_ETH_RD_THR 1 CACHE STRING + "Number of reader threads in Ethernet IPCP") +set(IPCP_ETH_WR_THR 1 CACHE STRING + "Number of writer threads in Ethernet IPCP") +set(IPCP_ETH_QDISC_BYPASS false CACHE BOOL + "Bypass the Qdisc in the kernel when using raw sockets") +set(IPCP_ETH_SNDBUF 4096 CACHE STRING + "Raw socket SO_SNDBUF in bytes (floored to one frame); 0 = kernel default") +set(IPCP_ETH_RCVBUF 0 CACHE STRING + "Raw socket SO_RCVBUF in bytes; 0 = leave kernel default (rmem_default)") +set(IPCP_ETH_LO_MTU 9000 CACHE STRING + "Restrict Ethernet MTU over loopback interfaces") +set(IPCP_ETH_MGMT_FRAME_SIZE 9000 CACHE STRING + "Management frame buffer size for Ethernet IPCPs") +set(IPCP_ETH_MPL 100 CACHE STRING + "Default maximum packet lifetime for the Ethernet IPCPs, in ms") diff --git a/cmake/config/ipcp/local.cmake b/cmake/config/ipcp/local.cmake new file mode 100644 index 00000000..70423cd1 --- /dev/null +++ b/cmake/config/ipcp/local.cmake @@ -0,0 +1,39 @@ +# Local IPCP configuration options for Ouroboros + +set(IPCP_LOCAL_TARGET ipcpd-local) + +set(IPCP_LOCAL_MPL 50 CACHE STRING + "Default maximum packet lifetime for the Local IPCP, in ms") + +set(IPCP_LOCAL_MTU 65000 CACHE STRING + "Layer MTU advertised by the Local IPCP, in bytes") + +set(IPCP_LOCAL_POLLING FALSE CACHE BOOL + "Enable active polling in the Local IPCP for low-latency mode") + +# IPCP_LOCAL_MTU must fit in the largest enabled GSPP and PUP class +# (sender-side allocation: daemons use GSPP, apps use PUP). Reserve a +# margin for sizeof(struct ssm_pk_buff) + HEADSPACE + TAILSPACE. +math(EXPR _ssm_pk_overhead + "${SSM_PK_BUFF_HEADSPACE} + ${SSM_PK_BUFF_TAILSPACE} + 64") + +foreach(_pool GSPP PUP) + set(_largest 0) + foreach(_pair "256;256" "512;512" "1K;1024" "2K;2048" "4K;4096" + "16K;16384" "64K;65536" "256K;262144" "1M;1048576") + list(GET _pair 0 _name) + list(GET _pair 1 _bytes) + if(SSM_${_pool}_${_name}_BLOCKS GREATER 0 + AND _bytes GREATER _largest) + set(_largest ${_bytes}) + endif() + endforeach() + math(EXPR _avail "${_largest} - ${_ssm_pk_overhead}") + if(IPCP_LOCAL_MTU GREATER _avail) + message(FATAL_ERROR + "IPCP_LOCAL_MTU (${IPCP_LOCAL_MTU}) exceeds largest enabled " + "SSM_${_pool} class minus per-block overhead " + "(${_largest} - ${_ssm_pk_overhead} = ${_avail} bytes). " + "Lower IPCP_LOCAL_MTU or enable a larger SSM_${_pool}_*_BLOCKS.") + endif() +endforeach() diff --git a/cmake/config/ipcp/udp.cmake b/cmake/config/ipcp/udp.cmake new file mode 100644 index 00000000..af84a844 --- /dev/null +++ b/cmake/config/ipcp/udp.cmake @@ -0,0 +1,16 @@ +# UDP IPCP configuration options for Ouroboros +# Options for udp4 and udp6 IPCPs + +set(IPCP_UDP4_TARGET ipcpd-udp4) +set(IPCP_UDP6_TARGET ipcpd-udp6) + +set(IPCP_UDP_RD_THR 3 CACHE STRING + "Number of reader threads in UDP IPCPs") +set(IPCP_UDP_WR_THR 3 CACHE STRING + "Number of writer threads in UDP IPCPs") +set(IPCP_UDP_MPL 5000 CACHE STRING + "Default maximum packet lifetime for the UDP IPCPs, in ms") +set(IPCP_UDP4_MTU 1472 CACHE STRING + "Fallback UDP4 layer MTU when getsockopt(IP_MTU) is unavailable, in bytes") +set(IPCP_UDP6_MTU 1452 CACHE STRING + "Fallback UDP6 layer MTU when getsockopt(IPV6_MTU) is unavailable, in bytes") diff --git a/cmake/config/ipcp/unicast.cmake b/cmake/config/ipcp/unicast.cmake new file mode 100644 index 00000000..92eeae65 --- /dev/null +++ b/cmake/config/ipcp/unicast.cmake @@ -0,0 +1,35 @@ +# Unicast IPCP configuration options for Ouroboros + +set(IPCP_UNICAST_TARGET ipcpd-unicast) + +set(IPCP_UNICAST_MPL 100 CACHE STRING + "Default maximum packet lifetime for the Unicast IPCP, in ms") +set(IPCP_UNICAST_MTU 1400 CACHE STRING + "Layer MTU advertised by the Unicast IPCP, in bytes (TODO: derive per-flow from n-1 path MTU minus DT PCI)") +set(PFT_SIZE 256 CACHE STRING + "Prefix forwarding table size for the Unicast IPCP") + +# Aggregate congestion-avoidance context interning. One ctx is shared +# per (peer, qos cube); this is the hash table bucket count. Must be a +# power of two (the bucket index masks with CA_BUCKETS - 1). +set(IPCP_CA_BUCKETS 64 CACHE STRING + "Hash buckets for aggregate CA context interning (power of two)") +math(EXPR IPCP_CA_BUCKETS_POW2 "${IPCP_CA_BUCKETS} & (${IPCP_CA_BUCKETS} - 1)") +if((IPCP_CA_BUCKETS LESS 1) OR (NOT IPCP_CA_BUCKETS_POW2 EQUAL 0)) + message(FATAL_ERROR "IPCP_CA_BUCKETS must be a positive power of two") +endif() + +# Per-flow (non-aggregated) congestion avoidance. Aggregate CA per +# (peer, qos cube) is the production behaviour; enable this only to +# build the legacy per-flow reference for A/B testing and bisection. +set(IPCP_CA_PER_FLOW FALSE CACHE BOOL + "Use per-flow congestion avoidance (testing only)") +if(IPCP_CA_PER_FLOW) + message(STATUS "IPCP per-flow congestion avoidance (testing build)") +endif() + +# Protocol debugging +set(DEBUG_PROTO_DHT FALSE CACHE BOOL + "Add DHT protocol debug logging") +set(DEBUG_PROTO_LS FALSE CACHE BOOL + "Add link state protocol debug logging") diff --git a/cmake/config/irmd.cmake b/cmake/config/irmd.cmake new file mode 100644 index 00000000..79e24bae --- /dev/null +++ b/cmake/config/irmd.cmake @@ -0,0 +1,46 @@ +# IRMd configuration options for Ouroboros +# Options affecting the IPC Resource Manager daemon + +# Timeouts (all in milliseconds unless noted) +set(IRMD_REQ_ARR_TIMEOUT 1000 CACHE STRING + "Timeout for an application to respond to a new flow (ms)") +set(BOOTSTRAP_TIMEOUT 5000 CACHE STRING + "Timeout for an IPCP to bootstrap (ms)") +set(ENROLL_TIMEOUT 20000 CACHE STRING + "Timeout for an IPCP to enroll (ms)") +set(REG_TIMEOUT 20000 CACHE STRING + "Timeout for registering a name (ms)") +set(QUERY_TIMEOUT 2000 CACHE STRING + "Timeout to query a name with an IPCP (ms); must exceed shim retry budget") +set(CONNECT_TIMEOUT 20000 CACHE STRING + "Timeout to connect an IPCP to another IPCP (ms)") +set(FLOW_ALLOC_TIMEOUT 20000 CACHE STRING + "Timeout for a flow allocation response (ms)") + +# OAP (Ouroboros Authentication Protocol) +set(OAP_REPLAY_TIMER 20 CACHE STRING + "OAP replay protection window (s)") +set(OAP_REPLAY_MAX 4096 CACHE STRING + "Maximum entries in the OAP replay cache (bounds memory/CPU under flood)") +set(OAP_REKEY_TIMER 120 CACHE STRING + "Tier-2 re-key interval (s); bounds key age / PCS healing, 0 disables") +set(OAP_CLIENT_AUTH_DEFAULT TRUE CACHE BOOL + "Client requires the server to authenticate by default") +set(DEBUG_PROTO_OAP FALSE CACHE BOOL + "Add Flow allocation protocol message output to IRMd debug logging") + +# Threading +set(IRMD_MIN_THREADS 8 CACHE STRING + "Minimum number of worker threads in the IRMd") +set(IRMD_ADD_THREADS 8 CACHE STRING + "Number of extra threads to start when the IRMD faces thread starvation") + +# Direct IPC +set(DISABLE_DIRECT_IPC FALSE CACHE BOOL + "Disable direct inter-process communication between local applications") + +# Process management +set(IRMD_PKILL_TIMEOUT 30 CACHE STRING + "Number of seconds to wait before sending SIGKILL to subprocesses on exit") +set(IRMD_KILL_ALL_PROCESSES TRUE CACHE BOOL + "Kill all processes on exit") diff --git a/cmake/config/lib.cmake b/cmake/config/lib.cmake new file mode 100644 index 00000000..81a7d6ba --- /dev/null +++ b/cmake/config/lib.cmake @@ -0,0 +1,139 @@ +# Library configuration options for Ouroboros +# Options affecting libouroboros-common, libouroboros-dev, libouroboros-irm + +# Flow limits +set(SYS_MAX_FLOWS 10240 CACHE STRING + "Maximum number of total flows for this system") +set(PROC_MAX_FLOWS 4096 CACHE STRING + "Maximum number of flows in an application") +set(PROC_RES_FDS 64 CACHE STRING + "Number of reserved flow descriptors per application") +set(PROC_MAX_FQUEUES 32 CACHE STRING + "Maximum number of flow sets per application") + +# Threading +if(NOT APPLE) + set(PTHREAD_COND_CLOCK "CLOCK_MONOTONIC" CACHE STRING + "Clock to use for condition variable timing") +else() + set(PTHREAD_COND_CLOCK "CLOCK_REALTIME" CACHE INTERNAL + "Clock to use for condition variable timing") +endif() + +# Timeouts +set(SOCKET_TIMEOUT 500 CACHE STRING + "Default timeout for responses from IPCPs (ms)") + +# QoS settings +set(QOS_DISABLE_CRC TRUE CACHE BOOL + "Ignores ber setting on all QoS cubes") + +include(utils/CPUUtils) +detect_pclmul() +detect_pmull() +if(HAVE_PCLMUL) + message(STATUS "CRC-64/NVMe backend: PCLMUL (x86 SSE4.1+PCLMUL)") +elseif(HAVE_PMULL) + message(STATUS "CRC-64/NVMe backend: PMULL (aarch64 crypto)") +else() + message(STATUS "CRC-64/NVMe backend: byte table (no acceleration)") +endif() + +# Delta-t protocol timers (Watson bound: 3*MPL + A + R). +# MPL is reported per IPCP (IPCP_*_MPL); A and R are FRCT-wide. +set(DELTA_T_ACK 1000 CACHE STRING + "Maximum time to acknowledge a packet (ms)") +set(DELTA_T_RTX 30000 CACHE STRING + "Maximum time to retransmit a packet (ms)") + +# FRCT configuration +set(FRCT_REORDER_QUEUE_SIZE 128 CACHE STRING + "Size of the reordering queue, must be a power of 2") +set(FRCT_START_WINDOW 128 CACHE STRING + "Start window, must be a power of 2") +set(FRCT_LINUX_RTT_ESTIMATOR TRUE CACHE BOOL + "Use Linux RTT estimator formula instead of the TCP RFC formula") +set(FRCT_RTO_MDEV_MULTIPLIER 2 CACHE STRING + "Multiplier for deviation term in the RTO: RTO = sRTT + (mdev << X)") +set(FRCT_RTO_INC_FACTOR 0 CACHE STRING + "Divisor for RTO increase after timeout: RTO += RTX >> X, 0: Karn/Partridge") +set(FRCT_RTO_MIN 250 CACHE STRING + "Hard floor for Retransmission Timeout (RTO) for FRCT (us)") +set(FRCT_TICK_TIME 5000 CACHE STRING + "Tick time for FRCT activity (retransmission, acknowledgments) (us)") +set(FRCT_DEBUG_STDOUT FALSE CACHE BOOL + "Print FRCT final counters to stdout at flow teardown") + +# Retransmission (RXM) configuration +set(RXM_MIN_RESOLUTION 20 CACHE STRING + "Minimum retransmission delay (ns), as a power to 2") +set(RXM_WHEEL_MULTIPLIER 4 CACHE STRING + "Factor for retransmission wheel levels as a power to 2") +set(RXM_WHEEL_LEVELS 3 CACHE STRING + "Number of levels in the retransmission wheel") +set(RXM_WHEEL_SLOTS_PER_LEVEL 256 CACHE STRING + "Number of slots per level in the retransmission wheel, must be a power of 2") + +# Acknowledgment wheel configuration +set(ACK_WHEEL_SLOTS 256 CACHE STRING + "Number of slots in the acknowledgment wheel, must be a power of 2") +set(ACK_WHEEL_RESOLUTION 18 CACHE STRING + "Minimum acknowledgment delay (ns), as a power to 2") + +# Thread pool manager (TPM) debugging +set(TPM_DEBUG_REPORT_INTERVAL 0 CACHE STRING + "Interval at wich the TPM will report long running threads (s), 0 disables") +set(TPM_DEBUG_ABORT_TIMEOUT 0 CACHE STRING + "TPM abort process after a thread reaches this timeout (s), 0 disables") + +# Encryption +set(KEY_LEAF_BITS 20 CACHE STRING + "Packets per leaf key as a power of two (2^20 = AEAD-safe default)") +set(KEY_NODE_BITS 6 CACHE STRING + "Leaf keys per node key, power of two (2^6 = 64; leak compartment)") +set(KEY_NODE_COUNT 128 CACHE STRING + "Node keys per batch (N); <= 4096, the 12-bit on-wire node index") +set(KEY_REKEY_WATERMARK 4 CACHE STRING + "Re-key when this many node keys remain; 0 disables the count trigger") +set(KEY_REPLAY_WINDOW 2048 CACHE STRING + "RX replay window in packets; power of two, >= 128") +set(KEY_REKEY_WM_CHECK_BITS 16 CACHE STRING + "Re-key watermark is consulted once per 2^n flow writes") +if(NOT KEY_REPLAY_WINDOW MATCHES "^[0-9]+$") + message(FATAL_ERROR "KEY_REPLAY_WINDOW must be a positive integer") +endif() +math(EXPR _krw_p2 "${KEY_REPLAY_WINDOW} & (${KEY_REPLAY_WINDOW} - 1)") +if(KEY_REPLAY_WINDOW LESS 128 OR NOT _krw_p2 EQUAL 0) + message(FATAL_ERROR "KEY_REPLAY_WINDOW must be a power of two >= 128") +endif() + +# Re-key must finish within its lead window - KEY_REKEY_WATERMARK node keys +# worth of packets - before the batch exhausts and TX fails closed. dev.c only +# evaluates the watermark once per FLOW_WM_CHECK writes, so a lead below ~2x +# that leaves a high-rate flow no room to complete the exchange. Production +# defaults are vast; this guards under-sized (test) geometries. +if(KEY_REKEY_WATERMARK GREATER 0) + math(EXPR _rk_wm_check "1 << ${KEY_REKEY_WM_CHECK_BITS}") + math(EXPR _rk_lead + "${KEY_REKEY_WATERMARK} << (${KEY_LEAF_BITS} + ${KEY_NODE_BITS})") + math(EXPR _rk_min "2 * ${_rk_wm_check}") + if(_rk_lead LESS _rk_min) + message(WARNING + "Re-key lead is ${_rk_lead} packets vs the watermark check interval " + "${_rk_wm_check}; a high-rate flow may exhaust its key batch before the " + "re-key completes (TX fails closed until it does). Raise KEY_LEAF_BITS, " + "KEY_NODE_BITS, or KEY_REKEY_WATERMARK.") + endif() +endif() + +# Flow statistics (requires FUSE) +if(HAVE_FUSE) + set(PROC_FLOW_STATS TRUE CACHE BOOL + "Enable flow statistics tracking for application flows") + if(PROC_FLOW_STATS) + message(STATUS "Application flow statistics enabled") + else() + message(STATUS "Application flow statistics disabled") + endif() +endif() + diff --git a/cmake/config/ssm.cmake b/cmake/config/ssm.cmake new file mode 100644 index 00000000..589171ea --- /dev/null +++ b/cmake/config/ssm.cmake @@ -0,0 +1,168 @@ +# Secure Shared Memory (SSM) pool configuration for Ouroboros +# This file defines the allocation parameters for the secure shared memory +# pool allocator + +# Shared memory pool naming configuration +set(SSM_PREFIX "ouroboros" CACHE STRING + "Prefix for secure shared memory pools") + +# Pool naming (internal) +set(SSM_GSPP_NAME "/${SSM_PREFIX}.gspp" CACHE INTERNAL + "Name for the Global Shared Packet Pool") +set(SSM_PUP_NAME_FMT "/${SSM_PREFIX}.pup.%d" CACHE INTERNAL + "Format string for Per-User Pool names (uid as argument)") + +# Packet buffer configuration +set(SSM_POOL_NAME "/${SHM_PREFIX}.pool" CACHE INTERNAL + "Name for the main POSIX shared memory pool") +set(SSM_PK_BUFF_HEADSPACE 256 CACHE STRING + "Bytes of headspace to reserve for future headers") +set(SSM_PK_BUFF_TAILSPACE 32 CACHE STRING + "Bytes of tailspace to reserve for future tails") +set(SSM_RBUFF_SIZE 1024 CACHE STRING + "Number of slots in a flow's rbuff ring; must be a power of 2") +set(SSM_RBUFF_PREFIX "/${SHM_PREFIX}.rbuff." CACHE INTERNAL + "Prefix for rbuff POSIX shared memory filenames") +set(SSM_FLOW_SET_PREFIX "/${SHM_PREFIX}.set." CACHE INTERNAL + "Prefix for the POSIX shared memory flow set") + +# Number of shards per size class for reducing contention +set(SSM_POOL_SHARDS 4 CACHE STRING + "Number of allocator shards per size class") +set(SSM_POOL_RECLAIM_AGE_S 60 CACHE STRING + "Minimum age in seconds before a block is presumed stale and reclaimed") + +# Global Shared Packet Pool (GSPP) - for privileged processes +# Shared by all processes in 'ouroboros' group (~60 MB total) +set(SSM_GSPP_256_BLOCKS 1024 CACHE STRING + "GSPP: Number of 256B blocks") +set(SSM_GSPP_512_BLOCKS 2048 CACHE STRING + "GSPP: Number of 512B blocks") +set(SSM_GSPP_1K_BLOCKS 512 CACHE STRING + "GSPP: Number of 1KB blocks") +set(SSM_GSPP_2K_BLOCKS 384 CACHE STRING + "GSPP: Number of 2KB blocks") +set(SSM_GSPP_4K_BLOCKS 256 CACHE STRING + "GSPP: Number of 4KB blocks") +set(SSM_GSPP_16K_BLOCKS 128 CACHE STRING + "GSPP: Number of 16KB blocks") +set(SSM_GSPP_64K_BLOCKS 64 CACHE STRING + "GSPP: Number of 64KB blocks") +set(SSM_GSPP_256K_BLOCKS 32 CACHE STRING + "GSPP: Number of 256KB blocks") +set(SSM_GSPP_1M_BLOCKS 16 CACHE STRING + "GSPP: Number of 1MB blocks") + +# Per-User Pool (PUP) - for unprivileged applications +# Each unprivileged app gets its own smaller pool (~7.5 MB total) +set(SSM_PUP_256_BLOCKS 512 CACHE STRING + "PUP: Number of 256B blocks") +set(SSM_PUP_512_BLOCKS 512 CACHE STRING + "PUP: Number of 512B blocks") +set(SSM_PUP_1K_BLOCKS 512 CACHE STRING + "PUP: Number of 1KB blocks") +set(SSM_PUP_2K_BLOCKS 512 CACHE STRING + "PUP: Number of 2KB blocks") +set(SSM_PUP_4K_BLOCKS 32 CACHE STRING + "PUP: Number of 4KB blocks") +set(SSM_PUP_16K_BLOCKS 16 CACHE STRING + "PUP: Number of 16KB blocks") +set(SSM_PUP_64K_BLOCKS 8 CACHE STRING + "PUP: Number of 64KB blocks") +set(SSM_PUP_256K_BLOCKS 2 CACHE STRING + "PUP: Number of 256KB blocks") +set(SSM_PUP_1M_BLOCKS 0 CACHE STRING + "PUP: Number of 1MB blocks") + +# Zero classes too small for spb header + HEADSPACE + TAILSPACE + 1 B. +math(EXPR _SSM_MIN_USEFUL_CLASS + "32 + ${SSM_PK_BUFF_HEADSPACE} + ${SSM_PK_BUFF_TAILSPACE}") +foreach(_pair "256:256" "512:512" "1K:1024" "2K:2048") + string(REPLACE ":" ";" _p "${_pair}") + list(GET _p 0 _suffix) + list(GET _p 1 _size) + if(_size LESS _SSM_MIN_USEFUL_CLASS) + set(SSM_GSPP_${_suffix}_BLOCKS 0) + set(SSM_PUP_${_suffix}_BLOCKS 0) + endif() +endforeach() +unset(_SSM_MIN_USEFUL_CLASS) +unset(_p) +unset(_suffix) +unset(_size) + +# SSM pool size calculations +include(utils/HumanReadable) + +math(EXPR SSM_GSPP_TOTAL_SIZE + "(1 << 8) * ${SSM_GSPP_256_BLOCKS} + \ + (1 << 9) * ${SSM_GSPP_512_BLOCKS} + \ + (1 << 10) * ${SSM_GSPP_1K_BLOCKS} + \ + (1 << 11) * ${SSM_GSPP_2K_BLOCKS} + \ + (1 << 12) * ${SSM_GSPP_4K_BLOCKS} + \ + (1 << 14) * ${SSM_GSPP_16K_BLOCKS} + \ + (1 << 16) * ${SSM_GSPP_64K_BLOCKS} + \ + (1 << 18) * ${SSM_GSPP_256K_BLOCKS} + \ + (1 << 20) * ${SSM_GSPP_1M_BLOCKS}") + +set(SSM_GSPP_TOTAL_SIZE ${SSM_GSPP_TOTAL_SIZE} CACHE INTERNAL + "GSPP total size in bytes") + +math(EXPR SSM_PUP_TOTAL_SIZE + "(1 << 8) * ${SSM_PUP_256_BLOCKS} + \ + (1 << 9) * ${SSM_PUP_512_BLOCKS} + \ + (1 << 10) * ${SSM_PUP_1K_BLOCKS} + \ + (1 << 11) * ${SSM_PUP_2K_BLOCKS} + \ + (1 << 12) * ${SSM_PUP_4K_BLOCKS} + \ + (1 << 14) * ${SSM_PUP_16K_BLOCKS} + \ + (1 << 16) * ${SSM_PUP_64K_BLOCKS} + \ + (1 << 18) * ${SSM_PUP_256K_BLOCKS} + \ + (1 << 20) * ${SSM_PUP_1M_BLOCKS}") + +set(SSM_PUP_TOTAL_SIZE ${SSM_PUP_TOTAL_SIZE} CACHE INTERNAL + "PUP total size in bytes") + +set(SSM_POOL_TOTAL_SIZE ${SSM_GSPP_TOTAL_SIZE} CACHE INTERNAL + "Total shared memory pool size in bytes") + +format_bytes_human_readable(${SSM_GSPP_TOTAL_SIZE} SSM_GSPP_SIZE_DISPLAY) +format_bytes_human_readable(${SSM_PUP_TOTAL_SIZE} SSM_PUP_SIZE_DISPLAY) + +message(STATUS "Secure Shared Memory Pool Configuration:") +message(STATUS " Pool prefix: ${SSM_PREFIX}") +message(STATUS " Size classes: " + "256B, 512B, 1KiB, 2KiB, 4KiB, 16KiB, 64KiB, 256KiB, 1MiB") +message(STATUS " Max allocation: 1 MB") +message(STATUS " Shards per class: ${SSM_POOL_SHARDS}") +message(STATUS " GSPP (privileged): ${SSM_GSPP_SIZE_DISPLAY} " + "(${SSM_GSPP_TOTAL_SIZE} bytes)") +message(STATUS " Blocks: ${SSM_GSPP_256_BLOCKS}, ${SSM_GSPP_512_BLOCKS}, " + "${SSM_GSPP_1K_BLOCKS}, ${SSM_GSPP_2K_BLOCKS}, ${SSM_GSPP_4K_BLOCKS}, " + "${SSM_GSPP_16K_BLOCKS}, ${SSM_GSPP_64K_BLOCKS}, ${SSM_GSPP_256K_BLOCKS}, " + "${SSM_GSPP_1M_BLOCKS}") +message(STATUS " PUP (unprivileged): ${SSM_PUP_SIZE_DISPLAY} " + "(${SSM_PUP_TOTAL_SIZE} bytes)") +message(STATUS " Blocks: ${SSM_PUP_256_BLOCKS}, ${SSM_PUP_512_BLOCKS}, " + "${SSM_PUP_1K_BLOCKS}, ${SSM_PUP_2K_BLOCKS}, ${SSM_PUP_4K_BLOCKS}, " + "${SSM_PUP_16K_BLOCKS}, ${SSM_PUP_64K_BLOCKS}, ${SSM_PUP_256K_BLOCKS}, " + "${SSM_PUP_1M_BLOCKS}") + +# FRCT reorder queue must fit in every enabled size class. If RQ_SIZE +# >= any backing pool, the receiver advertises a window the pool +# cannot back; np1_flow_write fails under load and a single dropped +# fragment wedges the flow. Auto-zeroed classes are skipped. +foreach(_class 256 512 1K 2K) + if(SSM_PUP_${_class}_BLOCKS GREATER 0 + AND NOT FRCT_REORDER_QUEUE_SIZE LESS SSM_PUP_${_class}_BLOCKS) + message(FATAL_ERROR + "FRCT_REORDER_QUEUE_SIZE (${FRCT_REORDER_QUEUE_SIZE}) must be " + "< SSM_PUP_${_class}_BLOCKS (${SSM_PUP_${_class}_BLOCKS}): " + "the FC window cannot exceed the pool that backs OOO stashing.") + endif() + if(SSM_GSPP_${_class}_BLOCKS GREATER 0 + AND NOT FRCT_REORDER_QUEUE_SIZE LESS SSM_GSPP_${_class}_BLOCKS) + message(FATAL_ERROR + "FRCT_REORDER_QUEUE_SIZE (${FRCT_REORDER_QUEUE_SIZE}) must be " + "< SSM_GSPP_${_class}_BLOCKS (${SSM_GSPP_${_class}_BLOCKS}).") + endif() +endforeach() diff --git a/cmake/config/tests.cmake b/cmake/config/tests.cmake new file mode 100644 index 00000000..37c06ca9 --- /dev/null +++ b/cmake/config/tests.cmake @@ -0,0 +1,17 @@ +# Test configuration options + +set(DISABLE_TESTS_LOGGING TRUE CACHE BOOL + "Disable Ouroboros log output in tests") +if(DISABLE_TESTS_LOGGING) + message(STATUS "Ouroboros logging in test output disabled") +else() + message(STATUS "Ouroboros logging in test output enabled") +endif() + +set(DISABLE_TESTS_CORE_DUMPS TRUE CACHE BOOL + "Disable core dumps for tests") +if(DISABLE_TESTS_CORE_DUMPS) + message(STATUS "Core dumps in tests disabled") +else() + message(STATUS "Core dumps in tests enabled") +endif() |
