bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Martin KaFai Lau <martin.lau@linux.dev>
To: Lorenzo Bianconi <lorenzo@kernel.org>
Cc: netdev@vger.kernel.org, ast@kernel.org, daniel@iogearbox.net,
	andrii@kernel.org, davem@davemloft.net, kuba@kernel.org,
	hawk@kernel.org, pabeni@redhat.com, edumazet@google.com,
	toke@redhat.com, memxor@gmail.com, alardam@gmail.com,
	saeedm@nvidia.com, anthony.l.nguyen@intel.com,
	gospo@broadcom.com, vladimir.oltean@nxp.com, nbd@nbd.name,
	john@phrozen.org, leon@kernel.org, simon.horman@corigine.com,
	aelior@marvell.com, christophe.jaillet@wanadoo.fr,
	ecree.xilinx@gmail.com, mst@redhat.com, bjorn@kernel.org,
	magnus.karlsson@intel.com, maciej.fijalkowski@intel.com,
	intel-wired-lan@lists.osuosl.org, lorenzo.bianconi@redhat.com,
	niklas.soderlund@corigine.com, bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next 7/7] selftests/bpf: introduce XDP compliance test tool
Date: Mon, 23 Jan 2023 22:34:36 -0800	[thread overview]
Message-ID: <d2606312-1e04-55ff-e01e-daf83ed99836@linux.dev> (raw)
In-Reply-To: <986321f8621e9367653e21b35566e7cda976b886.1674234430.git.lorenzo@kernel.org>

