Signed-off-by: Jiri Benc <[email protected]>
---
clock.c | 15 ++++++++++++---
port.c | 6 +++---
port.h | 3 ++-
3 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/clock.c b/clock.c
index c5dd873e64c5..c541951dcc68 100644
--- a/clock.c
+++ b/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;
}
diff --git a/port.c b/port.c
index 390aa389adc4..e84067395f53 100644
--- a/port.c
+++ b/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,
diff --git a/port.h b/port.h
index 9d1ddc9e94a3..804e4631d00c 100644
--- a/port.h
+++ b/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);
--
1.7.6.5
------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos. Get
unparalleled scalability from the best Selenium testing platform available.
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Linuxptp-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel