Skip to content
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

added GetBPFmapInfo method to support PIN_NONE where pinpath does not… #96

Merged
merged 1 commit into from
Nov 5, 2024

Conversation

nithu0115
Copy link
Contributor

… exist

Issue #, if available: We use containers to create probes. While loading our elf file we found that we cannot create map under /sys/fs/bpf directory as it is set to read only. When we tried to set PIN_NONE, we found that code path is still looking at pinPath reading in mapLoad run time exception. This change helps to load maps with create an pinPath -

{“level”:“info”,“ts”:“2024-11-04T19:32:13.617Z”,“caller”:“elfparser/elf.go:197",“msg”:“Create map done with fd : 8"}
{“level”:“error”,“ts”:“2024-11-04T18:56:09.733Z”,“caller”:“maps/loader.go:219",“msg”:“error creating directory /sys/fs/bpf/globals/aws/maps: mkdir /sys/fs/bpf/globals: no such file or directory”}

Description of changes: This change helps to load maps with create an pinPath when PINNING is set PIN_NONE

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

if err != nil {
return nil, fmt.Errorf("map '%s' doesn't exist", mapNameStr)
if loadedMaps.PinOptions.Type == constdef.PIN_NONE.Index() {
mapInfo, err := (e.bpfMapApi).GetBPFmapInfo(bpfMap.MapFD)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally we can just use FD for both scenarios. But using pin path will get additional validation. It is fine for now and we can later optimize this..

@@ -668,3 +671,87 @@ func TestProgType(t *testing.T) {
})
}
}

func TestLoadMap(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this :)

Copy link
Contributor

@jayanthvn jayanthvn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@jayanthvn jayanthvn merged commit 135349f into aws:main Nov 5, 2024
2 checks passed
jayanthvn added a commit that referenced this pull request Nov 5, 2024
* Use default error formating instead of wrap when errors.Wrap isn't implemented.

Use default error formatting when the error wrap isn't available.

The error message that was seen was

```{"level":"error","ts":"2024-06-30T10:52:42.597Z","caller":"ebpf/bpf_client.go:563","msg":"failed to find device by name eni3d4ff16416b: %!w(netlink.LinkNotFoundError={0xc0007ae7c0})"}
```

* Fixup update flow (#88)

* Bump golang.org/x/sys from 0.20.0 to 0.24.0 (#89)

Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.20.0 to 0.24.0.
- [Commits](golang/sys@v0.20.0...v0.24.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sys
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* fix test on rel-branch

* Log the return error no from syscall

* Fix PR checks

Fix PR checks

* fix go dependencies.

* fix go.sum dependencies.

* Bump github.com/vishvananda/netlink from 1.1.0 to 1.3.0

Bumps [github.com/vishvananda/netlink](https://github.com/vishvananda/netlink) from 1.1.0 to 1.3.0.
- [Release notes](https://github.com/vishvananda/netlink/releases)
- [Commits](vishvananda/netlink@v1.1.0...v1.3.0)

---
updated-dependencies:
- dependency-name: github.com/vishvananda/netlink
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Updated go.mod dependencies.

* Bump golang.org/x/sys from 0.24.0 to 0.26.0

Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.24.0 to 0.26.0.
- [Commits](golang/sys@v0.24.0...v0.26.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sys
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* updated go mod and go sum.

* added GetBPFmapInfo method to support PIN_NONE where pinpath does not exist (#96)

Co-authored-by: Nithish Kumar Murcherla <nithmu@amazon.com>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Senthil Kumaran <senthilx@amazon.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Jay Deokar <jsdeokar@amazon.com>
Co-authored-by: Yash Thakkar <ythakkar97@gmail.com>
Co-authored-by: Senthil Kumaran <orsenthil@gmail.com>
Co-authored-by: Nithish Murcherla <murcherla.kumar@gmail.com>
Co-authored-by: Nithish Kumar Murcherla <nithmu@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants