Hi, Since moving to systemd, the ethernet interfaces were renamed, so 'eth0' does not exist anymore. I replace the 'eth0' with %I following the convention of systemd. Adding a new ptp using the convention: systemctl enable ptp4l@<interface name>
I did not handle the case where PTP runs on 2 interfaces and need a different configuration, But I guess, that can be tackled easily. I was using a packet sniffer that monitor NIC hardware time stamp, so I prevent the PTP daemon to downgrade the rx time stamp filter. Erez
--- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +linuxptp (1.8-2) unstable; urgency=medium + + * support multiple interfaces and skip predefined interface name + * use the RX filter patch + + -- Erez Geva <erez.geva....@siemens.com> Wed, 30 Aug 2017 15:55:47 +0200 + linuxptp (1.8-1) unstable; urgency=medium * New upstream version 1.8 --- a/debian/rules +++ b/debian/rules @@ -1,6 +1,6 @@ #!/usr/bin/make -f -DPKG_EXPORT_BUILDFLAGS = 1 +DPKG_EXPORT_BUILDFLAGS = 2 export DEB_BUILD_MAINT_OPTIONS = hardening=+all export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed include /usr/share/dpkg/default.mk @@ -13,11 +13,11 @@ override_dh_auto_install: dh_auto_install -- prefix=/usr mandir=/usr/share/man override_dh_systemd_start: - dh_systemd_start ptp4l.service + dh_systemd_start --no-start ptp4l.service dh_systemd_start --no-start phc2sys.service dh_systemd_start --no-start timemaster.service override_dh_systemd_enable: - dh_systemd_enable ptp4l.service + dh_systemd_enable --no-enable ptp4l.service dh_systemd_enable --no-enable phc2sys.service dh_systemd_enable --no-enable timemaster.service --- a/debian/linuxptp.install +++ b/debian/linuxptp.install @@ -1,6 +1,6 @@ #!/usr/bin/dh-exec -debian/ptp4l.service /lib/systemd/system/ -debian/phc2sys.service /lib/systemd/system/ +debian/ptp4l.service => /lib/systemd/system/ptp4l@.service +debian/phc2sys.service => /lib/systemd/system/phc2sys@.service debian/timemaster.service /lib/systemd/system/ default.cfg => /etc/linuxptp/ptp4l.conf debian/timemaster.conf /etc/linuxptp/ --- a/debian/ptp4l.service +++ b/debian/ptp4l.service @@ -1,10 +1,13 @@ [Unit] Description=Precision Time Protocol (PTP) service Documentation=man:ptp4l +Wants=dev-pps0.device +After=dev-pps0.device +ConditionPathExists=/dev/pps0 [Service] Type=simple -ExecStart=/usr/sbin/ptp4l -f /etc/linuxptp/ptp4l.conf -i eth0 +ExecStart=/usr/sbin/ptp4l -f /etc/linuxptp/ptp4l.conf -i %I [Install] WantedBy=multi-user.target --- a/debian/phc2sys.service +++ b/debian/phc2sys.service @@ -2,12 +2,12 @@ Description=Synchronize system clock or PTP hardware clock (PHC) Documentation=man:phc2sys After=ntpdate.service -Requires=ptp4l.service -After=ptp4l.service +Requires=ptp4l@%I.service +After=ptp4l@%I.service [Service] Type=simple -ExecStart=/usr/sbin/phc2sys -w -s eth0 +ExecStart=/usr/sbin/phc2sys -w -s %I [Install] WantedBy=multi-user.target --- a/debian/README.Debian +++ b/debian/README.Debian @@ -5,26 +5,20 @@ 2. Systemd services -The service ptp4l invokes ptp4l on eth0 by default. To adjust the -parameters, follow these steps: +To activate the ptp4l service using the interface ifX, + invoke the following commands as root: -1. create a directory /etc/systemd/system/ptp4l.service.d +# systemctl enable ptp4l@ifX +# systemctl start ptp4l@ifX -2. place a file with its name ending in .conf there +You can invoke as a separate service for each interface you have. -3. put these lines into the file, with the parameters adjusted to your needs: +The service phc2sys syncs the system clock with the PTP clock. +It is not enabled and started by default. +To activate this service using the interface ifX, + invoke the following commands as root: -[Service] -ExecStart= -ExecStart=/usr/sbin/ptp4l -f /etc/linuxptp/ptp4l.conf -i eth0 - -The service phc2sys syncs the system clock with the PTP clock. It is not -enabled and started by default. To activate this service, invoke the -following commands as root: - -$ systemctl enable phc2sys -$ systemctl start phc2sys - -It also uses eth0 as the default and can be customized as described above. +# systemctl enable phc2sys@ifX +# systemctl start phc2sys@ifX The service timemaster also isn't enabled and started by default --- a/debian/patches/series +++ b/debian/patches/series @@ -0,0 +1 @@ +rx_filter.patch --- a/debian/patches/rx_filter.patch +++ b/debian/patches/rx_filter.patch @@ -0,0 +1,22 @@ +--- a/sk.c ++++ b/sk.c +@@ -55,8 +55,18 @@ static int hwts_init(int fd, const char *device, int rx_filter, int one_step) + strncpy(ifreq.ifr_name, device, sizeof(ifreq.ifr_name) - 1); + + ifreq.ifr_data = (void *) &cfg; ++ ++ if (ioctl(fd, SIOCGHWTSTAMP, &ifreq) < 0) ++ { ++ pr_err("ioctl SIOCGHWTSTAMP failed: %m"); ++ return -1; ++ } ++ + cfg.tx_type = one_step ? HWTSTAMP_TX_ONESTEP_SYNC : HWTSTAMP_TX_ON; +- cfg.rx_filter = rx_filter; ++ // Change rx filter only when needed ++ if (cfg.rx_filter != HWTSTAMP_FILTER_ALL && ++ cfg.rx_filter != HWTSTAMP_FILTER_PTP_V2_EVENT) ++ cfg.rx_filter = rx_filter; + req = cfg; + err = ioctl(fd, SIOCSHWTSTAMP, &ifreq); + if (err < 0)