From: W.C.A. Wijngaards Date: Thu, 3 Jul 2025 13:54:33 +0000 (+0200) Subject: - For #1300: implement sock-queue-timeout for FreeBSD as well. X-Git-Tag: release-1.24.0rc1~64 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cb919d51269c11bad892a0c0429c602a505326bd;p=thirdparty%2Funbound.git - For #1300: implement sock-queue-timeout for FreeBSD as well. --- diff --git a/doc/Changelog b/doc/Changelog index fa29c32dd..425f36f7f 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -1,5 +1,6 @@ 3 July 2025: Wouter - Fix #1300: Is 'sock-queue-timeout' a linux only feature. + - For #1300: implement sock-queue-timeout for FreeBSD as well. 2 July 2025: Wouter - Merge #1299: Fix typos. diff --git a/doc/unbound.conf.rst b/doc/unbound.conf.rst index 2f1f96340..c6cc91387 100644 --- a/doc/unbound.conf.rst +++ b/doc/unbound.conf.rst @@ -910,7 +910,7 @@ These options are part of the **server:** clause. This could happen if the host has not been able to service the queries for a while, i.e. Unbound is not running, and then is enabled again. It uses timestamp socket options. - The socket option is available on the Linux platform. + The socket option is available on the Linux and FreeBSD platforms. Default: 0 (disabled) diff --git a/services/listen_dnsport.c b/services/listen_dnsport.c index 1c45fce3c..b7d3d747c 100644 --- a/services/listen_dnsport.c +++ b/services/listen_dnsport.c @@ -1183,6 +1183,15 @@ set_recvtimestamp(int s) return 0; } return 1; +#elif defined(SO_TIMESTAMP) && defined(SCM_TIMESTAMP) + int on = 1; + /* FreeBSD and also Linux. */ + if (setsockopt(s, SOL_SOCKET, SO_TIMESTAMP, (void*)&on, (socklen_t)sizeof(on)) < 0) { + log_err("setsockopt(..., SO_TIMESTAMP, ...) failed: %s", + strerror(errno)); + return 0; + } + return 1; #else log_err("packets timestamping is not supported on this platform"); (void)s; diff --git a/util/netevent.c b/util/netevent.c index 898db57e9..2d2a54420 100644 --- a/util/netevent.c +++ b/util/netevent.c @@ -1083,6 +1083,12 @@ comm_point_udp_ancil_callback(int fd, short event, void* arg) } else if( cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SO_TIMESTAMP) { memmove(&rep.c->recv_tv, CMSG_DATA(cmsg), sizeof(struct timeval)); +#elif defined(SO_TIMESTAMP) && defined(SCM_TIMESTAMP) + } else if( cmsg->cmsg_level == SOL_SOCKET && + cmsg->cmsg_type == SCM_TIMESTAMP) { + /* FreeBSD and also Linux. */ + memmove(&rep.c->recv_tv, CMSG_DATA(cmsg), sizeof +(struct timeval)); #endif /* HAVE_LINUX_NET_TSTAMP_H */ } }