Skip to content

Allow callers to create VariableSpecs #1868

@ti-mo

Description

@ti-mo

For testing purposes, it would be really convenient if the caller could instantiate their own VariableSpecs. Cilium currently uses something like this:

var _ VariableSpec = (*ebpf.VariableSpec)(nil)

type VariableSpec interface {
	MapName() string
	Offset() uint64
	Size() uint64
	Get(out any) error
	Constant() bool
}

This requires converting ebpf.VariableSpecs to our Cilium-internal VariableSpec since that's what our internal functions take to allow tests to provide their own.

This issue is for adding a NewVariableSpec or similar with some sanity checks to allow users to create their own. As long as the accesses performed by the VariableSpec are valid, I guess this isn't something we should really prevent. Pay attention to CollectionSpec/VariableSpec.Copy() behaviour.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions