ethernet: Copy only 6 bytes of mac address into a u64 51/25751/6
authorJon Loeliger <jdl@netgate.com>
Mon, 9 Mar 2020 18:13:35 +0000 (13:13 -0500)
committerMatthew Smith <mgsmith@netgate.com>
Wed, 18 Mar 2020 15:53:24 +0000 (15:53 +0000)
Rather than leaving 2 bytes of junk in the upper word
of a mac address represented as a u64, zero them out.
That way later compairsons stand a chance of matching
when deleting a bridge's arp termination entries.

The volatile qualifier shouldn't be needed here, but
without it the compiler removes the clib_memcpy() at -O2.
Bad compiler.  No biscuit.

Type: fix
commit: faf22cb303b65e2a6bf8dad959d7f5ee6d031c4f

Change-Id: Iebcf35fdd421293dccbcaefadef767f7e139438e
Signed-off-by: Jon Loeliger <jdl@netgate.com>
src/vnet/ethernet/mac_address.h

index 68feb39..0631ec3 100644 (file)
@@ -111,11 +111,11 @@ mac_address_is_zero (const mac_address_t * mac)
 static_always_inline u64
 mac_address_as_u64 (const mac_address_t * mac)
 {
-  u64 *as_u64;
+  volatile u64 as_u64 = 0;
 
-  as_u64 = (u64 *) mac->bytes;
+  clib_memcpy ((void *) &as_u64, mac->bytes, 6);
 
-  return (*as_u64);
+  return as_u64;
 }
 
 static_always_inline void