controlplane

package
v0.0.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 42 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package controlplane implements the node core's control service: beaconing and the drafts' services — segment creation, registration, and lookup, trust material and chain renewal — with the server that composes the services and the peer client that calls its peers', every protocol the core speaks the drafts' own. Both ride the SCION-native channel of pkg/libs/scionrpc, which carries the drafts' RPC over SCION paths and answers their service resolution, as it does any application's.

Index

Constants

View Source
const (
	// PropagationInterval is the beaconing period: the draft's intra-ISD
	// floor of five seconds (Section 2.3.4).
	PropagationInterval = 5 * time.Second

	// RegistrationInterval is the registration period (Section 3.1), on the
	// order of a minute.
	RegistrationInterval = time.Minute

	// SendTimeout bounds each beacon and registration RPC, and with it how
	// long a peer that went dark holds its slot.
	SendTimeout = 5 * time.Second
)
View Source
const EnrollmentMinInterval = time.Second

EnrollmentMinInterval is the chain-renewal door's rate cap: the least pause between admissions of one source — the rendezvous acceptor's own cap the shape.

Variables

This section is empty.

Functions

This section is empty.

Types

type BeaconStore

type BeaconStore struct {
	// contains filtered or unexported fields
}

BeaconStore holds candidate PCBs in memory (draft Section 2.3.2): keyed by ingress interface and route, keeping each route's latest origination and when it arrived, expiring entries with their hops. A restarted node is rebuilt by the next period's beacons.

func NewBeaconStore

func NewBeaconStore() *BeaconStore

func (*BeaconStore) Insert

func (s *BeaconStore) Insert(ingress uint16, pcb *segment.PCB)

Insert stores the beacon, replacing the entry with the same key — a re-origination of one route over one ingress — when the new origination is fresher, recording when it arrived, and keeping per-interface capacity bounded by evicting the stalest candidates.

func (*BeaconStore) Len

func (s *BeaconStore) Len() int

Len returns the number of stored candidates.

func (*BeaconStore) Qualifying added in v0.0.10

func (s *BeaconStore) Qualifying(
	window time.Duration, keep func(beaconing.Candidate) bool) []beaconing.Candidate

Qualifying returns the unexpired candidates keep admits whose latest origination arrived within the window, in no particular order. keep runs under the store's lock.

type Beaconer

type Beaconer struct {
	// contains filtered or unexported fields
}

Beaconer runs beacon exploration: the core tiers — founding and authoritative alike — originate signed path-segment beacons on their links and terminate core beacons into core segments, every node verifies the accumulated signatures against the TRC before storing or propagating them, propagation floods outward — pruning the interfaces toward the cores the TRC names and toward the neighbors a beacon already crosses — and non-cores terminate accepted beacons into registered segments. Link roles are not configured: the interface a beacon arrives on is the node's parent side, the interfaces beacons are propagated to are child sides, and a link whose neighbor the TRC names as a core is a core link.

func NewBeaconer

func NewBeaconer(cfg BeaconerConfig) (*Beaconer, error)

NewBeaconer returns a beaconer with the defaults filled in.

func (*Beaconer) BootstrapCore

func (b *Beaconer) BootstrapCore() addr.IA

BootstrapCore returns the origin of the freshest bootstrap beacon, the core a node that has not pinned the TRC aims its founder route at: a node not enrolled receives the founder's beacons alone, so the origin is the founder unless a neighbor broke that rule, which the founder's WebPKI identity then exposes. Zero when the node holds none. Beacons originate only at cores.

func (*Beaconer) BootstrapNeighbor added in v0.0.10

func (b *Beaconer) BootstrapNeighbor(origin addr.IA) addr.IA

BootstrapNeighbor returns the neighbor that sent the freshest bootstrap beacon of the origin — the beacon's last AS entry — and zero when the node holds none of it.

func (*Beaconer) BootstrapRoute

