Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backends/ebpf: Add support for XDP model. #4160

Merged
merged 11 commits into from
Sep 24, 2023

Conversation

thomascalvert-xlnx
Copy link
Member

This PR adds support for the xdp_model.p4 file. It is effectively a resurrection of the p4c-xdp work by @mihaibudiu.

The net effect is that it's possible to write a simple P4->eBPF program with a deparser (whereas previously one could only classify the packet).

It also adds support for running ebpf-kernel tests in the XDP hook (rather than TC) and includes a couple simple tests of the new functionality.

The PR starts with a few minor "cleanup" type commits which hopefully aren't too controversial.

I hope that these changes don't break anything else - I have tried to run as many tests as possible but am still seeing a couple failures:

  • bmv2-ptf/ternary2-bmv2 fails due to the clients not being able to connect to the thrift/grpc server. I don't understand this one but have convinced myself that it's an issue with my setup and not something broken by these changes.
  • PSA tests (backends/ebpf/tests/test.sh): I see these fail due to ptf_out/bng.p4info.txt not being created. Again I don't think it's caused by these changes.

All the other testcases are passing as far as I can tell, and even a few more than before. :)

Note that this PR depends on #4159 and #4134 -- the commits are unfortunately duplicated here since GH can't deal with dependent PRs. I am happy to rebase this PR if/when they are merged.

@mihaibudiu
Copy link
Contributor

ebpf_psa is much more featured that this backend, and also actively maintained. I assume that you want a simpler architecture.

@fruffy fruffy added the ebpf Topics related to the eBPF back end label Sep 15, 2023
@thomascalvert-xlnx
Copy link
Member Author

ebpf_psa is much more featured that this backend, and also actively maintained. I assume that you want a simpler architecture.

That's correct, the existing xdp_model.p4 architecture implemented here just exposes "vanilla" XDP, whereas PSA implements a higher-level architecture on top of both XDP and TC. Both share code from the eBPF backend.

This avoids the 'root is not in the sudoers file' error.
The same instruction is already emitted in EBPFParser::emit().
As things stand, when using the ebpf backend (not PSA or TC), the emitDeparserExternCalls()
causes the deparsing code to be emitted before any variables are initialised.
This is obviously incorrect however wasn't noticed since the only users of the
deparser code currently override this method.
@thomascalvert-xlnx
Copy link
Member Author

Fixed clang-format issues and rebased onto main.

@thomascalvert-xlnx
Copy link
Member Author

There seems to be one test failure in the last run but I don't understand how it can be related to these changes. From memory this test didn't fail in previous runs - could it be a one-off failure?

 1302/1627 Test #3279: testgen-p4c-bmv2-ptf/gauntlet_nested_table_calls-bmv2.p4 .................***Failed    1.82 sec
(...)
WARNING: FileNotFoundError: [Errno 2] No such file or directory: 'ptf.log'
ERROR: Error 1 when executing "ip netns exec 984d755a-b74b-4eba-9a6b-935167d2b8e3 ptf --pypath /home/runner/work/p4c/p4c/backends/bmv2 --test-dir /home/runner/work/p4c/p4c/build/tmpk1dhkqkj --list".

I have tried to reproduce locally but am hitting other issues with my VM's local configuration. Any pointers appreciated - thanks.

@mihaibudiu
Copy link
Contributor

mihaibudiu commented Sep 21, 2023 via email

@fruffy
Copy link
Collaborator

fruffy commented Sep 21, 2023

This is a spurious failure that can happen because of a bug in the packet test framework. Rerunning the tests should fix the issue.

@jafingerhut
Copy link
Contributor

One approval and all tests passing, so merging this in.

@jafingerhut jafingerhut merged commit aefe41f into p4lang:main Sep 24, 2023
17 checks passed
fruffy pushed a commit that referenced this pull request Jan 22, 2024
* backends/ebpf: Fix errors tests failing when run with -j

CI jobs don't run parallel builds so weren't encountering this error.

* backends/ebpf: Improve docs to reflect recent XDP model addition.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ebpf Topics related to the eBPF back end
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants