Skip to content

dpgen,datapath: generate Go types for BPF maps and variables#44755

Merged
ti-mo merged 9 commits intocilium:mainfrom
ti-mo:tb/dpgen-struct
Mar 19, 2026
Merged

dpgen,datapath: generate Go types for BPF maps and variables#44755
ti-mo merged 9 commits intocilium:mainfrom
ti-mo:tb/dpgen-struct

Conversation

@ti-mo
Copy link
Copy Markdown
Contributor

@ti-mo ti-mo commented Mar 12, 2026

Best reviewed per commit, but at a high level:

  • Bump ebpf-go to the new v0.21 release
  • Use union v4addr to represent ipv4 addresses everywhere in BPF code
  • Some internal dpgen code cleanups
  • Generate Go types for all BPF C types used as CONFIG() variables and keys/values of pinned maps
  • Use generated Go types for compound types in config structs in pkg/datapath/config
Use Go code generation for providing datapath types to the agent

@maintainer-s-little-helper maintainer-s-little-helper bot added the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label Mar 12, 2026
@ti-mo ti-mo added the release-note/misc This PR makes changes that have no direct user impact. label Mar 12, 2026
@maintainer-s-little-helper maintainer-s-little-helper bot removed the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label Mar 12, 2026
@ti-mo
Copy link
Copy Markdown
Contributor Author

ti-mo commented Mar 12, 2026

/test

1 similar comment
@cilium-ariane
Copy link
Copy Markdown

cilium-ariane bot commented Mar 12, 2026

/test

@ti-mo ti-mo force-pushed the tb/dpgen-struct branch from d699bc8 to c657de5 Compare March 13, 2026 08:21
@ti-mo
Copy link
Copy Markdown
Contributor Author

ti-mo commented Mar 13, 2026

/test

1 similar comment
@cilium-ariane
Copy link
Copy Markdown

cilium-ariane bot commented Mar 13, 2026

/test

@ti-mo ti-mo force-pushed the tb/dpgen-struct branch from c657de5 to b276e42 Compare March 14, 2026 00:51
@ti-mo
Copy link
Copy Markdown
Contributor Author

ti-mo commented Mar 14, 2026

/test

@ti-mo ti-mo force-pushed the tb/dpgen-struct branch from b276e42 to d0a9317 Compare March 14, 2026 01:04
@cilium-ariane
Copy link
Copy Markdown

cilium-ariane bot commented Mar 14, 2026

/test

@ti-mo ti-mo force-pushed the tb/dpgen-struct branch from d0a9317 to 8bb3de0 Compare March 16, 2026 21:22
@ti-mo
Copy link
Copy Markdown
Contributor Author

ti-mo commented Mar 16, 2026

/test

@ti-mo ti-mo force-pushed the tb/dpgen-struct branch from 8bb3de0 to 21b0296 Compare March 16, 2026 21:46
@ti-mo
Copy link
Copy Markdown
Contributor Author

ti-mo commented Mar 16, 2026

/test

1 similar comment
@cilium-ariane
Copy link
Copy Markdown

cilium-ariane bot commented Mar 16, 2026

/test

@ti-mo ti-mo marked this pull request as ready for review March 16, 2026 23:10
@ti-mo ti-mo requested review from a team as code owners March 16, 2026 23:10
@ti-mo ti-mo force-pushed the tb/dpgen-struct branch from 21b0296 to 3597d0b Compare March 17, 2026 09:52
@ti-mo
Copy link
Copy Markdown
Contributor Author

ti-mo commented Mar 17, 2026

/test

1 similar comment
@cilium-ariane
Copy link
Copy Markdown

cilium-ariane bot commented Mar 17, 2026

/test

@ti-mo ti-mo requested a review from tklauser March 17, 2026 16:36
Copy link
Copy Markdown
Member

@HadrienPatte HadrienPatte left a comment

Choose a reason for hiding this comment

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

vendor LGTM

Copy link
Copy Markdown
Member

@tklauser tklauser left a comment

Choose a reason for hiding this comment

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

Thanks, nice work! Looks good for my code owners and I briefly looked through the core changes too. My review comment has been addressed.

ti-mo added 9 commits March 18, 2026 20:08
Signed-off-by: Timo Beckers <timo@isovalent.com>
Signed-off-by: Timo Beckers <timo@isovalent.com>
For parsing v4addr into a Go type that can be assigned to with a byte slice,
the byte array needs to be the first member in the union. bpf2go picks the first
member since Go doesn't have unions. Otherwise, v4addr would become `struct
{ be32 uint32; }`, which is not very convenient nor sound in Go.

Also make sure structs embedding a v4/v6 union get zero-initialized correctly,
since having implicit padding means uninitialized memory can get passed to map
lookups which may upset the verifier.

Signed-off-by: Timo Beckers <timo@isovalent.com>
Signed-off-by: Timo Beckers <timo@isovalent.com>
…kage

dpgen imports these. If there's a bug that causes pkg/datapath/config to not
build, dpgen can't be run anymore. Turns out it's not a great idea to manage
a package you import. Move the constants to a separate package to prevent
this chicken-egg problem.

Signed-off-by: Timo Beckers <timo@isovalent.com>
If an incompatible map error occurs due to a partial rebuild or a subtle bug
with build permutations, it can be difficult to figure out where the problem
lies exactly. By dumping successful files along with the name of the incoming
map and object, this becomes much easier to troubleshoot.

```
Error: "bpf_host.o" contains map "cilium_calls" incompatible with one or more
BPF objects [bpf_alignchecker.o]: max entries mismatch: 49 != 50
```

Signed-off-by: Timo Beckers <timo@isovalent.com>
… keys

We'll need this for variables in a follow-up commit.

Signed-off-by: Timo Beckers <timo@isovalent.com>
Signed-off-by: Timo Beckers <timo@isovalent.com>
Signed-off-by: Timo Beckers <timo@isovalent.com>
@ti-mo ti-mo force-pushed the tb/dpgen-struct branch from 3597d0b to 756c9f6 Compare March 18, 2026 19:11
@ti-mo
Copy link
Copy Markdown
Contributor Author

ti-mo commented Mar 18, 2026

/test

1 similar comment
@cilium-ariane
Copy link
Copy Markdown

cilium-ariane bot commented Mar 18, 2026

/test

@ti-mo ti-mo enabled auto-merge March 19, 2026 15:02
Copy link
Copy Markdown
Contributor

@rgo3 rgo3 left a comment

Choose a reason for hiding this comment

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

ACK for ipsec changes.

@ti-mo ti-mo added this pull request to the merge queue Mar 19, 2026
Merged via the queue into cilium:main with commit 6285048 Mar 19, 2026
80 of 87 checks passed
@ti-mo ti-mo deleted the tb/dpgen-struct branch March 19, 2026 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-note/misc This PR makes changes that have no direct user impact.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants