aboutsummaryrefslogtreecommitdiff
path: root/example
diff options
context:
space:
mode:
authorMatias Elo <matias.elo@nokia.com>2020-07-01 08:20:58 +0300
committerMatias Elo <matias.elo@nokia.com>2020-07-02 09:45:43 +0300
commitd2c0b0c768308286dcd3536b6c67f067288ea750 (patch)
treed88b294540ea89164b1cbb69eca6155ff66b9c9b /example
parent5207bba074ed8070f508fbc1ae40d20dad032f5d (diff)
example: ipsec: detect failure to allocate test packets
Previously, the IPSec example tests would pass in the CI even though the tests were not properly run due to failures to allocate test input packets. Signed-off-by: Matias Elo <matias.elo@nokia.com> Reviewed-by: Janne Peltonen <janne.peltonen@nokia.com>
Diffstat (limited to 'example')
-rw-r--r--example/ipsec/odp_ipsec.c5
-rw-r--r--example/ipsec/odp_ipsec_stream.c10
-rw-r--r--example/ipsec/odp_ipsec_stream.h3
-rw-r--r--example/ipsec_api/odp_ipsec.c5
4 files changed, 19 insertions, 4 deletions
diff --git a/example/ipsec/odp_ipsec.c b/example/ipsec/odp_ipsec.c
index a50468d6e..2db4c9158 100644
--- a/example/ipsec/odp_ipsec.c
+++ b/example/ipsec/odp_ipsec.c
@@ -1326,6 +1326,10 @@ main(int argc, char *argv[])
/* If we have test streams build them before starting workers */
resolve_stream_db();
stream_count = create_stream_db_inputs();
+ if (stream_count < 0) {
+ ODPH_ERR("Error: creating input packets failed\n");
+ exit(EXIT_FAILURE);
+ }
/*
* Create and init worker threads
@@ -1632,6 +1636,7 @@ static void usage(char *progname)
"\n"
"Optional OPTIONS\n"
" -c, --count <number> CPU count, 0=all available, default=1\n"
+ " -s, --stream SrcIP:DstIP:InIntf:OutIntf:Count:Length\n"
" -h, --help Display help and exit.\n"
" environment variables: ODP_IPSEC_USE_POLL_QUEUES\n"
" to enable use of poll queues instead of scheduled (default)\n"
diff --git a/example/ipsec/odp_ipsec_stream.c b/example/ipsec/odp_ipsec_stream.c
index 23a17b634..d689c6198 100644
--- a/example/ipsec/odp_ipsec_stream.c
+++ b/example/ipsec/odp_ipsec_stream.c
@@ -562,7 +562,7 @@ int create_stream_db_inputs(void)
pkt_pool = odp_pool_lookup("packet_pool");
if (pkt_pool == ODP_POOL_INVALID) {
ODPH_ERR("Error: pkt_pool not found\n");
- exit(EXIT_FAILURE);
+ return -1;
}
if (odp_pool_info(pkt_pool, &pool_info)) {
ODPH_ERR("Error: pool info failed\n");
@@ -599,13 +599,13 @@ int create_stream_db_inputs(void)
pkt = create_ipv4_packet(stream, dmac, pkt_pool, max_len);
if (ODP_PACKET_INVALID == pkt) {
- printf("Packet buffers exhausted\n");
+ ODPH_ERR("Error: packet buffers exhausted\n");
break;
}
stream->created++;
if (odp_pktout_send(queue, &pkt, 1) != 1) {
odp_packet_free(pkt);
- printf("Queue enqueue failed\n");
+ ODPH_ERR("Error: queue enqueue failed\n");
break;
}
@@ -614,6 +614,10 @@ int create_stream_db_inputs(void)
created++;
}
}
+ if ((stream_db->index > 0) && created == 0) {
+ ODPH_ERR("Error: failed to create any input streams\n");
+ return -1;
+ }
return created;
}
diff --git a/example/ipsec/odp_ipsec_stream.h b/example/ipsec/odp_ipsec_stream.h
index 62b42a40c..b32f1d7cb 100644
--- a/example/ipsec/odp_ipsec_stream.h
+++ b/example/ipsec/odp_ipsec_stream.h
@@ -110,10 +110,11 @@ odp_bool_t verify_ipv4_packet(stream_db_entry_t *stream,
*
* Create input packets based on the configured streams and enqueue them
* into loop interface input queues. Once packet processing starts these
- * packets will be remomved and processed as if they had come from a normal
+ * packets will be removed and processed as if they had come from a normal
* packet interface.
*
* @return number of streams successfully processed
+ * @return <0 on failure
*/
int create_stream_db_inputs(void);
diff --git a/example/ipsec_api/odp_ipsec.c b/example/ipsec_api/odp_ipsec.c
index a02343467..c7ae1be4e 100644
--- a/example/ipsec_api/odp_ipsec.c
+++ b/example/ipsec_api/odp_ipsec.c
@@ -1020,6 +1020,10 @@ main(int argc, char *argv[])
/* If we have test streams build them before starting workers */
resolve_stream_db();
stream_count = create_stream_db_inputs();
+ if (stream_count < 0) {
+ ODPH_ERR("Error: creating input packets failed\n");
+ exit(EXIT_FAILURE);
+ }
/*
* Create and init worker threads
@@ -1331,6 +1335,7 @@ static void usage(char *progname)
"\n"
"Optional OPTIONS\n"
" -c, --count <number> CPU count, 0=all available, default=1\n"
+ " -s, --stream SrcIP:DstIP:InIntf:OutIntf:Count:Length\n"
" -h, --help Display help and exit.\n"
" environment variables: ODP_IPSEC_USE_POLL_QUEUES\n"
" to enable use of poll queues instead of scheduled (default)\n"