As machine byte order may vary.
Ensure TLV_PORT_STATS_NP statistics use defined order.

As most of us use little endian hardware and
 to retain backward compatible with most of us,
 we decide to use little endian for the statistics.
All other TLVs messages remain in network order.

Signed-off-by: Erez Geva <erez.geva....@siemens.com>
---
 tlv.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/tlv.c b/tlv.c
index 98ef6e1..6e919e6 100644
--- a/tlv.c
+++ b/tlv.c
@@ -324,6 +324,10 @@ static int mgt_post_recv(struct management_tlv *m, 
uint16_t data_len,
                psn = (struct port_stats_np *)m->data;
                psn->portIdentity.portNumber =
                        ntohs(psn->portIdentity.portNumber);
+               for (i = 0 ; i < MAX_MESSAGE_TYPES; i++) {
+                       psn->stats.rxMsgType[i] = 
le64_to_cpu(psn->stats.rxMsgType[i]);
+                       psn->stats.txMsgType[i] = 
le64_to_cpu(psn->stats.txMsgType[i]);
+               }
                extra_len = sizeof(struct port_stats_np);
                break;
        case TLV_SAVE_IN_NON_VOLATILE_STORAGE:
@@ -436,6 +440,10 @@ static void mgt_pre_send(struct management_tlv *m, struct 
tlv_extra *extra)
                psn = (struct port_stats_np *)m->data;
                psn->portIdentity.portNumber =
                        htons(psn->portIdentity.portNumber);
+               for (i = 0 ; i < MAX_MESSAGE_TYPES; i++) {
+                       psn->stats.rxMsgType[i] = 
cpu_to_le64(psn->stats.rxMsgType[i]);
+                       psn->stats.txMsgType[i] = 
cpu_to_le64(psn->stats.txMsgType[i]);
+               }
                break;
        }
 }
-- 
2.20.1



_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to