Respond with an error to management messages to non-existing ports
Signed-off-by: Jiri Benc <jbenc@redhat.com>master
parent
14742ef566
commit
ba577d7123
15
clock.c
15
clock.c
|
@ -798,7 +798,7 @@ static void clock_forward_mgmt_msg(struct clock *c, struct port *p, struct ptp_m
|
|||
|
||||
int clock_manage(struct clock *c, struct port *p, struct ptp_message *msg)
|
||||
{
|
||||
int changed = 0, i;
|
||||
int changed = 0, i, res, answers;
|
||||
struct management_tlv *mgt;
|
||||
struct ClockIdentity *tcid, wildcard = {
|
||||
{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}
|
||||
|
@ -883,9 +883,18 @@ int clock_manage(struct clock *c, struct port *p, struct ptp_message *msg)
|
|||
clock_management_send_error(p, msg, NOT_SUPPORTED);
|
||||
break;
|
||||
default:
|
||||
answers = 0;
|
||||
for (i = 0; i < c->nports; i++) {
|
||||
if (port_manage(c->port[i], p, msg))
|
||||
break;
|
||||
res = port_manage(c->port[i], p, msg);
|
||||
if (res < 0)
|
||||
return changed;
|
||||
if (res > 0)
|
||||
answers++;
|
||||
}
|
||||
if (!answers) {
|
||||
/* IEEE 1588 Interpretation #21 suggests to use
|
||||
* WRONG_VALUE for ports that do not exist */
|
||||
clock_management_send_error(p, msg, WRONG_VALUE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
6
port.c
6
port.c
|
@ -2198,11 +2198,11 @@ int port_manage(struct port *p, struct port *ingress, struct ptp_message *msg)
|
|||
switch (management_action(msg)) {
|
||||
case GET:
|
||||
if (port_management_get_response(p, ingress, mgt->id, msg))
|
||||
return 0;
|
||||
return 1;
|
||||
break;
|
||||
case SET:
|
||||
if (port_management_set(p, ingress, mgt->id, msg))
|
||||
return 0;
|
||||
return 1;
|
||||
break;
|
||||
case COMMAND:
|
||||
break;
|
||||
|
@ -2234,7 +2234,7 @@ int port_manage(struct port *p, struct port *ingress, struct ptp_message *msg)
|
|||
port_management_send_error(p, ingress, msg, NO_SUCH_ID);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int port_management_error(struct PortIdentity pid, struct port *ingress,
|
||||
|
|
3
port.h
3
port.h
|
@ -116,7 +116,8 @@ struct PortIdentity port_identity(struct port *p);
|
|||
* @param p A pointer previously obtained via port_open().
|
||||
* @param ingress The port on which 'msg' was received.
|
||||
* @param msg A management message.
|
||||
* @return Zero if the message is valid, non-zero otherwise.
|
||||
* @return 1 if the message was responded to, 0 if it did not apply
|
||||
* to the port, -1 if it was invalid.
|
||||
*/
|
||||
int port_manage(struct port *p, struct port *ingress, struct ptp_message *msg);
|
||||
|
||||
|
|
Loading…
Reference in New Issue