Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

samples: Add an IPv6 '-6' option to the pktgen scripts

Add a '-6' option to the sample pktgen scripts for sending out
IPv6 packets.

[root@kerneldev010.prn1 ~/pktgen]# ./pktgen_sample03_burst_single_flow.sh -i eth0 -s 64 -d fe80::f652:14ff:fec2:a14c -m f4:52:14:c2:a1:4c -b 32 -6

[root@kerneldev011.prn1 ~]# tcpdump -i eth0 -nn -c3 port 9
tcpdump: WARNING: eth0: no IPv4 address assigned
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes
14:38:51.815297 IP6 fe80::f652:14ff:fec2:2ad2.9 > fe80::f652:14ff:fec2:a14c.9: UDP, length 16
14:38:51.815311 IP6 fe80::f652:14ff:fec2:2ad2.9 > fe80::f652:14ff:fec2:a14c.9: UDP, length 16
14:38:51.815313 IP6 fe80::f652:14ff:fec2:2ad2.9 > fe80::f652:14ff:fec2:a14c.9: UDP, length 16

Signed-off-by: Martin KaFai Lau <kafai@fb.com>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Martin KaFai Lau and committed by
David S. Miller
0f06a678 1c137ef4

+26 -11
+6 -1
samples/pktgen/parameters.sh
··· 14 14 echo " -b : (\$BURST) HW level bursting of SKBs" 15 15 echo " -v : (\$VERBOSE) verbose" 16 16 echo " -x : (\$DEBUG) debug" 17 + echo " -6 : (\$IP6) IPv6" 17 18 echo "" 18 19 } 19 20 20 21 ## --- Parse command line arguments / parameters --- 21 22 ## echo "Commandline options:" 22 - while getopts "s:i:d:m:t:c:b:vxh" option; do 23 + while getopts "s:i:d:m:t:c:b:vxh6" option; do 23 24 case $option in 24 25 i) # interface 25 26 export DEV=$OPTARG ··· 60 59 export DEBUG=yes 61 60 info "Debug mode: DEBUG=$DEBUG" 62 61 ;; 62 + 6) 63 + export IP6=6 64 + info "IP6: IP6=$IP6" 65 + ;; 63 66 h|?|*) 64 67 usage; 65 68 err 2 "[ERROR] Unknown parameters!!!"
+4 -2
samples/pktgen/pktgen_bench_xmit_mode_netif_receive.sh
··· 34 34 source ${basedir}/parameters.sh 35 35 # Using invalid DST_MAC will cause the packets to get dropped in 36 36 # ip_rcv() which is part of the test 37 - [ -z "$DEST_IP" ] && DEST_IP="198.18.0.42" 37 + if [ -z "$DEST_IP" ]; then 38 + [ -z "$IP6" ] && DEST_IP="198.18.0.42" || DEST_IP="FD00::1" 39 + fi 38 40 [ -z "$DST_MAC" ] && DST_MAC="90:e2:ba:ff:ff:ff" 39 41 [ -z "$BURST" ] && BURST=1024 40 42 ··· 66 64 67 65 # Destination 68 66 pg_set $dev "dst_mac $DST_MAC" 69 - pg_set $dev "dst $DEST_IP" 67 + pg_set $dev "dst$IP6 $DEST_IP" 70 68 71 69 # Inject packet into RX path of stack 72 70 pg_set $dev "xmit_mode netif_receive"
+4 -2
samples/pktgen/pktgen_bench_xmit_mode_queue_xmit.sh
··· 13 13 14 14 # Parameter parsing via include 15 15 source ${basedir}/parameters.sh 16 - [ -z "$DEST_IP" ] && DEST_IP="198.18.0.42" 16 + if [ -z "$DEST_IP" ]; then 17 + [ -z "$IP6" ] && DEST_IP="198.18.0.42" || DEST_IP="FD00::1" 18 + fi 17 19 [ -z "$DST_MAC" ] && DST_MAC="90:e2:ba:ff:ff:ff" 18 20 19 21 # Burst greater than 1 are invalid for queue_xmit mode ··· 49 47 50 48 # Destination 51 49 pg_set $dev "dst_mac $DST_MAC" 52 - pg_set $dev "dst $DEST_IP" 50 + pg_set $dev "dst$IP6 $DEST_IP" 53 51 54 52 # Inject packet into TX qdisc egress path of stack 55 53 pg_set $dev "xmit_mode queue_xmit"
+4 -2
samples/pktgen/pktgen_sample01_simple.sh
··· 14 14 source ${basedir}/parameters.sh 15 15 # 16 16 # Set some default params, if they didn't get set 17 - [ -z "$DEST_IP" ] && DEST_IP="198.18.0.42" 17 + if [ -z "$DEST_IP" ]; then 18 + [ -z "$IP6" ] && DEST_IP="198.18.0.42" || DEST_IP="FD00::1" 19 + fi 18 20 [ -z "$CLONE_SKB" ] && CLONE_SKB="0" 19 21 # Example enforce param "-m" for dst_mac 20 22 [ -z "$DST_MAC" ] && usage && err 2 "Must specify -m dst_mac" ··· 56 54 57 55 # Destination 58 56 pg_set $DEV "dst_mac $DST_MAC" 59 - pg_set $DEV "dst $DEST_IP" 57 + pg_set $DEV "dst$IP6 $DEST_IP" 60 58 61 59 # Setup random UDP port src range 62 60 pg_set $DEV "flag UDPSRC_RND"
+4 -2
samples/pktgen/pktgen_sample02_multiqueue.sh
··· 23 23 UDP_MAX=109 24 24 25 25 # (example of setting default params in your script) 26 - [ -z "$DEST_IP" ] && DEST_IP="198.18.0.42" 26 + if [ -z "$DEST_IP" ]; then 27 + [ -z "$IP6" ] && DEST_IP="198.18.0.42" || DEST_IP="FD00::1" 28 + fi 27 29 [ -z "$DST_MAC" ] && DST_MAC="90:e2:ba:ff:ff:ff" 28 30 29 31 # General cleanup everything since last run ··· 56 54 57 55 # Destination 58 56 pg_set $dev "dst_mac $DST_MAC" 59 - pg_set $dev "dst $DEST_IP" 57 + pg_set $dev "dst$IP6 $DEST_IP" 60 58 61 59 # Setup random UDP port src range 62 60 pg_set $dev "flag UDPSRC_RND"
+4 -2
samples/pktgen/pktgen_sample03_burst_single_flow.sh
··· 25 25 # Parameter parsing via include 26 26 source ${basedir}/parameters.sh 27 27 # Set some default params, if they didn't get set 28 - [ -z "$DEST_IP" ] && DEST_IP="198.18.0.42" 28 + if [ -z "$DEST_IP" ]; then 29 + [ -z "$IP6" ] && DEST_IP="198.18.0.42" || DEST_IP="FD00::1" 30 + fi 29 31 [ -z "$DST_MAC" ] && DST_MAC="90:e2:ba:ff:ff:ff" 30 32 [ -z "$BURST" ] && BURST=32 31 33 [ -z "$CLONE_SKB" ] && CLONE_SKB="100000" ··· 57 55 58 56 # Destination 59 57 pg_set $dev "dst_mac $DST_MAC" 60 - pg_set $dev "dst $DEST_IP" 58 + pg_set $dev "dst$IP6 $DEST_IP" 61 59 62 60 # Setup burst, for easy testing -b 0 disable bursting 63 61 # (internally in pktgen default and minimum burst=1)