Contribution rules and Make targets are in CONTRIBUTING.md.
See pkg.go.dev for the public Go API.
This is the multi-page printable view of this section. Click here to print.
Contribution rules and Make targets are in CONTRIBUTING.md.
See pkg.go.dev for the public Go API.
| Package | Role |
|---|---|
cmd/polad | The daemon: loads configuration and starts the PCEP listener, gRPC server, and GoBGP monitor. |
cmd/pola | The CLI client of the gRPC API. |
api/pola/v1 | Protocol Buffers definitions and generated code for PCEService. |
pkg/server | PCEP listener, one session per peer address, and the PCEService implementation. |
pkg/packet/pcep | PCEP message, object, and TLV encoding and decoding. See PCEP Library. |
pkg/table | TED, SR Policy and segment models, SID validation, and underlay planes. |
pkg/cspf | Shortest-path computation over the TED. |
pkg/logger | Structured logging. |
internal/gobgp | Reads BGP-LS from GoBGP and converts it into TED elements. |
internal/config | Parses and validates polad.yaml. |
pola CLI / gRPC clients
|
v
+-- PCInitiate / PCUpd ----------------- APIServer
| ^
v |
PCC <--PCEP--> Session (one per peer) | reads current TED
^ |
| reads current TED |
| |
+---------------------------------------- Server (holds current TED)
^
syncTEDLoop replaces the current TED with a new LsTED
|
GoBGP --(ListPath, triggered by watch)--> internal/gobgp --> []TEDElem
Session. A duplicate connection from the same peer address is rejected with PCErr 9/1.LsTED rather than modifying the existing one. Sessions read the current TED and its readiness on each use. See TED and CSPF.github.com/nttcom/pola/pkg/packet/pcep is a Go library for encoding and decoding PCEP messages.
It has no third-party dependencies. The PCInitiate and PCUpd constructors use Pola’s table.SRPolicy type (pkg/table).
The API reference is available on pkg.go.dev.
| File | Contents |
|---|---|
message.go | Common header, PCEP messages (Open, Keepalive, PCErr, Close, PCRpt, PCInitiate, PCUpd), and their constructors. |
object.go | Objects (OPEN, SRP, LSP, ERO, ASSOCIATION, VENDOR-INFORMATION, and others), timer helpers, and PCC type detection. |
tlv.go | TLVs, including typed capability TLVs and unknown TLVs. |
tlv_common.go | Length, padding, and address helpers. |
pcep_util.go | Byte-slice and bit-manipulation helpers. |
capability.go | CapabilityInterface, the capabilities Pola advertises (DefaultCapabilities), capability negotiation helpers, and FlattenCapabilities. |
vendor.go | Enterprise numbers (Cisco, Huawei, Juniper) and their names. |
reference.go | The Reference type that maps code points to their RFC or draft. |
DeterminePccType identifies legacy Cisco (0x14) and Juniper (0xffe1) peers from ASSOC-TYPE-LIST. Juniper takes precedence if both are present in the same TLV; all other cases are classified as standard (RFCCompliant).NewPCInitiateMessage selects color and preference encoding based on VendorSpecific (PCC type) and SRPolicyAssociation (whether the SR Policy Association was negotiated). pkg/server sets these options as described in What Pola sends.DefaultCapabilities.The session logic is implemented in negotiateOpen and the message loop in pkg/server/session.go; tests are in pkg/server/session_internal_test.go.
Operator-facing settings are in PCEP Sessions.
RFC 5440 Appendix A does not list an Open event in KeepWait, although section 6.2 allows a peer to resend its Open after a PCErr 1/4. Following the state table literally could therefore terminate a valid negotiation. Pola instead tracks two conditions and derives the state name from them:
RemoteOK: the peer’s Open has been accepted.LocalOK: the peer has acknowledged Pola’s current Open with a Keepalive.| RemoteOK | LocalOK | Peer Open rejected | State |
|---|---|---|---|
| true | true | - | Up |
| true | false | - | KeepWait |
| false | false | yes | KeepWait |
| false | false | no | OpenWait |
| false | true | - | OpenWait |
During establishment, the derived state determines the initialization timer (1 minute) and the error sent on expiry (PCErr 1/2 in OpenWait or 1/7 in KeepWait).
minKeepalive to maxKeepalive:allowNegotiation, Pola sends PCErr 1/4 with an OPEN object proposing acceptable values: the peer’s Session-ID, the Keepalive clamped into the range, and a DeadTimer of four times that (0 if that cannot exceed the Keepalive).RemoteOK and starts Keepalives, the first sent immediately.RemoteOK is set, another Open is answered with PCErr 1/1 and ends the attempt; the accepted parameters are kept.LocalOK. Pola responds with PCErr 1/6 if the proposal is unacceptable, contains no OPEN object, or is the second PCErr 1/4 received during establishment.Session establishment failures are logged at debug level with the failure reason.
The advertised values and the Keepalive interval are described in PCEP Sessions.
effectiveKeepalive computes the interval. If the advertised Keepalive is 0, Pola sends no Keepalives, regardless of the peer’s DeadTimer (RFC 5440 section 7.3).User-facing behavior is described in Traffic Engineering Database and Dynamic Paths.
table.LsTED (pkg/table/ted.go) stores LsNode values keyed by IGP router ID.
Each node contains prefixes and Prefix-SIDs, the SRGB, links, SRv6 SIDs, SR-Algorithm information, and advertised FADs.
LsLink. Separate NLRIs create separate links unless their keys match, in which case the later NLRI replaces the earlier one without merging attributes.pkg/table/plane.go), defined by an address family, a data plane, and an IGP algorithm. IPv4/SR-MPLS, IPv6/SR-MPLS, and IPv6/SRv6 are valid; IPv4/SRv6 is not. Algorithm 0 is the default SPF algorithm; 128-255 select a Flexible Algorithm (RFC 9350); 1-127 are rejected.LsTED.FlexAlgoDefinition(algo) returns the winning FAD for an algorithm across the TED. The election rule is in FAD election.internal/gobgp connects to GoBGP over plaintext gRPC.
ListPath retrieves the global BGP-LS table and converts it into TEDElem values (nodes, links, prefixes, and SRv6 SIDs).ListPath is performed.Server.syncTEDLoop (pkg/server/server.go) builds a new LsTED from each snapshot and replaces the server’s pointer.
An existing LsTED is never mutated.
ted.asn are dropped. A link is dropped if either endpoint belongs to another AS.FlexAlgoDefinition.Unsupported records why a FAD cannot be used.cspf.Compute (pkg/cspf/cspf.go) is the single entry point.
A request specifies the source and destination router IDs, plane, metric, and optional loose waypoints; the function runs Dijkstra and returns one node SID per hop.
min-delay value of 0 is treated as missing.Flex-Algo (RFC 9350) uses a computation profile that determines the metric, node eligibility, and link eligibility from the request’s plane and the winning FAD.
ResolveMetricType rejects the winning FAD when FlexAlgoDefinition.Unsupported is set. See FAD parsing and validation.LsLink.FlexAlgoAttributes. A link that lacks the required metric or has a malformed ASLA (LsLink.ASLAMalformed) is pruned rather than causing a computation error (RFC 9350 §13).LsLink.FlexAlgoMetric reads the IGP metric from the top-level attribute and TE and min-delay from FlexAlgoAttributes. The selection rules are in Link attributes.GoBGP’s API omits unknown FAD sub-TLVs and the FAD Unsupported sub-TLV. internal/gobgp/fad.go therefore parses FAD TLVs (1039) from the raw BGP-LS attribute (PattrsBinary) when converting a Node NLRI, and sets FlexAlgoDefinition.Unsupported for the conditions listed in Flexible Algorithm.
IS-IS may split a FAD across LSPs, requiring Exclude-SRLG union and LSP-order-dependent field selection (RFC 9350 §6). OSPF uses the first applicable FAD (§5.2). BGP-LS carries the originating protocol (Node NLRI Protocol-ID, RFC 9552 §5.2) but not the LSP order. Pola marks an algorithm unsupported when a node advertises multiple FAD TLVs for it.
GoBGP v4 does not decode ASLA (TLV 1122), so internal/gobgp requests raw path attributes (EnableAttributeBinary) and parses the BGP-LS attribute in asla.go.
Malformed ASLA marks the link without failing the snapshot.
A delay or min-delay with the A bit set (RFC 8571 §2.1–§2.2) is stored as not advertised.
ASLA selection is implemented in pkg/table/linkattr.go; the rules are in Link attributes.
NewPCE initializes an empty LsTED that is not ready; with TED disabled, the TED is nil.tedElemsChan message contains a complete snapshot. applyTEDSnapshot replaces the TED, marks it ready, and reports whether this is the first snapshot. An empty first snapshot also marks it ready.Session uses a tedSource (Server.tedState) that returns the TED and readiness under one lock. Each computation reads both once. Session.ted is used only when no source is set.handleSRPolicyWithPLSPID handles a report in this order:pendingRecompute. For each PLSP-ID, pendingRecompute keeps one report: the one with the greatest LSPObject.LSPID (distinct from the PLSP-ID), or the latest report when those LSP-IDs are equal.syncTEDLoop calls recomputeSessions. Each session runs recomputePending in its own goroutine, preventing a slow peer from blocking others. Deferred reports are reprocessed in PLSP-ID order by handleSRPolicyWithPLSPID.reportMu serializes PCRpt handling with recomputePending, so each report is either computed against a ready TED or deferred for recomputation, whichever takes the lock first.DeleteSRPolicy drops the deferred report for that PLSP-ID.s.pce.TED() without waiting for TED readiness.Later snapshots do not trigger recomputation; see the limitation in Dynamic Paths.
The contribution workflow and Make targets are documented in CONTRIBUTING.md.
Add unit tests to cover all reachable lines, and run make test-examples for the separate examples module.
make test-coverage-diff checks changed-line coverage against DIFF_BASE and fails below DIFF_COVER_MIN (default 90%). CI enforces the same threshold on pull requests.
make ci runs the local checks. CI runs these checks except make check-proto, and also runs the following CI-only checks:
make test-racemake vulnThe documentation build runs for changes under docs/.
Scenario tests run polad built from the source tree against emulated routers in Containerlab. Their topologies are under test/scenario/, separate from but similar to the example labs.
Run them with make test-scenario. make test-scenario-parallel runs four workers; tests that share a topology run on the same worker.
They require Docker, Containerlab, uv, and images for XRd and vJunos. Pola does not distribute these images. Setup and options are documented in test/README.md.
Edit api/pola/v1/pola.proto, run make proto, and verify that make check-proto passes. CI does not run this check.
Update the gRPC API and pola references in the same pull request.
This site documents the develop branch, not the latest release.
It is built with Hugo and Docsy from docs/ and published at /pola/ on GitHub Pages.
make docs-setup # check tools, then npm ci
make docs-serve # preview at http://localhost:1313/
make docs-build # production build with the /pola/ base path, then the link check
| Section | Audience and content |
|---|---|
User Guide (docs/user/) | Operators: installation, provisioning, operation, and troubleshooting. |
Reference (docs/reference/) | Lookup material: CLI commands, configuration, gRPC API, and supported standards. |
Developer Guide (docs/developer/) | Contributors and library users: internals, tests, and documentation. |
About (docs/about/) | Presentations, license, and credits. |
Keep each topic in one canonical source; other pages and READMEs link to it instead of repeating it.
| Topic | Canonical source |
|---|---|
| Example labs | examples/containerlab/*/README.md |
| Go gRPC client examples | examples/grpc/go/README.md |
| Scenario tests | test/README.md |
| Contribution rules, Make targets, image builds | CONTRIBUTING.md |
| Site dependencies and publishing | docs/README.md |
| Protocol Buffers API | api/pola/v1/pola.proto |
| Go API reference | pkg.go.dev |
docs/content/en/. The front matter title is the page heading; start body headings at ##.ref shortcode and an absolute content path, such as {{< ref "/docs/user/dynamic-paths" >}}. A broken ref fails the build.repo-url, adding "tree" for directories. Do not hard-code branch URLs; repo-url uses github_branch in hugo.yaml.static-url for files under docs/static/. The docs/schemas/ directory is mounted at schemas/; for example, {{< static-url "schemas/server/polad_config.json" >}}./docs/...; they lose the /pola/ base path. npm run check:links reports them.Update the documentation in the same pull request as behavior changes, including fixes to documented limitations.