diff mbox series

[ovs-dev,RFC,4/5] tun_metadata: Use OVS_ALIGNED_VAR to align opts field

Message ID 20200310152911.983479-5-toshiaki.makita1@gmail.com
State Superseded
Headers show
Series XDP offload using flow API provider | expand

Commit Message

Toshiaki Makita March 10, 2020, 3:29 p.m. UTC
In the following commit I want to include flow.h from BPF programs, but
with "clang -target bpf" with clang 9, UINTPTR_MAX somehow equals to
UINT32_MAX while the size of pointer is 8. As a result unnecessary pad
is added in struct tun_metadata in bpf code and cannot build bpf code
due to build assertion.

Use OVS_ALIGNED_VAR instead of pad. This works for clang BPF as well as
other compilers and architectures.

Signed-off-by: Toshiaki Makita <toshiaki.makita1@gmail.com>
---
 include/openvswitch/tun-metadata.h | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/include/openvswitch/tun-metadata.h b/include/openvswitch/tun-metadata.h
index dc0312ecb..1009d82e1 100644
--- a/include/openvswitch/tun-metadata.h
+++ b/include/openvswitch/tun-metadata.h
@@ -54,14 +54,10 @@  struct tun_metadata {
     } present;
     const struct tun_table *tab; /* Types & lengths for 'opts' and 'opt_map'. */
 
-#if UINTPTR_MAX == UINT32_MAX
-    uint8_t pad[4];             /* Pad to 64-bit boundary. */
-#endif
-
     union {
         uint8_t u8[TUN_METADATA_TOT_OPT_SIZE]; /* Values from tunnel TLVs. */
         struct geneve_opt gnv[TLV_TOT_OPT_SIZE / sizeof(struct geneve_opt)];
-    } opts;
+    } opts OVS_ALIGNED_VAR(8);
 };
 BUILD_ASSERT_DECL(offsetof(struct tun_metadata, opts) % 8 == 0);
 BUILD_ASSERT_DECL(sizeof(((struct tun_metadata *)0)->present.map) * 8 >=