Skip to content

Commit

Permalink
Add support for extended ACK
Browse files Browse the repository at this point in the history
NETLINK_EXT_ACK is a socket option to enable the
reporting of additional error/warning TLVs.

Signed-off-by: Florian Kauer <[email protected]>
  • Loading branch information
koalo committed Jan 3, 2024
1 parent 8fb8bad commit cbeee53
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,23 @@ impl Socket {
)?;
Ok(res == 1)
}

/// `NETLINK_EXT_ACK`
/// Extended ACK controls reporting of additional error/warning TLVs in NLMSG_ERROR and NLMSG_DONE messages.
/// To maintain backward compatibility this feature has to be explicitly enabled.
pub fn set_ext_ack(&mut self, value: bool) -> Result<()> {
let value: libc::c_int = value.into();
setsockopt(self.0, libc::SOL_NETLINK, libc::NETLINK_EXT_ACK, value)
}

pub fn get_ext_ack(&self) -> Result<bool> {
let res = getsockopt::<libc::c_int>(
self.0,
libc::SOL_NETLINK,
libc::NETLINK_EXT_ACK,
)?;
Ok(res == 1)
}
}

/// Wrapper around `getsockopt`:
Expand Down

0 comments on commit cbeee53

Please sign in to comment.