]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
ntp: check PHC index before opening device
authorMiroslav Lichvar <mlichvar@redhat.com>
Mon, 21 May 2018 14:49:26 +0000 (16:49 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Fri, 25 May 2018 08:53:21 +0000 (10:53 +0200)
Apparently, it is possible for an interface to report all necessary
flags for HW timestamping without having a PHC. Check the PHC index to
avoid an error message in the system log saying that /dev/ptp-1 cannot
be opened.

ntp_io_linux.c

index 6f794c7a790cc66efc19eb6831f9164568e7975c..da39c950c0b2096dc05fa51d90323874d7adfd3e 100644 (file)
@@ -171,6 +171,12 @@ add_interface(CNF_HwTsInterface *conf_iface)
     return 0;
   }
 
+  if (ts_info.phc_index < 0) {
+    DEBUG_LOG("PHC missing on %s", req.ifr_name);
+    close(sock_fd);
+    return 0;
+  }
+
   ts_config.flags = 0;
   ts_config.tx_type = HWTSTAMP_TX_ON;