Currently, it is assumed that the management TLV data of management COMMAND
messages is always empty. This is not true for the INITIALIZE command and
also for a custom command we'll be introducing.

Move the check to msg_post_recv and let it check only the TLVs defined by
the standard.

Signed-off-by: Jiri Benc <jb...@redhat.com>
---
 clock.c |    4 ----
 tlv.c   |    9 +++++++++
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/clock.c b/clock.c
index 3aa2407d0bcc..10fa4b6621c4 100644
--- a/clock.c
+++ b/clock.c
@@ -848,10 +848,6 @@ int clock_manage(struct clock *c, struct port *p, struct 
ptp_message *msg)
                        return changed;
                break;
        case COMMAND:
-               if (mgt->length != 2) {
-                       clock_management_send_error(p, msg, WRONG_LENGTH);
-                       return changed;
-               }
                break;
        default:
                return changed;
diff --git a/tlv.c b/tlv.c
index f32514ff12c8..b8cdd3959c9b 100644
--- a/tlv.c
+++ b/tlv.c
@@ -242,6 +242,15 @@ static int mgt_post_recv(struct management_tlv *m, 
uint16_t data_len,
                pdsnp->neighborPropDelayThresh = 
ntohl(pdsnp->neighborPropDelayThresh);
                pdsnp->asCapable = ntohl(pdsnp->asCapable);
                break;
+       case SAVE_IN_NON_VOLATILE_STORAGE:
+       case RESET_NON_VOLATILE_STORAGE:
+       case INITIALIZE:
+       case FAULT_LOG_RESET:
+       case ENABLE_PORT:
+       case DISABLE_PORT:
+               if (data_len != 0)
+                       goto bad_length;
+               break;
        }
        if (extra_len) {
                if (extra_len % 2)
-- 
1.7.6.5


------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to