]> git.droids-corp.org - dpdk.git/commitdiff
net: fix L2TPv2 common header
authorJie Wang <jie1x.wang@intel.com>
Wed, 9 Feb 2022 09:38:53 +0000 (17:38 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Wed, 9 Feb 2022 20:30:14 +0000 (21:30 +0100)
The fields of L2TPv2 common header were reversed in big endian and
little endian.

This patch fixes this error to ensure L2TPv2 can be parsed correctly.

For L2TP reference:
https://datatracker.ietf.org/doc/html/rfc2661#section-3.1

Fixes: 3a929df1f286 ("ethdev: support L2TPv2 and PPP procotol")
Cc: stable@dpdk.org
Signed-off-by: Jie Wang <jie1x.wang@intel.com>
Acked-by: Ori Kam <orika@nvidia.com>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
lib/net/rte_l2tpv2.h

index 938a993b48b193105f49b0f0f6d6e8d1353c7522..1f3ad3f03cf3b42825359935e85bf2b0764e93cb 100644 (file)
@@ -89,16 +89,6 @@ struct rte_l2tpv2_common_hdr {
                __extension__
                struct {
 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
-                       uint16_t t:1;           /**< message Type */
-                       uint16_t l:1;           /**< length option bit */
-                       uint16_t res1:2;        /**< reserved */
-                       uint16_t s:1;           /**< ns/nr option bit */
-                       uint16_t res2:1;        /**< reserved */
-                       uint16_t o:1;           /**< offset option bit */
-                       uint16_t p:1;           /**< priority option bit */
-                       uint16_t res3:4;        /**< reserved */
-                       uint16_t ver:4;         /**< protocol version */
-#elif RTE_BYTE_ORDER == RTE_BIG_ENDIAN
                        uint16_t ver:4;         /**< protocol version */
                        uint16_t res3:4;        /**< reserved */
                        uint16_t p:1;           /**< priority option bit */
@@ -108,6 +98,16 @@ struct rte_l2tpv2_common_hdr {
                        uint16_t res1:2;        /**< reserved */
                        uint16_t l:1;           /**< length option bit */
                        uint16_t t:1;           /**< message Type */
+#elif RTE_BYTE_ORDER == RTE_BIG_ENDIAN
+                       uint16_t t:1;           /**< message Type */
+                       uint16_t l:1;           /**< length option bit */
+                       uint16_t res1:2;        /**< reserved */
+                       uint16_t s:1;           /**< ns/nr option bit */
+                       uint16_t res2:1;        /**< reserved */
+                       uint16_t o:1;           /**< offset option bit */
+                       uint16_t p:1;           /**< priority option bit */
+                       uint16_t res3:4;        /**< reserved */
+                       uint16_t ver:4;         /**< protocol version */
 #endif
                };
        };