]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
ntp: allow binding to address that doesn't exist yet
authorMiroslav Lichvar <mlichvar@redhat.com>
Mon, 4 Aug 2014 15:21:15 +0000 (17:21 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Fri, 15 Aug 2014 08:58:43 +0000 (10:58 +0200)
ntp_io.c

index 144e6da0326f65e5fc50f9fa3b6620218a3f1204..a0a670ec64c963ec881802f5eee2065a0f8528a2 100644 (file)
--- a/ntp_io.c
+++ b/ntp_io.c
@@ -190,6 +190,14 @@ prepare_socket(int family, int port_number, int client_only)
   }
 #endif
 
+#ifdef IP_FREEBIND
+  /* Allow binding to address that doesn't exist yet */
+  if (my_addr_len > 0 &&
+      setsockopt(sock_fd, IPPROTO_IP, IP_FREEBIND, (char *)&on_off, sizeof(on_off)) < 0) {
+    LOG(LOGS_ERR, LOGF_NtpIO, "Could not set free bind socket option");
+  }
+#endif
+
   if (family == AF_INET) {
 #ifdef IP_PKTINFO
     /* We want the local IP info on server sockets */