diff options
Diffstat (limited to 'example')
34 files changed, 941 insertions, 207 deletions
diff --git a/example/cli/odp_cli.c b/example/cli/odp_cli.c index e3998129c..597d01812 100644 --- a/example/cli/odp_cli.c +++ b/example/cli/odp_cli.c @@ -88,6 +88,14 @@ static void sig_handler(int signo) shutdown_sig = 1; } +static void my_cmd(int argc, char *argv[]) +{ + odph_cli_log("%s(%d): %s\n", __FILE__, __LINE__, __func__); + + for (int i = 0; i < argc; i++) + odph_cli_log("argv[%d]: %s\n", i, argv[i]); +} + int main(int argc, char *argv[]) { signal(SIGINT, sig_handler); @@ -140,13 +148,27 @@ int main(int argc, char *argv[]) if (opt.port) cli_param.port = opt.port; + /* Initialize CLI helper. */ + if (odph_cli_init(inst, &cli_param)) { + ODPH_ERR("CLI helper initialization failed.\n"); + exit(EXIT_FAILURE); + } + + /* Register user command. */ + if (odph_cli_register_command("my_command", my_cmd, + "Example user command.")) { + ODPH_ERR("Registering user command failed.\n"); + exit(EXIT_FAILURE); + } + /* Start CLI server. */ - if (odph_cli_start(inst, &cli_param)) { + if (odph_cli_start()) { ODPH_ERR("CLI start failed.\n"); exit(EXIT_FAILURE); } - printf("CLI server started on %s:%d\n", cli_param.address, cli_param.port); + printf("CLI server started on %s:%d\n", cli_param.address, + cli_param.port); /* Wait for the given number of seconds. */ for (int i = 0; (opt.time < 0 || i < opt.time) && !shutdown_sig; i++) @@ -160,6 +182,12 @@ int main(int argc, char *argv[]) exit(EXIT_FAILURE); } + /* Terminate CLI helper. */ + if (odph_cli_term()) { + ODPH_ERR("CLI helper termination failed.\n"); + exit(EXIT_FAILURE); + } + /* Terminate ODP. */ if (odp_term_local()) { diff --git a/example/debug/odp_debug.c b/example/debug/odp_debug.c index 48591134a..24364a688 100644 --- a/example/debug/odp_debug.c +++ b/example/debug/odp_debug.c @@ -346,6 +346,7 @@ static int timer_debug(void) odp_pool_t pool; odp_pool_param_t pool_param; odp_timeout_t timeout; + odp_timer_res_capability_t timer_res_capa; odp_timer_capability_t timer_capa; odp_timer_pool_t timer_pool; odp_timer_pool_param_t timer_param; @@ -374,7 +375,7 @@ static int timer_debug(void) return -1; } - if (odp_timer_capability(ODP_CLOCK_CPU, &timer_capa)) { + if (odp_timer_capability(ODP_CLOCK_DEFAULT, &timer_capa)) { ODPH_ERR("Timer capa failed\n"); return -1; } @@ -382,15 +383,22 @@ static int timer_debug(void) if (timer_capa.max_tmo.max_tmo < max_tmo) max_tmo = timer_capa.max_tmo.max_tmo; - if (timer_capa.max_tmo.res_ns > res) - res = timer_capa.max_tmo.res_ns; + memset(&timer_res_capa, 0, sizeof(odp_timer_res_capability_t)); + timer_res_capa.max_tmo = max_tmo; + if (odp_timer_res_capability(ODP_CLOCK_DEFAULT, &timer_res_capa)) { + ODPH_ERR("Timer resolution capability failed\n"); + return -1; + } + + if (timer_res_capa.res_ns > res) + res = timer_res_capa.res_ns; memset(&timer_param, 0, sizeof(timer_param)); timer_param.res_ns = res; timer_param.min_tmo = max_tmo / 10; timer_param.max_tmo = max_tmo; timer_param.num_timers = 10; - timer_param.clk_src = ODP_CLOCK_CPU; + timer_param.clk_src = ODP_CLOCK_DEFAULT; timer_pool = odp_timer_pool_create("debug_timer", &timer_param); diff --git a/example/ipfragreass/odp_ipfragreass_reassemble.c b/example/ipfragreass/odp_ipfragreass_reassemble.c index 35742d3a5..fba900f7a 100644 --- a/example/ipfragreass/odp_ipfragreass_reassemble.c +++ b/example/ipfragreass/odp_ipfragreass_reassemble.c @@ -303,11 +303,17 @@ static int send_packet(struct packet *tail, odp_queue_t out) */ while (current && equal_flow(current, &result)) { struct packet new_result = *current; - int concat_success; + int concat_success, trunc_success; current = prev_packet(new_result); header = odp_packet_data(result.handle); - odp_packet_pull_head(result.handle, ipv4hdr_ihl(*header)); + trunc_success = odp_packet_trunc_head(&result.handle, ipv4hdr_ihl(*header), + NULL, NULL); + if (trunc_success < 0) { + fprintf(stderr, "ERROR: odp_packet_trunc_head\n"); + return -1; + } + concat_success = odp_packet_concat(&new_result.handle, result.handle); if (concat_success < 0) { diff --git a/example/ipsec_api/.gitignore b/example/ipsec_api/.gitignore index 78ef1173c..77f399c54 100644 --- a/example/ipsec_api/.gitignore +++ b/example/ipsec_api/.gitignore @@ -1 +1,2 @@ odp_ipsec_api +pktio_env diff --git a/example/ipsec_api/Makefile.am b/example/ipsec_api/Makefile.am index b3621fcd2..05471008d 100644 --- a/example/ipsec_api/Makefile.am +++ b/example/ipsec_api/Makefile.am @@ -2,18 +2,31 @@ include $(top_srcdir)/example/Makefile.inc bin_PROGRAMS = odp_ipsec_api -dist_check_SCRIPTS = \ - odp_ipsec_api_run_ah_in.sh \ - odp_ipsec_api_run_ah_out.sh \ - odp_ipsec_api_run_ah_tun_in.sh \ - odp_ipsec_api_run_ah_tun_out.sh \ - odp_ipsec_api_run_esp_in.sh \ - odp_ipsec_api_run_esp_out.sh \ - odp_ipsec_api_run_esp_tun_in.sh \ - odp_ipsec_api_run_esp_tun_out.sh \ - odp_ipsec_api_run_live.sh \ - odp_ipsec_api_run_router.sh \ - odp_ipsec_api_run_simple.sh +if test_example +TESTS = \ + odp_ipsec_api_run_ah_in.sh \ + odp_ipsec_api_run_ah_out.sh \ + odp_ipsec_api_run_ah_tun_in.sh \ + odp_ipsec_api_run_ah_tun_out.sh \ + odp_ipsec_api_run_esp_in.sh \ + odp_ipsec_api_run_esp_out.sh \ + odp_ipsec_api_run_esp_tun_in.sh \ + odp_ipsec_api_run_esp_tun_out.sh \ + odp_ipsec_api_run_simple.sh +endif + +EXTRA_DIST = \ + odp_ipsec_api_run_ah_in.sh \ + odp_ipsec_api_run_ah_out.sh \ + odp_ipsec_api_run_ah_tun_in.sh \ + odp_ipsec_api_run_ah_tun_out.sh \ + odp_ipsec_api_run_esp_in.sh \ + odp_ipsec_api_run_esp_out.sh \ + odp_ipsec_api_run_esp_tun_in.sh \ + odp_ipsec_api_run_esp_tun_out.sh \ + odp_ipsec_api_run_live.sh \ + odp_ipsec_api_run_router.sh \ + odp_ipsec_api_run_simple.sh odp_ipsec_api_SOURCES = \ odp_ipsec.c \ @@ -45,16 +58,17 @@ endif # So copy all script and data files explicitly here. all-local: if [ "x$(srcdir)" != "x$(builddir)" ]; then \ - for f in $(dist_check_SCRIPTS); do \ + for f in $(EXTRA_DIST); do \ if [ -e $(srcdir)/$$f ]; then \ mkdir -p $(builddir)/$$(dirname $$f); \ cp -f $(srcdir)/$$f $(builddir)/$$f; \ fi \ done \ fi + ln -f -s ../../platform/$(with_platform)/test/example/ipsec_api/pktio_env pktio_env clean-local: if [ "x$(srcdir)" != "x$(builddir)" ]; then \ - for f in $(dist_check_SCRIPTS); do \ + for f in $(EXTRA_DIST); do \ rm -f $(builddir)/$$f; \ done \ fi diff --git a/example/ipsec_api/odp_ipsec.c b/example/ipsec_api/odp_ipsec.c index 98e31d6ce..d23eeb2c6 100644 --- a/example/ipsec_api/odp_ipsec.c +++ b/example/ipsec_api/odp_ipsec.c @@ -640,11 +640,20 @@ pkt_disposition_e do_ipsec_in_classify(odp_packet_t *ppkt) return PKT_POSTED; } else { int out = 1; + odp_ipsec_packet_result_t result; rc = odp_ipsec_in(ppkt, 1, ppkt, &out, &in_param); if (rc <= 0) return PKT_DROP; + if (odp_ipsec_result(&result, *ppkt) < 0) { + ODPH_DBG("odp_ipsec_result() failed\n"); + return PKT_DROP; + } + if (result.status.error.all != 0) { + ODPH_DBG("Error in inbound IPsec processing\n"); + return PKT_DROP; + } return PKT_CONTINUE; } } @@ -704,11 +713,20 @@ pkt_disposition_e do_ipsec_out_classify(odp_packet_t *ppkt, pkt_ctx_t *ctx) return PKT_POSTED; } else { int out = 1; + odp_ipsec_packet_result_t result; rc = odp_ipsec_out(ppkt, 1, ppkt, &out, &out_param); if (rc <= 0) return PKT_DROP; + if (odp_ipsec_result(&result, *ppkt) < 0) { + ODPH_DBG("odp_ipsec_result() failed\n"); + return PKT_DROP; + } + if (result.status.error.all != 0) { + ODPH_DBG("Error in outbound IPsec processing\n"); + return PKT_DROP; + } return PKT_CONTINUE; } } diff --git a/example/ipsec_api/odp_ipsec_api_run_ah_in.sh b/example/ipsec_api/odp_ipsec_api_run_ah_in.sh index 22a56f380..3aa8ea577 100755 --- a/example/ipsec_api/odp_ipsec_api_run_ah_in.sh +++ b/example/ipsec_api/odp_ipsec_api_run_ah_in.sh @@ -4,9 +4,36 @@ # - 2 loop interfaces # - 10 packets # - Specify API mode on command line -./odp_ipsec_api -i loop1,loop2 \ --r 192.168.111.2/32,loop1,08:00:27:76:B5:E0 \ --p 192.168.222.0/24,192.168.111.0/24,in,ah \ --a 192.168.222.2,192.168.111.2,md5,300,27f6d123d7077b361662fc6e451f65d8 \ --s 192.168.222.2,192.168.111.2,loop2,loop1,10,100 \ --c 2 "$@" + +# IPSEC_APP_MODE: 0 - STANDALONE, 1 - LIVE, 2 - ROUTER +IPSEC_APP_MODE=0 + +if [ -f ./pktio_env ]; then + . ./pktio_env +else + echo "BUG: unable to find pktio_env!" + echo "pktio_env has to be in current directory" + exit 1 +fi + +setup_interfaces + +./odp_ipsec_api -i $IF_LIST \ + -r 192.168.111.2/32,$ROUTE_IF_INB,08:00:27:76:B5:E0 \ + -p 192.168.222.0/24,192.168.111.0/24,in,ah \ + -a 192.168.222.2,192.168.111.2,md5,300,27f6d123d7077b361662fc6e451f65d8 \ + -s 192.168.222.2,192.168.111.2,$OUT_IF,$IN_IF,10,100 \ + -c 2 "$@" + +STATUS=$? + +if [ ${STATUS} -ne 0 ]; then + echo "Error: status ${STATUS}" + exit 1 +fi + +validate_result + +cleanup_interfaces + +exit 0 diff --git a/example/ipsec_api/odp_ipsec_api_run_ah_out.sh b/example/ipsec_api/odp_ipsec_api_run_ah_out.sh index 8194485a4..2712da52a 100755 --- a/example/ipsec_api/odp_ipsec_api_run_ah_out.sh +++ b/example/ipsec_api/odp_ipsec_api_run_ah_out.sh @@ -4,9 +4,36 @@ # - 2 loop interfaces # - 10 packets # - Specify API mode on command line -./odp_ipsec_api -i loop1,loop2 \ --r 192.168.222.2/32,loop2,08:00:27:F5:8B:DB \ --p 192.168.111.0/24,192.168.222.0/24,out,ah \ --a 192.168.111.2,192.168.222.2,md5,200,a731649644c5dee92cbd9c2e7e188ee6 \ --s 192.168.111.2,192.168.222.2,loop1,loop2,10,100 \ --c 2 "$@" + +# IPSEC_APP_MODE: 0 - STANDALONE, 1 - LIVE, 2 - ROUTER +IPSEC_APP_MODE=0 + +if [ -f ./pktio_env ]; then + . ./pktio_env +else + echo "BUG: unable to find pktio_env!" + echo "pktio_env has to be in current directory" + exit 1 +fi + +setup_interfaces + +./odp_ipsec_api -i $IF_LIST \ + -r 192.168.222.2/32,$ROUTE_IF_OUTB,08:00:27:F5:8B:DB \ + -p 192.168.111.0/24,192.168.222.0/24,out,ah \ + -a 192.168.111.2,192.168.222.2,md5,200,a731649644c5dee92cbd9c2e7e188ee6 \ + -s 192.168.111.2,192.168.222.2,$IN_IF,$OUT_IF,10,100 \ + -c 2 "$@" + +STATUS=$? + +if [ ${STATUS} -ne 0 ]; then + echo "Error: status ${STATUS}" + exit 1 +fi + +validate_result + +cleanup_interfaces + +exit 0 diff --git a/example/ipsec_api/odp_ipsec_api_run_ah_tun_in.sh b/example/ipsec_api/odp_ipsec_api_run_ah_tun_in.sh index 89331bbea..f6efc3869 100755 --- a/example/ipsec_api/odp_ipsec_api_run_ah_tun_in.sh +++ b/example/ipsec_api/odp_ipsec_api_run_ah_tun_in.sh @@ -4,10 +4,37 @@ # - 2 loop interfaces # - 10 packets # - Specify API mode on command line -./odp_ipsec_api -i loop1,loop2 \ --r 192.168.111.2/32,loop1,08:00:27:76:B5:E0 \ --p 192.168.222.0/24,192.168.111.0/24,in,ah \ --a 192.168.222.2,192.168.111.2,md5,300,27f6d123d7077b361662fc6e451f65d8 \ --t 192.168.222.2,192.168.111.2,10.0.222.2,10.0.111.2 \ --s 192.168.222.2,192.168.111.2,loop2,loop1,10,100 \ --c 2 "$@" + +# IPSEC_APP_MODE: 0 - STANDALONE, 1 - LIVE, 2 - ROUTER +IPSEC_APP_MODE=0 + +if [ -f ./pktio_env ]; then + . ./pktio_env +else + echo "BUG: unable to find pktio_env!" + echo "pktio_env has to be in current directory" + exit 1 +fi + +setup_interfaces + +./odp_ipsec_api -i $IF_LIST \ + -r 192.168.111.2/32,$ROUTE_IF_INB,08:00:27:76:B5:E0 \ + -p 192.168.222.0/24,192.168.111.0/24,in,ah \ + -a 192.168.222.2,192.168.111.2,md5,300,27f6d123d7077b361662fc6e451f65d8 \ + -t 192.168.222.2,192.168.111.2,10.0.222.2,10.0.111.2 \ + -s 192.168.222.2,192.168.111.2,$OUT_IF,$IN_IF,10,100 \ + -c 2 "$@" + +STATUS=$? + +if [ ${STATUS} -ne 0 ]; then + echo "Error: status ${STATUS}" + exit 1 +fi + +validate_result + +cleanup_interfaces + +exit 0 diff --git a/example/ipsec_api/odp_ipsec_api_run_ah_tun_out.sh b/example/ipsec_api/odp_ipsec_api_run_ah_tun_out.sh index bd15f5956..ec888d314 100755 --- a/example/ipsec_api/odp_ipsec_api_run_ah_tun_out.sh +++ b/example/ipsec_api/odp_ipsec_api_run_ah_tun_out.sh @@ -4,10 +4,37 @@ # - 2 loop interfaces # - 10 packets # - Specify API mode on command line -./odp_ipsec_api -i loop1,loop2 \ --r 192.168.222.2/32,loop2,08:00:27:F5:8B:DB \ --p 192.168.111.0/24,192.168.222.0/24,out,ah \ --a 192.168.111.2,192.168.222.2,md5,200,a731649644c5dee92cbd9c2e7e188ee6 \ --t 192.168.111.2,192.168.222.2,10.0.111.2,10.0.222.2 \ --s 192.168.111.2,192.168.222.2,loop1,loop2,10,100 \ --c 2 "$@" + +# IPSEC_APP_MODE: 0 - STANDALONE, 1 - LIVE, 2 - ROUTER +IPSEC_APP_MODE=0 + +if [ -f ./pktio_env ]; then + . ./pktio_env +else + echo "BUG: unable to find pktio_env!" + echo "pktio_env has to be in current directory" + exit 1 +fi + +setup_interfaces + +./odp_ipsec_api -i $IF_LIST \ + -r 192.168.222.2/32,$ROUTE_IF_OUTB,08:00:27:F5:8B:DB \ + -p 192.168.111.0/24,192.168.222.0/24,out,ah \ + -a 192.168.111.2,192.168.222.2,md5,200,a731649644c5dee92cbd9c2e7e188ee6 \ + -t 192.168.111.2,192.168.222.2,10.0.111.2,10.0.222.2 \ + -s 192.168.111.2,192.168.222.2,$IN_IF,$OUT_IF,10,100 \ + -c 2 "$@" + +STATUS=$? + +if [ ${STATUS} -ne 0 ]; then + echo "Error: status ${STATUS}" + exit 1 +fi + +validate_result + +cleanup_interfaces + +exit 0 diff --git a/example/ipsec_api/odp_ipsec_api_run_esp_in.sh b/example/ipsec_api/odp_ipsec_api_run_esp_in.sh index 61873bf76..1c3414498 100755 --- a/example/ipsec_api/odp_ipsec_api_run_esp_in.sh +++ b/example/ipsec_api/odp_ipsec_api_run_esp_in.sh @@ -4,10 +4,36 @@ # - 2 loop interfaces # - 10 packets # - Specify API mode on command line -./odp_ipsec_api -i loop1,loop2 \ --r 192.168.111.2/32,loop1,08:00:27:76:B5:E0 \ --p 192.168.222.0/24,192.168.111.0/24,in,esp \ --e 192.168.222.2,192.168.111.2,\ -3des,301,c966199f24d095f3990a320d749056401e82b26570320292 \ --s 192.168.222.2,192.168.111.2,loop2,loop1,10,100 \ --c 2 "$@" + +# IPSEC_APP_MODE: 0 - STANDALONE, 1 - LIVE, 2 - ROUTER +IPSEC_APP_MODE=0 + +if [ -f ./pktio_env ]; then + . ./pktio_env +else + echo "BUG: unable to find pktio_env!" + echo "pktio_env has to be in current directory" + exit 1 +fi + +setup_interfaces + +./odp_ipsec_api -i $IF_LIST \ + -r 192.168.111.2/32,$ROUTE_IF_INB,08:00:27:76:B5:E0 \ + -p 192.168.222.0/24,192.168.111.0/24,in,esp \ + -e 192.168.222.2,192.168.111.2,3des,301,c966199f24d095f3990a320d749056401e82b26570320292 \ + -s 192.168.222.2,192.168.111.2,$OUT_IF,$IN_IF,10,100 \ + -c 2 "$@" + +STATUS=$? + +if [ ${STATUS} -ne 0 ]; then + echo "Error: status ${STATUS}" + exit 1 +fi + +validate_result + +cleanup_interfaces + +exit 0 diff --git a/example/ipsec_api/odp_ipsec_api_run_esp_out.sh b/example/ipsec_api/odp_ipsec_api_run_esp_out.sh index 834daa4cc..c9809e8ac 100755 --- a/example/ipsec_api/odp_ipsec_api_run_esp_out.sh +++ b/example/ipsec_api/odp_ipsec_api_run_esp_out.sh @@ -5,14 +5,39 @@ # - 10 packets # - Specify API mode on command line +# IPSEC_APP_MODE: 0 - STANDALONE, 1 - LIVE, 2 - ROUTER +IPSEC_APP_MODE=0 + +if [ -f ./pktio_env ]; then + . ./pktio_env +else + echo "BUG: unable to find pktio_env!" + echo "pktio_env has to be in current directory" + exit 1 +fi + +setup_interfaces + if [ -z "$IPSEC_EXAMPLE_PATH" ]; then IPSEC_EXAMPLE_PATH=. fi -${IPSEC_EXAMPLE_PATH}/odp_ipsec_api -i loop1,loop2 \ --r 192.168.222.2/32,loop2,08:00:27:F5:8B:DB \ --p 192.168.111.0/24,192.168.222.0/24,out,esp \ --e 192.168.111.2,192.168.222.2,\ -3des,201,656c8523255ccc23a66c1917aa0cf30991fce83532a4b224 \ --s 192.168.111.2,192.168.222.2,loop1,loop2,10,100 \ --c 2 "$@" +${IPSEC_EXAMPLE_PATH}/odp_ipsec_api -i $IF_LIST \ + -r 192.168.222.2/32,$ROUTE_IF_OUTB,08:00:27:F5:8B:DB \ + -p 192.168.111.0/24,192.168.222.0/24,out,esp \ + -e 192.168.111.2,192.168.222.2,3des,201,656c8523255ccc23a66c1917aa0cf30991fce83532a4b224 \ + -s 192.168.111.2,192.168.222.2,$IN_IF,$OUT_IF,10,100 \ + -c 2 "$@" + +STATUS=$? + +if [ ${STATUS} -ne 0 ]; then + echo "Error: status ${STATUS}" + exit 1 +fi + +validate_result + +cleanup_interfaces + +exit 0 diff --git a/example/ipsec_api/odp_ipsec_api_run_esp_tun_in.sh b/example/ipsec_api/odp_ipsec_api_run_esp_tun_in.sh index 42be4559f..3b4f91e41 100755 --- a/example/ipsec_api/odp_ipsec_api_run_esp_tun_in.sh +++ b/example/ipsec_api/odp_ipsec_api_run_esp_tun_in.sh @@ -4,11 +4,37 @@ # - 2 loop interfaces # - 10 packets # - Specify API mode on command line -./odp_ipsec_api -i loop1,loop2 \ --r 192.168.111.2/32,loop1,08:00:27:76:B5:E0 \ --p 192.168.222.0/24,192.168.111.0/24,in,esp \ --e 192.168.222.2,192.168.111.2,\ -3des,301,c966199f24d095f3990a320d749056401e82b26570320292 \ --t 192.168.222.2,192.168.111.2,10.0.222.2,10.0.111.2 \ --s 192.168.222.2,192.168.111.2,loop2,loop1,10,100 \ --c 2 "$@" + +# IPSEC_APP_MODE: 0 - STANDALONE, 1 - LIVE, 2 - ROUTER +IPSEC_APP_MODE=0 + +if [ -f ./pktio_env ]; then + . ./pktio_env +else + echo "BUG: unable to find pktio_env!" + echo "pktio_env has to be in current directory" + exit 1 +fi + +setup_interfaces + +./odp_ipsec_api -i $IF_LIST \ + -r 192.168.111.2/32,$ROUTE_IF_INB,08:00:27:76:B5:E0 \ + -p 192.168.222.0/24,192.168.111.0/24,in,esp \ + -e 192.168.222.2,192.168.111.2,3des,301,c966199f24d095f3990a320d749056401e82b26570320292 \ + -t 192.168.222.2,192.168.111.2,10.0.222.2,10.0.111.2 \ + -s 192.168.222.2,192.168.111.2,$OUT_IF,$IN_IF,10,100 \ + -c 2 "$@" + +STATUS=$? + +if [ ${STATUS} -ne 0 ]; then + echo "Error: status ${STATUS}" + exit 1 +fi + +validate_result + +cleanup_interfaces + +exit 0 diff --git a/example/ipsec_api/odp_ipsec_api_run_esp_tun_out.sh b/example/ipsec_api/odp_ipsec_api_run_esp_tun_out.sh index 7b0c42bcb..a4c62e226 100755 --- a/example/ipsec_api/odp_ipsec_api_run_esp_tun_out.sh +++ b/example/ipsec_api/odp_ipsec_api_run_esp_tun_out.sh @@ -4,10 +4,36 @@ # - 2 loop interfaces # - 10 packets # - Specify API mode on command line -./odp_ipsec_api -i loop1,loop2 \ --r 192.168.222.2/32,loop2,08:00:27:F5:8B:DB \ --p 192.168.111.0/24,192.168.222.0/24,out,esp \ --e 192.168.111.2,192.168.222.2,\ -3des,201,656c8523255ccc23a66c1917aa0cf30991fce83532a4b224 \ --s 192.168.111.2,192.168.222.2,loop1,loop2,10,100 \ --c 2 "$@" + +# IPSEC_APP_MODE: 0 - STANDALONE, 1 - LIVE, 2 - ROUTER +IPSEC_APP_MODE=0 + +if [ -f ./pktio_env ]; then + . ./pktio_env +else + echo "BUG: unable to find pktio_env!" + echo "pktio_env has to be in current directory" + exit 1 +fi + +setup_interfaces + +./odp_ipsec_api -i $IF_LIST \ + -r 192.168.222.2/32,$ROUTE_IF_OUTB,08:00:27:F5:8B:DB \ + -p 192.168.111.0/24,192.168.222.0/24,out,esp \ + -e 192.168.111.2,192.168.222.2,3des,201,656c8523255ccc23a66c1917aa0cf30991fce83532a4b224 \ + -s 192.168.111.2,192.168.222.2,$IN_IF,$OUT_IF,10,100 \ + -c 2 "$@" + +STATUS=$? + +if [ ${STATUS} -ne 0 ]; then + echo "Error: status ${STATUS}" + exit 1 +fi + +validate_result + +cleanup_interfaces + +exit 0 diff --git a/example/ipsec_api/odp_ipsec_api_run_live.sh b/example/ipsec_api/odp_ipsec_api_run_live.sh index 318e640fe..da8523485 100755 --- a/example/ipsec_api/odp_ipsec_api_run_live.sh +++ b/example/ipsec_api/odp_ipsec_api_run_live.sh @@ -3,13 +3,59 @@ # Live router test # - 2 interfaces interfaces # - Specify API mode on command line -sudo ./odp_ipsec_api -i p7p1,p8p1 \ --r 192.168.111.2/32,p7p1,08:00:27:76:B5:E0 \ --r 192.168.222.2/32,p8p1,08:00:27:F5:8B:DB \ --p 192.168.111.0/24,192.168.222.0/24,out,esp \ --e 192.168.111.2,192.168.222.2,\ -3des,201,656c8523255ccc23a66c1917aa0cf30991fce83532a4b224 \ --p 192.168.222.0/24,192.168.111.0/24,in,esp \ --e 192.168.222.2,192.168.111.2,\ -3des,301,c966199f24d095f3990a320d749056401e82b26570320292 \ --c 2 "$@" + +# IPSEC_APP_MODE: 0 - STANDALONE, 1 - LIVE, 2 - ROUTER +IPSEC_APP_MODE=1 + +if [ -f ./pktio_env ]; then + . ./pktio_env +else + echo "BUG: unable to find pktio_env!" + echo "pktio_env has to be in current directory" + exit 1 +fi + +setup_interfaces + +# this just turns off output buffering so that you still get periodic +# output while piping to tee, as long as stdbuf is available. +STDBUF="`which stdbuf 2>/dev/null` -o 0" || STDBUF= +LOG=odp_ipsec_api_tmp.log +PID=app_pid + +($STDBUF \ + ./odp_ipsec_api -i $IF0,$IF1 \ + -r 192.168.111.2/32,$IF0,$NEXT_HOP_MAC0 \ + -r 192.168.222.2/32,$IF1,$NEXT_HOP_MAC1 \ + -p 192.168.111.0/24,192.168.222.0/24,out,esp \ + -e 192.168.111.2,192.168.222.2,3des,201,656c8523255ccc23a66c1917aa0cf30991fce83532a4b224 \ + -p 192.168.222.0/24,192.168.111.0/24,in,esp \ + -e 192.168.222.2,192.168.111.2,3des,301,c966199f24d095f3990a320d749056401e82b26570320292 \ + -c 2 "$@" & echo $! > $PID) | tee $LOG & + +APP_PID=`cat $PID` + +# Wait till application thread starts. +APP_READY="Pktio thread \[..\] starts" + +until [ -f $LOG ] +do + sleep 1 +done + +tail -f $LOG | grep -qm 1 "$APP_READY" + +validate_result +ret=$? + +kill -2 ${APP_PID} + +# Wait till the application exits +tail --pid=$APP_PID -f /dev/null + +rm -f $PID +rm -f $LOG + +cleanup_interfaces + +exit $ret diff --git a/example/ipsec_api/odp_ipsec_api_run_router.sh b/example/ipsec_api/odp_ipsec_api_run_router.sh index 2cdbd2272..79a0ef5c6 100755 --- a/example/ipsec_api/odp_ipsec_api_run_router.sh +++ b/example/ipsec_api/odp_ipsec_api_run_router.sh @@ -3,7 +3,55 @@ # Live router test # - 2 interfaces interfaces # - Specify API mode on command line -sudo ./odp_ipsec_api -i p7p1,p8p1 \ --r 192.168.111.2/32,p7p1,08:00:27:76:B5:E0 \ --r 192.168.222.2/32,p8p1,08:00:27:F5:8B:DB \ --c 1 "$@" + +# IPSEC_APP_MODE: 0 - STANDALONE, 1 - LIVE, 2 - ROUTER +IPSEC_APP_MODE=2 + +if [ -f ./pktio_env ]; then + . ./pktio_env +else + echo "BUG: unable to find pktio_env!" + echo "pktio_env has to be in current directory" + exit 1 +fi + +setup_interfaces + +# this just turns off output buffering so that you still get periodic +# output while piping to tee, as long as stdbuf is available. +STDBUF="`which stdbuf 2>/dev/null` -o 0" || STDBUF= +LOG=odp_ipsec_api_tmp.log +PID=app_pid + +($STDBUF \ + ./odp_ipsec_api -i $IF0,$IF1 \ + -r 192.168.111.2/32,$IF0,$NEXT_HOP_MAC0 \ + -r 192.168.222.2/32,$IF1,$NEXT_HOP_MAC1 \ + -c 1 "$@" & echo $! > $PID) | tee -a $LOG & + +APP_PID=`cat $PID` + +# Wait till application thread starts. +APP_READY="Pktio thread \[..\] starts" + +until [ -f $LOG ] +do + sleep 1 +done + +tail -f $LOG | grep -qm 1 "$APP_READY" + +validate_result +ret=$? + +kill -2 ${APP_PID} + +# Wait till the application stops +tail --pid=$APP_PID -f /dev/null + +rm -f $PID +rm -f $LOG + +cleanup_interfaces + +exit $ret diff --git a/example/ipsec_api/odp_ipsec_api_run_simple.sh b/example/ipsec_api/odp_ipsec_api_run_simple.sh index 56c022291..2921f978b 100755 --- a/example/ipsec_api/odp_ipsec_api_run_simple.sh +++ b/example/ipsec_api/odp_ipsec_api_run_simple.sh @@ -5,11 +5,37 @@ # - 10 packets # - Specify API mode on command line +# IPSEC_APP_MODE: 0 - STANDALONE, 1 - LIVE, 2 - ROUTER +IPSEC_APP_MODE=0 + +if [ -f ./pktio_env ]; then + . ./pktio_env +else + echo "BUG: unable to find pktio_env!" + echo "pktio_env has to be in current directory" + exit 1 +fi + +setup_interfaces + if [ -z "$IPSEC_EXAMPLE_PATH" ]; then IPSEC_EXAMPLE_PATH=. fi -${IPSEC_EXAMPLE_PATH}/odp_ipsec_api -i loop1,loop2 \ --r 192.168.222.2/32,loop2,08:00:27:F5:8B:DB \ --s 192.168.111.2,192.168.222.2,loop1,loop2,10,100 \ --c 2 "$@" +${IPSEC_EXAMPLE_PATH}/odp_ipsec_api -i $IF_LIST \ + -r 192.168.222.2/32,$ROUTE_IF_OUTB,08:00:27:F5:8B:DB \ + -s 192.168.111.2,192.168.222.2,$IN_IF,$OUT_IF,10,100 \ + -c 2 "$@" + +STATUS=$? + +if [ ${STATUS} -ne 0 ]; then + echo "Error: status ${STATUS}" + exit 1 +fi + +validate_result + +cleanup_interfaces + +exit 0 diff --git a/example/ipsec_crypto/.gitignore b/example/ipsec_crypto/.gitignore index 2467edfd4..e8b9e69a1 100644 --- a/example/ipsec_crypto/.gitignore +++ b/example/ipsec_crypto/.gitignore @@ -1 +1,2 @@ odp_ipsec_crypto +pktio_env diff --git a/example/ipsec_crypto/Makefile.am b/example/ipsec_crypto/Makefile.am index 2e3652252..1db0d72d0 100644 --- a/example/ipsec_crypto/Makefile.am +++ b/example/ipsec_crypto/Makefile.am @@ -2,16 +2,28 @@ include $(top_srcdir)/example/Makefile.inc bin_PROGRAMS = odp_ipsec_crypto -dist_check_SCRIPTS = \ - odp_ipsec_crypto_run_ah_in.sh \ - odp_ipsec_crypto_run_ah_out.sh \ - odp_ipsec_crypto_run_both_in.sh \ - odp_ipsec_crypto_run_both_out.sh \ - odp_ipsec_crypto_run_esp_in.sh \ - odp_ipsec_crypto_run_esp_out.sh \ - odp_ipsec_crypto_run_live.sh \ - odp_ipsec_crypto_run_router.sh \ - odp_ipsec_crypto_run_simple.sh +if test_example +TESTS = \ + odp_ipsec_crypto_run_ah_in.sh \ + odp_ipsec_crypto_run_ah_out.sh \ + odp_ipsec_crypto_run_both_in.sh \ + odp_ipsec_crypto_run_both_out.sh \ + odp_ipsec_crypto_run_esp_in.sh \ + odp_ipsec_crypto_run_esp_out.sh \ + odp_ipsec_crypto_run_live.sh \ + odp_ipsec_crypto_run_router.sh \ + odp_ipsec_crypto_run_simple.sh +endif +EXTRA_DIST = \ + odp_ipsec_crypto_run_ah_in.sh \ + odp_ipsec_crypto_run_ah_out.sh \ + odp_ipsec_crypto_run_both_in.sh \ + odp_ipsec_crypto_run_both_out.sh \ + odp_ipsec_crypto_run_esp_in.sh \ + odp_ipsec_crypto_run_esp_out.sh \ + odp_ipsec_crypto_run_live.sh \ + odp_ipsec_crypto_run_router.sh \ + odp_ipsec_crypto_run_simple.sh odp_ipsec_crypto_SOURCES = \ odp_ipsec.c \ @@ -43,16 +55,18 @@ endif # So copy all script and data files explicitly here. all-local: if [ "x$(srcdir)" != "x$(builddir)" ]; then \ - for f in $(dist_check_SCRIPTS); do \ + for f in $(EXTRA_DIST); do \ if [ -e $(srcdir)/$$f ]; then \ mkdir -p $(builddir)/$$(dirname $$f); \ cp -f $(srcdir)/$$f $(builddir)/$$f; \ fi \ done \ fi + ln -f -s ../../platform/$(with_platform)/test/example/ipsec_crypto/pktio_env pktio_env clean-local: if [ "x$(srcdir)" != "x$(builddir)" ]; then \ - for f in $(dist_check_SCRIPTS); do \ + for f in $(EXTRA_DIST); do \ rm -f $(builddir)/$$f; \ done \ fi + rm -f pktio_env diff --git a/example/ipsec_crypto/odp_ipsec_crypto_run_ah_in.sh b/example/ipsec_crypto/odp_ipsec_crypto_run_ah_in.sh index b64fd7d2d..0c8112306 100755 --- a/example/ipsec_crypto/odp_ipsec_crypto_run_ah_in.sh +++ b/example/ipsec_crypto/odp_ipsec_crypto_run_ah_in.sh @@ -4,9 +4,40 @@ # - 2 loop interfaces # - 10 packets # - Specify API mode on command line -./odp_ipsec_crypto -i loop1,loop2 \ --r 192.168.111.2/32,loop1,08:00:27:76:B5:E0 \ --p 192.168.222.0/24,192.168.111.0/24,in,ah \ --a 192.168.222.2,192.168.111.2,md5,300,27f6d123d7077b361662fc6e451f65d8 \ --s 192.168.222.2,192.168.111.2,loop2,loop1,10,100 \ --c 2 -m $1 + +# IPSEC_APP_MODE: 0 - STANDALONE, 1 - LIVE, 2 - ROUTER +IPSEC_APP_MODE=0 + +if [ -f ./pktio_env ]; then + . ./pktio_env +else + echo "BUG: unable to find pktio_env!" + echo "pktio_env has to be in current directory" + exit 1 +fi + +setup_interfaces + +if [ -z "$IPSEC_EXAMPLE_PATH" ]; then +IPSEC_EXAMPLE_PATH=. +fi + +${IPSEC_EXAMPLE_PATH}/odp_ipsec_crypto -i $IF_LIST \ + -r 192.168.111.2/32,$ROUTE_IF_INB,08:00:27:76:B5:E0 \ + -p 192.168.222.0/24,192.168.111.0/24,in,ah \ + -a 192.168.222.2,192.168.111.2,md5,300,27f6d123d7077b361662fc6e451f65d8 \ + -s 192.168.222.2,192.168.111.2,$OUT_IF,$IN_IF,10,100 \ + -c 2 "$@" + +STATUS=$? + +if [ ${STATUS} -ne 0 ]; then + echo "Error: status ${STATUS}" + exit 1 +fi + +validate_result + +cleanup_interfaces + +exit 0 diff --git a/example/ipsec_crypto/odp_ipsec_crypto_run_ah_out.sh b/example/ipsec_crypto/odp_ipsec_crypto_run_ah_out.sh index 0ff42289c..b0bb210f5 100755 --- a/example/ipsec_crypto/odp_ipsec_crypto_run_ah_out.sh +++ b/example/ipsec_crypto/odp_ipsec_crypto_run_ah_out.sh @@ -4,9 +4,40 @@ # - 2 loop interfaces # - 10 packets # - Specify API mode on command line -./odp_ipsec_crypto -i loop1,loop2 \ --r 192.168.222.2/32,loop2,08:00:27:F5:8B:DB \ --p 192.168.111.0/24,192.168.222.0/24,out,ah \ --a 192.168.111.2,192.168.222.2,md5,200,a731649644c5dee92cbd9c2e7e188ee6 \ --s 192.168.111.2,192.168.222.2,loop1,loop2,10,100 \ --c 2 -m $1 + +# IPSEC_APP_MODE: 0 - STANDALONE, 1 - LIVE, 2 - ROUTER +IPSEC_APP_MODE=0 + +if [ -f ./pktio_env ]; then + . ./pktio_env +else + echo "BUG: unable to find pktio_env!" + echo "pktio_env has to be in current directory" + exit 1 +fi + +setup_interfaces + +if [ -z "$IPSEC_EXAMPLE_PATH" ]; then +IPSEC_EXAMPLE_PATH=. +fi + +${IPSEC_EXAMPLE_PATH}/odp_ipsec_crypto -i $IF_LIST \ + -r 192.168.222.2/32,$ROUTE_IF_OUTB,08:00:27:F5:8B:DB \ + -p 192.168.111.0/24,192.168.222.0/24,out,ah \ + -a 192.168.111.2,192.168.222.2,md5,200,a731649644c5dee92cbd9c2e7e188ee6 \ + -s 192.168.111.2,192.168.222.2,$IN_IF,$OUT_IF,10,100 \ + -c 2 "$@" + +STATUS=$? + +if [ ${STATUS} -ne 0 ]; then + echo "Error: status ${STATUS}" + exit 1 +fi + +validate_result + +cleanup_interfaces + +exit 0 diff --git a/example/ipsec_crypto/odp_ipsec_crypto_run_both_in.sh b/example/ipsec_crypto/odp_ipsec_crypto_run_both_in.sh index a986b713e..4b8c6ab63 100755 --- a/example/ipsec_crypto/odp_ipsec_crypto_run_both_in.sh +++ b/example/ipsec_crypto/odp_ipsec_crypto_run_both_in.sh @@ -4,11 +4,41 @@ # - 2 loop interfaces # - 10 packets # - Specify API mode on command line -./odp_ipsec_crypto -i loop1,loop2 \ --r 192.168.111.2/32,loop1,08:00:27:76:B5:E0 \ --p 192.168.222.0/24,192.168.111.0/24,in,both \ --a 192.168.222.2,192.168.111.2,md5,300,27f6d123d7077b361662fc6e451f65d8 \ --e 192.168.222.2,192.168.111.2,\ -3des,301,c966199f24d095f3990a320d749056401e82b26570320292 \ --s 192.168.222.2,192.168.111.2,loop2,loop1,10,100 \ --c 2 -m $1 + +# IPSEC_APP_MODE: 0 - STANDALONE, 1 - LIVE, 2 - ROUTER +IPSEC_APP_MODE=0 + +if [ -f ./pktio_env ]; then + . ./pktio_env +else + echo "BUG: unable to find pktio_env!" + echo "pktio_env has to be in current directory" + exit 1 +fi + +setup_interfaces + +if [ -z "$IPSEC_EXAMPLE_PATH" ]; then +IPSEC_EXAMPLE_PATH=. +fi + +${IPSEC_EXAMPLE_PATH}/odp_ipsec_crypto -i $IF_LIST \ + -r 192.168.111.2/32,$ROUTE_IF_INB,08:00:27:76:B5:E0 \ + -p 192.168.222.0/24,192.168.111.0/24,in,both \ + -a 192.168.222.2,192.168.111.2,md5,300,27f6d123d7077b361662fc6e451f65d8 \ + -e 192.168.222.2,192.168.111.2,3des,301,c966199f24d095f3990a320d749056401e82b26570320292 \ + -s 192.168.222.2,192.168.111.2,$OUT_IF,$IN_IF,10,100 \ + -c 2 "$@" + +STATUS=$? + +if [ ${STATUS} -ne 0 ]; then + echo "Error: status ${STATUS}" + exit 1 +fi + +validate_result + +cleanup_interfaces + +exit 0 diff --git a/example/ipsec_crypto/odp_ipsec_crypto_run_both_out.sh b/example/ipsec_crypto/odp_ipsec_crypto_run_both_out.sh index ebbcde071..665534d98 100755 --- a/example/ipsec_crypto/odp_ipsec_crypto_run_both_out.sh +++ b/example/ipsec_crypto/odp_ipsec_crypto_run_both_out.sh @@ -4,11 +4,41 @@ # - 2 loop interfaces # - 10 packets # - Specify API mode on command line -./odp_ipsec_crypto -i loop1,loop2 \ --r 192.168.222.2/32,loop2,08:00:27:F5:8B:DB \ --p 192.168.111.0/24,192.168.222.0/24,out,both \ --e 192.168.111.2,192.168.222.2,\ -3des,201,656c8523255ccc23a66c1917aa0cf30991fce83532a4b224 \ --a 192.168.111.2,192.168.222.2,md5,200,a731649644c5dee92cbd9c2e7e188ee6 \ --s 192.168.111.2,192.168.222.2,loop1,loop2,10,100 \ --c 2 -m $1 + +# IPSEC_APP_MODE: 0 - STANDALONE, 1 - LIVE, 2 - ROUTER +IPSEC_APP_MODE=0 + +if [ -f ./pktio_env ]; then + . ./pktio_env +else + echo "BUG: unable to find pktio_env!" + echo "pktio_env has to be in current directory" + exit 1 +fi + +setup_interfaces + +if [ -z "$IPSEC_EXAMPLE_PATH" ]; then +IPSEC_EXAMPLE_PATH=. +fi + +${IPSEC_EXAMPLE_PATH}/odp_ipsec_crypto -i $IF_LIST \ + -r 192.168.222.2/32,$ROUTE_IF_OUTB,08:00:27:F5:8B:DB \ + -p 192.168.111.0/24,192.168.222.0/24,out,both \ + -e 192.168.111.2,192.168.222.2,3des,201,656c8523255ccc23a66c1917aa0cf30991fce83532a4b224 \ + -a 192.168.111.2,192.168.222.2,md5,200,a731649644c5dee92cbd9c2e7e188ee6 \ + -s 192.168.111.2,192.168.222.2,$IN_IF,$OUT_IF,10,100 \ + -c 2 "$@" + +STATUS=$? + +if [ ${STATUS} -ne 0 ]; then + echo "Error: status ${STATUS}" + exit 1 +fi + +validate_result + +cleanup_interfaces + +exit 0 diff --git a/example/ipsec_crypto/odp_ipsec_crypto_run_esp_in.sh b/example/ipsec_crypto/odp_ipsec_crypto_run_esp_in.sh index cdf84c517..6e6ff5769 100755 --- a/example/ipsec_crypto/odp_ipsec_crypto_run_esp_in.sh +++ b/example/ipsec_crypto/odp_ipsec_crypto_run_esp_in.sh @@ -4,10 +4,40 @@ # - 2 loop interfaces # - 10 packets # - Specify API mode on command line -./odp_ipsec_crypto -i loop1,loop2 \ --r 192.168.111.2/32,loop1,08:00:27:76:B5:E0 \ --p 192.168.222.0/24,192.168.111.0/24,in,esp \ --e 192.168.222.2,192.168.111.2,\ -3des,301,c966199f24d095f3990a320d749056401e82b26570320292 \ --s 192.168.222.2,192.168.111.2,loop2,loop1,10,100 \ --c 2 -m $1 + +# IPSEC_APP_MODE: 0 - STANDALONE, 1 - LIVE, 2 - ROUTER +IPSEC_APP_MODE=0 + +if [ -f ./pktio_env ]; then + . ./pktio_env +else + echo "BUG: unable to find pktio_env!" + echo "pktio_env has to be in current directory" + exit 1 +fi + +setup_interfaces + +if [ -z "$IPSEC_EXAMPLE_PATH" ]; then +IPSEC_EXAMPLE_PATH=. +fi + +${IPSEC_EXAMPLE_PATH}/odp_ipsec_crypto -i $IF_LIST \ + -r 192.168.111.2/32,$ROUTE_IF_INB,08:00:27:76:B5:E0 \ + -p 192.168.222.0/24,192.168.111.0/24,in,esp \ + -e 192.168.222.2,192.168.111.2,3des,301,c966199f24d095f3990a320d749056401e82b26570320292 \ + -s 192.168.222.2,192.168.111.2,$OUT_IF,$IN_IF,10,100 \ + -c 2 "$@" + +STATUS=$? + +if [ ${STATUS} -ne 0 ]; then + echo "Error: status ${STATUS}" + exit 1 +fi + +validate_result + +cleanup_interfaces + +exit 0 diff --git a/example/ipsec_crypto/odp_ipsec_crypto_run_esp_out.sh b/example/ipsec_crypto/odp_ipsec_crypto_run_esp_out.sh index ae257be4f..2b7107f80 100755 --- a/example/ipsec_crypto/odp_ipsec_crypto_run_esp_out.sh +++ b/example/ipsec_crypto/odp_ipsec_crypto_run_esp_out.sh @@ -5,14 +5,39 @@ # - 10 packets # - Specify API mode on command line +# IPSEC_APP_MODE: 0 - STANDALONE, 1 - LIVE, 2 - ROUTER +IPSEC_APP_MODE=0 + +if [ -f ./pktio_env ]; then + . ./pktio_env +else + echo "BUG: unable to find pktio_env!" + echo "pktio_env has to be in current directory" + exit 1 +fi + +setup_interfaces + if [ -z "$IPSEC_EXAMPLE_PATH" ]; then IPSEC_EXAMPLE_PATH=. fi -${IPSEC_EXAMPLE_PATH}/odp_ipsec_crypto -i loop1,loop2 \ --r 192.168.222.2/32,loop2,08:00:27:F5:8B:DB \ --p 192.168.111.0/24,192.168.222.0/24,out,esp \ --e 192.168.111.2,192.168.222.2,\ -3des,201,656c8523255ccc23a66c1917aa0cf30991fce83532a4b224 \ --s 192.168.111.2,192.168.222.2,loop1,loop2,10,100 \ --c 2 "$@" +${IPSEC_EXAMPLE_PATH}/odp_ipsec_crypto -i $IF_LIST \ + -r 192.168.222.2/32,$ROUTE_IF_OUTB,08:00:27:F5:8B:DB \ + -p 192.168.111.0/24,192.168.222.0/24,out,esp \ + -e 192.168.111.2,192.168.222.2,3des,201,656c8523255ccc23a66c1917aa0cf30991fce83532a4b224 \ + -s 192.168.111.2,192.168.222.2,$IN_IF,$OUT_IF,10,100 \ + -c 2 "$@" + +STATUS=$? + +if [ ${STATUS} -ne 0 ]; then + echo "Error: status ${STATUS}" + exit 1 +fi + +validate_result + +cleanup_interfaces + +exit 0 diff --git a/example/ipsec_crypto/odp_ipsec_crypto_run_live.sh b/example/ipsec_crypto/odp_ipsec_crypto_run_live.sh index c212097e0..90dda11ec 100755 --- a/example/ipsec_crypto/odp_ipsec_crypto_run_live.sh +++ b/example/ipsec_crypto/odp_ipsec_crypto_run_live.sh @@ -3,15 +3,63 @@ # Live router test # - 2 interfaces interfaces # - Specify API mode on command line -sudo ./odp_ipsec_crypto -i p7p1,p8p1 \ --r 192.168.111.2/32,p7p1,08:00:27:76:B5:E0 \ --r 192.168.222.2/32,p8p1,08:00:27:F5:8B:DB \ --p 192.168.111.0/24,192.168.222.0/24,out,both \ --e 192.168.111.2,192.168.222.2,\ -3des,201,656c8523255ccc23a66c1917aa0cf30991fce83532a4b224 \ --a 192.168.111.2,192.168.222.2,md5,200,a731649644c5dee92cbd9c2e7e188ee6 \ --p 192.168.222.0/24,192.168.111.0/24,in,both \ --e 192.168.222.2,192.168.111.2,\ -3des,301,c966199f24d095f3990a320d749056401e82b26570320292 \ --a 192.168.222.2,192.168.111.2,md5,300,27f6d123d7077b361662fc6e451f65d8 \ --c 2 -m $1 + +# IPSEC_APP_MODE: 0 - STANDALONE, 1 - LIVE, 2 - ROUTER +IPSEC_APP_MODE=1 + +if [ -f ./pktio_env ]; then + . ./pktio_env +else + echo "BUG: unable to find pktio_env!" + echo "pktio_env has to be in current directory" + exit 1 +fi + +setup_interfaces + +# this just turns off output buffering so that you still get periodic +# output while piping to tee, as long as stdbuf is available. +STDBUF="`which stdbuf 2>/dev/null` -o 0" || STDBUF= +LOG=odp_ipsec_crypto_tmp.log +PID=app_pid + +($STDBUF \ + ./odp_ipsec_crypto -i $IF0,$IF1 \ + -r 192.168.111.2/32,$IF0,$NEXT_HOP_MAC0 \ + -r 192.168.222.2/32,$IF1,$NEXT_HOP_MAC1 \ + -p 192.168.111.0/24,192.168.222.0/24,out,both \ + -e 192.168.111.2,192.168.222.2,\ + 3des,201,656c8523255ccc23a66c1917aa0cf30991fce83532a4b224 \ + -a 192.168.111.2,192.168.222.2,md5,200,a731649644c5dee92cbd9c2e7e188ee6 \ + -p 192.168.222.0/24,192.168.111.0/24,in,both \ + -e 192.168.222.2,192.168.111.2,\ + 3des,301,c966199f24d095f3990a320d749056401e82b26570320292 \ + -a 192.168.222.2,192.168.111.2,md5,300,27f6d123d7077b361662fc6e451f65d8 \ + -c 2 "$@" & echo $! > $PID) | tee -a $LOG & + +APP_PID=`cat $PID` + +# Wait till application thread starts. +APP_READY="Pktio thread \[..\] starts" + +until [ -f $LOG ] +do + sleep 1 +done + +tail -f $LOG | grep -qm 1 "$APP_READY" + +validate_result +ret=$? + +kill -2 ${APP_PID} + +# Wait till the application exits +tail --pid=$APP_PID -f /dev/null + +rm -f $PID +rm -f $LOG + +cleanup_interfaces + +exit $ret diff --git a/example/ipsec_crypto/odp_ipsec_crypto_run_router.sh b/example/ipsec_crypto/odp_ipsec_crypto_run_router.sh index d08490946..675027b59 100755 --- a/example/ipsec_crypto/odp_ipsec_crypto_run_router.sh +++ b/example/ipsec_crypto/odp_ipsec_crypto_run_router.sh @@ -3,7 +3,55 @@ # Live router test # - 2 interfaces interfaces # - Specify API mode on command line -sudo ./odp_ipsec_crypto -i p7p1,p8p1 \ --r 192.168.111.2/32,p7p1,08:00:27:76:B5:E0 \ --r 192.168.222.2/32,p8p1,08:00:27:F5:8B:DB \ --c 1 -m $1 + +# IPSEC_APP_MODE: 0 - STANDALONE, 1 - LIVE, 2 - ROUTER +IPSEC_APP_MODE=2 + +if [ -f ./pktio_env ]; then + . ./pktio_env +else + echo "BUG: unable to find pktio_env!" + echo "pktio_env has to be in current directory" + exit 1 +fi + +setup_interfaces + +# this just turns off output buffering so that you still get periodic +# output while piping to tee, as long as stdbuf is available. +STDBUF="`which stdbuf 2>/dev/null` -o 0" || STDBUF= +LOG=odp_ipsec_crypto_tmp.log +PID=app_pid + +($STDBUF \ + ./odp_ipsec_crypto -i $IF0,$IF1 \ + -r 192.168.111.2/32,$IF0,$NEXT_HOP_MAC0 \ + -r 192.168.222.2/32,$IF1,$NEXT_HOP_MAC1 \ + -c 1 "$@" & echo $! > $PID) | tee -a $LOG & + +APP_PID=`cat $PID` + +# Wait till application thread starts. +APP_READY="Pktio thread \[..\] starts" + +until [ -f $LOG ] +do + sleep 1 +done + +tail -f $LOG | grep -qm 1 "$APP_READY" + +validate_result +ret=$? + +kill -2 ${APP_PID} + +# Wait till the application exits +tail --pid=$APP_PID -f /dev/null + +rm -f $PID +rm -f $LOG + +cleanup_interfaces + +exit $ret diff --git a/example/ipsec_crypto/odp_ipsec_crypto_run_simple.sh b/example/ipsec_crypto/odp_ipsec_crypto_run_simple.sh index 5d3abcd51..00b176b36 100755 --- a/example/ipsec_crypto/odp_ipsec_crypto_run_simple.sh +++ b/example/ipsec_crypto/odp_ipsec_crypto_run_simple.sh @@ -5,11 +5,37 @@ # - 10 packets # - Specify API mode on command line +# IPSEC_APP_MODE: 0 - STANDALONE, 1 - LIVE, 2 - ROUTER +IPSEC_APP_MODE=0 + +if [ -f ./pktio_env ]; then + . ./pktio_env +else + echo "BUG: unable to find pktio_env!" + echo "pktio_env has to be in current directory" + exit 1 +fi + +setup_interfaces + if [ -z "$IPSEC_EXAMPLE_PATH" ]; then IPSEC_EXAMPLE_PATH=. fi -${IPSEC_EXAMPLE_PATH}/odp_ipsec_crypto -i loop1,loop2 \ --r 192.168.222.2/32,loop2,08:00:27:F5:8B:DB \ --s 192.168.111.2,192.168.222.2,loop1,loop2,10,100 \ --c 2 "$@" +${IPSEC_EXAMPLE_PATH}/odp_ipsec_crypto -i $IF_LIST \ + -r 192.168.222.2/32,$ROUTE_IF_OUTB,08:00:27:F5:8B:DB \ + -s 192.168.111.2,192.168.222.2,$IN_IF,$OUT_IF,10,100 \ + -c 2 "$@" + +STATUS=$? + +if [ ${STATUS} -ne 0 ]; then + echo "Error: status ${STATUS}" + exit 1 +fi + +validate_result + +cleanup_interfaces + +exit 0 diff --git a/example/ipsec_crypto/odp_ipsec_stream.c b/example/ipsec_crypto/odp_ipsec_stream.c index e53dbce0d..0ca5138bc 100644 --- a/example/ipsec_crypto/odp_ipsec_stream.c +++ b/example/ipsec_crypto/odp_ipsec_stream.c @@ -272,6 +272,10 @@ odp_packet_t create_ipv4_packet(stream_db_entry_t *stream, inner_ip = (odph_ipv4hdr_t *)data; memset((char *)inner_ip, 0, sizeof(*inner_ip)); inner_ip->ver_ihl = 0x45; + inner_ip->tot_len = odp_cpu_to_be_16(sizeof(odph_ipv4hdr_t) + + sizeof(odph_icmphdr_t) + + sizeof(stream_pkt_hdr_t) + + stream->length); inner_ip->proto = ODPH_IPPROTO_ICMPV4; inner_ip->id = odp_cpu_to_be_16(stream->id); inner_ip->ttl = 64; @@ -322,8 +326,8 @@ odp_packet_t create_ipv4_packet(stream_db_entry_t *stream, encrypt_len = ESP_ENCODE_LEN(payload_len + sizeof(*esp_t), entry->esp.block_len); - memset(data, 0, encrypt_len - payload_len); - data += encrypt_len - payload_len; + for (int n = 0; n < encrypt_len - payload_len; n++) + *data++ = n + 1; esp_t = (odph_esptrl_t *)(data) - 1; esp_t->pad_len = encrypt_len - payload_len - sizeof(*esp_t); diff --git a/example/sysinfo/odp_sysinfo.c b/example/sysinfo/odp_sysinfo.c index cad87b121..9e4ed4147 100644 --- a/example/sysinfo/odp_sysinfo.c +++ b/example/sysinfo/odp_sysinfo.c @@ -408,7 +408,7 @@ int main(void) return -1; } - if (odp_timer_capability(ODP_CLOCK_CPU, &timer_capa)) { + if (odp_timer_capability(ODP_CLOCK_DEFAULT, &timer_capa)) { printf("timer capability failed\n"); return -1; } diff --git a/example/timer/odp_timer_accuracy.c b/example/timer/odp_timer_accuracy.c index cafe362a7..df1fd5919 100644 --- a/example/timer/odp_timer_accuracy.c +++ b/example/timer/odp_timer_accuracy.c @@ -37,7 +37,7 @@ typedef struct { uint64_t num_exact; uint64_t num_after; - uint64_t num_tooearly; + uint64_t num_too_near; } test_stat_t; @@ -103,11 +103,11 @@ static void print_usage(void) " 1: Set first burst of timers at init. Restart timers during test with absolute time.\n" " 2: Set first burst of timers at init. Restart timers during test with relative time.\n" " -o, --output <file> Output file for measurement logs\n" - " -e, --early_retry <num> When timer restart fails due to ODP_TIMER_TOOEARLY, retry this many times\n" + " -e, --early_retry <num> When timer restart fails due to ODP_TIMER_TOO_NEAR, retry this many times\n" " with expiration time incremented by the period. Default: 0\n" " -s, --clk_src Clock source select (default 0):\n" - " 0: ODP_CLOCK_CPU\n" - " 1: ODP_CLOCK_EXT\n" + " 0: ODP_CLOCK_DEFAULT\n" + " 1: ODP_CLOCK_SRC_1, ...\n" " -i, --init Set global init parameters. Default: init params not set.\n" " -h, --help Display help and exit.\n\n"); } @@ -144,7 +144,7 @@ static int parse_options(int argc, char *argv[], test_global_t *test_global) test_global->opt.burst = 1; test_global->opt.burst_gap = 0; test_global->opt.mode = 0; - test_global->opt.clk_src = 0; + test_global->opt.clk_src = ODP_CLOCK_DEFAULT; test_global->opt.init = 0; test_global->opt.output = 0; test_global->opt.early_retry = 0; @@ -289,11 +289,7 @@ static int start_timers(test_global_t *test_global) } test_global->timeout_pool = pool; - - if (test_global->opt.clk_src == 0) - clk_src = ODP_CLOCK_CPU; - else - clk_src = ODP_CLOCK_EXT; + clk_src = test_global->opt.clk_src; if (odp_timer_capability(clk_src, &timer_capa)) { printf("Timer capa failed\n"); @@ -565,7 +561,7 @@ static void print_stat(test_global_t *test_global) printf(" num exact: %12" PRIu64 " / %.2f%%\n", stat->num_exact, 100.0 * stat->num_exact / tot_timers); printf(" num retry: %12" PRIu64 " / %.2f%%\n", - stat->num_tooearly, 100.0 * stat->num_tooearly / tot_timers); + stat->num_too_near, 100.0 * stat->num_too_near / tot_timers); printf(" error after (nsec):\n"); printf(" min: %12" PRIu64 " / %.3fx resolution\n", stat->nsec_after_min, (double)stat->nsec_after_min / res_ns); @@ -674,8 +670,8 @@ static void run_test(test_global_t *test_global) ret = odp_timer_set_rel(tim, tick, &ev); } - if (ret == ODP_TIMER_TOOEARLY) - stat->num_tooearly++; + if (ret == ODP_TIMER_TOO_NEAR) + stat->num_too_near++; else break; } diff --git a/example/timer/odp_timer_simple.c b/example/timer/odp_timer_simple.c index 683d6ff8d..4e28807c6 100644 --- a/example/timer/odp_timer_simple.c +++ b/example/timer/odp_timer_simple.c @@ -65,7 +65,7 @@ int main(int argc ODP_UNUSED, char *argv[] ODP_UNUSED) /* * Create pool of timeouts */ - if (odp_timer_capability(ODP_CLOCK_CPU, &timer_capa)) { + if (odp_timer_capability(ODP_CLOCK_DEFAULT, &timer_capa)) { ret += 1; goto err_tp; } @@ -76,7 +76,7 @@ int main(int argc ODP_UNUSED, char *argv[] ODP_UNUSED) tparams.max_tmo = 1 * ODP_TIME_SEC_IN_NS; tparams.num_timers = 1; /* One timer per worker */ tparams.priv = 0; /* Shared */ - tparams.clk_src = ODP_CLOCK_CPU; + tparams.clk_src = ODP_CLOCK_DEFAULT; timer_pool = odp_timer_pool_create("timer_pool", &tparams); if (timer_pool == ODP_TIMER_POOL_INVALID) { ret += 1; diff --git a/example/timer/odp_timer_test.c b/example/timer/odp_timer_test.c index ddb2ccfd5..8bfb99d8f 100644 --- a/example/timer/odp_timer_test.c +++ b/example/timer/odp_timer_test.c @@ -56,12 +56,12 @@ static const char *timerset2str(odp_timer_set_t val) switch (val) { case ODP_TIMER_SUCCESS: return "success"; - case ODP_TIMER_TOOEARLY: - return "too early"; - case ODP_TIMER_TOOLATE: - return "too late"; - case ODP_TIMER_NOEVENT: - return "no event"; + case ODP_TIMER_TOO_NEAR: + return "too near"; + case ODP_TIMER_TOO_FAR: + return "too far"; + case ODP_TIMER_FAIL: + return "failure"; default: return "?"; } @@ -273,7 +273,7 @@ static int parse_args(int argc, char *argv[], test_args_t *args) static const char *shortopts = "+c:r:m:x:p:t:h"; /* defaults */ - if (odp_timer_capability(ODP_CLOCK_CPU, &timer_capa)) + if (odp_timer_capability(ODP_CLOCK_DEFAULT, &timer_capa)) return -1; args->cpu_count = 1; @@ -444,7 +444,7 @@ int main(int argc, char *argv[]) tparams.max_tmo = gbls->args.max_us * ODP_TIME_USEC_IN_NS; tparams.num_timers = num_workers; /* One timer per worker */ tparams.priv = 0; /* Shared */ - tparams.clk_src = ODP_CLOCK_CPU; + tparams.clk_src = ODP_CLOCK_DEFAULT; gbls->tp = odp_timer_pool_create("timer_pool", &tparams); if (gbls->tp == ODP_TIMER_POOL_INVALID) { err = 1; diff --git a/example/traffic_mgmt/odp_traffic_mgmt.c b/example/traffic_mgmt/odp_traffic_mgmt.c index fba494853..521338785 100644 --- a/example/traffic_mgmt/odp_traffic_mgmt.c +++ b/example/traffic_mgmt/odp_traffic_mgmt.c @@ -62,8 +62,8 @@ static const odp_init_t ODP_INIT_PARAMS = { static profile_params_set_t COMPANY_PROFILE_PARAMS = { .shaper_params = { - .commit_bps = 50 * MBPS, .commit_burst = 1000000, - .peak_bps = 0, .peak_burst = 0, + .commit_rate = 50 * MBPS, .commit_burst = 1000000, + .peak_rate = 0, .peak_burst = 0, .dual_rate = FALSE, .shaper_len_adjust = 20 }, @@ -95,8 +95,8 @@ static profile_params_set_t COMPANY_PROFILE_PARAMS = { static profile_params_set_t COS0_PROFILE_PARAMS = { .shaper_params = { - .commit_bps = 1 * MBPS, .commit_burst = 100000, - .peak_bps = 4 * MBPS, .peak_burst = 200000, + .commit_rate = 1 * MBPS, .commit_burst = 100000, + .peak_rate = 4 * MBPS, .peak_burst = 200000, .dual_rate = FALSE, .shaper_len_adjust = 20 }, @@ -128,8 +128,8 @@ static profile_params_set_t COS0_PROFILE_PARAMS = { static profile_params_set_t COS1_PROFILE_PARAMS = { .shaper_params = { - .commit_bps = 500 * KBPS, .commit_burst = 50000, - .peak_bps = 1500 * KBPS, .peak_burst = 150000, + .commit_rate = 500 * KBPS, .commit_burst = 50000, + .peak_rate = 1500 * KBPS, .peak_burst = 150000, .dual_rate = FALSE, .shaper_len_adjust = 20 }, @@ -161,8 +161,8 @@ static profile_params_set_t COS1_PROFILE_PARAMS = { static profile_params_set_t COS2_PROFILE_PARAMS = { .shaper_params = { - .commit_bps = 200 * KBPS, .commit_burst = 20000, - .peak_bps = 400 * KBPS, .peak_burst = 40000, + .commit_rate = 200 * KBPS, .commit_burst = 20000, + .peak_rate = 400 * KBPS, .peak_burst = 40000, .dual_rate = FALSE, .shaper_len_adjust = 20 }, @@ -194,8 +194,8 @@ static profile_params_set_t COS2_PROFILE_PARAMS = { static profile_params_set_t COS3_PROFILE_PARAMS = { .shaper_params = { - .commit_bps = 100 * KBPS, .commit_burst = 5000, - .peak_bps = 0, .peak_burst = 0, + .commit_rate = 100 * KBPS, .commit_burst = 5000, + .peak_rate = 0, .peak_burst = 0, .dual_rate = FALSE, .shaper_len_adjust = 20 }, @@ -272,8 +272,8 @@ static uint32_t create_profile_set(profile_params_set_t *profile_params_set, odp_tm_shaper_params_init(&shaper_params); shaper = &profile_params_set->shaper_params; - shaper_params.commit_bps = shaper->commit_bps * shaper_scale; - shaper_params.peak_bps = shaper->peak_bps * shaper_scale; + shaper_params.commit_rate = shaper->commit_rate * shaper_scale; + shaper_params.peak_rate = shaper->peak_rate * shaper_scale; shaper_params.commit_burst = shaper->commit_burst * shaper_scale; shaper_params.peak_burst = shaper->peak_burst * shaper_scale; shaper_params.dual_rate = shaper->dual_rate; @@ -826,6 +826,13 @@ int main(int argc, char *argv[]) create_and_config_tm(); + /* Start TM */ + rc = odp_tm_start(odp_tm_test); + if (rc != 0) { + printf("Error: odp_tm_start() failed, rc=%d\n", rc); + return -1; + } + odp_random_data(random_buf, RANDOM_BUF_LEN, 1); next_rand_byte = 0; @@ -841,6 +848,13 @@ int main(int argc, char *argv[]) odp_tm_stats_print(odp_tm_test); + /* Stop TM */ + rc = odp_tm_stop(odp_tm_test); + if (rc != 0) { + printf("Error: odp_tm_stop() failed, rc = %d\n", rc); + return -1; + } + rc = destroy_tm_queues(); if (rc != 0) { printf("Error: destroy_tm_queues() failed, rc = %d\n", rc); |