func (b *Beaconer) BootstrapRoute(dst addr.IA) *spath.Decoded

BootstrapRoute returns the reversed data-plane path of the freshest beacon originating at dst, extended with the node's own unsigned hop — the route of a node that has not verified any up segment to that core: a fresh node's enrollment fetch and the trust fetches around it ride it, all protected by the WebPKI-authenticated channel, and a core tier, which stores no up segments, keeps riding it to its neighboring cores. It is never stored, propagated, or registered, serves only its originating core, and verified up segments take over the moment one exists. A beacon whose arrival interface the link table no longer holds serves none: the data plane carries no such interface, and a beacon over the link's new interface takes over once one arrives.

func (*Beaconer) HandleBeacon

func (b *Beaconer) HandleBeacon(
	ctx context.Context,
	pcb *segment.PCB,
	ingress uint16,
) error

HandleBeacon applies the reception checks of Section 2.3.1 to the received PCB and stores it as a candidate. A node that has not pinned the TRC cannot verify beacons; it records the freshest one as its bootstrap route for the enrollment fetch instead. A pinned node verifies with material its sender holds — the neighbor at the arrival interface, which verified the same entries before it propagated them — whatever routes the node holds to the core. It refreshes the slots it holds with each verified beacon, so their routes name the interfaces the link's two ends use now. A core opens a slot for every core it hears, whatever its pin: the slot is its only route to a core it links to. A non-core opens none after its pin: its slots stay the origins it heard before, the founder's alone when its neighbors sent it the founder's beacons alone.

func (*Beaconer) HandleRegistration

func (b *Beaconer) HandleRegistration(
	ctx context.Context,
	pb *control_plane.PathSegment,
	server net.Addr,
) error

HandleRegistration verifies a down segment registered with this core and stores it in the path database (Sections 3.1.3 and 3.3). Missing trust material is asked of server, the registrant's control service, before the provider's own source: the registrant holds every chain its segment references, whichever core issued them.

func (*Beaconer) Run

func (b *Beaconer) Run(ctx context.Context)

Run executes the beaconing loops until the context is canceled: propagation on every tier, origination and core-beacon termination on the core tiers, down-segment registration on the others, and the expired- segment sweep of the path database. It returns once every loop has exited and every RPC a pass started has returned, so a caller that waits for Run closes no store beneath an in-flight pass.

type BeaconerConfig

type BeaconerConfig struct {
	// IA is the local ISD-AS.
	IA addr.IA
	// Engine signs AS entries and verifies received ones.
	Engine *trust.Engine
	// MACKey is the data-plane forwarding key, MACing created hop fields
	// with the same algorithm the processor verifies.
	MACKey []byte
	// Store is the in-memory beacon store for candidates.
	Store *BeaconStore
	// DB is the persistent path database for registered segments.
	DB pathdb.DB
	// Links is the node's link state topic, read fresh each pass, so a node
	// may start with zero links. Its table alone names each neighbor's
	// identity and the destination its beacons are addressed with; a down
	// interface originates and propagates nothing, resuming with the
	// verdict's up edge. A nil topic serves no links.
	Links *bus.Topic[bus.LinkState]
	// Latencies is the node's link latency topic, whose last event's
	// estimates the entries the beaconer signs declare. A nil topic declares
	// nothing.
	Latencies *bus.Topic[bus.LinkLatencies]
	// Policy chooses, among the routes each receiver can take, those its
	// beacons carry.
	Policy beaconing.Policy
	// Sender sends beacon and registration RPCs over the SCION-native
	// channel.
	Sender SegmentSender
	// Core marks the core tiers — the founding and the authoritative —
	// which originate beacons beside propagating them and terminate core
	// beacons into core segments.
	Core bool
	// PropagationInterval and RegistrationInterval override the defaults;
	// zero keeps them.
	PropagationInterval  time.Duration
	RegistrationInterval time.Duration
}

BeaconerConfig configures a Beaconer.

type Client

Client implements the Interface by making RPC calls to a remote server: the drafts' services alone, the Link and Directory clients the topology application owns living beside their services.

func NewClient

func NewClient(clt connect.HTTPClient, baseURL string, opts ...connect.ClientOption) *Client

NewClient creates a new control plane client.

type LookupConfig

type LookupConfig struct {
	// IA is the local ISD-AS.
	IA addr.IA
	// DB is the local path database.
	DB pathdb.DB
	// IsCore selects the core handler's behavior: the core tiers — founding
	// and authoritative alike — serve from the local database.
	IsCore bool
	// Cores enumerates the core ASes of an ISD named by the pinned TRC; nil
	// cores mean the TRC is not pinned.
	Cores func(isd addr.ISD) []addr.IA
	// Fetch requests segments from a core's control service; the peer names
	// the core the question is addressed to, and the source of the question
	// is that core.
	Fetch func(ctx context.Context, peer *scion.Addr, src, dst addr.IA) (*cppb.SegmentsResponse, error)
}

LookupConfig configures a LookupService.

type LookupService

type LookupService struct {
	// contains filtered or unexported fields
}

LookupService implements the draft's segment-request handlers: the source- AS handler of a non-core (Section 4.2.2) — up segments from the local path database, core and down segments fetched from the cores' control services, source wildcards expanded per Table 4 — and the core handler (Section 4.2.3), which serves from the local database. The source handler keeps each core's last answer to a question and serves it at once, refreshing it behind the lookup; a core asked a refresh it fails to answer is set aside on the node's retry schedule while its last answer keeps serving.

func NewLookupService

func NewLookupService(cfg LookupConfig) *LookupService

NewLookupService returns a lookup service holding no answers.

func (*LookupService) DBGet

func (s *LookupService) DBGet(q pathdb.Query) []*pathdb.Segment

DBGet reads the local database. A read failure logs and answers empty: the read also serves dial paths, where a store closed under a write in flight is the shutdown racing the send, not corruption.

func (*LookupService) Down

func (s *LookupService) Down(ctx context.Context, dst addr.IA) []*pathdb.Segment

Down returns the down segments serving dst, each core's answer as ask serves it, in the cores' order; the path provider composes them. A non-core asks nothing for a core destination: down segments end at the non-core ASes that register them, and the core's handler answers a core destination with core segments alone, so the fetch would come back empty — never held, asked again at every call.

func (*LookupService) Segments

Segments serves a segment request (draft Section 5).

type Membership added in v0.0.10

type Membership interface {
	// Admit decides a chain the TRC verified: nil admits it, an error
	// refuses it.
	Admit(ctx context.Context, facts membership.Facts) error
	// Issued takes a chain the node issued.
	Issued(ctx context.Context, chain []*x509.Certificate) error
}

Membership is the membership module's seam the trust service calls.

type PeerClient

type PeerClient struct {
	// contains filtered or unexported fields
}

PeerClient is the SCION-native channel's RPC client: ConnectRPC over HTTP/3 (QUIC) riding SCION paths, peers authenticated by AS certificate chains verified against the pinned TRC. The peer address carries either a neighbor — sent over a one-hop path — or a SCION path supplied by the provider. Beacons ride a client-authenticated channel whose server certificate is not verified: their receivers may not be enrolled yet, and the PCB's signatures authenticate the path authoritatively anyway. The channel records instead whether each receiver presented a chain, the receivers' enrollment the beaconer reads. Registrations and lookups verify the peer's chain against the pinned TRC.

func NewPeerClient

func NewPeerClient(cfg scionrpc.PeerClientConfig) *PeerClient

NewPeerClient creates the client for the SCION-native channel.

func (*PeerClient) Beacon

func (c *PeerClient) Beacon(ctx context.Context, peer *scion.Addr, pcb *cppb.PathSegment) error

