Documentation
¶
Index ¶
- type Backend
- type Config
- type CounterView
- type HardwareRoute
- type MetricsService
- type ModuleHandle
- type Option
- type RouteModule
- type RouteService
- func (m *RouteService) DeleteConfig(ctx context.Context, req *routepb.DeleteConfigRequest) (*routepb.DeleteConfigResponse, error)
- func (m *RouteService) ListConfigs(ctx context.Context, req *routepb.ListConfigsRequest) (*routepb.ListConfigsResponse, error)
- func (m *RouteService) Metrics(tags ...*commonpb.MetricTag) ([]*commonpb.Metric, error)
- func (m *RouteService) ReclaimDeferred()
- func (m *RouteService) ShowFIB(ctx context.Context, req *routepb.ShowFIBRequest) (*routepb.ShowFIBResponse, error)
- func (m *RouteService) UnaryServerInterceptor() grpc.UnaryServerInterceptor
- func (m *RouteService) UpdateFIB(ctx context.Context, req *routepb.UpdateFIBRequest) (*routepb.UpdateFIBResponse, error)
- type RouteServiceOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend interface {
// UpdateModule builds a fresh ModuleConfig from the supplied FIB
// ranges and publishes it to the dataplane atomically.
UpdateModule(name string, entries []*routepb.FIBEntry) (ModuleHandle, error)
// DeleteModule removes a module config from the dataplane.
DeleteModule(name string) error
// ModuleCounters reads the named counters back from every position
// at which the named config is installed.
ModuleCounters(name string, counterNames []string) []CounterView
// RuntimeModuleCounters reads the named runtime counters (the
// config's per-nexthop registry) from every position at which the
// named config is installed.
RuntimeModuleCounters(name string, counterNames []string) []CounterView
}
Backend abstracts shared memory write-path operations for the route module.
func NewBackend ¶
NewBackend creates a Backend that operates on real shared memory.
type Config ¶
type Config struct {
// InstanceID specifies which dataplane instance this module serves.
//
// Required: a listed module must set it explicitly, even to 0.
InstanceID xcfg.Required[uint32] `yaml:"instance_id"`
// MemoryPath is the path to the shared-memory file that is used to
// communicate with dataplane.
MemoryPath xcfg.NonEmptyString `yaml:"memory_path"`
// MemoryRequirements is the amount of memory that is required for a
// single transaction.
MemoryRequirements xcfg.NonZero[datasize.ByteSize] `yaml:"memory_requirements"`
// 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.
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 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 ¶
func (m *MetricsService) GetMetrics(ctx context.Context, req *commonpb.GetMetricsRequest) (*commonpb.GetMetricsResponse, error)
GetMetrics returns a snapshot of route module metrics matching the request's tags.
type ModuleHandle ¶
type ModuleHandle interface {
DumpFIB() ([]croute.FIBEntry, 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
// config resolves prefixes to.
RouteCount() uint64
// FIBRangeCountV4 returns the number of IPv4 FIB ranges, equivalent
// to counting the IPv4 entries of DumpFIB but far cheaper.
FIBRangeCountV4() uint64
// FIBRangeCountV6 returns the number of IPv6 FIB ranges, equivalent
// to counting the IPv6 entries of DumpFIB but far cheaper.
FIBRangeCountV6() uint64
Free() error
}
ModuleHandle is a handle to a route module configuration in shared memory.
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) Endpoint ¶
func (m *RouteModule) Endpoint() string
Endpoint returns the gRPC endpoint for the route module shim.
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 ¶
func (m *RouteService) DeleteConfig( ctx context.Context, req *routepb.DeleteConfigRequest, ) (*routepb.DeleteConfigResponse, error)
DeleteConfig deletes a route module configuration.
func (*RouteService) ListConfigs ¶
func (m *RouteService) ListConfigs( ctx context.Context, req *routepb.ListConfigsRequest, ) (*routepb.ListConfigsResponse, error)
ListConfigs returns the names of all route module configurations currently known to the service.
func (*RouteService) Metrics ¶
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 deferred handle, dropping the ones whose generations have drained and keeping the rest deferred. It is the reclamation handler for this module's superseded configs; the service itself runs it after each successful publish, and anything else may call it at any time.
func (*RouteService) ShowFIB ¶
func (m *RouteService) ShowFIB( ctx context.Context, req *routepb.ShowFIBRequest, ) (*routepb.ShowFIBResponse, error)
ShowFIB returns the FIB entries currently applied in shared memory for the requested configuration.
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 ¶
func (m *RouteService) UpdateFIB( ctx context.Context, req *routepb.UpdateFIBRequest, ) (*routepb.UpdateFIBResponse, error)
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.