X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Fipsec%2Fah_decrypt.c;h=0cced35b5cde4873e546367c20752bea39ff3f76;hb=154a903a958ee6459ae1019883e6c4796b4cafc7;hp=b128dfaf26bdb4edf06db03020d258985c5a7866;hpb=b966e8bfdd3c63e2436ab6e5d250c8b1bf4dd102;p=vpp.git diff --git a/src/vnet/ipsec/ah_decrypt.c b/src/vnet/ipsec/ah_decrypt.c index b128dfaf26b..0cced35b5cd 100644 --- a/src/vnet/ipsec/ah_decrypt.c +++ b/src/vnet/ipsec/ah_decrypt.c @@ -151,28 +151,17 @@ ah_decrypt_inline (vlib_main_t * vm, seq = clib_host_to_net_u32 (ah0->seq_no); /* anti-replay check */ - if (sa0->use_anti_replay) + if (ipsec_sa_anti_replay_check (sa0, &ah0->seq_no)) { - int rv = 0; - - if (PREDICT_TRUE (sa0->use_esn)) - rv = esp_replay_check_esn (sa0, seq); - else - rv = esp_replay_check (sa0, seq); - - if (PREDICT_FALSE (rv)) - { - vlib_node_increment_counter (vm, node->node_index, - AH_DECRYPT_ERROR_REPLAY, 1); - goto trace; - } + i_b0->error = node->errors[AH_DECRYPT_ERROR_REPLAY]; + goto trace; } vlib_increment_combined_counter (&ipsec_sa_counters, thread_index, sa_index0, 1, i_b0->current_length); - icv_size = sa0->integ_trunc_size; + icv_size = sa0->integ_icv_size; if (PREDICT_TRUE (sa0->integ_alg != IPSEC_INTEG_ALG_NONE)) { u8 sig[64]; @@ -207,20 +196,11 @@ ah_decrypt_inline (vlib_main_t * vm, if (PREDICT_FALSE (memcmp (digest, sig, icv_size))) { - vlib_node_increment_counter (vm, node->node_index, - AH_DECRYPT_ERROR_INTEG_ERROR, - 1); + i_b0->error = node->errors[AH_DECRYPT_ERROR_INTEG_ERROR]; goto trace; } - if (PREDICT_TRUE (sa0->use_anti_replay)) - { - if (PREDICT_TRUE (sa0->use_esn)) - esp_replay_advance_esn (sa0, seq); - else - esp_replay_advance (sa0, seq); - } - + ipsec_sa_anti_replay_advance (sa0, &ah0->seq_no); } vlib_buffer_advance (i_b0, @@ -228,7 +208,7 @@ ah_decrypt_inline (vlib_main_t * vm, icv_padding_len); i_b0->flags |= VLIB_BUFFER_TOTAL_LENGTH_VALID; - if (PREDICT_TRUE (sa0->is_tunnel)) + if (PREDICT_TRUE (ipsec_sa_is_set_IS_TUNNEL (sa0))) { /* tunnel mode */ if (PREDICT_TRUE (ah0->nexthdr == IP_PROTOCOL_IP_IN_IP)) next0 = AH_DECRYPT_NEXT_IP4_INPUT; @@ -236,9 +216,8 @@ ah_decrypt_inline (vlib_main_t * vm, next0 = AH_DECRYPT_NEXT_IP6_INPUT; else { - vlib_node_increment_counter (vm, node->node_index, - AH_DECRYPT_ERROR_DECRYPTION_FAILED, - 1); + i_b0->error = + node->errors[AH_DECRYPT_ERROR_DECRYPTION_FAILED]; goto trace; } } @@ -280,12 +259,9 @@ ah_decrypt_inline (vlib_main_t * vm, } /* for IPSec-GRE tunnel next node is ipsec-gre-input */ - if (PREDICT_FALSE - ((vnet_buffer (i_b0)->ipsec.flags) & - IPSEC_FLAG_IPSEC_GRE_TUNNEL)) + if (PREDICT_FALSE (ipsec_sa_is_set_IS_GRE (sa0))) next0 = AH_DECRYPT_NEXT_IPSEC_GRE_INPUT; - vnet_buffer (i_b0)->sw_if_index[VLIB_TX] = (u32) ~ 0; trace: if (PREDICT_FALSE (i_b0->flags & VLIB_BUFFER_IS_TRACED))