[v2,03/10] net: clarify endianness of 32-bit fields in VXLAN headers

Message ID 20210312110745.31721-3-ivan.malov@oktetlabs.ru (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series [v2,01/10] ethdev: reuse header definition in flow pattern item ETH |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Ivan Malov March 12, 2021, 11:07 a.m. UTC
  These fields have network byte order. Highlight it using dedicated type.

Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Reviewed-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
---
 lib/librte_net/rte_vxlan.h | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
  

Comments

Ferruh Yigit March 16, 2021, 5:34 p.m. UTC | #1
On 3/12/2021 11:07 AM, Ivan Malov wrote:
> These fields have network byte order. Highlight it using dedicated type.
> 
> Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
> Reviewed-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
> Reviewed-by: Andy Moreton <amoreton@xilinx.com>

Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
  

Patch

diff --git a/lib/librte_net/rte_vxlan.h b/lib/librte_net/rte_vxlan.h
index 2ad606165..929fa7a1d 100644
--- a/lib/librte_net/rte_vxlan.h
+++ b/lib/librte_net/rte_vxlan.h
@@ -13,6 +13,7 @@ 
 
 #include <stdint.h>
 
+#include <rte_byteorder.h>
 #include <rte_udp.h>
 
 
@@ -30,8 +31,8 @@  extern "C" {
  * Reserved fields (24 bits and 8 bits)
  */
 struct rte_vxlan_hdr {
-	uint32_t vx_flags; /**< flag (8) + Reserved (24). */
-	uint32_t vx_vni;   /**< VNI (24) + Reserved (8). */
+	rte_be32_t vx_flags; /**< flag (8) + Reserved (24). */
+	rte_be32_t vx_vni;   /**< VNI (24) + Reserved (8). */
 } __rte_packed;
 
 /** VXLAN tunnel header length. */
@@ -48,7 +49,7 @@  struct rte_vxlan_gpe_hdr {
 	uint8_t vx_flags;    /**< flag (8). */
 	uint8_t reserved[2]; /**< Reserved (16). */
 	uint8_t proto;       /**< next-protocol (8). */
-	uint32_t vx_vni;     /**< VNI (24) + Reserved (8). */
+	rte_be32_t vx_vni;   /**< VNI (24) + Reserved (8). */
 } __rte_packed;
 
 /** VXLAN-GPE tunnel header length. */