Add dummy --filter-track-{tc,xdp} tests #921
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Test | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 | |
- name: Set up Go | |
uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a | |
with: | |
go-version: 1.23.1 | |
- name: Check module vendoring | |
run: | | |
go mod tidy | |
go mod vendor | |
go mod verify | |
test -z "$(git status --porcelain)" || (echo "please run 'go mod tidy && go mod vendor', and submit your changes"; exit 1) | |
- name: Generate and build | |
run: | | |
make release | |
tar xfv release/pwru-linux-amd64.tar.gz | |
- name: Store executable | |
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b | |
with: | |
name: pwru | |
path: pwru | |
- name: Build test-app | |
run: | | |
cd test-app | |
go build . | |
- name: Store test-app | |
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b | |
with: | |
name: test-app | |
path: test-app/test-app | |
test: | |
runs-on: ubuntu-latest | |
name: Test | |
needs: build | |
strategy: | |
fail-fast: false | |
matrix: | |
kernel: [ '5.4-20241218.004849', '5.10-20241218.004849', '5.15-20241218.004849', '6.1-20241218.004849', '6.6-20241218.004849', '6.12-20241218.004849', 'bpf-next-20250105.013256' ] | |
timeout-minutes: 10 | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 | |
- name: Retrieve stored pwru executable | |
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 | |
with: | |
name: pwru | |
path: pwru | |
- name: Retrieve stored test-app executable | |
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 | |
with: | |
name: test-app | |
path: test-app | |
- name: Derive kernel version | |
id: kernel | |
run: | | |
if [[ "${{ matrix.kernel }}" == bpf-next* ]]; then | |
VSN="42.0" | |
else | |
VSN=$(echo -n ${{ matrix.kernel }} | cut -d- -f1) | |
fi | |
major=$(echo -n $VSN | cut -d. -f1) | |
minor=$(echo -n $VSN | cut -d. -f2) | |
if (( $minor < 10 )); then | |
minor="0${minor}" | |
fi | |
echo "vsn=${major}${minor}" >> "$GITHUB_OUTPUT" | |
- name: Provision LVH VMs | |
uses: cilium/little-vm-helper@97c89f004bd0ab4caeacfe92ebc956e13e362e6b # v0.0.19 | |
with: | |
test-name: pwru-test | |
image-version: ${{ matrix.kernel }} | |
host-mount: ./ | |
install-dependencies: 'true' | |
cmd: | | |
chmod +x /host/pwru/pwru | |
chmod +x /host/test-app/test-app | |
- name: Test basic IPv4 | |
uses: ./.github/actions/pwru-test | |
with: | |
test-name: ${{ matrix.kernel }}-basic-ipv4 | |
pwru-pcap-filter: 'dst host 1.0.0.1 and port 8080' | |
setup: | | |
iptables -w 10 -I OUTPUT 1 -m tcp --proto tcp --dst 1.0.0.1/32 --dport 8080 -j DROP | |
gen-traffic: | | |
curl -vvv -sS --fail --connect-timeout "1" -o /dev/null http://1.0.0.1:8080 || true | |
expected-output-pattern: '1.0.0.1:8080.*(kfree_skb_reason|kfree_skb|sk_skb_reason_drop\b)' | |
- name: Test basic IPv6 | |
uses: ./.github/actions/pwru-test | |
with: | |
test-name: ${{ matrix.kernel }}-basic-ipv6 | |
pwru-pcap-filter: 'dst host 2606:4700:4700::1001 and port 8080' | |
setup: | | |
ip6tables -I OUTPUT 1 -m tcp --proto tcp --dst 2606:4700:4700::1001 --dport 8080 -j DROP | |
gen-traffic: | | |
curl -vvv -sS --fail --connect-timeout "1" -o /dev/null http://[2606:4700:4700::1001]:8080 || true | |
expected-output-pattern: '\[2606:4700:4700::1001\]:8080.*(kfree_skb_reason|kfree_skb|sk_skb_reason_drop\b)' | |
- name: Test advanced IPv4 | |
uses: ./.github/actions/pwru-test | |
with: | |
test-name: ${{ matrix.kernel }}-advanced-ipv4 | |
pwru-pcap-filter: 'tcp[tcpflags] = tcp-syn' | |
setup: | | |
iptables -w 10 -I OUTPUT 1 -m tcp --proto tcp --dst 1.0.0.2/32 --dport 8080 -j DROP | |
gen-traffic: | | |
curl -vvv -sS --fail --connect-timeout "1" -o /dev/null http://1.0.0.2:8080 || true | |
expected-output-pattern: '1.0.0.2:8080.*(kfree_skb_reason|kfree_skb|sk_skb_reason_drop\b)' | |
- name: Test advanced IPv6 | |
uses: ./.github/actions/pwru-test | |
with: | |
test-name: ${{ matrix.kernel }}-advanced-ipv6 | |
pwru-pcap-filter: 'ip6[53] & 0x3f = 0x2' | |
setup: | | |
ip6tables -I OUTPUT 1 -m tcp --proto tcp --dst 2606:4700:4700::1002 --dport 8080 -j DROP | |
gen-traffic: | | |
curl -vvv -sS --fail --connect-timeout "1" -o /dev/null http://[2606:4700:4700::1002]:8080 || true | |
expected-output-pattern: '\[2606:4700:4700::1002\]:8080.*(kfree_skb_reason|kfree_skb|sk_skb_reason_drop\b)' | |
- name: Test pcap filter using stack | |
uses: ./.github/actions/pwru-test | |
with: | |
test-name: ${{ matrix.kernel }}-pcap-filter-stack | |
pwru-pcap-filter: '(((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)' | |
gen-traffic: curl -vvv -sS --fail --connect-timeout "1" -o /dev/null http://1.1.1.1 || true; sleep 5 | |
expected-output-pattern: '1.1.1.1:80' | |
- name: Test --filter-track-skb | |
uses: ./.github/actions/pwru-test | |
with: | |
test-name: ${{ matrix.kernel }}-filter-track-skb | |
pwru-flags: --filter-track-skb | |
pwru-pcap-filter: dst host 10.10.20.99 | |
setup: | | |
iptables -w 10 -t nat -I OUTPUT 1 -d 10.10.20.99/32 -j DNAT --to-destination 10.10.14.2 | |
gen-traffic: | | |
curl -vvv -sS --fail --connect-timeout "1" -o /dev/null http://10.10.20.99:80 || true | |
expected-output-pattern: '10.10.14.2:80' | |
- name: Test ARP filter | |
uses: ./.github/actions/pwru-test | |
with: | |
test-name: ${{ matrix.kernel }}-filter-arp | |
pwru-pcap-filter: 'arp and arp[7] = 1 and arp[24]= 169 and arp[25] = 254 and arp[26] = 0 and arp[27] = 1' | |
setup: | | |
ip net a pwru | |
ip l a pwru-veth type veth peer name pwru-veth-peer | |
ip l s pwru-veth-peer up | |
ip l s pwru-veth netns pwru | |
ip net e pwru ip l s pwru-veth up | |
ip r a 10.0.0.1 dev pwru-veth-peer | |
ip net e pwru ip a a 10.0.0.1 dev pwru-veth | |
ip net e pwru ip r a 169.254.0.1 dev pwru-veth | |
ip net e pwru ip r a default via 169.254.0.1 dev pwru-veth | |
gen-traffic: | | |
ping -W1 -c1 10.0.0.1 || true | |
expected-output-pattern: 'arp_rcv' | |
- name: Test --filter-ifname | |
uses: ./.github/actions/pwru-test | |
with: | |
test-name: ${{ matrix.kernel }}-filter-ifname | |
pwru-flags: --filter-ifname lo | |
pwru-pcap-filter: icmp | |
gen-traffic: | | |
ping -W1 -c1 127.0.0.1 || true | |
expected-output-pattern: 'icmp' | |
- name: Test --backend=kprobe-multi | |
if: ${{ steps.kernel.outputs.vsn >= 518 }} | |
uses: ./.github/actions/pwru-test | |
with: | |
test-name: ${{ matrix.kernel }}-kprobe-multi-basic | |
pwru-flags: --backend=kprobe-multi | |
pwru-pcap-filter: 'dst host 1.0.0.1 and port 8080' | |
setup: | | |
iptables -w 10 -I OUTPUT 1 -m tcp --proto tcp --dst 1.0.0.1/32 --dport 8080 -j DROP | |
gen-traffic: | | |
curl -vvv -sS --fail --connect-timeout "1" -o /dev/null http://1.0.0.1:8080 || true | |
expected-output-pattern: '1.0.0.1:8080.*(kfree_skb_reason|kfree_skb|sk_skb_reason_drop\b)' | |
- name: Test --filter-track-{tc,xdp} | |
if: ${{ steps.kernel.outputs.vsn >= 600 }} | |
uses: ./.github/actions/pwru-test | |
with: | |
test-name: ${{ matrix.kernel }}-filter-trace-tc-xdp | |
pwru-flags: --filter-trace-tc --filter-trace-xdp | |
pwru-pcap-filter: 'dst host 1.0.0.1 and port 8080' | |
setup: | | |
# install test-app | |
ip link add dummy0 type dummy | |
ip link set dummy0 up | |
/host/test-app/test-app --attach-type xdp --iface dummy0 | |
/host/test-app/test-app --attach-type tc --iface dummy0 | |
iptables -w 10 -I OUTPUT 1 -m tcp --proto tcp --dst 1.0.0.1/32 --dport 8080 -j DROP | |
gen-traffic: | | |
curl -vvv -sS --fail --connect-timeout "1" -o /dev/null http://1.0.0.1:8080 || true | |
expected-output-pattern: '1.0.0.1:8080.*(kfree_skb_reason|kfree_skb|sk_skb_reason_drop\b)' | |
- name: Fetch artifacts | |
if: ${{ !success() }} | |
uses: cilium/little-vm-helper@97c89f004bd0ab4caeacfe92ebc956e13e362e6b # v0.0.19 | |
with: | |
provision: 'false' | |
cmd: | | |
for i in /tmp/pwru-*.status /tmp/pwru-*.ready /tmp/pwru-*.log; do | |
echo "--- \$i ---" | |
cat \$i || true | |
done |