app/crypto-perf: fix packet length check
authorPablo de Lara <pablo.de.lara.guarch@intel.com>
Thu, 5 Oct 2017 05:28:00 +0000 (06:28 +0100)
committerPablo de Lara <pablo.de.lara.guarch@intel.com>
Thu, 12 Oct 2017 14:14:45 +0000 (15:14 +0100)
When using DES-CBC, packet size has to be multiple
of 8 bytes, but if a list of packets is provided.
the check was not correct.

Fixes: fc4600fb2520 ("app/crypto-perf: add extra option checks")
Cc: stable@dpdk.org
Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Acked-by: Radu Nicolau <radu.nicolau@intel.com>
app/test-crypto-perf/cperf_options_parsing.c

index f3508a4..af81162 100644 (file)
@@ -876,14 +876,26 @@ check_cipher_buffer_length(struct cperf_options *options)
        if (options->cipher_algo == RTE_CRYPTO_CIPHER_DES_CBC ||
                        options->cipher_algo == RTE_CRYPTO_CIPHER_3DES_CBC ||
                        options->cipher_algo == RTE_CRYPTO_CIPHER_3DES_ECB) {
-               for (buffer_size = options->min_buffer_size;
-                               buffer_size < options->max_buffer_size;
-                               buffer_size += options->inc_buffer_size) {
+               if (options->inc_buffer_size != 0)
+                       buffer_size = options->min_buffer_size;
+               else
+                       buffer_size = options->buffer_size_list[0];
+
+               while (buffer_size <= options->max_buffer_size) {
                        if ((buffer_size % DES_BLOCK_SIZE) != 0) {
                                RTE_LOG(ERR, USER1, "Some of the buffer sizes are "
                                        "not suitable for the algorithm selected\n");
                                return -EINVAL;
                        }
+
+                       if (options->inc_buffer_size != 0)
+                               buffer_size += options->inc_buffer_size;
+                       else {
+                               if (++buffer_size_idx == options->buffer_size_count)
+                                       break;
+                               buffer_size = options->buffer_size_list[buffer_size_idx];
+                       }
+
                }
        }