]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
ntp: check supported flags before enabling HW timestamping
authorMiroslav Lichvar <mlichvar@redhat.com>
Fri, 27 Jan 2017 10:24:45 +0000 (11:24 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Fri, 27 Jan 2017 10:35:38 +0000 (11:35 +0100)
ntp_io_linux.c

index 092aef89b820fbcc92c1d902281b32cb3d9fecf5..4a18fecb8c2ea14ead7a9f99c2df549db2d9b7a1 100644 (file)
@@ -103,7 +103,7 @@ add_interface(CNF_HwTsInterface *conf_iface)
   struct ethtool_ts_info ts_info;
   struct hwtstamp_config ts_config;
   struct ifreq req;
-  int sock_fd, if_index, phc_fd;
+  int sock_fd, if_index, phc_fd, req_hwts_flags;
   unsigned int i;
   struct Interface *iface;
 
@@ -143,6 +143,14 @@ add_interface(CNF_HwTsInterface *conf_iface)
     return 0;
   }
 
+  req_hwts_flags = SOF_TIMESTAMPING_RX_HARDWARE | SOF_TIMESTAMPING_TX_HARDWARE |
+                   SOF_TIMESTAMPING_RAW_HARDWARE;
+  if ((ts_info.so_timestamping & req_hwts_flags) != req_hwts_flags) {
+    DEBUG_LOG(LOGF_NtpIOLinux, "HW timestamping not supported on %s", req.ifr_name);
+    close(sock_fd);
+    return 0;
+  }
+
   ts_config.flags = 0;
   ts_config.tx_type = HWTSTAMP_TX_ON;
   ts_config.rx_filter = HWTSTAMP_FILTER_ALL;