On 1/20/23 9:16 AM, Lorenzo Bianconi wrote:
> +static __always_inline int xdp_process_echo_packet(struct xdp_md *xdp, bool dut)
> +{
> +	void *data_end = (void *)(long)xdp->data_end;
> +	__be32 saddr = dut ? tester_ip : dut_ip;
> +	__be32 daddr = dut ? dut_ip : tester_ip;
> +	void *data = (void *)(long)xdp->data;
> +	struct ethhdr *eh = data;
> +	struct tlv_hdr *tlv;
> +	struct udphdr *uh;
> +	struct iphdr *ih;
> +	__be16 port;
> +	__u8 *cmd;
> +
> +	if (eh + 1 > (struct ethhdr *)data_end)
> +		return -EINVAL;
> +
> +	if (eh->h_proto != bpf_htons(ETH_P_IP))
> +		return -EINVAL;

Both v6 and v4 support are needed as a tool.

[ ... ]

> diff --git a/tools/testing/selftests/bpf/test_xdp_features.sh b/tools/testing/selftests/bpf/test_xdp_features.sh
> new file mode 100755
> index 000000000000..98b8fd2b6c16
> --- /dev/null
> +++ b/tools/testing/selftests/bpf/test_xdp_features.sh
> @@ -0,0 +1,99 @@
> +#!/bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +
> +# Create 2 namespaces with two veth peers, and
> +# check reported and detected XDP capabilities
> +#
> +#   NS0(v00)              NS1(v11)
> +#       |                     |
> +#       |                     |
> +# (v01, id:111)  ------  (v10,id:222)
> +
> +readonly NS0="ns1-$(mktemp -u XXXXXX)"
> +readonly NS1="ns2-$(mktemp -u XXXXXX)"
> +ret=1
> +
> +setup() {
> +	{
> +		ip netns add ${NS0}
> +		ip netns add ${NS1}
> +
> +		ip link add v01 index 111 type veth peer name v00 netns ${NS0}
> +		ip link add v10 index 222 type veth peer name v11 netns ${NS1}
> +
> +		ip link set v01 up
> +		ip addr add 10.10.0.1/24 dev v01
> +		ip link set v01 address 00:11:22:33:44:55
> +		ip -n ${NS0} link set dev v00 up
> +		ip -n ${NS0} addr add 10.10.0.11/24 dev v00
> +		ip -n ${NS0} route add default via 10.10.0.1
> +		ip -n ${NS0} link set v00 address 00:12:22:33:44:55
> +
> +		ip link set v10 up
> +		ip addr add 10.10.1.1/24 dev v10
> +		ip link set v10 address 00:13:22:33:44:55
> +		ip -n ${NS1} link set dev v11 up
> +		ip -n ${NS1} addr add 10.10.1.11/24 dev v11
> +		ip -n ${NS1} route add default via 10.10.1.1
> +		ip -n ${NS1} link set v11 address 00:14:22:33:44:55
> +
> +		sysctl -w net.ipv4.ip_forward=1
> +		# Enable XDP mode
> +		ethtool -K v01 gro on
> +		ethtool -K v01 tx-checksumming off
> +		ip netns exec ${NS0} ethtool -K v00 gro on
> +		ip netns exec ${NS0} ethtool -K v00 tx-checksumming off
> +		ethtool -K v10 gro on
> +		ethtool -K v10 tx-checksumming off
> +		ip netns exec ${NS1} ethtool -K v11 gro on
> +		ip netns exec ${NS1} ethtool -K v11 tx-checksumming off
> +	} > /dev/null 2>&1
> +}
> +
> +cleanup() {
> +	ip link del v01 2> /dev/null
> +	ip link del v10 2> /dev/null
> +	ip netns del ${NS0} 2> /dev/null
> +	ip netns del ${NS1} 2> /dev/null
> +	[ "$(pidof xdp_features)" = "" ] || kill $(pidof xdp_features) 2> /dev/null
> +}
> +
> +test_xdp_features() {
> +	setup
> +
> +	## XDP_PASS
> +	ip netns exec ${NS1} ./xdp_features -f XDP_PASS -D 10.10.1.11 -T 10.10.0.11 v11 &
> +	ip netns exec ${NS0} ./xdp_features -t -f XDP_PASS -D 10.10.1.11 -C 10.10.1.11 -T 10.10.0.11 v00
> +
> +	[ $? -ne 0 ] && exit
> +
> +	# XDP_DROP
> +	ip netns exec ${NS1} ./xdp_features -f XDP_DROP -D 10.10.1.11 -T 10.10.0.11 v11 &
> +	ip netns exec ${NS0} ./xdp_features -t -f XDP_DROP -D 10.10.1.11 -C 10.10.1.11 -T 10.10.0.11 v00
> +
> +	[ $? -ne 0 ] && exit
> +
> +	## XDP_TX
> +	./xdp_features -f XDP_TX -D 10.10.0.1 -T 10.10.0.11 v01 &
> +	ip netns exec ${NS0} ./xdp_features -t -f XDP_TX -D 10.10.0.1 -C 10.10.0.1 -T 10.10.0.11 v00
> +
> +	## XDP_REDIRECT
> +	ip netns exec ${NS1} ./xdp_features -f XDP_REDIRECT -D 10.10.1.11 -T 10.10.0.11 v11 &
> +	ip netns exec ${NS0} ./xdp_features -t -f XDP_REDIRECT -D 10.10.1.11 -C 10.10.1.11 -T 10.10.0.11 v00
> +
> +	[ $? -ne 0 ] && exit
> +
> +	## XDP_NDO_XMIT
> +	./xdp_features -f XDP_NDO_XMIT -D 10.10.0.1 -T 10.10.0.11 v01 &
> +	ip netns exec ${NS0} ./xdp_features -t -f XDP_NDO_XMIT -D 10.10.0.1 -C 10.10.0.1 -T 10.10.0.11 v00
> +
> +	ret=$?
> +	cleanup
> +}
> +
> +set -e
> +trap cleanup 2 3 6 9
> +
> +test_xdp_features

This won't be run by bpf CI.

A selftest in test_progs is needed to test the libbpf changes in patch 6.


  reply	other threads:[~2023-01-24  6:35 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-20 17:16 [PATCH bpf-next 0/7] xdp: introduce xdp-feature support Lorenzo Bianconi
2023-01-20 17:16 ` [PATCH bpf-next 1/7] netdev-genl: create a simple family for netdev stuff Lorenzo Bianconi
2023-01-21  1:19   ` Alexei Starovoitov
2023-01-22 17:45     ` Lorenzo Bianconi
2023-01-21  3:11   ` Jakub Kicinski
2023-01-22 23:00     ` Lorenzo Bianconi
2023-01-23 20:01       ` Jakub Kicinski
2023-01-23 23:29         ` Lorenzo Bianconi
2023-01-21  4:42   ` kernel test robot
2023-01-20 17:16 ` [PATCH bpf-next 2/7] drivers: net: turn on XDP features Lorenzo Bianconi
2023-01-21  3:11   ` Jakub Kicinski
2023-01-22 11:49     ` Lorenzo Bianconi
2023-01-23 20:03       ` Jakub Kicinski
2023-01-20 17:16 ` [PATCH bpf-next 3/7] xsk: add usage of XDP features flags Lorenzo Bianconi
2023-01-20 17:16 ` [PATCH bpf-next 4/7] libbpf: add the capability to specify netlink proto in libbpf_netlink_send_recv Lorenzo Bianconi
2023-01-20 17:16 ` [PATCH bpf-next 5/7] libbpf: add API to get XDP/XSK supported features Lorenzo Bianconi
2023-01-21  3:20   ` Jakub Kicinski
2023-01-22 12:09     ` Lorenzo Bianconi
2023-01-20 17:16 ` [PATCH bpf-next 6/7] bpf: devmap: check XDP features in bpf_map_update_elem and __xdp_enqueue Lorenzo Bianconi
2023-01-21  2:02   ` Martin KaFai Lau
2023-01-22 12:13     ` Lorenzo Bianconi
2023-01-23 20:09       ` Jakub Kicinski
2023-01-23 23:29         ` Lorenzo Bianconi
2023-01-20 17:16 ` [PATCH bpf-next 7/7] selftests/bpf: introduce XDP compliance test tool Lorenzo Bianconi
2023-01-24  6:34   ` Martin KaFai Lau [this message]
2023-01-24 11:12     ` Lorenzo Bianconi

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=d2606312-1e04-55ff-e01e-daf83ed99836@linux.dev \
    --to=martin.lau@linux.dev \
    --cc=aelior@marvell.com \
    --cc=alardam@gmail.com \
    --cc=andrii@kernel.org \
    --cc=anthony.l.nguyen@intel.com \
    --cc=ast@kernel.org \
    --cc=bjorn@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=ecree.xilinx@gmail.com \
    --cc=edumazet@google.com \
    --cc=gospo@broadcom.com \
    --cc=hawk@kernel.org \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=john@phrozen.org \
    --cc=kuba@kernel.org \
    --cc=leon@kernel.org \
    --cc=lorenzo.bianconi@redhat.com \
    --cc=lorenzo@kernel.org \
    --cc=maciej.fijalkowski@intel.com \
    --cc=magnus.karlsson@intel.com \
    --cc=memxor@gmail.com \
    --cc=mst@redhat.com \
    --cc=nbd@nbd.name \
    --cc=netdev@vger.kernel.org \
    --cc=niklas.soderlund@corigine.com \
    --cc=pabeni@redhat.com \
    --cc=saeedm@nvidia.com \
    --cc=simon.horman@corigine.com \
    --cc=toke@redhat.com \
    --cc=vladimir.oltean@nxp.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).