From: William Tu <u9012063@gmail.com>
To: bjorn.topel@gmail.com, magnus.karlsson@gmail.com, ast@kernel.org,
daniel@iogearbox.net, netdev@vger.kernel.org,
makita.toshiaki@lab.ntt.co.jp, yihung.wei@gmail.com,
magnus.karlsson@intel.com
Subject: [PATCH bpf-next RFCv3 6/6] samples: bpf: add veth AF_XDP example.
Date: Wed, 26 Dec 2018 12:27:53 -0800 [thread overview]
Message-ID: <1545856073-8680-7-git-send-email-u9012063@gmail.com> (raw)
In-Reply-To: <1545856073-8680-1-git-send-email-u9012063@gmail.com>
Add example use cases for AF_XDP socket on two namespaces.
The script runs sender at the root namespace, and receiver
at the at_ns0 namespace with different XDP actions.
Signed-off-by: William Tu <u9012063@gmail.com>
---
samples/bpf/test_veth_afxdp.sh | 82 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 82 insertions(+)
create mode 100755 samples/bpf/test_veth_afxdp.sh
diff --git a/samples/bpf/test_veth_afxdp.sh b/samples/bpf/test_veth_afxdp.sh
new file mode 100755
index 000000000000..d51c6031db47
--- /dev/null
+++ b/samples/bpf/test_veth_afxdp.sh
@@ -0,0 +1,82 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+
+# The script runs the sender at the root namespace, and
+# the receiver at the namespace at_ns0, with different mode
+# 1. XDP_DROP
+# 2. XDP_TX
+# 3. XDP_PASS
+# 4. XDP_REDIRECT
+# 5. Generic XDP
+
+XDPSOCK=./xdpsock
+XDP_RXQ_INFO=./xdp_rxq_info
+
+ip netns add at_ns0
+ip link add p0 type veth peer name p1
+ip link set p0 netns at_ns0
+ip link set dev p1 up
+ip netns exec at_ns0 ip link set dev p0 up
+
+test_xdp_drop()
+{
+ echo "[Peer] XDP_DROP"
+ ip netns exec at_ns0 $XDP_RXQ_INFO --dev p0 --action XDP_DROP &
+}
+
+test_xdp_pass()
+{
+ echo "[Peer] XDP_PASS"
+ ip netns exec at_ns0 $XDP_RXQ_INFO --dev p0 --action XDP_PASS &
+}
+
+test_xdp_tx()
+{
+ echo "[Peer] XDP_TX"
+ ip netns exec at_ns0 $XDP_RXQ_INFO --dev p0 --action XDP_TX &
+}
+
+test_generic_xdp()
+{
+ echo "[Peer] Generic XDP"
+ ip netns exec at_ns0 $XDPSOCK -i p0 -r -S &
+}
+
+test_xdp_redirect()
+{
+ echo "[Peer] XDP_REDIRECT"
+ ip netns exec at_ns0 $XDPSOCK -i p0 -r -N &
+}
+
+test_xdp_zcrx()
+{
+ echo "[Peer] AF_XDP RX"
+ ip netns exec at_ns0 $XDPSOCK -i p0 -r -N -z &
+}
+
+cleanup() {
+ killall xdpsock
+ sleep 1
+ killall xdp_rxq_info
+ ip netns del at_ns0
+ ip link del p1
+}
+
+trap cleanup 0 3 6
+
+if [ "$1" == "drop" ]; then
+ test_xdp_drop
+elif [ "$1" == "pass" ]; then
+ test_xdp_pass
+elif [ "$1" == "tx" ]; then
+ test_xdp_tx
+elif [ "$1" == "redirect" ]; then
+ test_xdp_redirect
+elif [ "$1" == "zcrx" ]; then
+ test_xdp_zcrx
+else
+ test_xdp_drop
+fi
+
+# send at root namespace
+$XDPSOCK -i p1 -t -N -z
--
2.7.4
prev parent reply other threads:[~2018-12-26 20:28 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-26 20:27 [PATCH bpf-next RFCv3 0/6] AF_XDP support for veth William Tu
2018-12-26 20:27 ` [PATCH bpf-next RFCv3 1/6] xsk: add xsk_umem_consume_tx_virtual William Tu
2018-12-26 20:27 ` [PATCH bpf-next RFCv3 2/6] veth: support AF_XDP TX copy-mode William Tu
2019-01-01 13:44 ` Toshiaki Makita
2019-01-05 15:55 ` William Tu
2019-01-08 7:25 ` Toshiaki Makita
2018-12-26 20:27 ` [PATCH bpf-next RFCv3 3/6] xsk: add new MEM type for virtual device William Tu
2018-12-26 20:27 ` [PATCH bpf-next RFCv3 4/6] veth: add zero-copy AF_XDP TX support William Tu
2018-12-26 20:27 ` [PATCH bpf-next RFCv3 5/6] veth: add AF_XDP RX support William Tu
2018-12-26 20:27 ` William Tu [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1545856073-8680-7-git-send-email-u9012063@gmail.com \
--to=u9012063@gmail.com \
--cc=ast@kernel.org \
--cc=bjorn.topel@gmail.com \
--cc=daniel@iogearbox.net \
--cc=magnus.karlsson@gmail.com \
--cc=magnus.karlsson@intel.com \
--cc=makita.toshiaki@lab.ntt.co.jp \
--cc=netdev@vger.kernel.org \
--cc=yihung.wei@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).