aya: Rename from_pinned and from_path to from_pin

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
pull/391/head
Dave Tucker 2 years ago
parent de6fa98963
commit 5693fb9941

@ -303,7 +303,7 @@ impl Map {
}
/// Loads a map from a pinned path in bpffs.
pub fn from_pinned<P: AsRef<Path>>(path: P) -> Result<Map, MapError> {
pub fn from_pin<P: AsRef<Path>>(path: P) -> Result<Map, MapError> {
let path_string =
CString::new(path.as_ref().to_string_lossy().into_owned()).map_err(|e| {
MapError::PinError {
@ -334,7 +334,7 @@ impl Map {
/// Loads a map from a [`RawFd`].
///
/// If loading from a BPF Filesystem (bpffs) you should use [`Map::from_pinned`].
/// If loading from a BPF Filesystem (bpffs) you should use [`Map::from_pin`].
/// This API is intended for cases where you have received a valid BPF FD from some other means.
/// For example, you received an FD over Unix Domain Socket.
pub fn from_fd(fd: RawFd) -> Result<Map, MapError> {

@ -188,7 +188,7 @@ impl PinnedLink {
}
/// Creates a [`PinnedLink`] from a valid path on bpffs.
pub fn from_path<P: AsRef<Path>>(path: P) -> Result<Self, LinkError> {
pub fn from_pin<P: AsRef<Path>>(path: P) -> Result<Self, LinkError> {
let path_string = CString::new(path.as_ref().to_string_lossy().to_string()).unwrap();
let fd =
bpf_get_object(&path_string).map_err(|(code, io_error)| LinkError::SyscallError {

@ -818,7 +818,7 @@ impl ProgramInfo {
}
/// Loads a program from a pinned path in bpffs.
pub fn from_pinned<P: AsRef<Path>>(path: P) -> Result<ProgramInfo, ProgramError> {
pub fn from_pin<P: AsRef<Path>>(path: P) -> Result<ProgramInfo, ProgramError> {
let path_string = CString::new(path.as_ref().to_str().unwrap()).unwrap();
let fd =
bpf_get_object(&path_string).map_err(|(_, io_error)| ProgramError::SyscallError {

@ -155,7 +155,7 @@ fn pin_lifecycle() -> anyhow::Result<()> {
let prog: &mut Xdp = bpf.program_mut("pass").unwrap().try_into().unwrap();
prog.load().unwrap();
let link = PinnedLink::from_path("/sys/fs/bpf/aya-xdp-test-lo")?.unpin()?;
let link = PinnedLink::from_pin("/sys/fs/bpf/aya-xdp-test-lo")?.unpin()?;
prog.attach_to_link(link.try_into()?)?;
assert_loaded("pass", true);
}

Loading…
Cancel
Save