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

Map removal fix #340

Closed
wants to merge 9 commits into from
Closed

Conversation

Atul-source
Copy link
Contributor

Sometimes Unpinning the eBPF maps don't remove the files ( internally os.Remove not worked). In this PR I have added a condition when Unpinning doesn't remove the map file the we should Remove it.

Signed-off-by: Atul-source <[email protected]>
Signed-off-by: Atul-source <[email protected]>
Signed-off-by: Atul-source <[email protected]>
Signed-off-by: Atul-source <[email protected]>
Signed-off-by: Atul-source <[email protected]>
@Atul-source Atul-source requested a review from aka320 February 29, 2024 17:22
aka320
aka320 previously approved these changes Feb 29, 2024
Copy link
Contributor

@aka320 aka320 left a comment

Choose a reason for hiding this comment

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

LGTM

@aka320
Copy link
Contributor

aka320 commented Feb 29, 2024

@Atul-source Please validate this case.

  • What happens if l3afd gets killed or terminates abruptly ?
  • Will all the maps remain in /sys/fs/bpf folder & later when l3afd starts again, does it create duplicate maps ?

@aka320 aka320 self-requested a review February 29, 2024 17:45
@aka320
Copy link
Contributor

aka320 commented Mar 1, 2024

@Atul-source Better to handle the deletion of Map files while loading the eBPF program, instead of handling during stopping of eBPF program, so that we can guarantee that there are no duplicate Maps.

kf/bpf.go Outdated
b.Program.Name, b.Program.ProgType, ifaceName, mapFilename, err)
}
if fileExists(mapFilename) {
Copy link
Contributor

Choose a reason for hiding this comment

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

If a BPF map is shared by multiple programs, and one program unpins the map while another program is still accessing it, it can lead to unpredictable behavior. To avoid this, you can check if the reference count of the map is less than 1 using v.GetRefCount(), and then proceed to delete the file.

Copy link
Contributor Author

@Atul-source Atul-source Mar 8, 2024

Choose a reason for hiding this comment

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

Is v.GetRefCount() a library function ?

@Atul-source Atul-source deleted the map_removal_fix branch January 2, 2025 05:05
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