udpgro_frglist.sh 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #!/bin/bash
  2. # SPDX-License-Identifier: GPL-2.0
  3. #
  4. # Run a series of udpgro benchmarks
  5. source lib.sh
  6. readonly PEER_NS="ns-peer-$(mktemp -u XXXXXX)"
  7. BPF_FILE="lib/xdp_dummy.bpf.o"
  8. cleanup() {
  9. local -r jobs="$(jobs -p)"
  10. local -r ns="$(ip netns list|grep $PEER_NS)"
  11. [ -n "${jobs}" ] && kill -INT ${jobs} 2>/dev/null
  12. [ -n "$ns" ] && ip netns del $ns 2>/dev/null
  13. }
  14. trap cleanup EXIT
  15. run_one() {
  16. # use 'rx' as separator between sender args and receiver args
  17. local -r all="$@"
  18. local -r tx_args=${all%rx*}
  19. local rx_args=${all#*rx}
  20. ip netns add "${PEER_NS}"
  21. ip -netns "${PEER_NS}" link set lo up
  22. ip link add type veth
  23. ip link set dev veth0 up
  24. ip addr add dev veth0 192.168.1.2/24
  25. ip addr add dev veth0 2001:db8::2/64 nodad
  26. ip link set dev veth1 netns "${PEER_NS}"
  27. ip -netns "${PEER_NS}" addr add dev veth1 192.168.1.1/24
  28. ip -netns "${PEER_NS}" addr add dev veth1 2001:db8::1/64 nodad
  29. ip -netns "${PEER_NS}" link set dev veth1 up
  30. ip netns exec "${PEER_NS}" ethtool -K veth1 rx-gro-list on
  31. ip -n "${PEER_NS}" link set veth1 xdp object ${BPF_FILE} section xdp
  32. tc -n "${PEER_NS}" qdisc add dev veth1 clsact
  33. tc -n "${PEER_NS}" filter add dev veth1 ingress prio 4 protocol ipv6 bpf object-file nat6to4.bpf.o section schedcls/ingress6/nat_6 direct-action
  34. tc -n "${PEER_NS}" filter add dev veth1 egress prio 4 protocol ip bpf object-file nat6to4.bpf.o section schedcls/egress4/snat4 direct-action
  35. echo ${rx_args}
  36. ip netns exec "${PEER_NS}" ./udpgso_bench_rx ${rx_args} -r &
  37. wait_local_port_listen "${PEER_NS}" 8000 udp
  38. ./udpgso_bench_tx ${tx_args}
  39. }
  40. run_in_netns() {
  41. local -r args=$@
  42. echo ${args}
  43. ./in_netns.sh $0 __subprocess ${args}
  44. }
  45. run_udp() {
  46. local -r args=$@
  47. echo "udp gso - over veth touching data"
  48. run_in_netns ${args} -u -S 0 rx -4 -v
  49. echo "udp gso and gro - over veth touching data"
  50. run_in_netns ${args} -S 0 rx -4 -G
  51. }
  52. run_tcp() {
  53. local -r args=$@
  54. echo "tcp - over veth touching data"
  55. run_in_netns ${args} -t rx -4 -t
  56. }
  57. run_all() {
  58. local -r core_args="-l 4"
  59. local -r ipv4_args="${core_args} -4 -D 192.168.1.1"
  60. local -r ipv6_args="${core_args} -6 -D 2001:db8::1"
  61. echo "ipv6"
  62. run_tcp "${ipv6_args}"
  63. run_udp "${ipv6_args}"
  64. }
  65. if [ ! -f ${BPF_FILE} ]; then
  66. echo "Missing ${BPF_FILE}. Run 'make' first"
  67. exit -1
  68. fi
  69. if [ ! -f nat6to4.bpf.o ]; then
  70. echo "Missing nat6to4 helper. Run 'make' first"
  71. exit -1
  72. fi
  73. if [[ $# -eq 0 ]]; then
  74. run_all
  75. elif [[ $1 == "__subprocess" ]]; then
  76. shift
  77. run_one $@
  78. else
  79. run_in_netns $@
  80. fi