]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- For #1300: implement sock-queue-timeout for FreeBSD as well.
authorW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Thu, 3 Jul 2025 13:54:33 +0000 (15:54 +0200)
committerW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Thu, 3 Jul 2025 13:54:33 +0000 (15:54 +0200)
doc/Changelog
doc/unbound.conf.rst
services/listen_dnsport.c
util/netevent.c

index fa29c32dda2ffd4e0ceb9903e2ad035b8e777a4a..425f36f7f8652be072fe56ec4e492dc3bc322c83 100644 (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.
index 2f1f96340b3b788e7b25ee453fa750008d77131b..c6cc91387fe2de461cceb8455829cc8f6d4eb413 100644 (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)
 
index 1c45fce3cc47be3d6f5304d4f9790749fd4d599d..b7d3d747c1aaf15d2ee0f89208d448a5e8a518af 100644 (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;
index 898db57e93908b875fab936007a0b3eb395ef205..2d2a5442017cf6442de65a549e93138c738f0ef2 100644 (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 */
                        }
                }