xref: /aosp_15_r20/external/ltp/testcases/network/virt/wireguard01.sh (revision 49cdfc7efb34551c7342be41a7384b9c40d7cab7)
1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0-or-later
3# Copyright (c) 2020 Oracle and/or its affiliates. All Rights Reserved.
4
5TST_NEEDS_CMDS="tc"
6TST_SETUP=setup
7TST_CLEANUP=cleanup
8TST_TESTFUNC=test
9TST_CNT=3
10
11setup()
12{
13	if tst_net_use_netns && [ "$VIRT_PERF_THRESHOLD" -lt 700 ]; then
14		tst_res TINFO "Adjust threshold for veth (no encap/encrypt)"
15		VIRT_PERF_THRESHOLD=700
16	fi
17
18	local netem_opt="reorder 30% 50% delay 1"
19	tst_res TINFO "Use netem $netem_opt"
20	ROD tc qdisc add dev $(tst_iface) root netem $netem_opt
21	wireguard_lib_setup
22}
23
24cleanup()
25{
26	tc qdisc del dev $(tst_iface) root netem >/dev/null 2>&1
27	wireguard_lib_cleanup
28}
29
30test1()
31{
32	tst_res TINFO "Using correct wireguard configuration"
33	virt_netperf_msg_sizes
34	wireguard_lib_cleanup
35}
36
37test2()
38{
39	tst_res TINFO "Invalid configuration with allowed IPs"
40	wireguard_lib_setup invalid_allowed_ips
41	virt_minimize_timeout
42	virt_compare_netperf "fail"
43	wireguard_lib_cleanup
44}
45
46test3()
47{
48	tst_res TINFO "Invalid configuration with public keys"
49	wireguard_lib_setup invalid_pub_keys
50	virt_minimize_timeout
51	virt_compare_netperf "fail"
52}
53
54. wireguard_lib.sh
55tst_run
56