mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-08-16 05:12:23 +00:00

Verify that a classic BPF linux socket filter correctly matches packet contents. Including when accessing contents in an skb_frag. 1. Open a SOCK_RAW socket with a classic BPF filter on UDP dport 8000. 2. Open a tap device with IFF_NAPI_FRAGS to inject skbs with frags. 3. Send a packet for which the UDP header is in frag[0]. 4. Receive this packet to demonstrate that the socket accepted it. Acked-by: Stanislav Fomichev <sdf@fomichev.me> Signed-off-by: Willem de Bruijn <willemb@google.com> Link: https://lore.kernel.org/r/20250408132833.195491-3-willemdebruijn.kernel@gmail.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
31 lines
769 B
Bash
Executable File
31 lines
769 B
Bash
Executable File
#!/bin/bash
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
|
|
readonly NS="ns-$(mktemp -u XXXXXX)"
|
|
|
|
cleanup() {
|
|
ip netns del $NS
|
|
}
|
|
|
|
ip netns add $NS
|
|
trap cleanup EXIT
|
|
|
|
ip -netns $NS link set lo up
|
|
ip -netns $NS tuntap add name tap1 mode tap
|
|
ip -netns $NS link set tap1 up
|
|
ip -netns $NS link set dev tap1 addr 02:00:00:00:00:01
|
|
ip -netns $NS -6 addr add fdab::1 peer fdab::2 dev tap1 nodad
|
|
ip netns exec $NS ethtool -K tap1 gro off
|
|
|
|
# disable early demux, else udp_v6_early_demux pulls udp header into linear
|
|
ip netns exec $NS sysctl -w net.ipv4.ip_early_demux=0
|
|
|
|
echo "no filter"
|
|
ip netns exec $NS ./skf_net_off -i tap1
|
|
|
|
echo "filter, linear skb (-f)"
|
|
ip netns exec $NS ./skf_net_off -i tap1 -f
|
|
|
|
echo "filter, fragmented skb (-f) (-F)"
|
|
ip netns exec $NS ./skf_net_off -i tap1 -f -F
|