[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1545856073-8680-7-git-send-email-u9012063@gmail.com>
Date: Wed, 26 Dec 2018 12:27:53 -0800
From: William Tu <u9012063@...il.com>
To: bjorn.topel@...il.com, magnus.karlsson@...il.com, ast@...nel.org,
daniel@...earbox.net, netdev@...r.kernel.org,
makita.toshiaki@....ntt.co.jp, yihung.wei@...il.com,
magnus.karlsson@...el.com
Subject: [PATCH bpf-next RFCv3 6/6] samples: bpf: add veth AF_XDP example.
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@...il.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
Powered by blists - more mailing lists