-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cilium/ebpf now has a CollectionSpec.RewriteMaps() API that we can use to rewrite maps instead of patching instructions ourselves. This originally attempted to workaround an upstream issue with cilium/ebpf that meant Hook.Patch() didn't work well with CollectionSpec.LoadAndAssign(). cilium/ebpf@04b5c2a fixes this, but keep the extra test to ensure it works. For posterity's sake, the original description of the issue: The "classic" cilium/ebpf way of doing things is to get a CollectionSpec, and use NewCollection() to create all the maps and load the programs into the kernel. The user can then retrieve the maps and programs of interest from the Collection. xdpcap.Patch() works well with this API: - if it's called, the program instructions are rewritten to use the hook map, and the map is removed from the spec to prevent NewCollection() from creating another one. - if it isn't called, NewCollection() creates an empy hook map. cilium/ebpf also supports a new API, CollectionSpec.LoadAndAssign() that allows programs and maps to be loaded into the kernel and assigned to a struct in one call. To avoid GC related issues I don't full understand, it requires that ProgramArray maps are either: - rewritten before LoadAndAssign(), so the caller already has a reference to them. - stored in the LoadAndAssign() struct if they're created by LoadAndAssign(), so the caller also has a reference to them. If xdpcap.Patch() isn't called, this breaks as users typically wouldn't store the hook map in the LoadAndAssign() struct as they have no use for it.
- Loading branch information
1 parent
854fe6e
commit 17bf89d
Showing
4 changed files
with
54 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.