net: mrp: fix definitions of MRP test packets
authorRasmus Villemoes <rasmus.villemoes@prevas.dk>
Thu, 21 Jan 2021 20:40:36 +0000 (21:40 +0100)
committerJakub Kicinski <kuba@kernel.org>
Sat, 23 Jan 2021 20:34:20 +0000 (12:34 -0800)
Wireshark says that the MRP test packets cannot be decoded - and the
reason for that is that there's a two-byte hole filled with garbage
between the "transitions" and "timestamp" members.

So Wireshark decodes the two garbage bytes and the top two bytes of
the timestamp written by the kernel as the timestamp value (which thus
fluctuates wildly), and interprets the lower two bytes of the
timestamp as a new (type, length) pair, which is of course broken.

Even though this makes the timestamp field in the struct unaligned, it
actually makes it end up on a 32 bit boundary in the frame as mandated
by the standard, since it is preceded by a two byte TLV header.

The struct definitions live under include/uapi/, but they are not
really part of any kernel<->userspace API/ABI, so fixing the
definitions by adding the packed attribute should not cause any
compatibility issues.

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Reviewed-by: Horatiu Vultur <horatiu.vultur@microchip.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
include/uapi/linux/mrp_bridge.h

index 9744773..5ce7713 100644 (file)
@@ -97,7 +97,7 @@ struct br_mrp_ring_test_hdr {
        __be16 state;
        __be16 transitions;
        __be32 timestamp;
-};
+} __attribute__((__packed__));
 
 struct br_mrp_ring_topo_hdr {
        __be16 prio;
@@ -142,7 +142,7 @@ struct br_mrp_in_test_hdr {
        __be16 state;
        __be16 transitions;
        __be32 timestamp;
-};
+} __attribute__((__packed__));
 
 struct br_mrp_in_topo_hdr {
        __u8 sa[ETH_ALEN];