]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
ntp: add PTP rxfilter
authorMiroslav Lichvar <mlichvar@redhat.com>
Wed, 18 Aug 2021 08:44:48 +0000 (10:44 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Wed, 18 Aug 2021 14:56:09 +0000 (16:56 +0200)
Setting rxfilter to ptp enables timestamping of PTPv2 packets (UDP or
all transports). It will be needed for NTP-over-PTP support.

conf.c
conf.h
doc/chrony.conf.adoc
ntp_io_linux.c

diff --git a/conf.c b/conf.c
index ce2ff0005ee3cd5e97d8875fdd088c1ed4c8cc9a..a525278971a61f2d868ae948bdb7b491f999f56e 100644 (file)
--- a/conf.c
+++ b/conf.c
@@ -1556,6 +1556,8 @@ parse_hwtimestamp(char *line)
         iface->rxfilter = CNF_HWTS_RXFILTER_NONE;
       else if (!strcasecmp(filter, "ntp"))
         iface->rxfilter = CNF_HWTS_RXFILTER_NTP;
+      else if (!strcasecmp(filter, "ptp"))
+        iface->rxfilter = CNF_HWTS_RXFILTER_PTP;
       else if (!strcasecmp(filter, "all"))
         iface->rxfilter = CNF_HWTS_RXFILTER_ALL;
       else
diff --git a/conf.h b/conf.h
index 0ba1be1706548339dbab0c78ee5d0f9df11fd7fd..437fa9690dba9450ba02605ea13d126755eb4356 100644 (file)
--- a/conf.h
+++ b/conf.h
@@ -134,6 +134,7 @@ typedef enum {
   CNF_HWTS_RXFILTER_ANY,
   CNF_HWTS_RXFILTER_NONE,
   CNF_HWTS_RXFILTER_NTP,
+  CNF_HWTS_RXFILTER_PTP,
   CNF_HWTS_RXFILTER_ALL,
 } CNF_HwTs_RxFilter;
 
index bd4f70d07750029c95eb3acb9342d8d2ae306b36..647270beba523431fc69111b917b6adfa8a6e43a 100644 (file)
@@ -2416,6 +2416,8 @@ _all_::::
 Enables timestamping of all received packets.
 _ntp_::::
 Enables timestamping of received NTP packets.
+_ptp_::::
+Enables timestamping of received PTP packets.
 _none_::::
 Disables timestamping of received packets.
 {blank}:::
index 02b59e17beff65bfea67dffdaa1fae8afb60ddca..a458ded43b9824ee9db07fb08dc9b57266d5b646 100644 (file)
@@ -189,6 +189,14 @@ add_interface(CNF_HwTsInterface *conf_iface)
       rx_filter = HWTSTAMP_FILTER_NTP_ALL;
       break;
 #endif
+    case CNF_HWTS_RXFILTER_PTP:
+      if (ts_info.rx_filters & (1 << HWTSTAMP_FILTER_PTP_V2_L4_EVENT))
+        rx_filter = HWTSTAMP_FILTER_PTP_V2_L4_EVENT;
+      else if (ts_info.rx_filters & (1 << HWTSTAMP_FILTER_PTP_V2_EVENT))
+        rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT;
+      else
+        rx_filter = HWTSTAMP_FILTER_NONE;
+      break;
     default:
       rx_filter = HWTSTAMP_FILTER_ALL;
       break;