xref: /aosp_15_r20/external/ltp/testcases/network/virt/wireguard02.sh (revision 49cdfc7efb34551c7342be41a7384b9c40d7cab7)
1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0-or-later
3# Copyright (c) 2022 Petr Vorel <[email protected]>
4# Copyright (c) 2020 Oracle and/or its affiliates. All Rights Reserved.
5
6TST_CLEANUP=cleanup
7TST_TESTFUNC=test1
8TST_SETUP=wireguard_lib_setup
9
10IPSEC_MODE="tunnel"
11IPSEC_PROTO="esp_aead"
12AEALGO="rfc4106_256"
13EALGO="aes"
14AALGO="sha256"
15
16cleanup()
17{
18	wireguard_lib_cleanup
19	tst_ipsec_cleanup
20}
21
22test1()
23{
24	local wgaddr
25	local clients_num="$TST_NETLOAD_CLN_NUMBER"
26
27	# Enforce multi-threading test, at least with 10 TCP clients
28	[ $clients_num -lt 10 ] && clients_num=10
29
30	tst_res TINFO "test wireguard"
31
32	[ -n "$TST_IPV6" ] && wgaddr="$ip6_virt_remote" || wgaddr="$ip_virt_remote"
33	tst_netload -H $wgaddr -a $clients_num -D ltp_v0
34	local time_wg=$(cat tst_netload.res)
35	wireguard_lib_cleanup
36
37	tst_res TINFO "test IPSec $IPSEC_MODE/$IPSEC_PROTO $EALGO"
38	tst_ipsec_setup_vti
39	tst_netload -H $ip_rmt_tun -a $clients_num -D $tst_vti
40	local time_ipsec=$(cat tst_netload.res)
41	tst_ipsec_cleanup
42
43	tst_netload_compare $time_ipsec $time_wg -100
44}
45
46. ipsec_lib.sh
47. wireguard_lib.sh
48tst_run
49