]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
ntp: enable PKTINFO on client sockets
authorMiroslav Lichvar <mlichvar@redhat.com>
Wed, 8 Oct 2014 13:10:33 +0000 (15:10 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Wed, 8 Oct 2014 13:13:02 +0000 (15:13 +0200)
This will be useful to detect synchronization loops.

ntp_io.c

index e90f58f6d3c539f4ee325a0e7db96d966c788f21..a5828073dd26a770510be377da895d7472da734b 100644 (file)
--- a/ntp_io.c
+++ b/ntp_io.c
@@ -174,8 +174,7 @@ prepare_socket(int family, int port_number, int client_only)
   if (family == AF_INET) {
 #ifdef IP_PKTINFO
     /* We want the local IP info on server sockets */
-    if (!client_only &&
-        setsockopt(sock_fd, IPPROTO_IP, IP_PKTINFO, (char *)&on_off, sizeof(on_off)) < 0) {
+    if (setsockopt(sock_fd, IPPROTO_IP, IP_PKTINFO, (char *)&on_off, sizeof(on_off)) < 0) {
       LOG(LOGS_ERR, LOGF_NtpIO, "Could not set packet info socket option");
       /* Don't quit - we might survive anyway */
     }
@@ -190,17 +189,15 @@ prepare_socket(int family, int port_number, int client_only)
     }
 #endif
 
-    if (!client_only) {
 #ifdef IPV6_RECVPKTINFO
-      if (setsockopt(sock_fd, IPPROTO_IPV6, IPV6_RECVPKTINFO, (char *)&on_off, sizeof(on_off)) < 0) {
-        LOG(LOGS_ERR, LOGF_NtpIO, "Could not set IPv6 packet info socket option");
-      }
+    if (setsockopt(sock_fd, IPPROTO_IPV6, IPV6_RECVPKTINFO, (char *)&on_off, sizeof(on_off)) < 0) {
+      LOG(LOGS_ERR, LOGF_NtpIO, "Could not set IPv6 packet info socket option");
+    }
 #elif defined(IPV6_PKTINFO)
-      if (setsockopt(sock_fd, IPPROTO_IPV6, IPV6_PKTINFO, (char *)&on_off, sizeof(on_off)) < 0) {
-        LOG(LOGS_ERR, LOGF_NtpIO, "Could not set IPv6 packet info socket option");
-      }
-#endif
+    if (setsockopt(sock_fd, IPPROTO_IPV6, IPV6_PKTINFO, (char *)&on_off, sizeof(on_off)) < 0) {
+      LOG(LOGS_ERR, LOGF_NtpIO, "Could not set IPv6 packet info socket option");
     }
+#endif
   }
 #endif