1 #!/bin/bash 2 # SPDX-License-Identifier: GPL-2.0 3 4 readonly server_ns=$(mktemp -u server-XXXXXXXX) 5 readonly client_ns=$(mktemp -u client-XXXXXXXX) 6 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" 12 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 17 18 ip netns exec "${ns_name}" ethtool -K "${ns_dev}" gro on tso off 19 } 20 21 setup_ns() { 22 # Set up server_ns namespace and client_ns namespace 23 ip link add name server type veth peer name client 24 25 setup_veth_ns "${dev}" ${server_ns} server "${SERVER_MAC}" 26 setup_veth_ns "${dev}" ${client_ns} client "${CLIENT_MAC}" 27 } 28 29 cleanup_ns() { 30 local ns_name 31 32 for ns_name in ${client_ns} ${server_ns}; do 33 [[ -e /var/run/netns/"${ns_name}" ]] && ip netns del "${ns_name}" 34 done 35 } 36 37 setup() { 38 # no global init setup step needed 39 : 40 } 41 42 cleanup() { 43 cleanup_ns 44 }
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.