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

PSA/eBPF: Enable passing packets up to the kernel stack #3691

Merged
merged 16 commits into from
Nov 23, 2022

Conversation

osinstom
Copy link
Contributor

This PR introduces an implicit custom packet path to the PSA model used for eBPF backend. The new packet path enables integrating PSA pipelines for eBPF with the standard Linux kernel network stack. The main use case is to delegate ARP/ICMP handling to the kernel, instead of re-inventing the wheel by implementing own ARP/ICMP handlers in userspace. The new packet path also enables sending packets to the userspace application listening on a socket.

To send packets to the kernel, a P4 programmer should set drop to false and leave egress_port unspecified (or set to 0) in the ingress pipeline.

Note that reply packets (ICMP Reply, ARP Response, etc.) traverse the egress pipeline, but the PSA Egress pipeline is unable to distinguish between packets from PSA Ingress and from kernel. Therefore, we disallow handling packets from kernel in the egress pipeline. Such packets are ignored by the egress eBPF program and directly send out to the output port.

@@ -568,6 +583,28 @@ void TCIngressPipeline::emitTrafficManager(CodeBuilder *builder) {
control->outputStandardMetadata->name.name);
builder->newline();

builder->appendFormat("if (%s.drop == false && %s.egress_port == 0) ",
Copy link
Contributor

Choose a reason for hiding this comment

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

usually you don't write 'x==false' but '!x'

The NTK packet path allows integrating P4/PSA programs for eBPF with the standard Linux kernel stack. The main use case is handling
ICMP/ARP requests and sending packet to the userspace process listening on a socket.

The NTK path is enforced if `drop` is set to `false` and `egress_port` is left unspecified or set to 0 (it's a special implicit port number that forwards packets to the kernel stack).
Copy link
Contributor

Choose a reason for hiding this comment

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

I would not say "unspecified", but "unchanged". Since it is an inout value, it must be initialized properly.

@osinstom
Copy link
Contributor Author

@mbudiu-vmw I addressed your comments, thanks! Can we merge this?

@mihaibudiu mihaibudiu merged commit 73908eb into p4lang:main Nov 23, 2022
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.

2 participants