Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / tools / testing / selftests / net / setup_veth.sh
blob1f78a87f6f37eaab8dc41850e1a906f9aef6315f
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
4 readonly server_ns=$(mktemp -u server-XXXXXXXX)
5 readonly client_ns=$(mktemp -u client-XXXXXXXX)
7 setup_veth_ns() {
8 local -r link_dev="$1"
9 local -r ns_name="$2"
10 local -r ns_dev="$3"
11 local -r ns_mac="$4"
13 [[ -e /var/run/netns/"${ns_name}" ]] || ip netns add "${ns_name}"
14 echo 1000000 > "/sys/class/net/${ns_dev}/gro_flush_timeout"
15 ip link set dev "${ns_dev}" netns "${ns_name}" mtu 65535
16 ip -netns "${ns_name}" link set dev "${ns_dev}" up
18 ip netns exec "${ns_name}" ethtool -K "${ns_dev}" gro on tso off
21 setup_ns() {
22 # Set up server_ns namespace and client_ns namespace
23 ip link add name server type veth peer name client
25 setup_veth_ns "${dev}" ${server_ns} server "${SERVER_MAC}"
26 setup_veth_ns "${dev}" ${client_ns} client "${CLIENT_MAC}"
29 cleanup_ns() {
30 local ns_name
32 for ns_name in ${client_ns} ${server_ns}; do
33 [[ -e /var/run/netns/"${ns_name}" ]] && ip netns del "${ns_name}"
34 done
37 setup() {
38 # no global init setup step needed
42 cleanup() {
43 cleanup_ns