There are two aspects.  First, on the receive path, we reply to
unicast peer delay requests in kind.  That is, if the peer sends a
unicast delay request, then reply with unicast, too, since this is
obviously what the peer expects.

Second, if configured, we transmit peer delay requests to the
specified unicast peer address.

Signed-off-by: Richard Cochran <richardcoch...@gmail.com>
---
 port.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/port.c b/port.c
index a0355dc..19d4939 100644
--- a/port.c
+++ b/port.c
@@ -40,6 +40,7 @@
 #include "tlv.h"
 #include "tmv.h"
 #include "tsproc.h"
+#include "unicast_client.h"
 #include "util.h"
 
 #define ALLOWED_LOST_RESPONSES 3
@@ -573,7 +574,11 @@ static int peer_prepare_and_send(struct port *p, struct 
ptp_message *msg,
        if (msg_pre_send(msg)) {
                return -1;
        }
-       cnt = transport_peer(p->trp, &p->fda, event, msg);
+       if (msg_unicast(msg)) {
+               cnt = transport_sendto(p->trp, &p->fda, event, msg);
+       } else {
+               cnt = transport_peer(p->trp, &p->fda, event, msg);
+       }
        if (cnt <= 0) {
                return -1;
        }
@@ -1234,6 +1239,11 @@ static int port_pdelay_request(struct port *p)
        msg->header.logMessageInterval = port_is_ieee8021as(p) ?
                p->logMinPdelayReqInterval : 0x7f;
 
+       if (unicast_client_enabled(p) && p->unicast_master_table->peer_name) {
+               msg->address = p->unicast_master_table->peer_addr.address;
+               msg->header.flagField[0] |= UNICAST;
+       }
+
        err = peer_prepare_and_send(p, msg, TRANS_EVENT);
        if (err) {
                pr_err("port %hu: send peer delay request failed", portnum(p));
@@ -1958,6 +1968,11 @@ int process_pdelay_req(struct port *p, struct 
ptp_message *m)
        }
        rsp->pdelay_resp.requestingPortIdentity = m->header.sourcePortIdentity;
 
+       if (msg_unicast(m)) {
+               rsp->address = m->address;
+               rsp->header.flagField[0] |= UNICAST;
+       }
+
        err = peer_prepare_and_send(p, rsp, event);
        if (err) {
                pr_err("port %hu: send peer delay response failed", portnum(p));
@@ -1991,6 +2006,11 @@ int process_pdelay_req(struct port *p, struct 
ptp_message *m)
        fup->pdelay_resp_fup.responseOriginTimestamp =
                tmv_to_Timestamp(rsp->hwts.ts);
 
+       if (msg_unicast(m)) {
+               fup->address = m->address;
+               fup->header.flagField[0] |= UNICAST;
+       }
+
        err = peer_prepare_and_send(p, fup, TRANS_GENERAL);
        if (err) {
                pr_err("port %hu: send pdelay_resp_fup failed", portnum(p));
-- 
2.11.0


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to