summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/vnet/ip/ip4_source_and_port_range_check.c40
1 files changed, 5 insertions, 35 deletions
diff --git a/src/vnet/ip/ip4_source_and_port_range_check.c b/src/vnet/ip/ip4_source_and_port_range_check.c
index fe5c1f24309..210d5b28951 100644
--- a/src/vnet/ip/ip4_source_and_port_range_check.c
+++ b/src/vnet/ip/ip4_source_and_port_range_check.c
@@ -99,48 +99,18 @@ static inline u32
check_adj_port_range_x1 (const protocol_port_range_dpo_t * ppr_dpo,
u16 dst_port, u32 next)
{
- u16x8vec_t key;
- u16x8vec_t diff1;
- u16x8vec_t diff2;
- u16x8vec_t sum, sum_equal_diff2;
- u16 sum_nonzero, sum_equal, winner_mask;
+ u16x8 key = u16x8_splat (dst_port);
int i;
if (NULL == ppr_dpo || dst_port == 0)
return IP4_SOURCE_AND_PORT_RANGE_CHECK_NEXT_DROP;
- /* Make the obvious screw-case work. A variant also works w/ no MMX */
- if (PREDICT_FALSE (dst_port == 65535))
- {
- int j;
-
- for (i = 0;
- i < VLIB_BUFFER_PRE_DATA_SIZE / sizeof (protocol_port_range_t);
- i++)
- {
- for (j = 0; j < 8; j++)
- if (ppr_dpo->blocks[i].low.as_u16[j] == 65535)
- return next;
- }
- return IP4_SOURCE_AND_PORT_RANGE_CHECK_NEXT_DROP;
- }
-
- key.as_u16x8 = u16x8_splat (dst_port);
for (i = 0; i < ppr_dpo->n_used_blocks; i++)
- {
- diff1.as_u16x8 =
- u16x8_sub_saturate (ppr_dpo->blocks[i].low.as_u16x8, key.as_u16x8);
- diff2.as_u16x8 =
- u16x8_sub_saturate (ppr_dpo->blocks[i].hi.as_u16x8, key.as_u16x8);
- sum.as_u16x8 = diff1.as_u16x8 + diff2.as_u16x8;
- sum_equal_diff2.as_u16x8 = (sum.as_u16x8 == diff2.as_u16x8);
- sum_nonzero = ~u16x8_zero_byte_mask (sum.as_u16x8);
- sum_equal = ~u16x8_zero_byte_mask (sum_equal_diff2.as_u16x8);
- winner_mask = sum_nonzero & sum_equal;
- if (winner_mask)
- return next;
- }
+ if (!u16x8_is_all_zero ((ppr_dpo->blocks[i].low.as_u16x8 >= key) &
+ (ppr_dpo->blocks[i].hi.as_u16x8 <= key)))
+ return next;
+
return IP4_SOURCE_AND_PORT_RANGE_CHECK_NEXT_DROP;
}