From e13baaa788d852d97e982057f864c839948517d4 Mon Sep 17 00:00:00 2001 From: lijinhui Date: Mon, 15 Aug 2022 17:41:39 +0800 Subject: interface: fix 4 or more interfaces equality comparison bug with xor operation using (a^a)^(b^b) Type: fix Signed-off-by: lijinhui Change-Id: I80783eed2b819a9e6fd4cee973821c9d97c285a6 --- src/vnet/ethernet/interface.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/vnet/ethernet/interface.c b/src/vnet/ethernet/interface.c index 46d4203cda1..bf2256630f0 100644 --- a/src/vnet/ethernet/interface.c +++ b/src/vnet/ethernet/interface.c @@ -527,7 +527,7 @@ simulated_ethernet_interface_tx (vlib_main_t * vm, while (n_left_from >= 4) { u32 sw_if_index0, sw_if_index1, sw_if_index2, sw_if_index3; - u32 not_all_match_config; + u32x4 xor_ifx4; /* Prefetch next iteration. */ if (PREDICT_TRUE (n_left_from >= 8)) @@ -544,12 +544,11 @@ simulated_ethernet_interface_tx (vlib_main_t * vm, sw_if_index2 = vnet_buffer (b[2])->sw_if_index[VLIB_TX]; sw_if_index3 = vnet_buffer (b[3])->sw_if_index[VLIB_TX]; - not_all_match_config = (sw_if_index0 ^ sw_if_index1) - ^ (sw_if_index2 ^ sw_if_index3); - not_all_match_config += sw_if_index0 ^ new_rx_sw_if_index; + xor_ifx4 = u32x4_gather (&sw_if_index0, &sw_if_index1, &sw_if_index2, + &sw_if_index3); /* Speed path / expected case: all pkts on the same intfc */ - if (PREDICT_TRUE (not_all_match_config == 0)) + if (PREDICT_TRUE (u32x4_is_all_equal (xor_ifx4, new_rx_sw_if_index))) { next[0] = next_index; next[1] = next_index; -- cgit 1.2.3-korg