Skip to content

Conversation

Copy link

Copilot AI commented Nov 13, 2025

This PR fixes the issue where bpf_performance_runner fails on the latest upstream kernel with error -EINVAL (error code -22, displayed as 4294967274 when printed as unsigned). The error originated from the kernel requiring the BPF_F_TEST_XDP_LIVE_FRAMES flag for XDP programs on newer kernels.

Changes Made

  1. Added compile-time check for flags field (runner/CMakeLists.txt):

    • Added HAS_BPF_TEST_RUN_OPTS_FLAGS check for the flags field in bpf_test_run_opts structure
    • Similar approach to existing HAS_BPF_TEST_RUN_OPTS_BATCH_SIZE check
    • Ensures backward compatibility with older libbpf versions
  2. Updated runner implementation (runner/runner.cc):

    • Included linux/bpf.h header and defined BPF_F_TEST_XDP_LIVE_FRAMES if not available
    • Track the actual program type being used (actual_prog_type)
    • Set the BPF_F_TEST_XDP_LIVE_FRAMES flag for XDP programs in both the main test execution and map state preparation
    • Used bitwise OR (|=) to preserve any existing flags
  3. Updated .gitignore:

    • Added CodeQL build artifacts to prevent them from being committed

Testing

  • ✅ All 42 tests pass successfully with the changes
  • ✅ Verified baseline, helper functions, and various map type tests
  • ✅ No security vulnerabilities detected by CodeQL
  • ✅ Backward compatibility maintained through conditional compilation

The fix ensures compatibility with both older and newer kernel versions by using conditional compilation based on the availability of the flags field in the bpf_test_run_opts structure.

Original prompt

This section details on the original issue you should resolve

<issue_title>Unable to execute the tests on latest upstream kernel</issue_title>
<issue_description>I'm experiencing issues while testing bpf_performance on the latest upstream kernel. The program fails with the following error:

./bpf_performance_runner -i tests.yml -t "Baseline"
Error: Program returned unexpected result 4294967274 in test Baseline expected 0

The test configuration shows:

=== TEST CONFIGURATION ===
Test name: Baseline
ELF file: baseline.o
Iteration count: 10000000
Batch size: 64
Pass data: 0
Pass context: 1
Expected result: 0
CPU count: 1

The program is returning -EINVAL (error code -22). After some debugging, I found that the error originates from this line: https://elixir.bootlin.com/linux/v6.18-rc5/source/net/bpf/test_run.c#L1231

The issue appears to be that bpf_performance_runner doesn't properly support the BPF_F_TEST_XDP_LIVE_FRAMES flag. I'm curious about which kernel versions are officially supported by this tool.

Since this tool supports both Windows and Linux, I'm uncertain whether BPF_F_TEST_XDP_LIVE_FRAMES and related XDP functionality are implemented on the Windows side to make changes to the tool.

Probably need similar hack like HAS_BPF_TEST_RUN_OPTS_BATCH_SIZE.
Also, I am curious why you chose xdp to run bpf_prog_test_run

Thanks in advance!</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@Alan-Jowett
Copy link
Member

@copilot your work on this fix got interrupted. Please resume work.

GitHub Copilot added 3 commits January 7, 2026 17:07
- Added compile-time check for flags field in bpf_test_run_opts structure
- Set BPF_F_TEST_XDP_LIVE_FRAMES flag when running XDP programs on Linux
- Fixed issue where programs fail with -EINVAL on latest upstream kernel
- Similar approach to existing HAS_BPF_TEST_RUN_OPTS_BATCH_SIZE flag

Signed-off-by: GitHub Copilot <copilot@github.com>
Addressed code review feedback to use |= operator instead of direct assignment for better future-proofing.

Signed-off-by: GitHub Copilot <copilot@github.com>
Signed-off-by: GitHub Copilot <copilot@github.com>
Copy link
Author

Copilot AI commented Jan 7, 2026

@copilot your work on this fix got interrupted. Please resume work.

I've resumed and completed the work. The fix has been implemented in commits 169363b and 61ddb2c.

The issue was that the latest upstream kernel requires the BPF_F_TEST_XDP_LIVE_FRAMES flag to be set for XDP programs. I've added:

  1. A compile-time check for the flags field (similar to HAS_BPF_TEST_RUN_OPTS_BATCH_SIZE)
  2. Code to set the BPF_F_TEST_XDP_LIVE_FRAMES flag when running XDP programs on Linux

All 42 tests now pass successfully, and there are no security vulnerabilities.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • esm.ubuntu.com
    • Triggering command: /usr/lib/apt/methods/https /usr/lib/apt/methods/https (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Fix execution issues for bpf_performance tests on latest kernel Fix execution issues for bpf_performance tests on latest kernel Jan 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unable to execute the tests on latest upstream kernel

2 participants