From e500e1cfbcfceb1ea402e1ea8299bcaf01426abd Mon Sep 17 00:00:00 2001 From: Marco Schlumpp Date: Fri, 2 Feb 2024 11:07:21 +0100 Subject: [PATCH] Ignore socket options not supported by LWIP For IP_RECVERR never returning the error structures that the option enables is a valid implementation. A proper implementation would require changes to the LWIP codebase. For TCP_FASTOPEN, it would only improve the latency and therefore we can safely ignore the option. Signed-off-by: Marco Schlumpp Reviewed-by: Stefan Jumarea Reviewed-by: Mihnea Firoiu Approved-by: Razvan Deaconescu GitHub-Closes: #46 --- sockets.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sockets.c b/sockets.c index 1af7a94..3af5daa 100644 --- a/sockets.c +++ b/sockets.c @@ -209,6 +209,9 @@ lwip_posix_socket_getsockopt(posix_sock *file, int level, return ret; } +#define LINUX_SOL_TCP 6 +#define LINUX_TCP_FASTOPEN 23 + static int lwip_posix_socket_setsockopt(posix_sock *file, int level, int optname, const void *optval, socklen_t optlen) @@ -219,6 +222,11 @@ lwip_posix_socket_setsockopt(posix_sock *file, int level, lwip_fd = _lwip_getfd(file); UK_ASSERT(lwip_fd >= 0); + if ((level == LINUX_SOL_TCP && optname == LINUX_TCP_FASTOPEN) || + (level == SOL_IP && optname == IP_RECVERR)) { + /* Ignore stuff that LWIP doesn't support */ + return 0; + } ret = lwip_setsockopt(lwip_fd, level, optname, optval, optlen); if (unlikely(ret < 0)) ret = -errno; -- 2.39.5