acl-plugin: use clib_bihash_search_inline_2_40_8 rather than clib_bihash_search_40_8... 55/12755/2
authorAndrew Yourtchenko <ayourtch@gmail.com>
Sat, 26 May 2018 17:02:34 +0000 (19:02 +0200)
committerDamjan Marion <dmarion.lists@gmail.com>
Sun, 27 May 2018 09:25:33 +0000 (09:25 +0000)
Use inline version rather than calling the function, this gives slightly better performance.

The straighforward diff uncovered an interesting problem: the stateful ACL IPv4 unit tests would fail
for the "make test" but succeed in "make test-debug". Also, they would succeed even in "make test",
if before calling the clib_bihash_search_inline_2_40_8 we would change the code
to store the key in a temporary variable.

Debugging revealed that the generated optimized code is not what one would expect:
the zeroing of the u64s overlaying the memcpy into ipv4 value of ip46_address_t
made the optimizer not notice the latter, and think that those fields should be
always zero in the bihash, thus generating incorrect assembly for the bihash key
comparison for the ipv4 nodes.

Changing the zeroing to be non-overlapping by zeroing only the pad fields resulted
in the optimizer generating the correct code and the tests pass.

Change-Id: Ib0f55cef2b5fe70c931d17ca4dc32a5755d160cd
Signed-off-by: Andrew Yourtchenko <ayourtch@gmail.com>
src/plugins/acl/public_inlines.h
src/plugins/acl/session_inlines.h

index 3e6c95a..e7b0852 100644 (file)
@@ -270,10 +270,8 @@ acl_fill_5tuple (acl_main_t * am, vlib_buffer_t * b0, int is_ip6,
     }
   else
     {
-      p5tuple_pkt->kv.key[0] = 0;
-      p5tuple_pkt->kv.key[1] = 0;
-      p5tuple_pkt->kv.key[2] = 0;
-      p5tuple_pkt->kv.key[3] = 0;
+      ip46_address_mask_ip4(&p5tuple_pkt->addr[0]);
+      ip46_address_mask_ip4(&p5tuple_pkt->addr[1]);
       clib_memcpy (&p5tuple_pkt->addr[0].ip4,
                   get_ptr_to_offset (b0,
                                      offsetof (ip4_header_t,
index d43e550..1fc4981 100644 (file)
@@ -447,7 +447,7 @@ always_inline int
 acl_fa_find_session (acl_main_t * am, u32 sw_if_index0, fa_5tuple_t * p5tuple,
                     clib_bihash_kv_40_8_t * pvalue_sess)
 {
-  return (clib_bihash_search_40_8
+  return (clib_bihash_search_inline_2_40_8
          (&am->fa_sessions_hash, &p5tuple->kv, pvalue_sess) == 0);
 }