Beacon propagates the extended PCB to the peer's beacon service (draft Section 2.3.5.1).

func (*PeerClient) Close

func (c *PeerClient) Close() error

Close releases the underlying QUIC transport.

func (*PeerClient) Enrolled added in v0.0.10

func (c *PeerClient) Enrolled(peer addr.IA) bool

Enrolled reports whether the peer's latest handshake on the beacon channel presented a chain the pinned TRC anchors; a peer the channel never dialed has not enrolled.

func (*PeerClient) Fetcher added in v0.0.10

func (c *PeerClient) Fetcher(server net.Addr) trust.Fetcher

Fetcher returns the trust fetcher that asks server — a node's control service, named by its ISD-AS as a service destination — for TRCs and chains over the one-hop channel (Section 2.4): a neighbor reached over the link a beacon arrived on, whatever routes the node holds beyond it, or a registrant reached over the path its address carries, the reverse of the one its registration arrived on.

func (*PeerClient) Issuers added in v0.0.10

func (c *PeerClient) Issuers(routes func() []*scion.Addr) trust.Remote

Issuers returns the trust remote that asks the issuers the routes list — the cores whose root the TRC carries — over the mutually verified channel: TRCs, chains, and chain renewals, each asked of the issuer whose turn it is. A call that fails moves the remote's next call to the next issuer the routes list, so a renewal retried moves on from an issuer that does not answer.

func (*PeerClient) OneHopClient added in v0.0.4

func (c *PeerClient) OneHopClient() *http.Client

OneHopClient returns the HTTP client of the mutually verified channel's one-hop side: the confirm's dial, whose requests ride the direct link of the entry they confirm.

func (*PeerClient) Probe added in v0.0.10

func (c *PeerClient) Probe(ctx context.Context, peer *scion.Addr) error

Probe sends the peer's control service a request no service answers over the beacon channel: a dial when no connection to the peer serves, which records whether its receiver enrolled, and a connection that serves the next beacon. A receiver that obtained a chain since the connection's handshake refuses the request and the channel dials anew.

func (*PeerClient) RegisterSegments

func (c *PeerClient) RegisterSegments(
	ctx context.Context,
	peer *scion.Addr,
	segments []*cppb.PathSegment,
) error

RegisterSegments registers down segments with the core's control service (Sections 3.1.3 and 3.3).

func (*PeerClient) Segments

func (c *PeerClient) Segments(
	ctx context.Context,
	peer *scion.Addr,
	src, dst addr.IA,
) (*cppb.SegmentsResponse, error)

Segments requests path segments from the peer's control service (Section 5.2).

func (*PeerClient) VerifiedClient

func (c *PeerClient) VerifiedClient() *http.Client

VerifiedClient returns the HTTP client of the mutually verified channel — the one registrations and lookups ride, peers authenticated by their chains against the pinned TRC — for an application's own services beside the drafts': the client machinery consumed as a library, sharing this client's transport and connection pool.

type SegmentSender

type SegmentSender interface {
	// Beacon propagates the extended PCB to the peer's beacon service.
	Beacon(ctx context.Context, peer *scion.Addr, pcb *control_plane.PathSegment) error
	// RegisterSegments registers down segments with the core's control
	// service.
	RegisterSegments(ctx context.Context, peer *scion.Addr,
		segments []*control_plane.PathSegment) error
	// Enrolled reports whether the peer's latest handshake on the beacon
	// channel presented a chain the pinned TRC anchors.
	Enrolled(peer addr.IA) bool
	// Probe reaches the peer's control service over the beacon channel,
	// so that the peer's enrollment is recorded whether or not a beacon
	// goes to it.
	Probe(ctx context.Context, peer *scion.Addr) error
}

SegmentSender sends beacon and registration RPCs over the SCION-native channel; PeerClient satisfies it.

type SegmentService

