ptp-helper: Allow sync to master clock on same host

If we drop all messages with the same clock id as ours we will also
drop all messages coming from a PTP clock on our host since both clock
ids are build from the same MAC address.

At least for Linux we do not see our own messages anyway since the
network stack can well distinguish between multicast send from our
socket or from another socket on the same machine. To make sure that
this works for all supported platforms just drop delay requests since
this is the only message that is sent from the GStreamer PTP clock.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6172>
This commit is contained in:
Jochen Henneberg 2024-02-21 16:56:48 +01:00 committed by GStreamer Marge Bot
parent b5b7064419
commit c6636533d4

View file

@ -37,7 +37,7 @@ mod rand;
mod thread;
use error::{Context, Error};
use parse::{PtpClockIdentity, PtpMessagePayload, ReadBytesBEExt, WriteBytesBEExt};
use parse::{PtpClockIdentity, PtpMessagePayload, PtpMessageType, ReadBytesBEExt, WriteBytesBEExt};
use rand::rand;
/// PTP Multicast group.
@ -240,12 +240,19 @@ fn run() -> Result<(), Error> {
trace!("Received PTP message {:#?}", ptp_message);
}
if ptp_message.source_port_identity.clock_identity == u64::from_be_bytes(clock_id) {
// The delay request is the only message that is sent
// from PTP clock implementation, if others are added
// additional match arms should be added.
match ptp_message.message_type {
PtpMessageType::DELAY_REQ => {
if args.verbose {
trace!("Ignoring our own PTP message");
}
continue 'next_packet;
}
_ => (),
}
if let PtpMessagePayload::DelayResp {
requesting_port_identity: PtpClockIdentity { clock_identity, .. },
..