60 lines · bash
1#!/bin/bash2# SPDX-License-Identifier: GPL-2.03#4# Verify that FQ has a packet limit per band:5#6# 1. set the limit to 10 per band7# 2. send 20 pkts on band A: verify that 10 are queued, 10 dropped8# 3. send 20 pkts on band A: verify that 0 are queued, 20 dropped9# 4. send 20 pkts on band B: verify that 10 are queued, 10 dropped10#11# Send packets with a delay to ensure that previously sent12# packets are still queued when later ones are sent.13# Use SO_TXTIME for this.14 15die() {16 echo "$1"17 exit 118}19 20# run inside private netns21if [[ $# -eq 0 ]]; then22 ./in_netns.sh "$0" __subprocess23 exit24fi25 26ip link add type dummy27ip link set dev dummy0 up28ip -6 addr add fdaa::1/128 dev dummy029ip -6 route add fdaa::/64 dev dummy030tc qdisc replace dev dummy0 root handle 1: fq quantum 1514 initial_quantum 1514 limit 1031 32DELAY=40000033 34./cmsg_sender -6 -p u -d "${DELAY}" -n 20 fdaa::2 800035OUT1="$(tc -s qdisc show dev dummy0 | grep '^\ Sent')"36 37./cmsg_sender -6 -p u -d "${DELAY}" -n 20 fdaa::2 800038OUT2="$(tc -s qdisc show dev dummy0 | grep '^\ Sent')"39 40./cmsg_sender -6 -p u -d "${DELAY}" -n 20 -P 7 fdaa::2 800041OUT3="$(tc -s qdisc show dev dummy0 | grep '^\ Sent')"42 43# Initial stats will report zero sent, as all packets are still44# queued in FQ. Sleep for at least the delay period and see that45# twenty are now sent.46sleep 0.647OUT4="$(tc -s qdisc show dev dummy0 | grep '^\ Sent')"48 49# Log the output after the test50echo "${OUT1}"51echo "${OUT2}"52echo "${OUT3}"53echo "${OUT4}"54 55# Test the output for expected values56echo "${OUT1}" | grep -q '0\ pkt\ (dropped\ 10' || die "unexpected drop count at 1"57echo "${OUT2}" | grep -q '0\ pkt\ (dropped\ 30' || die "unexpected drop count at 2"58echo "${OUT3}" | grep -q '0\ pkt\ (dropped\ 40' || die "unexpected drop count at 3"59echo "${OUT4}" | grep -q '20\ pkt\ (dropped\ 40' || die "unexpected accept count at 4"60