From 4b1bacffe34e56775d6abb1541dfcca17bd4e8ee Mon Sep 17 00:00:00 2001 From: Mohammed Hawari Date: Wed, 31 Mar 2021 17:26:19 +0200 Subject: geneve: fix options len parsing as 32-bits words See https://tools.ietf.org/html/rfc8926 3.4. second paragraph Opt Len Change-Id: I191d835651b2fa64eeb4ec4271497cf3342554be Signed-off-by: Mohammed Hawari Type: fix --- src/plugins/geneve/geneve_packet.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/plugins/geneve') diff --git a/src/plugins/geneve/geneve_packet.h b/src/plugins/geneve/geneve_packet.h index a0d0687434c..fb21a311f12 100644 --- a/src/plugins/geneve/geneve_packet.h +++ b/src/plugins/geneve/geneve_packet.h @@ -171,14 +171,15 @@ vnet_set_geneve_version (geneve_header_t * h, u8 version) static inline u8 vnet_get_geneve_options_len (geneve_header_t * h) { - return ((h->first_word & GENEVE_OPTLEN_MASK) >> GENEVE_OPTLEN_SHIFT); + return ((h->first_word & GENEVE_OPTLEN_MASK) >> GENEVE_OPTLEN_SHIFT) << 2; } static inline void vnet_set_geneve_options_len (geneve_header_t * h, u8 len) { + ASSERT ((len & 0x3) == 0); h->first_word &= ~(GENEVE_OPTLEN_MASK); - h->first_word |= ((len << GENEVE_OPTLEN_SHIFT) & GENEVE_OPTLEN_MASK); + h->first_word |= ((len << (GENEVE_OPTLEN_SHIFT - 2)) & GENEVE_OPTLEN_MASK); } static inline u8 -- cgit 1.2.3-korg