Bug#855834: linuxptp: default startup argument "-i eth0" should be removed

Felipe Sateler fsateler at debian.org
Wed Feb 22 13:43:26 UTC 2017


On Wed, Feb 22, 2017 at 10:31 AM, Tino Mettler <tino.mettler at tikei.de> wrote:
> On Wed, Feb 22, 2017 at 09:51:25 -0300, Felipe Sateler wrote:
>
> [...]
>
>> The readme suggests ptp4l can detect appropiate devices by itself. If
>> that is true, then there is no problem to be solved :).
>
> Hi,
>
> do you mean this?
>
> ---------------------------------------------------------------------
>    If the ethtool ioctl is available, then the ptp4l program will use
>    it in order to discover the proper PHC device.
> ---------------------------------------------------------------------

Yes, that's what I was reading.

>
> This means that ptp4l can find the proper PHC device (/dev/ptpX) that
> belongs to a certain ethernet interface (like eth0).  Before that, the
> user had to specify both the ethernet interface (-i) and the PHC device
> (-p) to use.
>
> The ethernet interface still has to be specified either on the command
> line (-i option) or in the config file.
>
> From the manual page:
>
> --------------------------------------------------------------------
>        -i interface
>               Specify  a PTP port, it may be used multiple times. At
>               least one port must be specified by this option or in
>               the configuration file.
> --------------------------------------------------------------------

OK. I don't have any clue about linuxptp, so I'm going by what I read.

>
>
>>
>> If that is not true, I suggest the following:
>>
>> 1. Convert ptp4l into a template unit, ptp4l at .service
>> 2. Change the device to be the instance:
>> ExecStart=ExecStart=/usr/sbin/ptp4l -f /etc/linuxptp/ptp4l.conf -i %i
>> 3. Do not enable the unit.
>> 4. Add a udev rule that starts the (properly instanced) service when
>> it is detected.
>>
>> You can see the ifupdown package for a similar approach: there is
>> ifup at .service, a udev rule, and a helper program (ifupdown-hotplug)
>> that determines if an instance should be started for the given device.
>
> Thanks. I don't fully understand 4. What exactly should be detected,
> and how?

A network card. A rule like the following:

SUBSYSTEM=="net", ACTION=="add|remove", RUN+="ptp-hotplug "

Will run the program /lib/udev/ptp-hotplug. In that program you should
be able to use the INTERFACE environment variable to then start the
appropriate service:

if [ -d /run/systemd/system ] ; then
  systemctl --no-block start \
   $(systemd-escape --template linuxptp at .service $INTERFACE)
  systemctl --no-block start \
   $(systemd-escape --template phc2sys at .service $INTERFACE)
fi

>
>> While I looked at the service files, I noticed you order them after
>> chrony, ntpdate and other time services. Systemd defines a standard
>> place for that, so you can replace all those alternatives with
>> `time-sync.target`.
>
> Thanks for the suggestions. Currently, I just look how Fedora sets up
> the services and do the same, so I'm always open for suggestions how to
> improve them.

Great. Hopefully the service files eventually reach upstream...

-- 

Saludos,
Felipe Sateler



More information about the pkg-multimedia-maintainers mailing list