Discussion:
[Linuxptp-devel] [PATCH 1/2] Detect and report missing delay response packets
Shawn Bohrer
2016-03-31 16:00:57 UTC
Permalink
From: Shawn Bohrer <***@rgmadvisors.com>

When we send a delay request message check to see if we received a delay
response to the previous delay request. This adds reporting of missing
responses and also reports if the sequence number of a response doesn't
match the request.

Signed-off-by: Shawn Bohrer <***@rgmadvisors.com>
---
port.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/port.c b/port.c
index 3fc262a..b4175f4 100644
--- a/port.c
+++ b/port.c
@@ -1066,8 +1066,11 @@ static int port_delay_request(struct port *p)
goto out;
}

- if (p->delay_req)
+ if (p->delay_req) {
+ pr_warning("port %hu: missed delay_resp for sequenceId: %" PRIu16,
+ portnum(p), ntohs(p->delay_req->header.sequenceId));
msg_put(p->delay_req);
+ }

p->delay_req = msg;
return 0;
@@ -1496,8 +1499,13 @@ static void process_delay_resp(struct port *p, struct ptp_message *m)
return;
if (!pid_eq(&rsp->requestingPortIdentity, &req->hdr.sourcePortIdentity))
return;
- if (rsp->hdr.sequenceId != ntohs(req->hdr.sequenceId))
+ if (rsp->hdr.sequenceId != ntohs(req->hdr.sequenceId)) {
+ pr_warning("port %hu: received delay_request sequenceId: %" PRIu16
+ " does not match delay_resp sequenceId: %" PRIu16,
+ portnum(p),
+ ntohs(req->hdr.sequenceId), rsp->hdr.sequenceId);
return;
+ }

clock_path_delay(p->clock, p->delay_req->hwts.ts, m->ts.pdu,
m->header.correction);
@@ -1509,6 +1517,8 @@ static void process_delay_resp(struct port *p, struct ptp_message *m)
portnum(p), p->logMinDelayReqInterval);
tmtab_init(&p->tmtab, 1 + p->logMinDelayReqInterval);
}
+
+ flush_delay_req(p);
}

static void process_follow_up(struct port *p, struct ptp_message *m)
--
2.2.1
Shawn Bohrer
2016-03-31 16:00:58 UTC
Permalink
From: Shawn Bohrer <***@rgmadvisors.com>

Signed-off-by: Shawn Bohrer <***@rgmadvisors.com>
---
config.c | 6 ++++++
config.h | 1 +
default.cfg | 1 +
ptp4l.8 | 4 ++++
ptp4l.c | 2 ++
udp.c | 7 +++++++
udp.h | 5 +++++
7 files changed, 26 insertions(+)

