[PATCH v2 14/15] net/vxlan: instance flag endianness refactored
Ronan Randles
ronan.randles at intel.com
Fri Jan 21 11:31:21 CET 2022
This patch improves the setting of the instance flag in the
rte_vxlan_hdr struct, by using a byte to represent vx_flag_bits.
Previously it was exposed to the user via a rte_be32_t value, which
required handling endianness at the application level. The code uses a
union to ensure that existing code continues to work as before, while
allowing the improved more usable method to co-exist.
A new #define is introduced to represent the instance bit, which must be
set if a vxlan header contains a valid VNI field, see
https://datatracker.ietf.org/doc/html/rfc7348 for details
Signed-off-by: Ronan Randles <ronan.randles at intel.com>
---
lib/net/rte_vxlan.h | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/lib/net/rte_vxlan.h b/lib/net/rte_vxlan.h
index 929fa7a1dd..86b6d8a3ae 100644
--- a/lib/net/rte_vxlan.h
+++ b/lib/net/rte_vxlan.h
@@ -24,6 +24,7 @@ extern "C" {
/** VXLAN default port. */
#define RTE_VXLAN_DEFAULT_PORT 4789
#define RTE_VXLAN_GPE_DEFAULT_PORT 4790
+#define RTE_VXLAN_FLAGS_I (1 << 3)
/**
* VXLAN protocol header.
@@ -31,7 +32,14 @@ extern "C" {
* Reserved fields (24 bits and 8 bits)
*/
struct rte_vxlan_hdr {
- rte_be32_t vx_flags; /**< flag (8) + Reserved (24). */
+ RTE_STD_C11
+ union {
+ struct {
+ uint8_t vx_flag_bits;
+ uint8_t reserved[3];
+ };
+ rte_be32_t vx_flags; /**< flag (8) + Reserved (24). */
+ };
rte_be32_t vx_vni; /**< VNI (24) + Reserved (8). */
} __rte_packed;
--
2.25.1
More information about the dev
mailing list