ipsec: Changes to make ipsec encoder/decoders reusable by the plugins
[vpp.git] / src / vnet / ipsec / ah_decrypt.c
index bc6b5c4..f46fa6e 100644 (file)
@@ -184,7 +184,8 @@ ah_decrypt_inline (vlib_main_t * vm,
       if (is_ip6)
        {
          ip6_ext_header_t *prev = NULL;
-         ip6_ext_header_find_t (ih6, prev, ah0, IP_PROTOCOL_IPSEC_AH);
+         ah0 =
+           ip6_ext_header_find (vm, b[0], ih6, IP_PROTOCOL_IPSEC_AH, &prev);
          pd->ip_hdr_size = sizeof (ip6_header_t);
          ASSERT ((u8 *) ah0 - (u8 *) ih6 == pd->ip_hdr_size);
        }
@@ -303,6 +304,13 @@ ah_decrypt_inline (vlib_main_t * vm,
 
       if (PREDICT_TRUE (sa0->integ_alg != IPSEC_INTEG_ALG_NONE))
        {
+         /* redo the anit-reply check. see esp_decrypt for details */
+         if (ipsec_sa_anti_replay_check (sa0, pd->seq))
+           {
+             b[0]->error = node->errors[AH_DECRYPT_ERROR_REPLAY];
+             next[0] = AH_DECRYPT_NEXT_DROP;
+             goto trace;
+           }
          ipsec_sa_anti_replay_advance (sa0, pd->seq);
        }