-
Notifications
You must be signed in to change notification settings - Fork 721
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LoadAndAssign
fails after RewriteMaps
#517
Comments
I can see why you'd like behaviour like this, but it's hard to make RewriteMaps work the way you want it to. We'd need a new API as pointed out by timo #515 (comment) FWIW, you can just set |
I ended up doing exactly that. My only reason to prefer a RewriteMaps like approach is that I don't have to pin the map if it's not already pinned. (If I'm creating the map or if I already have a reference to it). I'm fine with always using the pinning, but I think |
Hmm. Why does pinning / no pinning change dynamically for you? I don't fully understand the use case, sorry.
You shouldn't have to if you don't care about persisting the state. You're saying you want to persist without pinning? |
I have a golang application that creates and pins a given BPF map. I'm developing an extension to that application that loads an eBPF program that should use that map, so I have two options: (1) pass the map directly as a golang pointer (*ebpf.Map) and use
I meant, these two issues are not hard blockers for me as I found a workaround using the pinning. |
Makes sense, thanks for the context. |
LoadAndAssign
fails when RewriteMaps
and bpf2go are used LoadAndAssign
fails after RewriteMaps
@mauriciovasquezbernal The changes merged in #567 should address this issue as well as #515. To my best understanding, the root cause is the same: the lifetime of Closing this for now, but please do relay your feedback here if you get the time. Thanks for the help! |
Note: looking at your reproducer, that one still fails due to an unsupported interaction between As documented on RewriteMaps, it removes any maps it rewrites from the CollectionSpec to defend against accidentally creating new instances of them, as they won't end up being actually used by the programs. I see two options:
|
I'm wondering what the reason not to change it. I think it's straightforward to avoid creating a new map in
I'll stick to this solution for now. |
Hi @mauriciovasquezbernal , I just met this problem and I figured out that it is due to the misuse of the object type. The object you used here has a type of However, the To fix it, don't use var objs fooPrograms
if err := spec.LoadAndAssign(&objs, nil); err != nil {
log.Fatalf("loading objects: %v", err)
} The downside is that we have to load maps manually one by one to eliminate the pinned one which we have loaded before. |
@mauriciovasquezbernal Your suggestion would of course be the straightforward way to fix it, though adding a
I would consider the MapOptions idea after all. @lmb WDYT? |
I'm investigating this again because it turns out that in systemd < v238 bpffs is not mounted by default, hence passing a pinned map doesn't work. Having a way to replace a map and using
I did a quick try at inspektor-gadget@f46bf3e and it works fine, if you agree I could open a PR with that change. |
I just did a refresh of why Regarding inspektor-gadget@f46bf3e: it's on the right track, but I think Note that this solution would never pin a rewritten map, since we completely bypass that logic in newMapWithOptions. Probably ok. Given this we could consider deprecating |
I don't agree with this change. I think the fields in In my view, the best location for replacing a map with another is at loading time. All the ingredients are well prepared and can be used by the loader directly to replace FDs in BPF instructions. |
I think having this field on CollectionOptions (as suggested by @lmb above) would solve this issue.
|
Add a new way to replace references to specific maps when creating a new collection by introducing a ReplaceMaps field to the CollectionOptions struct. The goal of this functionality is the same provided by RewriteMaps(), but this new approach plays nicely with bpf2go as cilium#517 is fixed.
Add a new way to replace references to specific maps when creating a new collection by introducing a ReplaceMaps field to the CollectionOptions struct. The goal of this functionality is the same provided by RewriteMaps(), but this new approach plays nicely with bpf2go as cilium#517 is fixed. Signed-off-by: Mauricio Vásquez <[email protected]>
Add a new way to replace references to specific maps when creating a new collection by introducing a ReplaceMaps field to the CollectionOptions struct. The goal of this functionality is the same provided by RewriteMaps(), but this new approach plays nicely with bpf2go as cilium#517 is fixed. Signed-off-by: Mauricio Vásquez <[email protected]>
Add a new way to replace references to specific maps when creating a new collection by introducing a MapReplacements field to the CollectionOptions struct. The goal of this functionality is the same provided by RewriteMaps(), but this new approach plays nicely with bpf2go as cilium#517 is fixed. Signed-off-by: Mauricio Vásquez <[email protected]>
Add a new way to replace references to specific maps when creating a new collection by introducing a MapReplacements field to the CollectionOptions struct. The goal of this functionality is the same provided by RewriteMaps(), but this new approach plays nicely with bpf2go as cilium#517 is fixed. Signed-off-by: Mauricio Vásquez <[email protected]>
Add a new way to replace references to specific maps when creating a new collection by introducing a MapReplacements field to the CollectionOptions struct. The goal of this functionality is the same provided by RewriteMaps(), but this new approach plays nicely with bpf2go as cilium#517 is fixed. Signed-off-by: Mauricio Vásquez <[email protected]>
Add a new way to replace references to specific maps when creating a new collection by introducing a MapReplacements field to the CollectionOptions struct. The goal of this functionality is the same provided by RewriteMaps(), but this new approach plays nicely with bpf2go as #517 is fixed. Signed-off-by: Mauricio Vásquez <[email protected]>
Describe the bug
LoadAndAssign
fails whenRewriteMaps
and bpf2go are used with amissing map
error.To Reproduce
There is a reproducer available at https://github.com/mauriciovasquezbernal/ebpfissue/tree/1bfab92fea1c988c032d6b5715fdfee9ed80c1ce
Expected behavior
The object should load fine and IMO the rewritten map should be assigned to
fooMaps.MountNsSet
Note: I added a call to
runtime.KeepAlive
to avoid hitting #515.The text was updated successfully, but these errors were encountered: