From 3eb19cfd8a7c03920aeecae6692048429288af88 Mon Sep 17 00:00:00 2001 From: Stefano Brivio Date: Tue, 15 Mar 2022 23:17:44 +0100 Subject: tcp, udp, util: Enforce 24-bit limit on socket numbers This should never happen, but there are no formal guarantees: ensure socket numbers are below SOCKET_MAX. Signed-off-by: Stefano Brivio --- passt.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'passt.h') diff --git a/passt.h b/passt.h index 8344fca..3a62b15 100644 --- a/passt.h +++ b/passt.h @@ -45,7 +45,9 @@ union epoll_ref; union epoll_ref { struct { int32_t proto:8, - s:24; +#define SOCKET_REF_BITS 24 +#define SOCKET_MAX (1 << SOCKET_REF_BITS) + s:SOCKET_REF_BITS; union { union tcp_epoll_ref tcp; union udp_epoll_ref udp; -- cgit v1.2.3