Repository navigation
Conversation
A tc BPF program on the egress of the dummy device sixup-nat64 translates statelessly (RFC 7915): each IPv6 source gets an address of its own from 198.18.0.0/15, and conntrack and the source NAT on the way out do the stateful part, as for any IPv4 host behind the router. Translated packets go back to the device's ingress. TCP, UDP, ICMP and ICMP errors with their quotes are translated, fragments one by one, behind a prefix of any length RFC 6052 allows. Fragmented ICMP and IPv4 UDP without a checksum need the whole datagram and go through a slow path in sixup, which reassembles, translates and sends them back marked. Mappings conntrack has no flow for are removed. Linux 6.6 or later is needed for tcx. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Welcome to Codecov 馃帀Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. Thanks for integrating Codecov - We've got you covered 鈽傦笍 |
cilium/ebpf grew the binary by 1.6 MB, past the 6 MiB limit, and its perf package does not build for 32-bit big-endian MIPS. tools/bpfgen now compiles bpf/nat64.c for either byte order at go generate time and writes the instructions, maps, read-only data and relocations, and bpf.go loads them with the bpf() system call alone. The slow path reads a BPF ring buffer instead of a perf buffer. The binary is now 98 KB over main's. The recipes and the standards document recommend -nat64 bpf, with Jool for kernels older than 6.6, and sixup refuses to start when the pool 198.18.0.0/15 overlaps an address or route of the host, as it does for Jool's /31. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
-nat64 bpf: a stateless RFC 7915 translator in a tc BPF program on the egress of the dummy devicesixup-nat64. Each IPv6 source gets an address of its own from198.18.0.0/15; conntrack and the source NAT on the way out do the stateful part, so a MAP-E line's ports keep one allocator. Translated packets go back to the device's ingress.tools/bpfgen(stdlib only) compilesbpf/nat64.cfor either byte order atgo generatetime and writes the instructions, maps, read-only data and relocations;bpf.goloads them with thebpf()system call alone. The amd64 binary is 98 KB larger than main's, within the 6 MiB limit, and 32-bit big-endian MIPS builds.-nat64 bpf, with-nat64 joolfor kernels older than 6.6.Test plan
go build ./... && go vet ./... && go test ./..., andgo build ./...for linux, darwin and freebsdGOOS=linux golangci-lint run, with and without-tags integration./build.shfor amd64, arm64, mips and mipsle; amd64 at 5,886,112 bytesgo generatereproduces the committed files byte for byte64:ff9b::/96and a/64, with conntrack for IPv6 as sixup's firewall has it (ping, the router's own ping, TCP, UDP, fragments both ways, fragmented ping, UDP without checksum, UDP GSO both ways, ICMP errors incl. quoted fragments, PTB both ways, mapping sweep); the ICMP tables and the RFC 6052 examples throughBPF_PROG_TEST_RUN;bpf.go,nat64bpf.goandnat64slow.goat 100% coverage馃 Generated with Claude Code