controlplane

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: Apache-2.0 Imports: 36 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

	// BestSetSize is the fixed bounded set of PCBs selected for forwarding and
	// termination (no policy engine, no per-policy configuration).
	BestSetSize = 5

	// 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, originating ISD-AS, and segment ID, keeping the latest origination per key, expiring entries with their hops. A restarted node is rebuilt by the next period's beacons.

func NewBeaconStore

func NewBeaconStore() *BeaconStore

func (*BeaconStore) BestSet

func (s *BeaconStore) BestSet(n int) []Candidate

BestSet returns the fixed bounded set of freshest unexpired candidates — the store's per-key freshness ordering is the only selection rule (no policy engine).

func (*BeaconStore) Insert

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

Insert stores the beacon, replacing the entry with the same key — one origin's re-origination of one segment over one ingress — when the new origination is fresher, and keeping per-interface capacity bounded by evicting the stalest candidates. The origin is the beacon's first entry, the identity reception verified against the TRC's core list.

func (*BeaconStore) Len

func (s *BeaconStore) Len() int

Len returns the number of stored candidates.

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 with the TRC naming the cores whose interfaces are pruned, 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 ISD-AS a bootstrap beacon originated — the freshest origin first, alternating across calls, so the destination a node that has not pinned the TRC aims its core route at reaches every origin the beacons name: one origin's fresher beacons cannot starve another's route, and the issuer's is the one a retrying enrollment completes against. Once the TRC is pinned, only the origins it names issuers take turns, as in the core route's other branches: a core without a root certificate serves no renewal and hosts no voting application, and a joining core whose onboarding submission lands there stops. Zero when no origin qualifies. Beacons originate only at cores.

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 refreshes the slots it holds with each verified one, so their routes name the interfaces the link's two ends use now, and opens none: the cores BootstrapCore alternates over stay the ones the node heard before its pin.

func (*Beaconer) HandleRegistration

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

HandleRegistration verifies a down segment registered with this core and stores it in the path database (Sections 3.1.3 and 3.3).

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 snapshots the external links, interface ID to neighbor IA; the
	// beaconer reads it fresh each pass, so a node may start with zero
	// links. It is the store's snapshot alone: the neighbor's identity and
	// the destination its beacons are addressed with both come from it.
	Links func() map[uint16]addr.IA
	// Verdicts returns the health monitor's link verdicts by interface ID;
	// a down interface originates and propagates nothing, resuming with the
	// verdict's up edge. Nil treats every link as up.
	Verdicts func() map[uint16]bool
	// Latencies holds the node's latest per-link one-way delay samples; the
	// entries the beaconer signs declare them. Nil declares nothing.
	Latencies *LinkLatency
	// 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 Candidate

type Candidate struct {
	// Ingress is the interface the beacon arrived on: the node's parent
	// side of that link.
	Ingress uint16
	// PCB is the candidate beacon.
	PCB *segment.PCB
}

Candidate is a stored beacon with the interface it arrived on.

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 LinkLatency

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

LinkLatency is the node's latest per-link one-way delay samples: the selection loop's echo round trips halved, keyed by interface ID. The beaconer's entries declare them — the StaticInfoExtension the drafts define — so a sample one evaluation window measures rides the next beacons out, each AS attesting its own links alone. A link without a fresh sample declares nothing: recording zero drops the declaration, and a link that regains a sample declares again at the next entry the beacons carry.

func NewLinkLatency

func NewLinkLatency() *LinkLatency

NewLinkLatency returns an empty sample table.

func (*LinkLatency) Record

func (l *LinkLatency) Record(ifID uint16, oneWay time.Duration)

Record records the interface's one-way delay estimate; zero drops the interface's sample.

func (*LinkLatency) Sample

func (l *LinkLatency) Sample(ifID uint16) time.Duration

Sample returns the interface's latest one-way delay estimate; zero when the last window measured none.

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 core's control service with expiry-aware caching, source wildcards expanded per Table 4 — and the core handler (Section 4.2.3), which serves from the local database.

func NewLookupService

func NewLookupService(cfg LookupConfig) *LookupService

NewLookupService returns a lookup service with an empty cache.

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, fetching and caching them from the core's control service as needed; the path provider composes them.

func (*LookupService) Segments

Segments serves a segment request (draft Section 5).

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. 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) 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) 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
}

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.

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.
	DB trustdb.DB
	// Issuer signs certificate chains. It is nil on every node but the
	// founding core, the ISD's sole issuer.
	Issuer *trust.Issuer
	// Authorizer gates first issuance: it is asked exactly when possession is
	// verified and no chain exists for the name, never on a same-key renewal. The
	// same seam answers host registration on the coordination application. Nil is
	// open admission — the zero-conf default.
	Authorizer enrollauth.AdmissionAuthorizer
	// 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 check is the name-taken one.

func (*TrustService) ChainRenewal

ChainRenewal issues a certificate chain for the CSR carried by the request. First-issuance requests ride a CMS wrapper signed by the CSR's subject key itself — proof of possession of that key (PKI draft, Section 4.3) — since a fresh node has no certificate chain yet. The signed wrapper the reference implementation verifies against the requester's existing chain is honored for renewals only, which do not exist in this milestone.

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