Skip to content

Commit

Permalink
map: suggest incorrect MaxEntries on EINVAL
Browse files Browse the repository at this point in the history
If a map creation fails and the max entries provided by the spec is
zero, it's likely that it's because of that zero value.
Help the user by suggesting that MaxEntries may be incorrectly set to
zero.

Signed-off-by: Mark Pashmfouroush <mark@isovalent.com>
  • Loading branch information
markpash authored and lmb committed Jun 4, 2022
1 parent 6294837 commit 77edeba
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions map.go
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,9 @@ func (spec *MapSpec) createMap(inner *sys.FD, opts MapOptions, handles *handleCa
if !spec.hasBTF() {
return nil, fmt.Errorf("map create without BTF: %w", err)
}
if errors.Is(err, unix.EINVAL) && attr.MaxEntries == 0 {
return nil, fmt.Errorf("map create: %w (MaxEntries may be incorrectly set to zero)", err)
}
return nil, fmt.Errorf("map create: %w", err)
}
defer closeOnError(fd)
Expand Down

0 comments on commit 77edeba

Please sign in to comment.