Skip to content

Commit

Permalink
Convert xde to use MacClient (#156)
Browse files Browse the repository at this point in the history
  • Loading branch information
rzezeski committed May 24, 2022
1 parent 2047842 commit 0d27014
Show file tree
Hide file tree
Showing 7 changed files with 657 additions and 497 deletions.
37 changes: 12 additions & 25 deletions opte/src/engine/packet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,18 @@ impl<S: PacketState> Packet<S> {
pub fn num_segs(&self) -> usize {
self.segs.len()
}

/// Return the head of the underlying `mblk_t` segment chain and
/// consume `self`. The caller of this function now owns the
/// `mblk_t` segment chain.
pub fn unwrap(mut self) -> *mut mblk_t {
let mp_head = self.segs[0].mp;
// We need to make sure to NULL out the mp pointer or else
// `drop()` will `freemsg(9F)` even though ownership of the
// mblk has passed on to someone else.
self.segs[0].mp = ptr::null_mut();
mp_head
}
}

/// For the `no_std`/illumos kernel environment, we want the `mblk_t`
Expand Down Expand Up @@ -1135,19 +1147,6 @@ impl Packet<Initialized> {
})
}

/// Return the head of the underlying `mblk_t` segment chain and
/// consume `self`. The caller of this function now owns the
/// `mblk_t` segment chain.
pub fn unwrap(mut self) -> *mut mblk_t {
// self.segs.pop().unwrap().unwrap()
let mp_head = self.segs[0].mp;
// We need to make sure to NULL out the mp pointer or else
// `drop()` will `freemsg(9F)` even though ownership of the
// mblk has passed on to someone else.
self.segs[0].mp = ptr::null_mut();
mp_head
}

/// Wrap the `mblk_t` packet in a [`Packet`], taking ownership of
/// the `mblk_t` packet as a result. An `mblk_t` packet consists
/// of one or more `mblk_t` segments chained together via
Expand Down Expand Up @@ -1601,18 +1600,6 @@ impl Packet<Parsed> {
let pkt_offset = self.unify_outer_headers()?;
self.unify_inner_headers(pkt_offset)
}

/// Return the head of the underlying `mblk_t` segment chain and
/// consume `self`. The caller of this function now owns the
/// `mblk_t` segment chain.
pub fn unwrap(mut self) -> *mut mblk_t {
let mp_head = self.segs[0].mp;
// We need to make sure to NULL out the mp pointer or else
// `drop()` will `freemsg(9F)` even though ownership of the
// mblk has passed on to someone else.
self.segs[0].mp = ptr::null_mut();
mp_head
}
}

impl<S: CanRead + PacketState> Packet<S> {
Expand Down
1 change: 1 addition & 0 deletions xde/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions xde/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ authors = [
edition = "2018"

[dependencies]
bitflags = "1.3.2"
cstr_core = { version = "0.2.4", default-features = false }
illumos-ddi-dki = { path = "../illumos-ddi-dki" }
postcard = { version = "0.7.0", features = ["alloc"], default-features = false }
Expand Down
1 change: 1 addition & 0 deletions xde/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ pub mod dld;
pub mod dls;
pub mod ip;
pub mod mac;
mod mac_sys;
pub mod secpolicy;
pub mod sys;
pub mod xde;
Expand Down
Loading

0 comments on commit 0d27014

Please sign in to comment.