From 7c95a9d962f9ffdf02a3d82a6ae108c254a29122 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Tue, 24 Feb 2015 02:32:07 +0000 Subject: samples/pktgen: Add sample scripts for pktgen facility These are Robert Olsson's samples which used to be available from but currently are not. Change the documentation to refer to these consistently as 'sample scripts', matching the directory name used here. Cc: Robert Olsson Signed-off-by: Ben Hutchings Signed-off-by: David S. Miller --- samples/pktgen/pktgen.conf-1-1 | 66 ++++++++++++++++++++++++++ samples/pktgen/pktgen.conf-1-1-flows | 74 +++++++++++++++++++++++++++++ samples/pktgen/pktgen.conf-1-1-ip6 | 67 +++++++++++++++++++++++++++ samples/pktgen/pktgen.conf-1-1-ip6-rdos | 70 ++++++++++++++++++++++++++++ samples/pktgen/pktgen.conf-1-1-rdos | 71 ++++++++++++++++++++++++++++ samples/pktgen/pktgen.conf-1-2 | 76 ++++++++++++++++++++++++++++++ samples/pktgen/pktgen.conf-2-1 | 72 +++++++++++++++++++++++++++++ samples/pktgen/pktgen.conf-2-2 | 82 +++++++++++++++++++++++++++++++++ 8 files changed, 578 insertions(+) create mode 100755 samples/pktgen/pktgen.conf-1-1 create mode 100755 samples/pktgen/pktgen.conf-1-1-flows create mode 100755 samples/pktgen/pktgen.conf-1-1-ip6 create mode 100755 samples/pktgen/pktgen.conf-1-1-ip6-rdos create mode 100755 samples/pktgen/pktgen.conf-1-1-rdos create mode 100755 samples/pktgen/pktgen.conf-1-2 create mode 100755 samples/pktgen/pktgen.conf-2-1 create mode 100755 samples/pktgen/pktgen.conf-2-2 (limited to 'samples') diff --git a/samples/pktgen/pktgen.conf-1-1 b/samples/pktgen/pktgen.conf-1-1 new file mode 100755 index 000000000000..5d30f836ca3e --- /dev/null +++ b/samples/pktgen/pktgen.conf-1-1 @@ -0,0 +1,66 @@ +#! /bin/sh + +#modprobe pktgen + + +function pgset() { + local result + + echo $1 > $PGDEV + + result=`cat $PGDEV | fgrep "Result: OK:"` + if [ "$result" = "" ]; then + cat $PGDEV | fgrep Result: + fi +} + +function pg() { + echo inject > $PGDEV + cat $PGDEV +} + +# Config Start Here ----------------------------------------------------------- + + +# thread config +# Each CPU has own thread. Two CPU exammple. We add eth1, eth2 respectivly. + +PGDEV=/proc/net/pktgen/kpktgend_0 + echo "Removing all devices" + pgset "rem_device_all" + echo "Adding eth1" + pgset "add_device eth1" + echo "Setting max_before_softirq 10000" + pgset "max_before_softirq 10000" + + +# device config +# delay 0 means maximum speed. + +CLONE_SKB="clone_skb 1000000" +# NIC adds 4 bytes CRC +PKT_SIZE="pkt_size 60" + +# COUNT 0 means forever +#COUNT="count 0" +COUNT="count 10000000" +DELAY="delay 0" + +PGDEV=/proc/net/pktgen/eth1 + echo "Configuring $PGDEV" + pgset "$COUNT" + pgset "$CLONE_SKB" + pgset "$PKT_SIZE" + pgset "$DELAY" + pgset "dst 10.10.11.2" + pgset "dst_mac 00:04:23:08:91:dc" + + +# Time to run +PGDEV=/proc/net/pktgen/pgctrl + + echo "Running... ctrl^C to stop" + pgset "start" + echo "Done" + +# Result can be vieved in /proc/net/pktgen/eth1 diff --git a/samples/pktgen/pktgen.conf-1-1-flows b/samples/pktgen/pktgen.conf-1-1-flows new file mode 100755 index 000000000000..88a01b7d3531 --- /dev/null +++ b/samples/pktgen/pktgen.conf-1-1-flows @@ -0,0 +1,74 @@ +#! /bin/sh + +#modprobe pktgen + + +function pgset() { + local result + + echo $1 > $PGDEV + + result=`cat $PGDEV | fgrep "Result: OK:"` + if [ "$result" = "" ]; then + cat $PGDEV | fgrep Result: + fi +} + +function pg() { + echo inject > $PGDEV + cat $PGDEV +} + +# Config Start Here ----------------------------------------------------------- + + +# thread config +# Each CPU has own thread. Two CPU exammple. We add eth1, eth2 respectivly. + +PGDEV=/proc/net/pktgen/kpktgend_0 + echo "Removing all devices" + pgset "rem_device_all" + echo "Adding eth1" + pgset "add_device eth1" + echo "Setting max_before_softirq 10000" + pgset "max_before_softirq 10000" + + +# device config +# delay 0 +# We need to do alloc for every skb since we cannot clone here. + +CLONE_SKB="clone_skb 0" +# NIC adds 4 bytes CRC +PKT_SIZE="pkt_size 60" + +# COUNT 0 means forever +#COUNT="count 0" +COUNT="count 10000000" +DELAY="delay 0" + +PGDEV=/proc/net/pktgen/eth1 + echo "Configuring $PGDEV" + pgset "$COUNT" + pgset "$CLONE_SKB" + pgset "$PKT_SIZE" + pgset "$DELAY" + # Random address with in the min-max range + pgset "flag IPDST_RND" + pgset "dst_min 10.0.0.0" + pgset "dst_max 10.255.255.255" + + # 8k Concurrent flows at 4 pkts + pgset "flows 8192" + pgset "flowlen 4" + + pgset "dst_mac 00:04:23:08:91:dc" + +# Time to run +PGDEV=/proc/net/pktgen/pgctrl + + echo "Running... ctrl^C to stop" + pgset "start" + echo "Done" + +# Result can be vieved in /proc/net/pktgen/eth1 diff --git a/samples/pktgen/pktgen.conf-1-1-ip6 b/samples/pktgen/pktgen.conf-1-1-ip6 new file mode 100755 index 000000000000..752f112bd9e6 --- /dev/null +++ b/samples/pktgen/pktgen.conf-1-1-ip6 @@ -0,0 +1,67 @@ +#! /bin/sh + +#modprobe pktgen + + +function pgset() { + local result + + echo $1 > $PGDEV + + result=`cat $PGDEV | fgrep "Result: OK:"` + if [ "$result" = "" ]; then + cat $PGDEV | fgrep Result: + fi +} + +function pg() { + echo inject > $PGDEV + cat $PGDEV +} + +# Config Start Here ----------------------------------------------------------- + + +# thread config +# Each CPU has own thread. Two CPU exammple. We add eth1, eth2 respectivly. +# IPv6. Note increase in minimal packet length + +PGDEV=/proc/net/pktgen/kpktgend_0 + echo "Removing all devices" + pgset "rem_device_all" + echo "Adding eth1" + pgset "add_device eth1" + echo "Setting max_before_softirq 10000" + pgset "max_before_softirq 10000" + + +# device config +# delay 0 + +CLONE_SKB="clone_skb 1000000" +# NIC adds 4 bytes CRC +PKT_SIZE="pkt_size 66" + +# COUNT 0 means forever +#COUNT="count 0" +COUNT="count 10000000" +DELAY="delay 0" + +PGDEV=/proc/net/pktgen/eth1 + echo "Configuring $PGDEV" + pgset "$COUNT" + pgset "$CLONE_SKB" + pgset "$PKT_SIZE" + pgset "$DELAY" + pgset "dst6 fec0::1" + pgset "src6 fec0::2" + pgset "dst_mac 00:04:23:08:91:dc" + +# Time to run +PGDEV=/proc/net/pktgen/pgctrl + + echo "Running... ctrl^C to stop" + pgset "start" + echo "Done" + +# Result can be vieved in /proc/net/pktgen/eth1 diff --git a/samples/pktgen/pktgen.conf-1-1-ip6-rdos b/samples/pktgen/pktgen.conf-1-1-ip6-rdos new file mode 100755 index 000000000000..fd364277e43f --- /dev/null +++ b/samples/pktgen/pktgen.conf-1-1-ip6-rdos @@ -0,0 +1,70 @@ +#! /bin/sh + +#modprobe pktgen + + +function pgset() { + local result + + echo $1 > $PGDEV + + result=`cat $PGDEV | fgrep "Result: OK:"` + if [ "$result" = "" ]; then + cat $PGDEV | fgrep Result: + fi +} + +function pg() { + echo inject > $PGDEV + cat $PGDEV +} + +# Config Start Here ----------------------------------------------------------- + + +# thread config +# Each CPU has own thread. Two CPU exammple. We add eth1, eth2 respectivly. +# IPv6. Note increase in minimal packet length + +PGDEV=/proc/net/pktgen/kpktgend_0 + echo "Removing all devices" + pgset "rem_device_all" + echo "Adding eth1" + pgset "add_device eth1" + echo "Setting max_before_softirq 10000" + pgset "max_before_softirq 10000" + + +# device config +# delay 0 means maximum speed. + +# We need to do alloc for every skb since we cannot clone here. +CLONE_SKB="clone_skb 0" + +# NIC adds 4 bytes CRC +PKT_SIZE="pkt_size 66" + +# COUNT 0 means forever +#COUNT="count 0" +COUNT="count 10000000" +DELAY="delay 0" + +PGDEV=/proc/net/pktgen/eth1 + echo "Configuring $PGDEV" + pgset "$COUNT" + pgset "$CLONE_SKB" + pgset "$PKT_SIZE" + pgset "$DELAY" + pgset "dst6_min fec0::1" + pgset "dst6_max fec0::FFFF:FFFF" + + pgset "dst_mac 00:04:23:08:91:dc" + +# Time to run +PGDEV=/proc/net/pktgen/pgctrl + + echo "Running... ctrl^C to stop" + pgset "start" + echo "Done" + +# Result can be vieved in /proc/net/pktgen/eth1 diff --git a/samples/pktgen/pktgen.conf-1-1-rdos b/samples/pktgen/pktgen.conf-1-1-rdos new file mode 100755 index 000000000000..bc81fa319243 --- /dev/null +++ b/samples/pktgen/pktgen.conf-1-1-rdos @@ -0,0 +1,71 @@ +#! /bin/sh + +#modprobe pktgen + + +function pgset() { + local result + + echo $1 > $PGDEV + + result=`cat $PGDEV | fgrep "Result: OK:"` + if [ "$result" = "" ]; then + cat $PGDEV | fgrep Result: + fi +} + +function pg() { + echo inject > $PGDEV + cat $PGDEV +} + +# Config Start Here ----------------------------------------------------------- + + +# thread config +# Each CPU has own thread. Two CPU exammple. We add eth1, eth2 respectivly. + +PGDEV=/proc/net/pktgen/kpktgend_0 + echo "Removing all devices" + pgset "rem_device_all" + echo "Adding eth1" + pgset "add_device eth1" + echo "Setting max_before_softirq 10000" + pgset "max_before_softirq 10000" + + +# device config +# delay 0 + +# We need to do alloc for every skb since we cannot clone here. + +CLONE_SKB="clone_skb 0" +# NIC adds 4 bytes CRC +PKT_SIZE="pkt_size 60" + +# COUNT 0 means forever +#COUNT="count 0" +COUNT="count 10000000" +DELAY="delay 0" + +PGDEV=/proc/net/pktgen/eth1 + echo "Configuring $PGDEV" + pgset "$COUNT" + pgset "$CLONE_SKB" + pgset "$PKT_SIZE" + pgset "$DELAY" + # Random address with in the min-max range + pgset "flag IPDST_RND" + pgset "dst_min 10.0.0.0" + pgset "dst_max 10.255.255.255" + + pgset "dst_mac 00:04:23:08:91:dc" + +# Time to run +PGDEV=/proc/net/pktgen/pgctrl + + echo "Running... ctrl^C to stop" + pgset "start" + echo "Done" + +# Result can be vieved in /proc/net/pktgen/eth1 diff --git a/samples/pktgen/pktgen.conf-1-2 b/samples/pktgen/pktgen.conf-1-2 new file mode 100755 index 000000000000..f99b88673860 --- /dev/null +++ b/samples/pktgen/pktgen.conf-1-2 @@ -0,0 +1,76 @@ +#! /bin/sh + +#modprobe pktgen + + +function pgset() { + local result + + echo $1 > $PGDEV + + result=`cat $PGDEV | fgrep "Result: OK:"` + if [ "$result" = "" ]; then + cat $PGDEV | fgrep Result: + fi +} + +function pg() { + echo inject > $PGDEV + cat $PGDEV +} + +# Config Start Here ----------------------------------------------------------- + + +# thread config +# One CPU means one thread. One CPU exammple. We add eth1, eth2 respectivly. + +PGDEV=/proc/net/pktgen/kpktgend_0 + echo "Removing all devices" + pgset "rem_device_all" + echo "Adding eth1" + pgset "add_device eth1" + echo "Adding eth2" + pgset "add_device eth2" + echo "Setting max_before_softirq 10000" + pgset "max_before_softirq 10000" + + +# device config +# delay 0 means maximum speed. + +CLONE_SKB="clone_skb 1000000" +# NIC adds 4 bytes CRC +PKT_SIZE="pkt_size 60" + +# COUNT 0 means forever +#COUNT="count 0" +COUNT="count 10000000" +DELAY="delay 0" + +PGDEV=/proc/net/pktgen/eth1 + echo "Configuring $PGDEV" + pgset "$COUNT" + pgset "$CLONE_SKB" + pgset "$PKT_SIZE" + pgset "$DELAY" + pgset "dst 10.10.11.2" + pgset "dst_mac 00:04:23:08:91:dc" + +PGDEV=/proc/net/pktgen/eth2 + echo "Configuring $PGDEV" + pgset "$COUNT" + pgset "$CLONE_SKB" + pgset "$PKT_SIZE" + pgset "$DELAY" + pgset "dst 192.168.2.2" + pgset "dst_mac 00:04:23:08:91:de" + +# Time to run +PGDEV=/proc/net/pktgen/pgctrl + + echo "Running... ctrl^C to stop" + pgset "start" + echo "Done" + +# Result can be vieved in /proc/net/pktgen/eth[1,2] diff --git a/samples/pktgen/pktgen.conf-2-1 b/samples/pktgen/pktgen.conf-2-1 new file mode 100755 index 000000000000..845d7bf1609a --- /dev/null +++ b/samples/pktgen/pktgen.conf-2-1 @@ -0,0 +1,72 @@ +#! /bin/sh + +#modprobe pktgen + + +function pgset() { + local result + + echo $1 > $PGDEV + + result=`cat $PGDEV | fgrep "Result: OK:"` + if [ "$result" = "" ]; then + cat $PGDEV | fgrep Result: + fi +} + +function pg() { + echo inject > $PGDEV + cat $PGDEV +} + +# Config Start Here ----------------------------------------------------------- + + +# thread config +# Each CPU has own thread. Two CPU exammple. We add eth1, eth2 respectivly. + +PGDEV=/proc/net/pktgen/kpktgend_0 + echo "Removing all devices" + pgset "rem_device_all" + echo "Adding eth1" + pgset "add_device eth1" + echo "Setting max_before_softirq 10000" + pgset "max_before_softirq 10000" + +# We need to remove old config since we dont use this thread. We can only +# one NIC on one CPU due to affinity reasons. + +PGDEV=/proc/net/pktgen/kpktgend_1 + echo "Removing all devices" + pgset "rem_device_all" + +# device config +# delay 0 means maximum speed. + +CLONE_SKB="clone_skb 1000000" +# NIC adds 4 bytes CRC +PKT_SIZE="pkt_size 60" + +# COUNT 0 means forever +#COUNT="count 0" +COUNT="count 10000000" +DELAY="delay 0" + +PGDEV=/proc/net/pktgen/eth1 + echo "Configuring $PGDEV" + pgset "$COUNT" + pgset "$CLONE_SKB" + pgset "$PKT_SIZE" + pgset "$DELAY" + pgset "dst 10.10.11.2" + pgset "dst_mac 00:04:23:08:91:dc" + + +# Time to run +PGDEV=/proc/net/pktgen/pgctrl + + echo "Running... ctrl^C to stop" + pgset "start" + echo "Done" + +# Result can be vieved in /proc/net/pktgen/eth1 diff --git a/samples/pktgen/pktgen.conf-2-2 b/samples/pktgen/pktgen.conf-2-2 new file mode 100755 index 000000000000..7ce86470a3a9 --- /dev/null +++ b/samples/pktgen/pktgen.conf-2-2 @@ -0,0 +1,82 @@ +#! /bin/sh + +#modprobe pktgen + + +function pgset() { + local result + + echo $1 > $PGDEV + + result=`cat $PGDEV | fgrep "Result: OK:"` + if [ "$result" = "" ]; then + cat $PGDEV | fgrep Result: + fi +} + +function pg() { + echo inject > $PGDEV + cat $PGDEV +} + +# Config Start Here ----------------------------------------------------------- + + +# thread config +# Each CPU has own thread. Two CPU exammple. We add eth1, eth2 respectivly. + +PGDEV=/proc/net/pktgen/kpktgend_0 + echo "Removing all devices" + pgset "rem_device_all" + echo "Adding eth1" + pgset "add_device eth1" + echo "Setting max_before_softirq 10000" + pgset "max_before_softirq 10000" + +PGDEV=/proc/net/pktgen/kpktgend_1 + echo "Removing all devices" + pgset "rem_device_all" + echo "Adding eth2" + pgset "add_device eth2" + echo "Setting max_before_softirq 10000" + pgset "max_before_softirq 10000" + + +# device config +# delay 0 means maximum speed. + +CLONE_SKB="clone_skb 1000000" +# NIC adds 4 bytes CRC +PKT_SIZE="pkt_size 60" + +# COUNT 0 means forever +#COUNT="count 0" +COUNT="count 10000000" +DELAY="delay 0" + +PGDEV=/proc/net/pktgen/eth1 + echo "Configuring $PGDEV" + pgset "$COUNT" + pgset "$CLONE_SKB" + pgset "$PKT_SIZE" + pgset "$DELAY" + pgset "dst 10.10.11.2" + pgset "dst_mac 00:04:23:08:91:dc" + +PGDEV=/proc/net/pktgen/eth2 + echo "Configuring $PGDEV" + pgset "$COUNT" + pgset "$CLONE_SKB" + pgset "$PKT_SIZE" + pgset "$DELAY" + pgset "dst 192.168.2.2" + pgset "dst_mac 00:04:23:08:91:de" + +# Time to run +PGDEV=/proc/net/pktgen/pgctrl + + echo "Running... ctrl^C to stop" + pgset "start" + echo "Done" + +# Result can be vieved in /proc/net/pktgen/eth[1,2] -- cgit From 865367db658f6f4d7b8280b0968b47e2cbddab90 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Tue, 24 Feb 2015 02:32:17 +0000 Subject: samples/pktgen: Delete unused function pg() This function is not used and wouldn't do anything useful as pktgen does not have an 'inject' command. Signed-off-by: Ben Hutchings Signed-off-by: David S. Miller --- samples/pktgen/pktgen.conf-1-1 | 5 ----- samples/pktgen/pktgen.conf-1-1-flows | 5 ----- samples/pktgen/pktgen.conf-1-1-ip6 | 5 ----- samples/pktgen/pktgen.conf-1-1-ip6-rdos | 5 ----- samples/pktgen/pktgen.conf-1-1-rdos | 5 ----- samples/pktgen/pktgen.conf-1-2 | 5 ----- samples/pktgen/pktgen.conf-2-1 | 5 ----- samples/pktgen/pktgen.conf-2-2 | 5 ----- 8 files changed, 40 deletions(-) (limited to 'samples') diff --git a/samples/pktgen/pktgen.conf-1-1 b/samples/pktgen/pktgen.conf-1-1 index 5d30f836ca3e..0a81c985129c 100755 --- a/samples/pktgen/pktgen.conf-1-1 +++ b/samples/pktgen/pktgen.conf-1-1 @@ -14,11 +14,6 @@ function pgset() { fi } -function pg() { - echo inject > $PGDEV - cat $PGDEV -} - # Config Start Here ----------------------------------------------------------- diff --git a/samples/pktgen/pktgen.conf-1-1-flows b/samples/pktgen/pktgen.conf-1-1-flows index 88a01b7d3531..872dcbadd6c3 100755 --- a/samples/pktgen/pktgen.conf-1-1-flows +++ b/samples/pktgen/pktgen.conf-1-1-flows @@ -14,11 +14,6 @@ function pgset() { fi } -function pg() { - echo inject > $PGDEV - cat $PGDEV -} - # Config Start Here ----------------------------------------------------------- diff --git a/samples/pktgen/pktgen.conf-1-1-ip6 b/samples/pktgen/pktgen.conf-1-1-ip6 index 752f112bd9e6..cf0e86f8b43c 100755 --- a/samples/pktgen/pktgen.conf-1-1-ip6 +++ b/samples/pktgen/pktgen.conf-1-1-ip6 @@ -14,11 +14,6 @@ function pgset() { fi } -function pg() { - echo inject > $PGDEV - cat $PGDEV -} - # Config Start Here ----------------------------------------------------------- diff --git a/samples/pktgen/pktgen.conf-1-1-ip6-rdos b/samples/pktgen/pktgen.conf-1-1-ip6-rdos index fd364277e43f..799baeec0216 100755 --- a/samples/pktgen/pktgen.conf-1-1-ip6-rdos +++ b/samples/pktgen/pktgen.conf-1-1-ip6-rdos @@ -14,11 +14,6 @@ function pgset() { fi } -function pg() { - echo inject > $PGDEV - cat $PGDEV -} - # Config Start Here ----------------------------------------------------------- diff --git a/samples/pktgen/pktgen.conf-1-1-rdos b/samples/pktgen/pktgen.conf-1-1-rdos index bc81fa319243..e71f2818eef9 100755 --- a/samples/pktgen/pktgen.conf-1-1-rdos +++ b/samples/pktgen/pktgen.conf-1-1-rdos @@ -14,11 +14,6 @@ function pgset() { fi } -function pg() { - echo inject > $PGDEV - cat $PGDEV -} - # Config Start Here ----------------------------------------------------------- diff --git a/samples/pktgen/pktgen.conf-1-2 b/samples/pktgen/pktgen.conf-1-2 index f99b88673860..7f6e88e53ffd 100755 --- a/samples/pktgen/pktgen.conf-1-2 +++ b/samples/pktgen/pktgen.conf-1-2 @@ -14,11 +14,6 @@ function pgset() { fi } -function pg() { - echo inject > $PGDEV - cat $PGDEV -} - # Config Start Here ----------------------------------------------------------- diff --git a/samples/pktgen/pktgen.conf-2-1 b/samples/pktgen/pktgen.conf-2-1 index 845d7bf1609a..5e402cf9b0f5 100755 --- a/samples/pktgen/pktgen.conf-2-1 +++ b/samples/pktgen/pktgen.conf-2-1 @@ -14,11 +14,6 @@ function pgset() { fi } -function pg() { - echo inject > $PGDEV - cat $PGDEV -} - # Config Start Here ----------------------------------------------------------- diff --git a/samples/pktgen/pktgen.conf-2-2 b/samples/pktgen/pktgen.conf-2-2 index 7ce86470a3a9..d63dc5f2112d 100755 --- a/samples/pktgen/pktgen.conf-2-2 +++ b/samples/pktgen/pktgen.conf-2-2 @@ -14,11 +14,6 @@ function pgset() { fi } -function pg() { - echo inject > $PGDEV - cat $PGDEV -} - # Config Start Here ----------------------------------------------------------- -- cgit From 2ad1cdf2ea5991b42b934d76c36113ceb4561fa6 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Tue, 24 Feb 2015 02:32:37 +0000 Subject: samples/pktgen: Correct comments about the thread config They all claimed to be two CPU examples using eth1, eth2 but that is only true in one case! Rob Jones pointed out spelling and grammar errors here, which I've also corrected. Cc: Rob Jones Signed-off-by: Ben Hutchings Signed-off-by: David S. Miller --- samples/pktgen/pktgen.conf-1-1 | 2 +- samples/pktgen/pktgen.conf-1-1-flows | 2 +- samples/pktgen/pktgen.conf-1-1-ip6 | 2 +- samples/pktgen/pktgen.conf-1-1-ip6-rdos | 2 +- samples/pktgen/pktgen.conf-1-1-rdos | 2 +- samples/pktgen/pktgen.conf-1-2 | 2 +- samples/pktgen/pktgen.conf-2-1 | 3 ++- samples/pktgen/pktgen.conf-2-2 | 2 +- 8 files changed, 9 insertions(+), 8 deletions(-) (limited to 'samples') diff --git a/samples/pktgen/pktgen.conf-1-1 b/samples/pktgen/pktgen.conf-1-1 index 0a81c985129c..79462adad05d 100755 --- a/samples/pktgen/pktgen.conf-1-1 +++ b/samples/pktgen/pktgen.conf-1-1 @@ -18,7 +18,7 @@ function pgset() { # thread config -# Each CPU has own thread. Two CPU exammple. We add eth1, eth2 respectivly. +# Each CPU has its own thread. One CPU example. We add eth1. PGDEV=/proc/net/pktgen/kpktgend_0 echo "Removing all devices" diff --git a/samples/pktgen/pktgen.conf-1-1-flows b/samples/pktgen/pktgen.conf-1-1-flows index 872dcbadd6c3..629ac3eaee35 100755 --- a/samples/pktgen/pktgen.conf-1-1-flows +++ b/samples/pktgen/pktgen.conf-1-1-flows @@ -18,7 +18,7 @@ function pgset() { # thread config -# Each CPU has own thread. Two CPU exammple. We add eth1, eth2 respectivly. +# Each CPU has its own thread. One CPU example. We add eth1. PGDEV=/proc/net/pktgen/kpktgend_0 echo "Removing all devices" diff --git a/samples/pktgen/pktgen.conf-1-1-ip6 b/samples/pktgen/pktgen.conf-1-1-ip6 index cf0e86f8b43c..c392475d60cf 100755 --- a/samples/pktgen/pktgen.conf-1-1-ip6 +++ b/samples/pktgen/pktgen.conf-1-1-ip6 @@ -18,7 +18,7 @@ function pgset() { # thread config -# Each CPU has own thread. Two CPU exammple. We add eth1, eth2 respectivly. +# Each CPU has its own thread. One CPU example. We add eth1. # IPv6. Note increase in minimal packet length PGDEV=/proc/net/pktgen/kpktgend_0 diff --git a/samples/pktgen/pktgen.conf-1-1-ip6-rdos b/samples/pktgen/pktgen.conf-1-1-ip6-rdos index 799baeec0216..220d276f033a 100755 --- a/samples/pktgen/pktgen.conf-1-1-ip6-rdos +++ b/samples/pktgen/pktgen.conf-1-1-ip6-rdos @@ -18,7 +18,7 @@ function pgset() { # thread config -# Each CPU has own thread. Two CPU exammple. We add eth1, eth2 respectivly. +# Each CPU has its own thread. One CPU example. We add eth1. # IPv6. Note increase in minimal packet length PGDEV=/proc/net/pktgen/kpktgend_0 diff --git a/samples/pktgen/pktgen.conf-1-1-rdos b/samples/pktgen/pktgen.conf-1-1-rdos index e71f2818eef9..6013975d26d9 100755 --- a/samples/pktgen/pktgen.conf-1-1-rdos +++ b/samples/pktgen/pktgen.conf-1-1-rdos @@ -18,7 +18,7 @@ function pgset() { # thread config -# Each CPU has own thread. Two CPU exammple. We add eth1, eth2 respectivly. +# Each CPU has its own thread. One CPU example. We add eth1. PGDEV=/proc/net/pktgen/kpktgend_0 echo "Removing all devices" diff --git a/samples/pktgen/pktgen.conf-1-2 b/samples/pktgen/pktgen.conf-1-2 index 7f6e88e53ffd..136e10caff63 100755 --- a/samples/pktgen/pktgen.conf-1-2 +++ b/samples/pktgen/pktgen.conf-1-2 @@ -18,7 +18,7 @@ function pgset() { # thread config -# One CPU means one thread. One CPU exammple. We add eth1, eth2 respectivly. +# One CPU means one thread. One CPU example. We add eth1, eth2 respectivly. PGDEV=/proc/net/pktgen/kpktgend_0 echo "Removing all devices" diff --git a/samples/pktgen/pktgen.conf-2-1 b/samples/pktgen/pktgen.conf-2-1 index 5e402cf9b0f5..ccd32780bed1 100755 --- a/samples/pktgen/pktgen.conf-2-1 +++ b/samples/pktgen/pktgen.conf-2-1 @@ -18,7 +18,8 @@ function pgset() { # thread config -# Each CPU has own thread. Two CPU exammple. We add eth1, eth2 respectivly. +# Each CPU has its own thread. Two CPU example. We add eth1 to the first +# and leave the second idle. PGDEV=/proc/net/pktgen/kpktgend_0 echo "Removing all devices" diff --git a/samples/pktgen/pktgen.conf-2-2 b/samples/pktgen/pktgen.conf-2-2 index d63dc5f2112d..49ae4cf2bb76 100755 --- a/samples/pktgen/pktgen.conf-2-2 +++ b/samples/pktgen/pktgen.conf-2-2 @@ -18,7 +18,7 @@ function pgset() { # thread config -# Each CPU has own thread. Two CPU exammple. We add eth1, eth2 respectivly. +# Each CPU has its own thread. Two CPU example. We add eth1, eth2 respectively. PGDEV=/proc/net/pktgen/kpktgend_0 echo "Removing all devices" -- cgit From 06481f22c6fa5a85445770d5adceb261cac6620f Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Tue, 24 Feb 2015 02:32:48 +0000 Subject: samples/pktgen: Remove setting of obsolete max_before_softirq parameter Signed-off-by: Ben Hutchings Signed-off-by: David S. Miller --- samples/pktgen/pktgen.conf-1-1 | 2 -- samples/pktgen/pktgen.conf-1-1-flows | 2 -- samples/pktgen/pktgen.conf-1-1-ip6 | 2 -- samples/pktgen/pktgen.conf-1-1-ip6-rdos | 2 -- samples/pktgen/pktgen.conf-1-1-rdos | 2 -- samples/pktgen/pktgen.conf-1-2 | 2 -- samples/pktgen/pktgen.conf-2-1 | 2 -- samples/pktgen/pktgen.conf-2-2 | 4 ---- 8 files changed, 18 deletions(-) (limited to 'samples') diff --git a/samples/pktgen/pktgen.conf-1-1 b/samples/pktgen/pktgen.conf-1-1 index 79462adad05d..e32782e06caf 100755 --- a/samples/pktgen/pktgen.conf-1-1 +++ b/samples/pktgen/pktgen.conf-1-1 @@ -25,8 +25,6 @@ PGDEV=/proc/net/pktgen/kpktgend_0 pgset "rem_device_all" echo "Adding eth1" pgset "add_device eth1" - echo "Setting max_before_softirq 10000" - pgset "max_before_softirq 10000" # device config diff --git a/samples/pktgen/pktgen.conf-1-1-flows b/samples/pktgen/pktgen.conf-1-1-flows index 629ac3eaee35..ea859e441f6e 100755 --- a/samples/pktgen/pktgen.conf-1-1-flows +++ b/samples/pktgen/pktgen.conf-1-1-flows @@ -25,8 +25,6 @@ PGDEV=/proc/net/pktgen/kpktgend_0 pgset "rem_device_all" echo "Adding eth1" pgset "add_device eth1" - echo "Setting max_before_softirq 10000" - pgset "max_before_softirq 10000" # device config diff --git a/samples/pktgen/pktgen.conf-1-1-ip6 b/samples/pktgen/pktgen.conf-1-1-ip6 index c392475d60cf..0a81fd92426b 100755 --- a/samples/pktgen/pktgen.conf-1-1-ip6 +++ b/samples/pktgen/pktgen.conf-1-1-ip6 @@ -26,8 +26,6 @@ PGDEV=/proc/net/pktgen/kpktgend_0 pgset "rem_device_all" echo "Adding eth1" pgset "add_device eth1" - echo "Setting max_before_softirq 10000" - pgset "max_before_softirq 10000" # device config diff --git a/samples/pktgen/pktgen.conf-1-1-ip6-rdos b/samples/pktgen/pktgen.conf-1-1-ip6-rdos index 220d276f033a..21c3b1589fa7 100755 --- a/samples/pktgen/pktgen.conf-1-1-ip6-rdos +++ b/samples/pktgen/pktgen.conf-1-1-ip6-rdos @@ -26,8 +26,6 @@ PGDEV=/proc/net/pktgen/kpktgend_0 pgset "rem_device_all" echo "Adding eth1" pgset "add_device eth1" - echo "Setting max_before_softirq 10000" - pgset "max_before_softirq 10000" # device config diff --git a/samples/pktgen/pktgen.conf-1-1-rdos b/samples/pktgen/pktgen.conf-1-1-rdos index 6013975d26d9..fc4e345c4a34 100755 --- a/samples/pktgen/pktgen.conf-1-1-rdos +++ b/samples/pktgen/pktgen.conf-1-1-rdos @@ -25,8 +25,6 @@ PGDEV=/proc/net/pktgen/kpktgend_0 pgset "rem_device_all" echo "Adding eth1" pgset "add_device eth1" - echo "Setting max_before_softirq 10000" - pgset "max_before_softirq 10000" # device config diff --git a/samples/pktgen/pktgen.conf-1-2 b/samples/pktgen/pktgen.conf-1-2 index 136e10caff63..dfea8e6896d4 100755 --- a/samples/pktgen/pktgen.conf-1-2 +++ b/samples/pktgen/pktgen.conf-1-2 @@ -27,8 +27,6 @@ PGDEV=/proc/net/pktgen/kpktgend_0 pgset "add_device eth1" echo "Adding eth2" pgset "add_device eth2" - echo "Setting max_before_softirq 10000" - pgset "max_before_softirq 10000" # device config diff --git a/samples/pktgen/pktgen.conf-2-1 b/samples/pktgen/pktgen.conf-2-1 index ccd32780bed1..5d2fe4cdbd96 100755 --- a/samples/pktgen/pktgen.conf-2-1 +++ b/samples/pktgen/pktgen.conf-2-1 @@ -26,8 +26,6 @@ PGDEV=/proc/net/pktgen/kpktgend_0 pgset "rem_device_all" echo "Adding eth1" pgset "add_device eth1" - echo "Setting max_before_softirq 10000" - pgset "max_before_softirq 10000" # We need to remove old config since we dont use this thread. We can only # one NIC on one CPU due to affinity reasons. diff --git a/samples/pktgen/pktgen.conf-2-2 b/samples/pktgen/pktgen.conf-2-2 index 49ae4cf2bb76..474f200edcfb 100755 --- a/samples/pktgen/pktgen.conf-2-2 +++ b/samples/pktgen/pktgen.conf-2-2 @@ -25,16 +25,12 @@ PGDEV=/proc/net/pktgen/kpktgend_0 pgset "rem_device_all" echo "Adding eth1" pgset "add_device eth1" - echo "Setting max_before_softirq 10000" - pgset "max_before_softirq 10000" PGDEV=/proc/net/pktgen/kpktgend_1 echo "Removing all devices" pgset "rem_device_all" echo "Adding eth2" pgset "add_device eth2" - echo "Setting max_before_softirq 10000" - pgset "max_before_softirq 10000" # device config -- cgit From db72aba30a4f4c15eb20066f1d9c1bcbcf419236 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Tue, 24 Feb 2015 02:32:59 +0000 Subject: samples/pktgen: Use bash as interpreter These scripts use the non-POSIX 'function' and 'local' keywords so they won't work with every /bin/sh. We could drop 'function' as it is a no-op, but 'local' makes for cleaner scripts. Require use of bash. Signed-off-by: Ben Hutchings Signed-off-by: David S. Miller --- samples/pktgen/pktgen.conf-1-1 | 2 +- samples/pktgen/pktgen.conf-1-1-flows | 2 +- samples/pktgen/pktgen.conf-1-1-ip6 | 2 +- samples/pktgen/pktgen.conf-1-1-ip6-rdos | 2 +- samples/pktgen/pktgen.conf-1-1-rdos | 2 +- samples/pktgen/pktgen.conf-1-2 | 2 +- samples/pktgen/pktgen.conf-2-1 | 2 +- samples/pktgen/pktgen.conf-2-2 | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) (limited to 'samples') diff --git a/samples/pktgen/pktgen.conf-1-1 b/samples/pktgen/pktgen.conf-1-1 index e32782e06caf..bb5398367d4b 100755 --- a/samples/pktgen/pktgen.conf-1-1 +++ b/samples/pktgen/pktgen.conf-1-1 @@ -1,4 +1,4 @@ -#! /bin/sh +#!/bin/bash #modprobe pktgen diff --git a/samples/pktgen/pktgen.conf-1-1-flows b/samples/pktgen/pktgen.conf-1-1-flows index ea859e441f6e..db20ac8a66a7 100755 --- a/samples/pktgen/pktgen.conf-1-1-flows +++ b/samples/pktgen/pktgen.conf-1-1-flows @@ -1,4 +1,4 @@ -#! /bin/sh +#!/bin/bash #modprobe pktgen diff --git a/samples/pktgen/pktgen.conf-1-1-ip6 b/samples/pktgen/pktgen.conf-1-1-ip6 index 0a81fd92426b..e22199d1ed76 100755 --- a/samples/pktgen/pktgen.conf-1-1-ip6 +++ b/samples/pktgen/pktgen.conf-1-1-ip6 @@ -1,4 +1,4 @@ -#! /bin/sh +#!/bin/bash #modprobe pktgen diff --git a/samples/pktgen/pktgen.conf-1-1-ip6-rdos b/samples/pktgen/pktgen.conf-1-1-ip6-rdos index 21c3b1589fa7..58dd0524f264 100755 --- a/samples/pktgen/pktgen.conf-1-1-ip6-rdos +++ b/samples/pktgen/pktgen.conf-1-1-ip6-rdos @@ -1,4 +1,4 @@ -#! /bin/sh +#!/bin/bash #modprobe pktgen diff --git a/samples/pktgen/pktgen.conf-1-1-rdos b/samples/pktgen/pktgen.conf-1-1-rdos index fc4e345c4a34..2834ac789721 100755 --- a/samples/pktgen/pktgen.conf-1-1-rdos +++ b/samples/pktgen/pktgen.conf-1-1-rdos @@ -1,4 +1,4 @@ -#! /bin/sh +#!/bin/bash #modprobe pktgen diff --git a/samples/pktgen/pktgen.conf-1-2 b/samples/pktgen/pktgen.conf-1-2 index dfea8e6896d4..b519dab262ce 100755 --- a/samples/pktgen/pktgen.conf-1-2 +++ b/samples/pktgen/pktgen.conf-1-2 @@ -1,4 +1,4 @@ -#! /bin/sh +#!/bin/bash #modprobe pktgen diff --git a/samples/pktgen/pktgen.conf-2-1 b/samples/pktgen/pktgen.conf-2-1 index 5d2fe4cdbd96..6f57a558d817 100755 --- a/samples/pktgen/pktgen.conf-2-1 +++ b/samples/pktgen/pktgen.conf-2-1 @@ -1,4 +1,4 @@ -#! /bin/sh +#!/bin/bash #modprobe pktgen diff --git a/samples/pktgen/pktgen.conf-2-2 b/samples/pktgen/pktgen.conf-2-2 index 474f200edcfb..aa3225280521 100755 --- a/samples/pktgen/pktgen.conf-2-2 +++ b/samples/pktgen/pktgen.conf-2-2 @@ -1,4 +1,4 @@ -#! /bin/sh +#!/bin/bash #modprobe pktgen -- cgit From 16b5d0c4a24c793ca3584ca5c50fd5f8f2166120 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Tue, 24 Feb 2015 02:33:08 +0000 Subject: samples/pktgen: Trap SIGINT Otherwise ^C stops the script, not just pktgen. Signed-off-by: Ben Hutchings Signed-off-by: David S. Miller --- samples/pktgen/pktgen.conf-1-1 | 1 + samples/pktgen/pktgen.conf-1-1-flows | 1 + samples/pktgen/pktgen.conf-1-1-ip6 | 1 + samples/pktgen/pktgen.conf-1-1-ip6-rdos | 1 + samples/pktgen/pktgen.conf-1-1-rdos | 1 + samples/pktgen/pktgen.conf-1-2 | 1 + samples/pktgen/pktgen.conf-2-1 | 1 + samples/pktgen/pktgen.conf-2-2 | 1 + 8 files changed, 8 insertions(+) (limited to 'samples') diff --git a/samples/pktgen/pktgen.conf-1-1 b/samples/pktgen/pktgen.conf-1-1 index bb5398367d4b..fc1d15c98595 100755 --- a/samples/pktgen/pktgen.conf-1-1 +++ b/samples/pktgen/pktgen.conf-1-1 @@ -53,6 +53,7 @@ PGDEV=/proc/net/pktgen/eth1 PGDEV=/proc/net/pktgen/pgctrl echo "Running... ctrl^C to stop" + trap true INT pgset "start" echo "Done" diff --git a/samples/pktgen/pktgen.conf-1-1-flows b/samples/pktgen/pktgen.conf-1-1-flows index db20ac8a66a7..e00d66c8f5e5 100755 --- a/samples/pktgen/pktgen.conf-1-1-flows +++ b/samples/pktgen/pktgen.conf-1-1-flows @@ -61,6 +61,7 @@ PGDEV=/proc/net/pktgen/eth1 PGDEV=/proc/net/pktgen/pgctrl echo "Running... ctrl^C to stop" + trap true INT pgset "start" echo "Done" diff --git a/samples/pktgen/pktgen.conf-1-1-ip6 b/samples/pktgen/pktgen.conf-1-1-ip6 index e22199d1ed76..f16145303afb 100755 --- a/samples/pktgen/pktgen.conf-1-1-ip6 +++ b/samples/pktgen/pktgen.conf-1-1-ip6 @@ -54,6 +54,7 @@ PGDEV=/proc/net/pktgen/eth1 PGDEV=/proc/net/pktgen/pgctrl echo "Running... ctrl^C to stop" + trap true INT pgset "start" echo "Done" diff --git a/samples/pktgen/pktgen.conf-1-1-ip6-rdos b/samples/pktgen/pktgen.conf-1-1-ip6-rdos index 58dd0524f264..06b502834cc7 100755 --- a/samples/pktgen/pktgen.conf-1-1-ip6-rdos +++ b/samples/pktgen/pktgen.conf-1-1-ip6-rdos @@ -57,6 +57,7 @@ PGDEV=/proc/net/pktgen/eth1 PGDEV=/proc/net/pktgen/pgctrl echo "Running... ctrl^C to stop" + trap true INT pgset "start" echo "Done" diff --git a/samples/pktgen/pktgen.conf-1-1-rdos b/samples/pktgen/pktgen.conf-1-1-rdos index 2834ac789721..8f1ce1a0aa98 100755 --- a/samples/pktgen/pktgen.conf-1-1-rdos +++ b/samples/pktgen/pktgen.conf-1-1-rdos @@ -58,6 +58,7 @@ PGDEV=/proc/net/pktgen/eth1 PGDEV=/proc/net/pktgen/pgctrl echo "Running... ctrl^C to stop" + trap true INT pgset "start" echo "Done" diff --git a/samples/pktgen/pktgen.conf-1-2 b/samples/pktgen/pktgen.conf-1-2 index b519dab262ce..f151e85c536a 100755 --- a/samples/pktgen/pktgen.conf-1-2 +++ b/samples/pktgen/pktgen.conf-1-2 @@ -63,6 +63,7 @@ PGDEV=/proc/net/pktgen/eth2 PGDEV=/proc/net/pktgen/pgctrl echo "Running... ctrl^C to stop" + trap true INT pgset "start" echo "Done" diff --git a/samples/pktgen/pktgen.conf-2-1 b/samples/pktgen/pktgen.conf-2-1 index 6f57a558d817..e6b36b2f840e 100755 --- a/samples/pktgen/pktgen.conf-2-1 +++ b/samples/pktgen/pktgen.conf-2-1 @@ -60,6 +60,7 @@ PGDEV=/proc/net/pktgen/eth1 PGDEV=/proc/net/pktgen/pgctrl echo "Running... ctrl^C to stop" + trap true INT pgset "start" echo "Done" diff --git a/samples/pktgen/pktgen.conf-2-2 b/samples/pktgen/pktgen.conf-2-2 index aa3225280521..6484435c104e 100755 --- a/samples/pktgen/pktgen.conf-2-2 +++ b/samples/pktgen/pktgen.conf-2-2 @@ -67,6 +67,7 @@ PGDEV=/proc/net/pktgen/eth2 PGDEV=/proc/net/pktgen/pgctrl echo "Running... ctrl^C to stop" + trap true INT pgset "start" echo "Done" -- cgit From 4062bd25f0be9bd2dae25992ad87247ac4f73df3 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Tue, 24 Feb 2015 02:33:20 +0000 Subject: samples/pktgen: Show the results rather than just commenting where they are Signed-off-by: Ben Hutchings Signed-off-by: David S. Miller --- samples/pktgen/pktgen.conf-1-1 | 3 +-- samples/pktgen/pktgen.conf-1-1-flows | 3 +-- samples/pktgen/pktgen.conf-1-1-ip6 | 3 +-- samples/pktgen/pktgen.conf-1-1-ip6-rdos | 3 +-- samples/pktgen/pktgen.conf-1-1-rdos | 3 +-- samples/pktgen/pktgen.conf-1-2 | 3 +-- samples/pktgen/pktgen.conf-2-1 | 3 +-- samples/pktgen/pktgen.conf-2-2 | 3 +-- 8 files changed, 8 insertions(+), 16 deletions(-) (limited to 'samples') diff --git a/samples/pktgen/pktgen.conf-1-1 b/samples/pktgen/pktgen.conf-1-1 index fc1d15c98595..f91daad9e916 100755 --- a/samples/pktgen/pktgen.conf-1-1 +++ b/samples/pktgen/pktgen.conf-1-1 @@ -56,5 +56,4 @@ PGDEV=/proc/net/pktgen/pgctrl trap true INT pgset "start" echo "Done" - -# Result can be vieved in /proc/net/pktgen/eth1 + cat /proc/net/pktgen/eth1 diff --git a/samples/pktgen/pktgen.conf-1-1-flows b/samples/pktgen/pktgen.conf-1-1-flows index e00d66c8f5e5..081749c9707d 100755 --- a/samples/pktgen/pktgen.conf-1-1-flows +++ b/samples/pktgen/pktgen.conf-1-1-flows @@ -64,5 +64,4 @@ PGDEV=/proc/net/pktgen/pgctrl trap true INT pgset "start" echo "Done" - -# Result can be vieved in /proc/net/pktgen/eth1 + cat /proc/net/pktgen/eth1 diff --git a/samples/pktgen/pktgen.conf-1-1-ip6 b/samples/pktgen/pktgen.conf-1-1-ip6 index f16145303afb..0b9ffd47fd41 100755 --- a/samples/pktgen/pktgen.conf-1-1-ip6 +++ b/samples/pktgen/pktgen.conf-1-1-ip6 @@ -57,5 +57,4 @@ PGDEV=/proc/net/pktgen/pgctrl trap true INT pgset "start" echo "Done" - -# Result can be vieved in /proc/net/pktgen/eth1 + cat /proc/net/pktgen/eth1 diff --git a/samples/pktgen/pktgen.conf-1-1-ip6-rdos b/samples/pktgen/pktgen.conf-1-1-ip6-rdos index 06b502834cc7..ad98e5f40776 100755 --- a/samples/pktgen/pktgen.conf-1-1-ip6-rdos +++ b/samples/pktgen/pktgen.conf-1-1-ip6-rdos @@ -60,5 +60,4 @@ PGDEV=/proc/net/pktgen/pgctrl trap true INT pgset "start" echo "Done" - -# Result can be vieved in /proc/net/pktgen/eth1 + cat /proc/net/pktgen/eth1 diff --git a/samples/pktgen/pktgen.conf-1-1-rdos b/samples/pktgen/pktgen.conf-1-1-rdos index 8f1ce1a0aa98..c7553be49b80 100755 --- a/samples/pktgen/pktgen.conf-1-1-rdos +++ b/samples/pktgen/pktgen.conf-1-1-rdos @@ -61,5 +61,4 @@ PGDEV=/proc/net/pktgen/pgctrl trap true INT pgset "start" echo "Done" - -# Result can be vieved in /proc/net/pktgen/eth1 + cat /proc/net/pktgen/eth1 diff --git a/samples/pktgen/pktgen.conf-1-2 b/samples/pktgen/pktgen.conf-1-2 index f151e85c536a..ba4eb26e168d 100755 --- a/samples/pktgen/pktgen.conf-1-2 +++ b/samples/pktgen/pktgen.conf-1-2 @@ -66,5 +66,4 @@ PGDEV=/proc/net/pktgen/pgctrl trap true INT pgset "start" echo "Done" - -# Result can be vieved in /proc/net/pktgen/eth[1,2] + cat /proc/net/pktgen/eth1 /proc/net/pktgen/eth2 diff --git a/samples/pktgen/pktgen.conf-2-1 b/samples/pktgen/pktgen.conf-2-1 index e6b36b2f840e..e108e97d6d89 100755 --- a/samples/pktgen/pktgen.conf-2-1 +++ b/samples/pktgen/pktgen.conf-2-1 @@ -63,5 +63,4 @@ PGDEV=/proc/net/pktgen/pgctrl trap true INT pgset "start" echo "Done" - -# Result can be vieved in /proc/net/pktgen/eth1 + cat /proc/net/pktgen/eth1 diff --git a/samples/pktgen/pktgen.conf-2-2 b/samples/pktgen/pktgen.conf-2-2 index 6484435c104e..acea15503e71 100755 --- a/samples/pktgen/pktgen.conf-2-2 +++ b/samples/pktgen/pktgen.conf-2-2 @@ -70,5 +70,4 @@ PGDEV=/proc/net/pktgen/pgctrl trap true INT pgset "start" echo "Done" - -# Result can be vieved in /proc/net/pktgen/eth[1,2] + cat /proc/net/pktgen/eth1 /proc/net/pktgen/eth2 -- cgit From f91fe17e243d1f279d425071a35e3d41290758a0 Mon Sep 17 00:00:00 2001 From: Daniel Borkmann Date: Sun, 1 Mar 2015 12:31:41 +0100 Subject: ebpf: remove kernel test stubs Now that we have BPF_PROG_TYPE_SOCKET_FILTER up and running, we can remove the test stubs which were added to get the verifier suite up. We can just let the test cases probe under socket filter type instead. In the fill/spill test case, we cannot (yet) access fields from the context (skb), but we may adapt that test case in future. Signed-off-by: Daniel Borkmann Acked-by: Alexei Starovoitov Signed-off-by: David S. Miller --- samples/bpf/test_verifier.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'samples') diff --git a/samples/bpf/test_verifier.c b/samples/bpf/test_verifier.c index b96175e90363..7b56b59fad8e 100644 --- a/samples/bpf/test_verifier.c +++ b/samples/bpf/test_verifier.c @@ -288,7 +288,8 @@ static struct bpf_test tests[] = { BPF_LDX_MEM(BPF_DW, BPF_REG_2, BPF_REG_10, -8), /* should be able to access R0 = *(R2 + 8) */ - BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_2, 8), + /* BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_2, 8), */ + BPF_MOV64_REG(BPF_REG_0, BPF_REG_2), BPF_EXIT_INSN(), }, .result = ACCEPT, @@ -687,7 +688,7 @@ static int test(void) } printf("#%d %s ", i, tests[i].descr); - prog_fd = bpf_prog_load(BPF_PROG_TYPE_UNSPEC, prog, + prog_fd = bpf_prog_load(BPF_PROG_TYPE_SOCKET_FILTER, prog, prog_len * sizeof(struct bpf_insn), "GPL"); -- cgit From f1a66f85b74c5ef7b503f746ea97742dacd56419 Mon Sep 17 00:00:00 2001 From: Daniel Borkmann Date: Sun, 1 Mar 2015 12:31:43 +0100 Subject: ebpf: export BPF_PSEUDO_MAP_FD to uapi We need to export BPF_PSEUDO_MAP_FD to user space, as it's used in the ELF BPF loader where instructions are being loaded that need map fixups. An initial stage loads all maps into the kernel, and later on replaces related instructions in the eBPF blob with BPF_PSEUDO_MAP_FD as source register and the actual fd as immediate value. The kernel verifier recognizes this keyword and replaces the map fd with a real pointer internally. Signed-off-by: Daniel Borkmann Acked-by: Alexei Starovoitov Signed-off-by: David S. Miller --- samples/bpf/libbpf.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'samples') diff --git a/samples/bpf/libbpf.h b/samples/bpf/libbpf.h index 58c5fe1bdba1..a6bb7e9c22c3 100644 --- a/samples/bpf/libbpf.h +++ b/samples/bpf/libbpf.h @@ -92,7 +92,9 @@ extern char bpf_log_buf[LOG_BUF_SIZE]; .off = 0, \ .imm = ((__u64) (IMM)) >> 32 }) -#define BPF_PSEUDO_MAP_FD 1 +#ifndef BPF_PSEUDO_MAP_FD +# define BPF_PSEUDO_MAP_FD 1 +#endif /* pseudo BPF_LD_IMM64 insn used to refer to process-local map_fd */ #define BPF_LD_MAP_FD(DST, MAP_FD) \ -- cgit From 614cd3bd3758a806cea497d493b584e6157561f7 Mon Sep 17 00:00:00 2001 From: Alexei Starovoitov Date: Fri, 13 Mar 2015 11:57:43 -0700 Subject: samples: bpf: add skb->field examples and tests - modify sockex1 example to count number of bytes in outgoing packets - modify sockex2 example to count number of bytes and packets per flow - add 4 stress tests that exercise 'skb->field' code path of verifier Signed-off-by: Alexei Starovoitov Signed-off-by: David S. Miller --- samples/bpf/sockex1_kern.c | 8 ++++-- samples/bpf/sockex1_user.c | 2 +- samples/bpf/sockex2_kern.c | 26 ++++++++++------- samples/bpf/sockex2_user.c | 11 +++++-- samples/bpf/test_verifier.c | 70 +++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 101 insertions(+), 16 deletions(-) (limited to 'samples') diff --git a/samples/bpf/sockex1_kern.c b/samples/bpf/sockex1_kern.c index 066892662915..ed18e9a4909c 100644 --- a/samples/bpf/sockex1_kern.c +++ b/samples/bpf/sockex1_kern.c @@ -1,5 +1,6 @@ #include #include +#include #include #include "bpf_helpers.h" @@ -11,14 +12,17 @@ struct bpf_map_def SEC("maps") my_map = { }; SEC("socket1") -int bpf_prog1(struct sk_buff *skb) +int bpf_prog1(struct __sk_buff *skb) { int index = load_byte(skb, ETH_HLEN + offsetof(struct iphdr, protocol)); long *value; + if (skb->pkt_type != PACKET_OUTGOING) + return 0; + value = bpf_map_lookup_elem(&my_map, &index); if (value) - __sync_fetch_and_add(value, 1); + __sync_fetch_and_add(value, skb->len); return 0; } diff --git a/samples/bpf/sockex1_user.c b/samples/bpf/sockex1_user.c index 34a443ff3831..678ce4693551 100644 --- a/samples/bpf/sockex1_user.c +++ b/samples/bpf/sockex1_user.c @@ -40,7 +40,7 @@ int main(int ac, char **argv) key = IPPROTO_ICMP; assert(bpf_lookup_elem(map_fd[0], &key, &icmp_cnt) == 0); - printf("TCP %lld UDP %lld ICMP %lld packets\n", + printf("TCP %lld UDP %lld ICMP %lld bytes\n", tcp_cnt, udp_cnt, icmp_cnt); sleep(1); } diff --git a/samples/bpf/sockex2_kern.c b/samples/bpf/sockex2_kern.c index 6f0135f0f217..ba0e177ff561 100644 --- a/samples/bpf/sockex2_kern.c +++ b/samples/bpf/sockex2_kern.c @@ -42,13 +42,13 @@ static inline int proto_ports_offset(__u64 proto) } } -static inline int ip_is_fragment(struct sk_buff *ctx, __u64 nhoff) +static inline int ip_is_fragment(struct __sk_buff *ctx, __u64 nhoff) { return load_half(ctx, nhoff + offsetof(struct iphdr, frag_off)) & (IP_MF | IP_OFFSET); } -static inline __u32 ipv6_addr_hash(struct sk_buff *ctx, __u64 off) +static inline __u32 ipv6_addr_hash(struct __sk_buff *ctx, __u64 off) { __u64 w0 = load_word(ctx, off); __u64 w1 = load_word(ctx, off + 4); @@ -58,7 +58,7 @@ static inline __u32 ipv6_addr_hash(struct sk_buff *ctx, __u64 off) return (__u32)(w0 ^ w1 ^ w2 ^ w3); } -static inline __u64 parse_ip(struct sk_buff *skb, __u64 nhoff, __u64 *ip_proto, +static inline __u64 parse_ip(struct __sk_buff *skb, __u64 nhoff, __u64 *ip_proto, struct flow_keys *flow) { __u64 verlen; @@ -82,7 +82,7 @@ static inline __u64 parse_ip(struct sk_buff *skb, __u64 nhoff, __u64 *ip_proto, return nhoff; } -static inline __u64 parse_ipv6(struct sk_buff *skb, __u64 nhoff, __u64 *ip_proto, +static inline __u64 parse_ipv6(struct __sk_buff *skb, __u64 nhoff, __u64 *ip_proto, struct flow_keys *flow) { *ip_proto = load_byte(skb, @@ -96,7 +96,7 @@ static inline __u64 parse_ipv6(struct sk_buff *skb, __u64 nhoff, __u64 *ip_proto return nhoff; } -static inline bool flow_dissector(struct sk_buff *skb, struct flow_keys *flow) +static inline bool flow_dissector(struct __sk_buff *skb, struct flow_keys *flow) { __u64 nhoff = ETH_HLEN; __u64 ip_proto; @@ -183,18 +183,23 @@ static inline bool flow_dissector(struct sk_buff *skb, struct flow_keys *flow) return true; } +struct pair { + long packets; + long bytes; +}; + struct bpf_map_def SEC("maps") hash_map = { .type = BPF_MAP_TYPE_HASH, .key_size = sizeof(__be32), - .value_size = sizeof(long), + .value_size = sizeof(struct pair), .max_entries = 1024, }; SEC("socket2") -int bpf_prog2(struct sk_buff *skb) +int bpf_prog2(struct __sk_buff *skb) { struct flow_keys flow; - long *value; + struct pair *value; u32 key; if (!flow_dissector(skb, &flow)) @@ -203,9 +208,10 @@ int bpf_prog2(struct sk_buff *skb) key = flow.dst; value = bpf_map_lookup_elem(&hash_map, &key); if (value) { - __sync_fetch_and_add(value, 1); + __sync_fetch_and_add(&value->packets, 1); + __sync_fetch_and_add(&value->bytes, skb->len); } else { - long val = 1; + struct pair val = {1, skb->len}; bpf_map_update_elem(&hash_map, &key, &val, BPF_ANY); } diff --git a/samples/bpf/sockex2_user.c b/samples/bpf/sockex2_user.c index d2d5f5a790d3..29a276d766fc 100644 --- a/samples/bpf/sockex2_user.c +++ b/samples/bpf/sockex2_user.c @@ -6,6 +6,11 @@ #include #include +struct pair { + __u64 packets; + __u64 bytes; +}; + int main(int ac, char **argv) { char filename[256]; @@ -29,13 +34,13 @@ int main(int ac, char **argv) for (i = 0; i < 5; i++) { int key = 0, next_key; - long long value; + struct pair value; while (bpf_get_next_key(map_fd[0], &key, &next_key) == 0) { bpf_lookup_elem(map_fd[0], &next_key, &value); - printf("ip %s count %lld\n", + printf("ip %s bytes %lld packets %lld\n", inet_ntoa((struct in_addr){htonl(next_key)}), - value); + value.bytes, value.packets); key = next_key; } sleep(1); diff --git a/samples/bpf/test_verifier.c b/samples/bpf/test_verifier.c index 7b56b59fad8e..df6dbb6576f6 100644 --- a/samples/bpf/test_verifier.c +++ b/samples/bpf/test_verifier.c @@ -14,6 +14,7 @@ #include #include #include +#include #include "libbpf.h" #define MAX_INSNS 512 @@ -642,6 +643,75 @@ static struct bpf_test tests[] = { }, .result = ACCEPT, }, + { + "access skb fields ok", + .insns = { + BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1, + offsetof(struct __sk_buff, len)), + BPF_JMP_IMM(BPF_JGE, BPF_REG_0, 0, 1), + BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1, + offsetof(struct __sk_buff, mark)), + BPF_JMP_IMM(BPF_JGE, BPF_REG_0, 0, 1), + BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1, + offsetof(struct __sk_buff, pkt_type)), + BPF_JMP_IMM(BPF_JGE, BPF_REG_0, 0, 1), + BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1, + offsetof(struct __sk_buff, queue_mapping)), + BPF_JMP_IMM(BPF_JGE, BPF_REG_0, 0, 0), + BPF_EXIT_INSN(), + }, + .result = ACCEPT, + }, + { + "access skb fields bad1", + .insns = { + BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1, -4), + BPF_EXIT_INSN(), + }, + .errstr = "invalid bpf_context access", + .result = REJECT, + }, + { + "access skb fields bad2", + .insns = { + BPF_JMP_IMM(BPF_JGE, BPF_REG_1, 0, 9), + BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0), + BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), + BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), + BPF_LD_MAP_FD(BPF_REG_1, 0), + BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, BPF_FUNC_map_lookup_elem), + BPF_JMP_IMM(BPF_JNE, BPF_REG_0, 0, 1), + BPF_EXIT_INSN(), + BPF_MOV64_REG(BPF_REG_1, BPF_REG_0), + BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1, + offsetof(struct __sk_buff, pkt_type)), + BPF_EXIT_INSN(), + }, + .fixup = {4}, + .errstr = "different pointers", + .result = REJECT, + }, + { + "access skb fields bad3", + .insns = { + BPF_JMP_IMM(BPF_JGE, BPF_REG_1, 0, 2), + BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1, + offsetof(struct __sk_buff, pkt_type)), + BPF_EXIT_INSN(), + BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0), + BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), + BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), + BPF_LD_MAP_FD(BPF_REG_1, 0), + BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, BPF_FUNC_map_lookup_elem), + BPF_JMP_IMM(BPF_JNE, BPF_REG_0, 0, 1), + BPF_EXIT_INSN(), + BPF_MOV64_REG(BPF_REG_1, BPF_REG_0), + BPF_JMP_IMM(BPF_JA, 0, 0, -12), + }, + .fixup = {6}, + .errstr = "different pointers", + .result = REJECT, + }, }; static int probe_filter_length(struct bpf_insn *fp) -- cgit From c24973957975403521ca76a776c2dfd12fbe9add Mon Sep 17 00:00:00 2001 From: Alexei Starovoitov Date: Mon, 16 Mar 2015 18:06:02 -0700 Subject: bpf: allow BPF programs access 'protocol' and 'vlan_tci' fields as a follow on to patch 70006af95515 ("bpf: allow eBPF access skb fields") this patch allows 'protocol' and 'vlan_tci' fields to be accessible from extended BPF programs. The usage of 'protocol', 'vlan_present' and 'vlan_tci' fields is the same as corresponding SKF_AD_PROTOCOL, SKF_AD_VLAN_TAG_PRESENT and SKF_AD_VLAN_TAG accesses in classic BPF. Signed-off-by: Alexei Starovoitov Signed-off-by: David S. Miller --- samples/bpf/test_verifier.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'samples') diff --git a/samples/bpf/test_verifier.c b/samples/bpf/test_verifier.c index df6dbb6576f6..75d561f9fd6a 100644 --- a/samples/bpf/test_verifier.c +++ b/samples/bpf/test_verifier.c @@ -658,6 +658,15 @@ static struct bpf_test tests[] = { BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1, offsetof(struct __sk_buff, queue_mapping)), BPF_JMP_IMM(BPF_JGE, BPF_REG_0, 0, 0), + BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1, + offsetof(struct __sk_buff, protocol)), + BPF_JMP_IMM(BPF_JGE, BPF_REG_0, 0, 0), + BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1, + offsetof(struct __sk_buff, vlan_present)), + BPF_JMP_IMM(BPF_JGE, BPF_REG_0, 0, 0), + BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1, + offsetof(struct __sk_buff, vlan_tci)), + BPF_JMP_IMM(BPF_JGE, BPF_REG_0, 0, 0), BPF_EXIT_INSN(), }, .result = ACCEPT, -- cgit From 91bc4822c3d61b9bb7ef66d3b77948a4f9177954 Mon Sep 17 00:00:00 2001 From: Alexei Starovoitov Date: Wed, 1 Apr 2015 17:12:13 -0700 Subject: tc: bpf: add checksum helpers Commit 608cd71a9c7c ("tc: bpf: generalize pedit action") has added the possibility to mangle packet data to BPF programs in the tc pipeline. This patch adds two helpers bpf_l3_csum_replace() and bpf_l4_csum_replace() for fixing up the protocol checksums after the packet mangling. It also adds 'flags' argument to bpf_skb_store_bytes() helper to avoid unnecessary checksum recomputations when BPF programs adjusting l3/l4 checksums and documents all three helpers in uapi header. Moreover, a sample program is added to show how BPF programs can make use of the mangle and csum helpers. Signed-off-by: Alexei Starovoitov Acked-by: Daniel Borkmann Signed-off-by: David S. Miller --- samples/bpf/Makefile | 1 + samples/bpf/bpf_helpers.h | 7 +++++ samples/bpf/tcbpf1_kern.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+) create mode 100644 samples/bpf/tcbpf1_kern.c (limited to 'samples') diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile index b5b3600dcdf5..d24f51bca465 100644 --- a/samples/bpf/Makefile +++ b/samples/bpf/Makefile @@ -17,6 +17,7 @@ sockex2-objs := bpf_load.o libbpf.o sockex2_user.o always := $(hostprogs-y) always += sockex1_kern.o always += sockex2_kern.o +always += tcbpf1_kern.o HOSTCFLAGS += -I$(objtree)/usr/include diff --git a/samples/bpf/bpf_helpers.h b/samples/bpf/bpf_helpers.h index ca0333146006..72540ec1f003 100644 --- a/samples/bpf/bpf_helpers.h +++ b/samples/bpf/bpf_helpers.h @@ -37,4 +37,11 @@ struct bpf_map_def { unsigned int max_entries; }; +static int (*bpf_skb_store_bytes)(void *ctx, int off, void *from, int len, int flags) = + (void *) BPF_FUNC_skb_store_bytes; +static int (*bpf_l3_csum_replace)(void *ctx, int off, int from, int to, int flags) = + (void *) BPF_FUNC_l3_csum_replace; +static int (*bpf_l4_csum_replace)(void *ctx, int off, int from, int to, int flags) = + (void *) BPF_FUNC_l4_csum_replace; + #endif diff --git a/samples/bpf/tcbpf1_kern.c b/samples/bpf/tcbpf1_kern.c new file mode 100644 index 000000000000..7cf3f42a6e39 --- /dev/null +++ b/samples/bpf/tcbpf1_kern.c @@ -0,0 +1,71 @@ +#include +#include +#include +#include +#include +#include +#include "bpf_helpers.h" + +/* compiler workaround */ +#define _htonl __builtin_bswap32 + +static inline void set_dst_mac(struct __sk_buff *skb, char *mac) +{ + bpf_skb_store_bytes(skb, 0, mac, ETH_ALEN, 1); +} + +/* use 1 below for ingress qdisc and 0 for egress */ +#if 0 +#undef ETH_HLEN +#define ETH_HLEN 0 +#endif + +#define IP_CSUM_OFF (ETH_HLEN + offsetof(struct iphdr, check)) +#define TOS_OFF (ETH_HLEN + offsetof(struct iphdr, tos)) + +static inline void set_ip_tos(struct __sk_buff *skb, __u8 new_tos) +{ + __u8 old_tos = load_byte(skb, TOS_OFF); + + bpf_l3_csum_replace(skb, IP_CSUM_OFF, htons(old_tos), htons(new_tos), 2); + bpf_skb_store_bytes(skb, TOS_OFF, &new_tos, sizeof(new_tos), 0); +} + +#define TCP_CSUM_OFF (ETH_HLEN + sizeof(struct iphdr) + offsetof(struct tcphdr, check)) +#define IP_SRC_OFF (ETH_HLEN + offsetof(struct iphdr, saddr)) + +#define IS_PSEUDO 0x10 + +static inline void set_tcp_ip_src(struct __sk_buff *skb, __u32 new_ip) +{ + __u32 old_ip = _htonl(load_word(skb, IP_SRC_OFF)); + + bpf_l4_csum_replace(skb, TCP_CSUM_OFF, old_ip, new_ip, IS_PSEUDO | sizeof(new_ip)); + bpf_l3_csum_replace(skb, IP_CSUM_OFF, old_ip, new_ip, sizeof(new_ip)); + bpf_skb_store_bytes(skb, IP_SRC_OFF, &new_ip, sizeof(new_ip), 0); +} + +#define TCP_DPORT_OFF (ETH_HLEN + sizeof(struct iphdr) + offsetof(struct tcphdr, dest)) +static inline void set_tcp_dest_port(struct __sk_buff *skb, __u16 new_port) +{ + __u16 old_port = htons(load_half(skb, TCP_DPORT_OFF)); + + bpf_l4_csum_replace(skb, TCP_CSUM_OFF, old_port, new_port, sizeof(new_port)); + bpf_skb_store_bytes(skb, TCP_DPORT_OFF, &new_port, sizeof(new_port), 0); +} + +SEC("classifier") +int bpf_prog1(struct __sk_buff *skb) +{ + __u8 proto = load_byte(skb, ETH_HLEN + offsetof(struct iphdr, protocol)); + long *value; + + if (proto == IPPROTO_TCP) { + set_ip_tos(skb, 8); + set_tcp_ip_src(skb, 0xA010101); + set_tcp_dest_port(skb, 5001); + } + + return 0; +} +char _license[] SEC("license") = "GPL"; -- cgit