Move check of TLV length for management COMMAND messages

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 <jbenc@redhat.com>
master
Jiri Benc 2014-03-24 09:53:18 +01:00 committed by Richard Cochran
parent 683218aee6
commit 4ed4c0ef5a
2 changed files with 9 additions and 4 deletions

View File

@ -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;

9
tlv.c
View File

@ -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)