mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-15 06:56:44 +07:00
40f843ee5e
Currently, kernel pktgen has the feature to specify destination address range for sending packet. (e.g. pgset "dst_min/dst_max") But on samples, each pktgen script doesn't have any option to achieve this. This commit adds the feature to specify the destination address range with CIDR. -d : ($DEST_IP) destination IP. CIDR (e.g. 198.18.0.0/15) is also allowed # ./pktgen_sample01_simple.sh -6 -d fe80::20/126 -p 3000 -n 4 # tcpdump ip6 and udp 05:14:18.082285 IP6 fe80::99.71 > fe80::23.3000: UDP, length 16 05:14:18.082564 IP6 fe80::99.43 > fe80::23.3000: UDP, length 16 05:14:18.083366 IP6 fe80::99.107 > fe80::22.3000: UDP, length 16 05:14:18.083585 IP6 fe80::99.97 > fe80::21.3000: UDP, length 16 Signed-off-by: Daniel T. Lee <danieltimlee@gmail.com> Acked-by: Jesper Dangaard Brouer <brouer@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
122 lines
3.1 KiB
Bash
122 lines
3.1 KiB
Bash
#
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
# Common parameter parsing for pktgen scripts
|
|
#
|
|
|
|
function usage() {
|
|
echo ""
|
|
echo "Usage: $0 [-vx] -i ethX"
|
|
echo " -i : (\$DEV) output interface/device (required)"
|
|
echo " -s : (\$PKT_SIZE) packet size"
|
|
echo " -d : (\$DEST_IP) destination IP. CIDR (e.g. 198.18.0.0/15) is also allowed"
|
|
echo " -m : (\$DST_MAC) destination MAC-addr"
|
|
echo " -p : (\$DST_PORT) destination PORT range (e.g. 433-444) is also allowed"
|
|
echo " -t : (\$THREADS) threads to start"
|
|
echo " -f : (\$F_THREAD) index of first thread (zero indexed CPU number)"
|
|
echo " -c : (\$SKB_CLONE) SKB clones send before alloc new SKB"
|
|
echo " -n : (\$COUNT) num messages to send per thread, 0 means indefinitely"
|
|
echo " -b : (\$BURST) HW level bursting of SKBs"
|
|
echo " -v : (\$VERBOSE) verbose"
|
|
echo " -x : (\$DEBUG) debug"
|
|
echo " -6 : (\$IP6) IPv6"
|
|
echo ""
|
|
}
|
|
|
|
## --- Parse command line arguments / parameters ---
|
|
## echo "Commandline options:"
|
|
while getopts "s:i:d:m:p:f:t:c:n:b:vxh6" option; do
|
|
case $option in
|
|
i) # interface
|
|
export DEV=$OPTARG
|
|
info "Output device set to: DEV=$DEV"
|
|
;;
|
|
s)
|
|
export PKT_SIZE=$OPTARG
|
|
info "Packet size set to: PKT_SIZE=$PKT_SIZE bytes"
|
|
;;
|
|
d) # destination IP
|
|
export DEST_IP=$OPTARG
|
|
info "Destination IP set to: DEST_IP=$DEST_IP"
|
|
;;
|
|
m) # MAC
|
|
export DST_MAC=$OPTARG
|
|
info "Destination MAC set to: DST_MAC=$DST_MAC"
|
|
;;
|
|
p) # PORT
|
|
export DST_PORT=$OPTARG
|
|
info "Destination PORT set to: DST_PORT=$DST_PORT"
|
|
;;
|
|
f)
|
|
export F_THREAD=$OPTARG
|
|
info "Index of first thread (zero indexed CPU number): $F_THREAD"
|
|
;;
|
|
t)
|
|
export THREADS=$OPTARG
|
|
info "Number of threads to start: $THREADS"
|
|
;;
|
|
c)
|
|
export CLONE_SKB=$OPTARG
|
|
info "CLONE_SKB=$CLONE_SKB"
|
|
;;
|
|
n)
|
|
export COUNT=$OPTARG
|
|
info "COUNT=$COUNT"
|
|
;;
|
|
b)
|
|
export BURST=$OPTARG
|
|
info "SKB bursting: BURST=$BURST"
|
|
;;
|
|
v)
|
|
export VERBOSE=yes
|
|
info "Verbose mode: VERBOSE=$VERBOSE"
|
|
;;
|
|
x)
|
|
export DEBUG=yes
|
|
info "Debug mode: DEBUG=$DEBUG"
|
|
;;
|
|
6)
|
|
export IP6=6
|
|
info "IP6: IP6=$IP6"
|
|
;;
|
|
h|?|*)
|
|
usage;
|
|
err 2 "[ERROR] Unknown parameters!!!"
|
|
esac
|
|
done
|
|
shift $(( $OPTIND - 1 ))
|
|
|
|
if [ -z "$PKT_SIZE" ]; then
|
|
# NIC adds 4 bytes CRC
|
|
export PKT_SIZE=60
|
|
info "Default packet size set to: set to: $PKT_SIZE bytes"
|
|
fi
|
|
|
|
if [ -z "$F_THREAD" ]; then
|
|
# First thread (F_THREAD) reference the zero indexed CPU number
|
|
export F_THREAD=0
|
|
fi
|
|
|
|
if [ -z "$THREADS" ]; then
|
|
export THREADS=1
|
|
fi
|
|
|
|
export L_THREAD=$(( THREADS + F_THREAD - 1 ))
|
|
|
|
if [ -z "$DEV" ]; then
|
|
usage
|
|
err 2 "Please specify output device"
|
|
fi
|
|
|
|
if [ -z "$DST_MAC" ]; then
|
|
warn "Missing destination MAC address"
|
|
fi
|
|
|
|
if [ -z "$DEST_IP" ]; then
|
|
warn "Missing destination IP address"
|
|
fi
|
|
|
|
if [ ! -d /proc/net/pktgen ]; then
|
|
info "Loading kernel module: pktgen"
|
|
modprobe pktgen
|
|
fi
|