Skip to content

Allow callers to create VariableSpecs#1882

Merged
ti-mo merged 2 commits intocilium:mainfrom
lmb:variable-spec-public
Dec 1, 2025
Merged

Allow callers to create VariableSpecs#1882
ti-mo merged 2 commits intocilium:mainfrom
lmb:variable-spec-public

Conversation

@lmb
Copy link
Copy Markdown
Contributor

@lmb lmb commented Oct 22, 2025

See the commit messages for details.

Fixes: #1868

@github-actions github-actions bot added the breaking-change Changes exported API label Oct 22, 2025
@lmb lmb force-pushed the variable-spec-public branch from 5791c45 to 79f1b65 Compare October 22, 2025 14:55
@lmb lmb marked this pull request as ready for review October 22, 2025 15:02
@lmb lmb requested a review from a team as a code owner October 22, 2025 15:02
@lmb
Copy link
Copy Markdown
Contributor Author

lmb commented Oct 31, 2025

@ti-mo can you give this a review please?

@lmb lmb requested a review from ti-mo October 31, 2025 13:54
Copy link
Copy Markdown
Contributor

@ti-mo ti-mo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I have some doubts around the caller having to manage .Value before using .Set and .Get, PTAL.

@lmb lmb force-pushed the variable-spec-public branch from 24dc2e3 to 081c036 Compare November 10, 2025 10:06
@lmb lmb requested a review from ti-mo November 10, 2025 10:07
@lmb lmb force-pushed the variable-spec-public branch from 081c036 to 582b855 Compare November 10, 2025 10:38
@ti-mo ti-mo force-pushed the variable-spec-public branch from 582b855 to d75f93b Compare November 27, 2025 15:54
@ti-mo ti-mo marked this pull request as draft November 27, 2025 15:54
@ti-mo
Copy link
Copy Markdown
Contributor

ti-mo commented Nov 27, 2025

@lmb Please check my feedback commit and squash if okay. We need Size() and Constant() in Cilium, len(vs.Value) is annoying to use, and it's pretty nice if we can fall back to BTF in case it's not initialized yet.

@lmb lmb force-pushed the variable-spec-public branch from d75f93b to ad3a9e9 Compare November 27, 2025 16:27
@lmb lmb marked this pull request as ready for review November 27, 2025 16:27
lmb and others added 2 commits December 1, 2025 15:22
VariableSpec is the only component of CollectionSpec with unexported
fields. This makes it awkward to use during testing outside of package
ebpf.

Fix this by exporting and documenting the fields of variable spec.
To achieve this, VariableSpec.Set doesn't immediately copy data into
MapSpec.Contents. Instead VariableSpec.Value holds the marshaled data.

The collection loader ensures that VariableSpec.Value is copied into
MapSpec.Contents before loading. A nice side-effect is that this ends
up creating a lot less copies of MapSpec.Contents.

MapSpec uses uint32 to specify public sizes like ValueSize. This is
because the kernel interfaces only allow specifying 32 bit quantities.
Change the public API of VariableSpec and Variable to match this.

Fixes: cilium#1868

Signed-off-by: Lorenz Bauer <lmb@isovalent.com>
Co-authored-by: Timo Beckers <timo@isovalent.com>
MapSpec.dataSection() currently enforces the presence of BTF, even though the
downstream code doesn't explicitly rely on it. Remove this restriction.

Signed-off-by: Lorenz Bauer <lmb@isovalent.com>
@ti-mo ti-mo force-pushed the variable-spec-public branch from ad3a9e9 to 51d805c Compare December 1, 2025 14:23
Copy link
Copy Markdown
Contributor

@ti-mo ti-mo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! ❤️

@ti-mo ti-mo merged commit 3d4ca80 into cilium:main Dec 1, 2025
16 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking-change Changes exported API

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow callers to create VariableSpecs

2 participants