-
Notifications
You must be signed in to change notification settings - Fork 279
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
sys: bpf_prog_get_fd_by_id returns OwnedFd #688
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 |
---|---|---|
|
@@ -69,7 +69,7 @@ use libc::ENOSPC; | |
use std::{ | ||
ffi::CString, | ||
io, | ||
os::unix::io::{AsRawFd, RawFd}, | ||
os::fd::{AsRawFd, IntoRawFd as _, RawFd}, | ||
path::{Path, PathBuf}, | ||
}; | ||
use thiserror::Error; | ||
|
@@ -955,7 +955,7 @@ impl ProgramInfo { | |
call: "bpf_prog_get_fd_by_id", | ||
io_error, | ||
})?; | ||
Ok(fd as RawFd) | ||
Ok(fd.into_raw_fd()) | ||
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. Here is another place that this PR probably broke things. The
I think this would be a quick fix though, we just gotta make this function return an 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. Derp nvm, I thought we were calling for |
||
} | ||
|
||
/// Loads a program from a pinned path in bpffs. | ||
|
@@ -1003,14 +1003,12 @@ impl Iterator for ProgramsIter { | |
io_error, | ||
}) | ||
.and_then(|fd| { | ||
let info = bpf_prog_get_info_by_fd(fd) | ||
bpf_prog_get_info_by_fd(fd.as_raw_fd()) | ||
.map_err(|io_error| ProgramError::SyscallError { | ||
call: "bpf_prog_get_info_by_fd", | ||
io_error, | ||
}) | ||
.map(ProgramInfo); | ||
unsafe { libc::close(fd) }; | ||
info | ||
.map(ProgramInfo) | ||
}), | ||
) | ||
} | ||
|
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.
@tamird
I know this is already merged but the
OwnedFd
is dropped here since there are no other usages ofOwnedFd
and thus the file descriptor is closed and yet we are creating aLircLink
with this closed file descriptor.LircLink
has a methodinfo
that uses this file descriptor to get its program information but that file descriptor is now closed. I don't really use lirc probes so I am not how how to test/prove that but I figured it's worth calling out that this PR most likely broke getting the program information from a queried list of lirc programs.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.
Derp nvm, I thought we were calling for
as_raw_fd
. Ignore