From 2aaae0854e0e55d9bcc86924711c67d4b7d9de6a Mon Sep 17 00:00:00 2001 From: Richard Cochran Date: Tue, 4 Dec 2012 13:25:50 +0100 Subject: [PATCH] Distinguish between get and set management requests. The code previously treated all supported request as 'get' actions and ignored the actual action field in the message. This commit makes the code look at the action field when processing the requests. Signed-off-by: Richard Cochran --- clock.c | 10 +++++----- port.c | 23 +++++++++++++++++++---- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/clock.c b/clock.c index ab7b3fd..39f378e 100644 --- a/clock.c +++ b/clock.c @@ -130,8 +130,8 @@ static void clock_freq_est_reset(struct clock *c) c->fest.count = 0; }; -static int clock_management_response(struct clock *c, struct port *p, int id, - struct ptp_message *req) +static int clock_management_get_response(struct clock *c, struct port *p, + int id, struct ptp_message *req) { int datalen = 0, err, pdulen, respond = 0; struct management_tlv *tlv; @@ -614,6 +614,9 @@ void clock_manage(struct clock *c, struct port *p, struct ptp_message *msg) switch (management_action(msg)) { case GET: + if (clock_management_get_response(c, p, mgt->id, msg)) + return; + break; case SET: case COMMAND: break; @@ -623,9 +626,6 @@ void clock_manage(struct clock *c, struct port *p, struct ptp_message *msg) return; } - if (clock_management_response(c, p, mgt->id, msg)) - return; - switch (mgt->id) { case USER_DESCRIPTION: case SAVE_IN_NON_VOLATILE_STORAGE: diff --git a/port.c b/port.c index f14ae47..15ee8d8 100644 --- a/port.c +++ b/port.c @@ -392,8 +392,9 @@ static int port_ignore(struct port *p, struct ptp_message *m) return 0; } -static int port_management_response(struct port *target, struct port *ingress, - int id, struct ptp_message *req) +static int port_management_get_response(struct port *target, + struct port *ingress, int id, + struct ptp_message *req) { int datalen = 0, err, pdulen, respond = 0; struct management_tlv *tlv; @@ -1613,9 +1614,23 @@ int port_manage(struct port *p, struct port *ingress, struct ptp_message *msg) return 0; } mgt = (struct management_tlv *) msg->management.suffix; - if (port_management_response(p, ingress, mgt->id, msg)) { - return 0; + + switch (management_action(msg)) { + case GET: + if (port_management_get_response(p, ingress, mgt->id, msg)) + return 0; + break; + case SET: + if (port_managment_error(p->portIdentity, ingress, msg, + NOT_SUPPORTED)) + pr_err("port %hu: management error failed", portnum(p)); + break; + case COMMAND: + case RESPONSE: + case ACKNOWLEDGE: + return -1; } + switch (mgt->id) { case CLOCK_DESCRIPTION: case LOG_ANNOUNCE_INTERVAL: