Setting GRANDMASTER_SETTINGS_NP is allowed only from UDS, but
PORT_DATA_SET can be set from any port. Move the port check to
clock_manage(), so all clock and port SET actions are restricted
to the UDS port.

Signed-off-by: Miroslav Lichvar <[email protected]>
---
 clock.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/clock.c b/clock.c
index 219436f..7ef2852 100644
--- a/clock.c
+++ b/clock.c
@@ -320,10 +320,6 @@ static int clock_management_set(struct clock *c, struct 
port *p,
 
        switch (id) {
        case GRANDMASTER_SETTINGS_NP:
-               if (p != c->port[c->nports]) {
-                       /* Sorry, only allowed on the UDS port. */
-                       break;
-               }
                gsn = (struct grandmaster_settings_np *) tlv->data;
                c->dds.clockQuality = gsn->clockQuality;
                c->utc_offset = gsn->utc_offset;
@@ -843,6 +839,11 @@ int clock_manage(struct clock *c, struct port *p, struct 
ptp_message *msg)
                        clock_management_send_error(p, msg, WRONG_LENGTH);
                        return changed;
                }
+               if (p != c->port[c->nports]) {
+                       /* Sorry, only allowed on the UDS port. */
+                       clock_management_send_error(p, msg, NOT_SUPPORTED);
+                       return changed;
+               }
                if (clock_management_set(c, p, mgt->id, msg, &changed))
                        return changed;
                break;
-- 
1.8.4.2


------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121054471&iu=/4140/ostg.clktrk
_______________________________________________
Linuxptp-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to