Repository navigation
plugin development
Pre-Alpha. This page describes behavior that may change.
This is the plugin author's section. The audience is different from the operator section: you are writing code that registers with the engine, reacts to events, and possibly emits events of its own. Read the Plugins overview first if you want context on what kinds of plugins already exist.
There are two paths and you should pick one before you start writing code.
A Go plugin lives in the Ze repo and is compiled into the binary. System plugins (such as fib-kernel, fib-p4 and iface-dhcp) register in internal/plugins/, while BGP plugins register in internal/component/bgp/plugins/. The engine discovers it through its init() registration rather than a direct import, because any plugin, in-tree ones included, may run as an external process: a direct Go call from another component into a plugin does nothing when that plugin runs out of process. Latency is the lowest of any path, the type system catches most mistakes at compile time, and it has access to the in-process Go SDK without going through a serialisation layer.
You write a Go plugin when:
- You are extending Ze's BGP behaviour and want the plugin shipped with the binary.
- You need the lowest latency possible (
fib-kernel, the RIB, the route selection policy). - You want compile-time type checking.
- You want a filter type that runs in a Loc-RIB import chain (
isis,ospf,static,connected,rib). Those chains call in-process route evaluators registered withpolicy.MustRegisterRouteEvaluator; a chain naming a type with no evaluator is refused at load. A protocol with a filter attachment lists thepolicyplugin in itsDependencies, which is what auto-loads it.
Go plugins is the next page.
An external plugin is a separate process. Ze launches it, sets a small set of environment variables, and the plugin connects back over a single TLS connection (or stdin/stdout for the standalone debug case) and speaks the line protocol. Languages do not matter: any language that can read and write text and parse JSON can implement an external plugin.
You write an external plugin when:
- You want a language other than Go.
- You want crash isolation (the plugin can die without taking the daemon down).
- You want to ship and version it independently of Ze.
- You are migrating an ExaBGP process script through the bridge.
The External plugins page covers the wire protocol, the startup flow, and the practicalities of writing one in a language that is not Go. The in-tree plugin protocol guide is the canonical reference.
Whichever path you pick, the capabilities are the same.
- Receive BGP events (UPDATE, OPEN, peer state, NOTIFICATION, EOR, RPKI) as JSON.
- Provide commands callable from the CLI, the API, MCP, and other plugins.
- Encode and decode NLRI for custom address families.
- Extend the configuration tree with their own YANG schemas.
- Verify or apply config diffs at reload time. A plugin that reads config registers an apply handler (
OnConfigApplyin the Go SDK) or declares that it applies nothing (DeclareAppliesNothing). With neither, every reload that changes a section it reads is refused, naming the plugin and the restart that delivers the change. - Answer each reload with the OPEN capabilities the new config declares, which the engine installs when the reload commits.
- Inject capabilities into outgoing OPEN messages.
- Validate incoming OPEN messages.
- Emit events that other plugins consume.
- Dispatch commands through the engine to other plugins.
- Declare what a command's answer holds (one document, or rows), so the engine publishes the pipe operators it supports and refuses the rest by name.
- Answer a command with a row-by-row record sequence instead of one document, so a large walk is never held twice.
- Raise and clear problems on the daemon's report bus (
RaiseIssue,ClearIssue), each with the command that fixes it, soshow doctorreports them. - Declare doctor checks. A check that reads the plugin's live state declares
the
runtimephase and runs only inshow doctoron the daemon. Every finding setsfixto the command that clears it, alone, with nofix:label. See Health checks.
Whichever surface a plugin uses, the startup is the same five-stage handshake.
- declare-registration: the plugin tells the engine which families, commands, and schemas it provides.
- configure: the engine sends the plugin its configuration sections.
- declare-capabilities: the plugin tells the engine which BGP capabilities to inject into OPEN messages.
- share-registry: the engine shares the full command registry with the plugin.
- ready: the plugin enters its runtime event loop.
After ready, the engine can deliver-batch (BGP events) and execute-command to the plugin, and the plugin can update-route and emit-event to the engine. bye means the plugin was removed live or its subsystem stopped. A daemon stop sends no bye: the engine closes the connection and the SDK's Run returns nil.
Stage 1 also carries a protocol-version. The engine answers with the lower of its own and the plugin's, and refuses a declaration that states none. The Go SDK declares version 1. The answer also carries plugin-name, the configured instance name of the process, which can differ from the implementation's name; the Go SDK exposes it as Plugin.InstanceName() from OnConfigure on. Use it in recovery commands such as ze request plugin restart <name>.
Stage 2 carries more than config. It is the last point in the sequential handshake at which the engine can tell a plugin something that must be settled before peers start, so it also delivers the union of the exclusive role claims declared by the startup set. A decision that must not race session establishment belongs there and not in a post-startup callback.
In Go the declaration is passed by pointer: p.Run(ctx, &sdk.Registration{...}). Run copies it at entry and refuses nil. The same value feeds sdk.RunOrDeclare, which answers query mode (ZE_PLUGIN_MODE=declare) by printing the declaration without starting the plugin.
Each stage is bounded by progress rather than by a flat per-tier budget: the engine fails a stage only when the whole tier goes ze.plugin.stage.timeout (default 5s) with no plugin completing one. See Go plugins.
ze request plugin restart <name> restarts a configured plugin without restarting ze, whether it runs or not. It is the fix ze doctor names for a plugin left stopped (failure policy, respawn limit, failed restart, failed startup) and for a running plugin holding state only a new process clears. A running plugin is stopped and started again without its failure policy, the respawn limit and count are reset, and the startup handshake delivers the running configuration. The answer says plugin <name> started again or plugin <name> was running: stopped and started again.
| Refusal | When |
|---|---|
plugin <name> is not a configured plugin |
No plugin of that name was started by the config or its auto-load |
plugin <name> cannot restart itself |
The plugin sent the command for its own name; type it at the CLI |
plugin <name> was not restarted: a config transaction is in flight |
A reload or commit is running; retry once it answered |
plugin <name> was not restarted: its removal is still pending |
A reload removed it and the removal has not settled; ze request reload retries |
plugin <name> did not start again |
The restart failed; the plugin stays down under doctor-plugin-stopped
|
The restart waits at most 3 seconds for the stopped process to finish its calls into ze. When one has not returned, the restart fails with the stopped process has not finished its cleanup, and every restart or reload that would start the plugin is refused the same way until that call returns (or ze signal restart). If the old process outlives the bound anyway, ze doctor reports doctor-plugin-restart-overlap. Tab after request plugin restart offers every configured plugin, marked running or not running.
- Go plugins. Skeleton, registration, lifecycle, schema, handlers, tests.
- External plugins. Wire protocol, startup flow, writing one in another language.
- YANG schema. Authoring a schema for a plugin.
-
Handlers. The
On*callbacks the SDK gives you. - Commands. Declaring and serving commands.
-
Testing.
net.Pipetest pair, fuzz targets, functional tests.
- Plugins for the catalogue of plugins shipped in-tree.
- In-tree plugin development guide for the deeper material.
Adapted from main/docs/plugin-development/README.md.
Unreviewed draft. This wiki was authored in bulk and has not been reviewed. File corrections on the issue tracker.
- Install
- Docker
- netlab
- Appliance
- Quick Start
- Use Ze with an AI agent
- ExaBGP Migration
- CLI Tour
- Web UI Tour
- Overview
- YANG Model
- Editor Workflow
- Archive and Rollback
- Backup and Restore
- System
- Interfaces
- VRRP
- BFD
- FIB
- OSPF
- IS-IS
- MPLS / LDP / RSVP-TE
- RSVP-TE
- SRv6
- Static Routes
- Policy Routing
- Firewall
- Traffic Control
- Class of Service
- L2TP/PPP
- PPPoE
- VPP Data Plane
- RPKI
- IPsec VPN
- Path MTU
- TACACS+ AAA
- RADIUS AAA
- AS112 DNS
- DNS
- Authorization
- Fleet
- BGP
- Starting and Stopping
- Show Commands
- Monitoring
- Telemetry
- Flow Export
- DDoS Mitigation
- Anomaly Detection
- Health Checks
- Audit Trail
- Production Diagnostics
- Logging
- Operational Reports
- Healthcheck
- Self-Update
- Zero-Touch Provisioning
- MRT Analysis
- Upgrade and Restart
- Storage
- Policy
- Core
- Resilience
- Validation
- Link State
- Capabilities
- Address Families
- Protocol
- Subsystems
- Infrastructure
- Route Server at an IXP
- Transit Edge with RPKI
- Public Looking Glass
- ExaBGP Migration Walkthrough
- FlowSpec Injection
- Chaos-Tested Peering
- AS Path Topology