route

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2026 License: Apache-2.0 Imports: 22 Imported by: 2 modules, 1 package

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

Index

Constants

This section is empty.

Variables

View Source
var ErrTooManyNexthops = errors.New("too many distinct nexthops")

ErrTooManyNexthops reports a FIB that resolves to more distinct hardware nexthops than one route config can index.

Functions

This section is empty.

Types

type Backend

type Backend interface {
	// Published reads what is published under the name. The error wraps
	// ffi.ErrNotFound when no module config is published under it.
	Published(name string) (Published, error)
	// NewModule builds a module config linking the devices, without
	// publishing it. It returns the module's device table by index,
	// which may hold entries the module links on its own.
	NewModule(name string, devices []string) (ModuleHandle, []string, error)
	// NewFIB builds a table object from the supplied FIB ranges, naming
	// devices by their index in the table, without publishing it.
	NewFIB(name string, devices []string, entries []*routepb.FIBEntry) (FIBHandle, error)
	// DeleteModule removes a module config from the dataplane.
	DeleteModule(name string) error
	// DeleteFIB removes a table object from the dataplane.
	DeleteFIB(name string) error
	// DumpFIB reads the published table of the named config. The error
	// wraps ffi.ErrNotFound when the config is not published.
	DumpFIB(name string) ([]croute.FIBEntry, error)
	// ModuleCounters reads the named counters back from every position
	// at which the named config is installed.
	ModuleCounters(name string, counterNames []string) []CounterView
	// NexthopCounters reads the named per-nexthop counters, which the
	// module counts on its link to the table object, from every position
	// at which the named config is installed.
	NexthopCounters(name string, counterNames []string) []CounterView
}

Backend abstracts shared memory write-path operations for the route module.

A config is a module config and a table object published under the same name. The object names egress devices by their index in the module's device table, so the table only ever grows and a module is rebuilt only when a table needs a device it lacks.

func NewBackend

func NewBackend(agent *ffi.Agent) Backend

NewBackend creates a Backend that operates on real shared memory.

type Config

type Config struct {
	ffi.AttachConfig `yaml:",inline"`

	// Endpoint is the gRPC endpoint of the route module shim.
	Endpoint xcfg.NonEmptyString `yaml:"endpoint"`
	// DisableNexthopCounters turns off the per-nexthop dataplane counters.
	//
	// Negative polarity so the zero value keeps counters on: an operator
	// who never sets this field gets the safer, more observable default
	// without DefaultConfig needing an explicit entry for it.
	DisableNexthopCounters bool `yaml:"disable_nexthop_counters"`
}

Config is the route module shim configuration.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns a Config populated with sensible defaults.

func (*Config) Default

func (m *Config) Default()

Default resets Config to DefaultConfig.

type CounterView

type CounterView struct {
	Device   string
	Pipeline string
	Function string
	Chain    string
	Name     string
	// Values holds the counter slots per worker instance, indexed as
	// [instance][slot].
	Values [][]uint64
}

CounterView is a single dataplane counter read back from one position at which a route config is installed.

type FIBHandle added in v0.1.0

type FIBHandle interface {
	// Publish upserts the object into a new configuration generation.
	Publish() error
	// ActiveNexthopCounterNames returns the deduplicated, sorted set of
	// per-nexthop counter names reachable through the resolved FIB.
	//
	// The only realistic failure is a control-plane allocation failure.
	ActiveNexthopCounterNames() ([]string, error)
	// RouteCount returns the number of distinct hardware nexthops the
	// table resolves prefixes to.
	RouteCount() uint64
	// FIBRangeCountV4 returns the number of IPv4 FIB ranges, equivalent
	// to counting the IPv4 entries of a dump but far cheaper.
	FIBRangeCountV4() uint64
	// FIBRangeCountV6 returns the number of IPv6 FIB ranges, equivalent
	// to counting the IPv6 entries of a dump but far cheaper.
	FIBRangeCountV6() uint64
	Free() error
}

FIBHandle is a handle to a forwarding table object in shared memory, owned by the control plane until it is freed.

type HardwareRoute

type HardwareRoute = hwroute.HardwareRoute

HardwareRoute is the dataplane's Layer 2 forwarding identity.

The type lives in the leaf hwroute package so that consumers needing only the identity, such as the route operator, do not link the cgo shared-memory stack behind this package; the alias keeps this package's public API intact.

type MetricsService

type MetricsService struct {
	routepb.UnimplementedMetricsServiceServer
	// contains filtered or unexported fields
}

MetricsService exposes route module metrics over its own gRPC service.

func NewMetricsService

func NewMetricsService(source metricsSource) *MetricsService

NewMetricsService creates a MetricsService backed by source.

func (*MetricsService) GetMetrics

GetMetrics returns a snapshot of route module metrics matching the request's tags.

type ModuleHandle

type ModuleHandle interface {
	// Publish upserts the module config into a new configuration
	// generation. The table object it links must already be published.
	Publish() error
	Free() error
}

ModuleHandle is a handle to a route module configuration in shared memory, owned by the control plane until it is freed.

type Option

type Option func(*moduleOptions)

Option configures the RouteModule constructor.

func WithLog

func WithLog(log *zap.Logger) Option

WithLog sets the logger for the route module.

type Published added in v0.1.0

type Published struct {
	Devices []string
	FIB     bool
}

Published describes what the dataplane holds for a config name: the module's device table by index and whether its table object is out.

type RouteModule

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

RouteModule is the slim route-module shim that owns shared memory and exposes the routepb.RouteService gRPC surface.

The module no longer owns a RIB or a neighbour table. The yanet-route-operator agent rebuilds the FIB and pushes it via UpdateFIB.

func NewRouteModule

func NewRouteModule(cfg *Config, options ...Option) (*RouteModule, error)

NewRouteModule creates a new RouteModule.

func (*RouteModule) Close

func (m *RouteModule) Close() error

Close closes the module.

func (*RouteModule) Endpoint

func (m *RouteModule) Endpoint() string

Endpoint returns the gRPC endpoint for the route module shim.

func (*RouteModule) Name

func (m *RouteModule) Name() string

Name returns the module name.

func (*RouteModule) RegisterService

func (m *RouteModule) RegisterService(server *grpc.Server)

RegisterService registers the route module's gRPC service.

func (*RouteModule) ServicesNames

func (m *RouteModule) ServicesNames() []string

ServicesNames returns the gRPC service names exposed by the module.

func (*RouteModule) UnaryServerInterceptors

func (m *RouteModule) UnaryServerInterceptors() []grpc.UnaryServerInterceptor

UnaryServerInterceptors returns the gRPC unary interceptors for this module.

type RouteService

type RouteService struct {
	routepb.UnimplementedRouteServiceServer
	// contains filtered or unexported fields
}

RouteService is the gRPC service implementation backing the slim route-module shim.

func NewRouteService

func NewRouteService(backend Backend, options ...RouteServiceOption) *RouteService

NewRouteService builds a RouteService bound to the supplied backend.

func (*RouteService) DeleteConfig

DeleteConfig deletes a route module configuration.

func (*RouteService) ListConfigs

ListConfigs returns the names of all route module configurations currently known to the service.

func (*RouteService) Metrics

func (m *RouteService) Metrics(tags ...*commonpb.MetricTag) ([]*commonpb.Metric, error)

Metrics returns route module metrics matching tags: per-config FIB gauges, the module-level dataplane counters, the per-nexthop dataplane counters, plus gRPC call metrics.

A "counter" tag is pushed down into both dataplane counter reads, so counters excluded by tags are never read from shared memory.

Labels:

  • config: route config name (all gauge and counter metrics)
  • family: address family, "v4", "v6", or "unknown" when the ethertype was not IP (route_fib_entries, route_forwarded_*, route_drop_*)
  • device: dataplane device name (all dataplane counter metrics)
  • pipeline: pipeline name (all dataplane counter metrics)
  • function: pipeline function name (all dataplane counter metrics)
  • chain: pipeline chain name (all dataplane counter metrics)
  • reason: drop cause (route_drop_packets / route_drop_bytes only)
  • counter: per-nexthop counter name (route_nexthop_packets / route_nexthop_bytes only)
  • grpc_type: always "unary" (gRPC metrics)
  • grpc_service: fully-qualified gRPC service name (gRPC metrics)
  • grpc_method: RPC name (gRPC metrics)
  • grpc_code: gRPC status code string (grpc_server_handled_total only)

func (*RouteService) ReclaimDeferred

func (m *RouteService) ReclaimDeferred()

ReclaimDeferred retries every retired config whose free was refused, dropping the ones whose generations have drained. The store runs it after each successful mutation, and anything else may call it at any time.

func (*RouteService) ShowFIB

ShowFIB returns the FIB entries currently applied in shared memory for the requested configuration.

The read pins the configuration generation it walks and takes no lock of this service, so it neither waits for an update nor delays one.

func (*RouteService) UnaryServerInterceptor

func (m *RouteService) UnaryServerInterceptor() grpc.UnaryServerInterceptor

UnaryServerInterceptor returns the service's gRPC metrics interceptor, or nil when metrics are not configured.

func (*RouteService) UpdateFIB

UpdateFIB applies a freshly-built FIB to the dataplane atomically.

type RouteServiceOption

type RouteServiceOption func(*routeServiceOptions)

RouteServiceOption configures the RouteService constructor.

func WithMetrics

func WithMetrics(factory grpcmetrics.Factory) RouteServiceOption

WithMetrics sets the gRPC metrics factory.

When unset, no metrics are collected.

func WithNexthopCountersDisabled

func WithNexthopCountersDisabled() RouteServiceOption

WithNexthopCountersDisabled turns off per-nexthop dataplane counters.

UpdateFIB then rejects any nexthop that carries an explicit counter name, and never materializes one for a nexthop that left it empty.

Directories

Path Synopsis
Package hwroute holds the route module's Layer 2 forwarding identity.
Package hwroute holds the route module's Layer 2 forwarding identity.
routepb
v1

Jump to

Keyboard shortcuts

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