diff --git a/config.c b/config.c
index 8cae57f..2c27ac5 100644
--- a/config.c
+++ b/config.c
@@ -387,6 +387,12 @@ static enum parser_result parse_global_setting(const char *option,
for (i = 0; i < MAC_LEN; i++)
cfg->p2p_dst_mac[i] = mac[i];

+ } else if (!strcmp(option, "udp4_mcast_ttl")) {
+ r = get_ranged_int(value, &val, 1, INT_MAX);
+ if (r != PARSED_OK)
+ return r;
+ *cfg->udp4_mcast_ttl = val;
+
} else if (!strcmp(option, "udp6_scope")) {
r = get_ranged_uint(value, &uval, 0x00, 0x0F);
if (r != PARSED_OK)
diff --git a/config.h b/config.h
index 94704a4..86231ac 100644
--- a/config.h
+++ b/config.h
@@ -89,6 +89,7 @@ struct config {
unsigned char *ptp_dst_mac;
unsigned char *p2p_dst_mac;
unsigned char *udp6_scope;
+ int *udp4_mcast_ttl;

int print_level;
int use_syslog;
diff --git a/default.cfg b/default.cfg
index 72665a6..4ecf812 100644
--- a/default.cfg
+++ b/default.cfg
@@ -58,6 +58,7 @@ clock_servo pi
transportSpecific 0x0
ptp_dst_mac 01:1B:19:00:00:00
p2p_dst_mac 01:80:C2:00:00:0E
+udp4_mcast_ttl 1
udp6_scope 0x0E
#
# Default interface options
diff --git a/ptp4l.8 b/ptp4l.8
index 493626d..9551b19 100644
--- a/ptp4l.8
+++ b/ptp4l.8
@@ -348,6 +348,10 @@ Relevant only with L2 transport. The default is 01:1B:19:00:00:00.
The MAC address where should be peer delay messages the PTP peer.
Relevant only with L2 transport. The default is 01:80:C2:00:00:0E.
.TP
+.B udp4_mcast_ttl
+Specifies the time-to-live value of outgoing multicast messages.
+This option is only relevant with IPv4 transport. The default is 1.
+.TP
.B udp6_scope
Specifies the desired scope for the IPv6 multicast messages. This
will be used as the second byte of the primary address. This option
diff --git a/ptp4l.c b/ptp4l.c
index b0d1c9c..664914b 100644
--- a/ptp4l.c
+++ b/ptp4l.c
@@ -31,6 +31,7 @@
#include "raw.h"
#include "sk.h"
#include "transport.h"
+#include "udp.h"
#include "udp6.h"
#include "util.h"
#include "version.h"
@@ -111,6 +112,7 @@ static struct config cfg_settings = {
.ptp_dst_mac = ptp_dst_mac,
.p2p_dst_mac = p2p_dst_mac,
.udp6_scope = &udp6_scope,
+ .udp4_mcast_ttl = &udp4_mcast_ttl,

.print_level = LOG_INFO,
.use_syslog = 1,
diff --git a/udp.c b/udp.c
index be7f2b7..d39f83c 100644
--- a/udp.c
+++ b/udp.c
@@ -41,6 +41,8 @@
#define PTP_PRIMARY_MCAST_IPADDR "224.0.1.129"
#define PTP_PDELAY_MCAST_IPADDR "224.0.0.107"

+int udp4_mcast_ttl = 1;
+
struct udp {
struct transport t;
uint8_t ip[4];
@@ -124,6 +126,11 @@ static int open_socket(char *name, struct in_addr mc_addr[2], short port)
pr_err("setsockopt SO_BINDTODEVICE failed: %m");
goto no_option;
}
+ if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_TTL,
+ &udp4_mcast_ttl, sizeof(udp4_mcast_ttl))) {
+ pr_err("setsockopt IP_MULTICAST_TTL failed: %m");
+ goto no_option;
+ }
addr.sin_addr = mc_addr[0];
if (mcast_join(fd, index, (struct sockaddr *) &addr, sizeof(addr))) {
pr_err("mcast_join failed");
diff --git a/udp.h b/udp.h
index fc0d54d..a95922f 100644
--- a/udp.h
+++ b/udp.h
@@ -24,6 +24,11 @@
#include "transport.h"

/**
+ * The desired time-to-live value of outgoing multicast messages.
+ */
+extern int udp4_mcast_ttl;
+
+/**
* Allocate an instance of a UDP/IPv4 transport.
* @return Pointer to a new transport instance on success, NULL otherwise.
*/
--
2.2.1
Richard Cochran
2016-04-01 09:28:03 UTC
Permalink
Post by Shawn Bohrer
---
config.c | 6 ++++++
config.h | 1 +
default.cfg | 1 +
ptp4l.8 | 4 ++++
ptp4l.c | 2 ++
udp.c | 7 +++++++
udp.h | 5 +++++
7 files changed, 26 insertions(+)
Neither does this one.

Thanks,
Richard

Richard Cochran
2016-04-01 09:27:04 UTC
Permalink
Post by Shawn Bohrer
When we send a delay request message check to see if we received a delay
response to the previous delay request. This adds reporting of missing
responses and also reports if the sequence number of a response doesn't
match the request.
---
port.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
This patch doesn't apply.

Thanks,
Richard
Loading...