Hi everyone,
I’ve released v2 of p4runtime-go-controller, a Go SDK and CLI for building P4Runtime controllers. The latest version is v2.0.1.
For those unfamiliar with P4, it’s a language for describing how network devices process packets. P4Runtime is the API a controller uses to install a P4 pipeline and manage resources such as forwarding tables, counters and registers.
This project provides Go helpers for those operations, including resource lookup by name, value encoding, connection management and stream handling.
Features include:
- Table entry builders with exact, LPM, ternary, range and optional matches, plus bit-width validation.
- Controller arbitration, pipeline configuration, automatic reconnection, TLS and mutual TLS.
- PacketIn and PacketOut handling, digest subscriptions, counters, meters, registers and packet replication.
- A p4ctl CLI for pipeline, table and counter operations, with text, JSON and YAML output.
The SDK uses context.Context for cancellation and deadlines, and log/slog for structured logging. It requires Go 1.26 or newer and is licensed under Apache 2.0.
To add it to an existing Go module:
go get github.com/zhh2001/p4runtime-go-controller/v2@v2.0.1
To install the CLI:
go install github.com/zhh2001/p4runtime-go-controller/v2/cmd/p4ctl@v2.0.1
The repository includes API documentation and runnable BMv2 examples covering L2 forwarding, packet I/O and counters. Testing so far has focused on BMv2, including control-plane operations and packet forwarding.
If you’re working on programmable networking or SDN in Go, I’d welcome feedback on the API and examples.
If you find the project useful, a GitHub star would help others discover it. Issues and contributions are welcome.