Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions libbpf-rs/src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,18 @@ impl Map {
util::parse_ret(ret)
}

/// Freeze the map as read-only from user space.
///
/// Entries from a frozen map can no longer be updated or deleted with the
/// bpf() system call. This operation is not reversible, and the map remains
/// immutable from user space until its destruction. However, read and write
/// permissions for BPF programs to the map remain unchanged.
pub fn freeze(&self) -> Result<()> {
let ret = unsafe { libbpf_sys::bpf_map_freeze(self.fd) };

util::parse_ret(ret)
}

/// Returns an iterator over keys in this map
///
/// Note that if the map is not stable (stable meaning no updates or deletes) during iteration,
Expand Down