15 Commits
Author SHA1 Message Date
Kevin KrakauerandgVisor bot 9db874189a xdp: user real BPF helper functions, not a hacky forward definition
PiperOrigin-RevId: 600574627
2024-01-22 14:41:45 -08:00
Kevin KrakauerandgVisor bot 9e2db2c131 xdp: add a tunnel mode to avoid sharing UMEM among sandboxes
The existing redirect mode uses XDP to maximize performance but is not suitably
secure: packets are copied directly from the driver into a userspace buffer
(UMEM). But because the UMEM is shared among all processes with a socket open
on a particular NIC queue, sandboxes using redirect mode all map the same UMEM
and thus can read each other's packets.

Tunnel mode instead installs an eBPF program that copies packets from the
host's NIC driver into a per-sandbox NIC driver. This incurs an additional
copy, but there is no longer memory shared between sandboxes.

Benchmarking tunnel mode with redis-benchmark shows a performance gain over
standard Docker networking of 20%. Redirect mode showed a 30% improvement.

PiperOrigin-RevId: 595746162
2024-01-04 10:45:43 -08:00
Kevin KrakauerandgVisor bot f76d64021e xdp: update the incorrectly named "Readonly*" names
PiperOrigin-RevId: 592664806
2023-12-20 14:57:27 -08:00
Kevin KrakauerandgVisor bot cd4a40b584 xdp: use builtin constants and functions in xdp_loader eBPF
With cl/590826409's submission, we can use these.

PiperOrigin-RevId: 591148462
2023-12-14 22:25:20 -08:00
Kevin KrakauerandgVisor bot 6beb925dfd xdp: add flag for runsc to use an XDP socket on a host device
In combination with `xdp_loader redirect`, this allows `runsc` to receive
packets directly from any NIC. It is intended to be used with a machine's NIC
to avoid the Linux networking stack entirely.

PiperOrigin-RevId: 591090544
2023-12-14 17:02:25 -08:00
Kevin KrakauerandgVisor bot 3b77e29e3b xdp: split xdp_loader subcommands into cmd directory
This allows other code to use them as deps, which is impossible as a go_binary.

PiperOrigin-RevId: 591054831
2023-12-14 14:38:57 -08:00
Kevin KrakauerandgVisor bot f6d380ad8c xdp: add a program that redirects packets from a NIC to an AF_XDP socket
Usage is something like:

```
$ xdp_loader redirect --devidx 2 --unpin # Clear xdp_loader state on device 2
$ xdp_loader redirect --devidx 2 # Add and pin a map and program on device 2
```

When the map and program are pinned, a socket can be inserted so that packets
are routed directly from the NIC to that socket. SSH packets (IPv4 TCP port 22)
packets are allowed through for debugging.

Also, make xdp_loader fully static for ease of deployment.

PiperOrigin-RevId: 590955764
2023-12-14 09:04:07 -08:00
Kevin KrakauerandgVisor bot 89d6bf18c8 have gVisor use renamed buffer package
PiperOrigin-RevId: 537209194
2023-06-01 21:27:49 -07:00
Adin ScannellandgVisor bot 1ceb814544 Add default_applicable_licenses rules to packages.
PiperOrigin-RevId: 513581243
2023-03-02 10:50:04 -08:00
Kevin KrakauerandgVisor bot d8aa09e04c convert uses of interface{} to any
Done via:
  find . -name "*.go" | xargs sed -i -E 's/interface\{\}/any/g'

PiperOrigin-RevId: 487033228
2022-11-08 13:14:06 -08:00
Kevin KrakauerandgVisor bot 140384fa22 xdp: TX support
PiperOrigin-RevId: 480680001
2022-10-12 11:51:51 -07:00
Kevin KrakauerandgVisor bot 7c8624e575 xdp_loader: refactor to use subcommands
No change to behavior, just a refactor.

Another program (tunnel) is coming, and the code is becoming unwieldy. Impose
some structure.

PiperOrigin-RevId: 472818768
2022-09-07 14:55:23 -07:00
Kevin KrakauerandgVisor bot ad7b1121d4 xdp: use needs-wakeup flag
This is recommended in the kernel docs:
https://www.kernel.org/doc/html/latest/networking/af_xdp.html#xdp-use-need-wakeup-bind-flag

PiperOrigin-RevId: 472596449
2022-09-06 17:34:14 -07:00
Kevin KrakauerandgVisor bot 9bf0b63a37 xdp_loader: add tcpdump-ish program
Uses an AF_XDP socket to log packets entering a device. Can be used for
testing, but mostly useful as a minimal example of receiving packets via
AF_XDP.

Note that this actually prevents the packets from reaching their intended
destination, as redirection does not also send the packet through Linux's
network stack.

PiperOrigin-RevId: 470073040
2022-08-25 13:46:15 -07:00
Kevin KrakauerandgVisor bot 03b6826243 xdp: tooling and dependencies
Setup gVisor so that an AF_XDP dispatcher can be implemented.

Specifically:

- xdp_loader: a binary for testing XDP programs
- Two basic XDP programs
- Update the cilium/ebpf dep
- Genrule for building BPF programs
- Install clang on buildkite to support building BPF programs

PiperOrigin-RevId: 464562411
2022-08-01 10:11:57 -07:00