From: Marco Schlumpp Date: Fri, 2 Feb 2024 10:07:21 +0000 (+0100) Subject: Ignore socket options not supported by LWIP X-Git-Tag: RELEASE-0.16.2~6 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=e500e1cfbcfceb1ea402e1ea8299bcaf01426abd;p=unikraft%2Flibs%2Flwip.git 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 --- 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;