~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/net/io_uring_zerocopy_tx.sh

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 #!/bin/bash
  2 #
  3 # Send data between two processes across namespaces
  4 # Run twice: once without and once with zerocopy
  5 
  6 set -e
  7 
  8 readonly DEV="veth0"
  9 readonly DEV_MTU=65535
 10 readonly BIN_TX="./io_uring_zerocopy_tx"
 11 readonly BIN_RX="./msg_zerocopy"
 12 
 13 readonly RAND="$(mktemp -u XXXXXX)"
 14 readonly NSPREFIX="ns-${RAND}"
 15 readonly NS1="${NSPREFIX}1"
 16 readonly NS2="${NSPREFIX}2"
 17 
 18 readonly SADDR4='192.168.1.1'
 19 readonly DADDR4='192.168.1.2'
 20 readonly SADDR6='fd::1'
 21 readonly DADDR6='fd::2'
 22 
 23 readonly path_sysctl_mem="net.core.optmem_max"
 24 
 25 # No arguments: automated test
 26 if [[ "$#" -eq "0" ]]; then
 27         IPs=( "4" "6" )
 28 
 29         for IP in "${IPs[@]}"; do
 30                 for mode in $(seq 1 3); do
 31                         $0 "$IP" udp -m "$mode" -t 1 -n 32
 32                         $0 "$IP" tcp -m "$mode" -t 1 -n 1
 33                 done
 34         done
 35 
 36         echo "OK. All tests passed"
 37         exit 0
 38 fi
 39 
 40 # Argument parsing
 41 if [[ "$#" -lt "2" ]]; then
 42         echo "Usage: $0 [4|6] [tcp|udp|raw|raw_hdrincl|packet|packet_dgram] <args>"
 43         exit 1
 44 fi
 45 
 46 readonly IP="$1"
 47 shift
 48 readonly TXMODE="$1"
 49 shift
 50 readonly EXTRA_ARGS="$@"
 51 
 52 # Argument parsing: configure addresses
 53 if [[ "${IP}" == "4" ]]; then
 54         readonly SADDR="${SADDR4}"
 55         readonly DADDR="${DADDR4}"
 56 elif [[ "${IP}" == "6" ]]; then
 57         readonly SADDR="${SADDR6}"
 58         readonly DADDR="${DADDR6}"
 59 else
 60         echo "Invalid IP version ${IP}"
 61         exit 1
 62 fi
 63 
 64 # Argument parsing: select receive mode
 65 #
 66 # This differs from send mode for
 67 # - packet:     use raw recv, because packet receives skb clones
 68 # - raw_hdrinc: use raw recv, because hdrincl is a tx-only option
 69 case "${TXMODE}" in
 70 'packet' | 'packet_dgram' | 'raw_hdrincl')
 71         RXMODE='raw'
 72         ;;
 73 *)
 74         RXMODE="${TXMODE}"
 75         ;;
 76 esac
 77 
 78 # Start of state changes: install cleanup handler
 79 
 80 cleanup() {
 81         ip netns del "${NS2}"
 82         ip netns del "${NS1}"
 83 }
 84 
 85 trap cleanup EXIT
 86 
 87 # Create virtual ethernet pair between network namespaces
 88 ip netns add "${NS1}"
 89 ip netns add "${NS2}"
 90 
 91 # Configure system settings
 92 ip netns exec "${NS1}" sysctl -w -q "${path_sysctl_mem}=1000000"
 93 ip netns exec "${NS2}" sysctl -w -q "${path_sysctl_mem}=1000000"
 94 
 95 ip link add "${DEV}" mtu "${DEV_MTU}" netns "${NS1}" type veth \
 96   peer name "${DEV}" mtu "${DEV_MTU}" netns "${NS2}"
 97 
 98 # Bring the devices up
 99 ip -netns "${NS1}" link set "${DEV}" up
100 ip -netns "${NS2}" link set "${DEV}" up
101 
102 # Set fixed MAC addresses on the devices
103 ip -netns "${NS1}" link set dev "${DEV}" address 02:02:02:02:02:02
104 ip -netns "${NS2}" link set dev "${DEV}" address 06:06:06:06:06:06
105 
106 # Add fixed IP addresses to the devices
107 ip -netns "${NS1}" addr add 192.168.1.1/24 dev "${DEV}"
108 ip -netns "${NS2}" addr add 192.168.1.2/24 dev "${DEV}"
109 ip -netns "${NS1}" addr add       fd::1/64 dev "${DEV}" nodad
110 ip -netns "${NS2}" addr add       fd::2/64 dev "${DEV}" nodad
111 
112 # Optionally disable sg or csum offload to test edge cases
113 # ip netns exec "${NS1}" ethtool -K "${DEV}" sg off
114 
115 do_test() {
116         local readonly ARGS="$1"
117 
118         echo "ipv${IP} ${TXMODE} ${ARGS}"
119         ip netns exec "${NS2}" "${BIN_RX}" "-${IP}" -t 2 -C 2 -S "${SADDR}" -D "${DADDR}" -r "${RXMODE}" &
120         sleep 0.2
121         ip netns exec "${NS1}" "${BIN_TX}" "-${IP}" -t 1 -D "${DADDR}" ${ARGS} "${TXMODE}"
122         wait
123 }
124 
125 do_test "${EXTRA_ARGS}"
126 echo ok

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php