From: Szymon Sliwa Date: Wed, 14 Feb 2018 14:57:48 +0000 (+0100) Subject: plugins: odp: ipsec: Fix multiple issues X-Git-Url: https://gerrit.fd.io/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F56%2F10656%2F1;p=odp4vpp.git plugins: odp: ipsec: Fix multiple issues 1) added casts on assignment to post_crypto.next_index as the type of the field changed 2) removed checking result when crypto operation is asynchronous as it make no sense 3) fixed bug which could cause issues when some of the operations are done synchronously and some asynchronously Change-Id: I123d70402c0210b11dfc2d0fff2c72aa100ce838 Signed-off-by: Szymon Sliwa --- diff --git a/src/plugins/odp/ipsec/esp_decrypt.c b/src/plugins/odp/ipsec/esp_decrypt.c index 814c52bd..20b3b306 100644 --- a/src/plugins/odp/ipsec/esp_decrypt.c +++ b/src/plugins/odp/ipsec/esp_decrypt.c @@ -128,7 +128,6 @@ esp_decrypt_node_fn (vlib_main_t * vm, while (n_left_from > 0) { u32 n_left_to_next; - u32 buffers_passed = 0; vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next); @@ -317,7 +316,7 @@ esp_decrypt_node_fn (vlib_main_t * vm, goto trace; } - if (PREDICT_FALSE (!result.ok)) + if (PREDICT_FALSE (!posted && !result.ok)) { vlib_node_increment_counter (vm, odp_crypto_esp_decrypt_node.index, ESP_DECRYPT_ERROR_INTEG_ERROR, @@ -405,7 +404,7 @@ esp_decrypt_node_fn (vlib_main_t * vm, vnet_buffer (b0)->sw_if_index[VLIB_TX] = (u32) ~ 0; - vnet_buffer (b0)->post_crypto.next_index = next0; + vnet_buffer (b0)->post_crypto.next_index = (u8) next0; } trace: @@ -421,11 +420,14 @@ esp_decrypt_node_fn (vlib_main_t * vm, { vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next, n_left_to_next, bi0, next0); - buffers_passed += 1; + } + else + { + to_next -= 1; + n_left_to_next += 1; } } - if (buffers_passed > 0) - vlib_put_next_frame (vm, node, next_index, n_left_to_next); + vlib_put_next_frame (vm, node, next_index, n_left_to_next); } vlib_node_increment_counter (vm, odp_crypto_esp_decrypt_node.index, ESP_DECRYPT_ERROR_RX_PKTS, diff --git a/src/plugins/odp/ipsec/esp_encrypt.c b/src/plugins/odp/ipsec/esp_encrypt.c index 24e40185..4e1d34da 100644 --- a/src/plugins/odp/ipsec/esp_encrypt.c +++ b/src/plugins/odp/ipsec/esp_encrypt.c @@ -131,7 +131,6 @@ esp_encrypt_node_fn (vlib_main_t * vm, while (n_left_from > 0) { u32 n_left_to_next; - u32 buffers_passed = 0; vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next); @@ -379,7 +378,7 @@ esp_encrypt_node_fn (vlib_main_t * vm, b0->current_length += em->esp_integ_algs[sa0->integ_alg].trunc_size; - vnet_buffer (b0)->post_crypto.next_index = next0; + vnet_buffer (b0)->post_crypto.next_index = (u8) next0; int ret = odp_crypto_operation (&crypto_op_params, &posted, &result); @@ -430,12 +429,14 @@ esp_encrypt_node_fn (vlib_main_t * vm, vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next, n_left_to_next, bi0, next0); - buffers_passed += 1; } - + else + { + to_next -= 1; + n_left_to_next += 1; + } } - if (buffers_passed > 0) - vlib_put_next_frame (vm, node, next_index, n_left_to_next); + vlib_put_next_frame (vm, node, next_index, n_left_to_next); } vlib_node_increment_counter (vm, odp_crypto_esp_encrypt_node.index, ESP_ENCRYPT_ERROR_RX_PKTS,