-
Notifications
You must be signed in to change notification settings - Fork 730
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
improve error handling for einval with lpm trie. #1720
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -556,7 +556,12 @@ func handleMapCreateError(attr sys.MapCreateAttr, spec *MapSpec, err error) erro | |
if errors.Is(err, unix.EINVAL) && spec.Type == UnspecifiedMap { | ||
return fmt.Errorf("map create: cannot use type %s", UnspecifiedMap) | ||
} | ||
if errors.Is(err, unix.EINVAL) && spec.Flags&sys.BPF_F_NO_PREALLOC > 0 { | ||
// LPM trie key size must be a multiple of 8 and not exceed 2048. | ||
// Ref: https://docs.kernel.org/bpf/map_lpm_trie.html#bpf-map-type-lpm-trie | ||
if errors.Is(err, unix.EINVAL) && spec.Type == LPMTrie && (spec.KeySize%8 != 0 || spec.KeySize > 2048) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is becoming a bit too specific for me. The goal is not to be exhaustive, and the wording here has always been soft on purpose. Could you drop this change? The actual problem is a false-positive on the error message. I suggest adding the the following to types.go:
I'd check the kernel sources for all currently-known cases and make this function return true for LPM, cgroup storage and others that require NO_PREALLOC to be set. |
||
return fmt.Errorf("map create: LPMTrie: invalid key size %d (LPM trie key size must be a multiple of 8 and not exceed 2048)", LPMTrie) | ||
} | ||
if errors.Is(err, unix.EINVAL) && spec.Flags&sys.BPF_F_NO_PREALLOC > 0 && spec.Type != LPMTrie { | ||
return fmt.Errorf("map create: %w (noPrealloc flag may be incompatible with map type %s)", err, spec.Type) | ||
} | ||
|
||
|
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.
This seems incorrect according to my experience and the doc
https://docs.ebpf.io/linux/map-type/BPF_MAP_TYPE_LPM_TRIE/
.