Documentation
¶
Index ¶
- type ACLModule
- type ACLService
- func (m *ACLService) DeleteConfig(ctx context.Context, req *aclpb.DeleteConfigRequest) (*aclpb.DeleteConfigResponse, error)
- func (m *ACLService) DrainMetricsReads()
- func (m *ACLService) GetRulesCounters(ctx context.Context, req *aclpb.GetRulesCountersRequest) (*aclpb.GetRulesCountersResponse, error)
- func (m *ACLService) ListConfigs(ctx context.Context, req *aclpb.ListConfigsRequest) (*aclpb.ListConfigsResponse, error)
- func (m *ACLService) Metrics(ctx context.Context, tags ...*commonpb.MetricTag) ([]*commonpb.Metric, error)
- func (m *ACLService) RuleMetrics(ctx context.Context, req *aclpb.GetMetricsRulesRequest) ([]*commonpb.Metric, error)
- func (m *ACLService) ShowConfig(ctx context.Context, req *aclpb.ShowConfigRequest) (*aclpb.ShowConfigResponse, error)
- func (m *ACLService) UnaryServerInterceptor() grpc.UnaryServerInterceptor
- func (m *ACLService) UpdateConfig(ctx context.Context, req *aclpb.UpdateConfigRequest) (*aclpb.UpdateConfigResponse, error)
- type Backend
- type Config
- type MetricsService
- type ModuleHandle
- type ModuleOption
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ACLModule ¶
type ACLModule struct {
// contains filtered or unexported fields
}
ACLModule is a control-plane component for ACL (Access Control List) module.
func NewACLModule ¶
func NewACLModule(cfg *Config, options ...ModuleOption) (*ACLModule, error)
NewACLModule creates a new ACL module instance.
func (*ACLModule) RegisterService ¶
func (*ACLModule) ServicesNames ¶
func (*ACLModule) UnaryServerInterceptors ¶
func (m *ACLModule) UnaryServerInterceptors() []grpc.UnaryServerInterceptor
UnaryServerInterceptors returns the gRPC unary interceptors for this module.
type ACLService ¶
type ACLService struct {
aclpb.UnimplementedACLServiceServer
// contains filtered or unexported fields
}
ACLService implements the gRPC ACL service.
func NewACLService ¶
func NewACLService(backend Backend, options ...Option) *ACLService
NewACLService creates an ACL gRPC service backed by the given Backend.
func (*ACLService) DeleteConfig ¶
func (m *ACLService) DeleteConfig( ctx context.Context, req *aclpb.DeleteConfigRequest, ) (*aclpb.DeleteConfigResponse, error)
func (*ACLService) DrainMetricsReads ¶
func (m *ACLService) DrainMetricsReads()
DrainMetricsReads blocks until every in-flight metrics collection has finished.
A collection outlives the request handlers that joined it, so the shared memory it reads may only be released after this returns.
func (*ACLService) GetRulesCounters ¶
func (m *ACLService) GetRulesCounters( ctx context.Context, req *aclpb.GetRulesCountersRequest, ) (*aclpb.GetRulesCountersResponse, error)
GetRulesCounters returns the per-rule counters of the named config, or of every config when the request names none.
The counters come from the same merged read the rule metrics scrape uses, so the two requests never read the family concurrently. Counters whose packets and bytes are both zero across all workers are omitted, matching the metrics read.
func (*ACLService) ListConfigs ¶
func (m *ACLService) ListConfigs( ctx context.Context, req *aclpb.ListConfigsRequest, ) (*aclpb.ListConfigsResponse, error)
func (*ACLService) Metrics ¶
func (m *ACLService) Metrics(ctx context.Context, tags ...*commonpb.MetricTag) ([]*commonpb.Metric, error)
Metrics returns ACL module metrics matching tags: per-pipeline packet counters, ACL compilation info, and gRPC call metrics.
Concurrent scrapes are coalesced into one shared collection of the per-position packet-counter reads, and every concurrent caller receives the same values filtered by its own tags.
Per-rule counters are served by RuleMetrics and GetRulesCounters, not here. Counter metrics are omitted when all worker values are zero to reduce output noise.
Labels:
- config: ACL config name (all counter metrics)
- device: dataplane device name (all counter metrics)
- pipeline: pipeline name (all counter metrics)
- function: pipeline function name (all counter metrics)
- chain: pipeline chain name (all counter metrics)
- 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 (*ACLService) RuleMetrics ¶
func (m *ACLService) RuleMetrics(ctx context.Context, req *aclpb.GetMetricsRulesRequest) ([]*commonpb.Metric, error)
RuleMetrics returns ACL per-rule counter metrics for the selected positions: one packets and one bytes counter for every rule counter.
One merged shared-memory read serves every selector: concurrent scrapes are coalesced into it, and selection of each caller's positions happens on its shared result.
These are the counters Metrics leaves out, read from the runtime-kind storages it never touches. An empty request field matches every value. One read serves every position, and each metric's position comes from the tags its counter group carries. Requests received over gRPC reject selector values the fixed-size counter-tag fields cannot carry. Counter metrics are omitted when all worker values are zero to reduce output noise.
Labels:
- config: ACL config name
- device: dataplane device name
- pipeline: pipeline name
- function: pipeline function name
- chain: pipeline chain name
- counter: rule counter name
func (*ACLService) ShowConfig ¶
func (m *ACLService) ShowConfig( ctx context.Context, req *aclpb.ShowConfigRequest, ) (*aclpb.ShowConfigResponse, error)
func (*ACLService) UnaryServerInterceptor ¶
func (m *ACLService) UnaryServerInterceptor() grpc.UnaryServerInterceptor
UnaryServerInterceptor returns the service's gRPC metrics interceptor, or nil when metrics are not configured.
func (*ACLService) UpdateConfig ¶
func (m *ACLService) UpdateConfig( ctx context.Context, req *aclpb.UpdateConfigRequest, ) (*aclpb.UpdateConfigResponse, error)
type Backend ¶
type Backend interface {
// NewModule allocates a new ACL module config in shared memory with
// the ruleset compiled into it and the named fwstate-map objects
// linked. The returned handle is not yet published to the dataplane.
NewModule(
name string,
rules []cacl.ACLRule,
fw4MapName, fw6MapName string,
) (ModuleHandle, error)
// UpdateModule publishes handle to dp_config_gen so the dataplane
// picks it up on the next round.
UpdateModule(handle ModuleHandle) error
// DeleteModule removes a module config from the dataplane.
DeleteModule(name string) error
// DPConfig returns the dataplane configuration handle for counter
// and position queries.
DPConfig() *ffi.DPConfig
}
Backend abstracts shared-memory operations for the ACL service.
func NewBackend ¶
NewBackend creates a Backend that operates on real shared memory.
type Config ¶
type Config struct {
ffi.AttachConfig `yaml:",inline"`
// Endpoint is the gRPC endpoint address
Endpoint xcfg.NonEmptyString `yaml:"endpoint"`
}
Config represents ACL module configuration
type MetricsService ¶
type MetricsService struct {
aclpb.UnimplementedMetricsServiceServer
// contains filtered or unexported fields
}
MetricsService exposes ACL 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 ACL module metrics matching the request's tags.
func (*MetricsService) GetMetricsRules ¶
func (m *MetricsService) GetMetricsRules(ctx context.Context, req *aclpb.GetMetricsRulesRequest) (*commonpb.GetMetricsResponse, error)
GetMetricsRules returns the per-rule counter metrics GetMetrics leaves out.
type ModuleHandle ¶
type ModuleHandle interface {
Free() error
AsFFIModule() ffi.ModuleConfig
GetInfo() *cacl.ACLConfigInfo
}
ModuleHandle is a handle to an ACL module configuration written to shared memory. The handle is fully built at construction and never updated afterwards; Free releases it.
type ModuleOption ¶
type ModuleOption func(*moduleOptions)
ModuleOption configures the ACLModule constructor.
func WithModuleLog ¶
func WithModuleLog(log *zap.Logger) ModuleOption
WithModuleLog sets the logger for the ACL module.
type Option ¶
type Option func(*options)
Option configures an ACLService.
func WithMetrics ¶
func WithMetrics(factory grpcmetrics.Factory) Option
WithMetrics sets the gRPC metrics factory.
When unset, no metrics are collected.