vrrp: change init of vrrp key in VR lookup 92/28192/2
authorMatthew Smith <mgsmith@netgate.com>
Wed, 5 Aug 2020 22:04:06 +0000 (17:04 -0500)
committerFlorin Coras <florin.coras@gmail.com>
Fri, 7 Aug 2020 17:06:21 +0000 (17:06 +0000)
Type: fix

A struct that is used as a hash key was being initialized in its
declaration. On CentOS 8 this caused some hash lookups to fail.
This seems to be caused by uninitialized padding.

Use clib_memset() to initialize the key with 0's to avoid the issue.

Change-Id: I00555c201a1ab34133971313ba14f20f4e867a30
Signed-off-by: Matthew Smith <mgsmith@netgate.com>
src/plugins/vrrp/vrrp.h

index 9c636c4..0eda5d6 100644 (file)
@@ -230,13 +230,15 @@ always_inline vrrp_vr_t *
 vrrp_vr_lookup (u32 sw_if_index, u8 vr_id, u8 is_ipv6)
 {
   vrrp_main_t *vmp = &vrrp_main;
-  vrrp_vr_key_t key = {
-    .sw_if_index = sw_if_index,
-    .vr_id = vr_id,
-    .is_ipv6 = (is_ipv6 != 0),
-  };
+  vrrp_vr_key_t key;
   uword *p;
 
+  clib_memset (&key, 0, sizeof (key));
+
+  key.sw_if_index = sw_if_index;
+  key.vr_id = vr_id;
+  key.is_ipv6 = (is_ipv6 != 0);
+
   p = mhash_get (&vmp->vr_index_by_key, &key);
   if (p)
     return pool_elt_at_index (vmp->vrs, p[0]);