Skip to content

Conversation

Copy link

Copilot AI commented Nov 13, 2025

  • Understand the issue: BPF_F_TEST_XDP_LIVE_FRAMES flag support needed for latest kernel
  • Check if flags field exists in bpf_test_run_opts structure
  • Add compile-time check for flags field existence (similar to HAS_BPF_TEST_RUN_OPTS_BATCH_SIZE)
  • Update runner.cc to set BPF_F_TEST_XDP_LIVE_FRAMES flag when XDP program type is used
  • Update CMakeLists.txt to add check for flags field
  • Test the fix with baseline test and other tests
  • Address code review feedback (use bitwise OR for flags)
  • Run security checks (no vulnerabilities found)
  • Verify all tests pass (all 42 tests passing)
  • Update gitignore to exclude CodeQL build artifacts
  • Fix program type tracking for reused BPF objects
  • Add validation for program type mismatch on reuse

Summary

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 the flags field in bpf_test_run_opts structure (similar to existing HAS_BPF_TEST_RUN_OPTS_BATCH_SIZE)
  2. Set BPF_F_TEST_XDP_LIVE_FRAMES flag when running XDP programs on Linux
  3. Used conditional compilation to ensure backward compatibility with older kernels/libbpf versions
  4. Applied flag using bitwise OR to preserve any existing flags
  5. Updated .gitignore to exclude CodeQL build artifacts
  6. Store program type alongside BPF object to correctly handle reused objects
  7. NEW: Validate program type matches when reusing BPF objects from cache

Testing:

  • All 42 tests pass successfully with the changes
  • Verified baseline, helper functions, and various map type tests
  • No security vulnerabilities detected by CodeQL
  • Program type is now correctly tracked and validated for both new and reused BPF objects

The fix ensures compatibility with both older and newer kernel versions through conditional compilation, and prevents configuration mismatches when reusing BPF objects.

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
@Alan-Jowett Alan-Jowett marked this pull request as ready for review January 20, 2026 23:56
@Alan-Jowett Alan-Jowett requested a review from Copilot January 20, 2026 23:56
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes execution issues where the bpf_performance_runner fails on newer Linux kernels that require the BPF_F_TEST_XDP_LIVE_FRAMES flag for XDP programs. The fix uses a compile-time check to detect the availability of the flags field in the bpf_test_run_opts structure, ensuring backward compatibility with older libbpf versions.

Changes:

  • Added compile-time detection for the flags field in bpf_test_run_opts structure
  • Updated runner to set BPF_F_TEST_XDP_LIVE_FRAMES flag for XDP programs on Linux
  • Added CodeQL build artifacts to .gitignore

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.

File Description
runner/CMakeLists.txt Added compile-time check for flags field availability in bpf_test_run_opts, following the same pattern as the existing batch_size check
runner/runner.cc Added linux/bpf.h include, defined BPF_F_TEST_XDP_LIVE_FRAMES constant, tracked program type, and set the flag for XDP programs in both test execution and map state preparation
.gitignore Added CodeQL build directory artifacts to prevent them from being committed

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Alan-Jowett
Copy link
Member

@copilot address and reply to each comment with what you fixed

Fixed issue where actual_prog_type was not updated when reusing BPF
objects from the cache. Now storing program type alongside the BPF
object in bpf_object_info structure, ensuring correct flag settings
for all tests including those with reused objects.

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

Copilot AI commented Jan 21, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

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:

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 3 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Alan-Jowett
Copy link
Member

@copilot address and reply to each comment with what you fixed

Added validation to ensure that when a BPF object is reused from cache, the program_type specified in the YAML matches the type used when the object was first loaded. This prevents silent mismatches where different tests specify different program types for the same ELF file, which would lead to incorrect flag settings and unexpected behavior.

Co-authored-by: Alan-Jowett <20480683+Alan-Jowett@users.noreply.github.com>
Copy link
Author

Copilot AI commented Jan 27, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

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:

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 3 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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