- For #1300: implement sock-queue-timeout for FreeBSD as well.

This commit is contained in:
W.C.A. Wijngaards 2025-07-03 15:54:33 +02:00
parent 444c839474
commit cb919d5126
4 changed files with 17 additions and 1 deletions

View file

@ -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.

View file

@ -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)

View file

@ -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;

View file

@ -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 */
}
}