-
Notifications
You must be signed in to change notification settings - Fork 651
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
map: detect map Name and PinPath separately #414
Conversation
Hi @hao-lee, I think this is not a safe default: If we want to tackle this in the library we need to come up with a safer default. Maybe it's possible to derive a subdirectory using |
Hello,
I think maybe it's the responsibility of the eBPF program developer to make sure the map's name is unique.
This is indeed a solution if we want to avoid conflicts as soon as possible, although If the developer doesn't configure the map's PinPath attribute in the Go code, the program will fail to load because of the missing PinPath. I think this behavior is too mandatory, especially for some beginners who only want to fire up a runnable eBPF program as simple as possible. 😅 |
From my experience this unfortunately doesn't happen.
Will beginners start by pinning maps? Maybe we can improve the error message? |
Agree. The error message confused me. |
@lmb Hello, I have updated the commit. The current implementation separates error detections. This should be more reasonable than setting default path. |
map.go
Outdated
} | ||
|
||
if opts.PinPath == "" { | ||
return nil, fmt.Errorf("pin by name: missing PinPath") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe MapOptions.PinPath
?
Detecting map Name and PinPath separately to make the error message more clear. Signed-off-by: Hao Lee <haolee@didiglobal.com>
libbpf uses
/sys/fs/bpf
as the default pinpath if the user doesn't specifyone. We'd better keep consistent with it.
Signed-off-by: Hao Lee haolee@didiglobal.com