• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0-or-later
3# Copyright (c) 2021 Oracle and/or its affiliates. All Rights Reserved.
4
5TST_TESTFUNC=virt_netperf_rand_sizes
6TST_SETUP=do_setup
7TST_CLEANUP=do_cleanup
8TST_NEEDS_TMPDIR=1
9TST_OPTS="t:"
10TST_PARSE_ARGS="parse_args"
11
12virt_type="fou"
13. virt_lib.sh
14
15GRE_IP_PROTO=47
16
17parse_args()
18{
19	case $1 in
20	t) virt_type="$2";;
21	esac
22}
23
24do_cleanup()
25{
26	if [ "$FOU_PORT" ]; then
27		tst_net_run -l $FOU_PORT -r $FOU_PORT_RMT \
28			"ip fou del $FOU_PROTO ${TST_IPV6_FLAG} port"
29	fi
30
31	virt_cleanup_rmt
32	virt_cleanup
33}
34
35do_setup()
36{
37	local get_port_cmd="tst_get_unused_port ipv${TST_IPVER} dgram"
38	local encap_cmd="encap $virt_type encap-sport auto encap-dport"
39	local loc_ip=$(tst_ipaddr)
40	local rmt_ip=$(tst_ipaddr rhost)
41	local fou="fou$TST_IPV6"
42
43	case $virt_type in
44	fou) FOU_PROTO="ipproto $GRE_IP_PROTO";;
45	gue) FOU_PROTO="gue";;
46	esac
47
48	tst_require_drivers $fou
49	tst_net_run -s modprobe $fou
50
51	FOU_PORT=$($get_port_cmd)
52	FOU_PORT_RMT=$(tst_rhost_run -c "$get_port_cmd")
53
54	tst_net_run -s -l $FOU_PORT -r $FOU_PORT_RMT \
55		"ip fou add $FOU_PROTO ${TST_IPV6_FLAG} port"
56
57	virt_setup "local $loc_ip remote $rmt_ip $encap_cmd $FOU_PORT_RMT" \
58		   "local $rmt_ip remote $loc_ip $encap_cmd $FOU_PORT"
59}
60
61tst_run
62