type SegmentService struct {
	// Beaconer receives and verifies beacons and registrations.
	Beaconer *Beaconer
	// Lookup serves segment requests.
	Lookup *LookupService
}

SegmentService implements the segment RPCs of the control endpoint: beacon reception on SegmentCreationService, down-segment registration on SegmentRegistrationService, and the source-AS segment-request handler on SegmentLookupService.

func (*SegmentService) Beacon

Beacon receives a propagated PCB (draft Section 2.3.5.1), applying the reception checks of Section 2.3.1 before anything is stored. Beacons terminate on each node's control service, so every node serves this RPC.

func (*SegmentService) Segments

Segments serves a segment request (Section 5).

func (*SegmentService) SegmentsRegistration

SegmentsRegistration receives down segments registered by a non-core (Sections 3.1.3 and 3.3); the receiving core verifies each registered segment as on beacon reception, asking the registrant for the trust material it lacks.

type Server

type Server struct {
	Handler http.Handler
}

Server implements the control plane server.

func NewServer

func NewServer(svc ControlPlane) *Server

NewServer creates a new control plane server.

type Services

type Services struct {
	*TrustService
	*SegmentService
	// Mounts are the application mounts the endpoint serves.
	Mounts []scionrpc.Mount
}

Services composes the trust and segment services into one ControlPlane; the segment service's methods take precedence over the trust service's unimplemented embeds. Mounts are the handlers a loaded application — the topology provider and the voting application among them — serves behind the peer-authenticating middleware, mounted beside the drafts' services; empty when none loads.

type TrustService

type TrustService struct {
	control_planeconnect.UnimplementedSegmentCreationServiceHandler
	control_planeconnect.UnimplementedSegmentRegistrationServiceHandler
	control_planeconnect.UnimplementedSegmentLookupServiceHandler

	// DB serves trust material from the local trust database, and holds the
	// founding core's bindings of names to keys.
	DB trustdb.DB
	// Issuer signs certificate chains: a core's, nil on a normal node. An
	// authoritative core's issues once its root lands in the TRC.
	Issuer *trust.Issuer
	// Enrolls marks the founding core's service, the one that serves first
	// issuance; every other issuer renews on the requester's chain alone.
	Enrolls bool
	// Authorizer gates first issuance: it is asked exactly when possession is
	// verified and the name is bound to no key, never on a renewal or a bound
	// holder's re-enrollment. The same seam answers host registration on the
	// coordination application. Nil is open admission — the zero-conf default.
	Authorizer enrollauth.AdmissionAuthorizer
	// Membership admits the chain a renewal rests on, and takes every chain
	// the service issues.
	Membership Membership
	// MinInterval is the least pause between admissions of one source at the
	// renewal door; zero uses the default.
	MinInterval time.Duration
	// contains filtered or unexported fields
}

TrustService implements the trust material and chain renewal RPCs of the control endpoint. The segment service RPCs it embeds unimplemented come from SegmentService, which takes precedence in the Services composition. Admission is the provider's alone: enrollment is reachable only over paths, paths exist only over established links, and the loaded provider admits every link — the acceptor's policy is where the decision lives, and this service's own checks are the name's binding to its key at first issuance and the membership at a renewal.

func (*TrustService) ChainRenewal

ChainRenewal issues a certificate chain for the CSR carried by the request. A request whose CMS wrapper carries the requester's chain is a renewal: the chain's key signed it (PKI draft, Section 4.3), and any issuer serves it. One signed by the CSR's subject key itself — proof of possession, for a fresh node has no chain yet — is a first issuance, which the founding core alone serves. An issuer whose root no pinned TRC carries yet answers Unavailable.

func (*TrustService) Chains

Chains serves the certificate chains matching the request.

func (*TrustService) TRC

TRC serves a signed TRC. A request without base and serial numbers asks for the latest TRC of the ISD, which in a base-TRC-only milestone is the base TRC.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL