Skip to content

socket::sockopt adding SOL_FILTER level options for illumos. #2611

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

Merged
merged 3 commits into from
Mar 25, 2025
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions changelog/2611.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add `FilAttach` and `FilDetach` to socket::sockopt for Illumos
21 changes: 20 additions & 1 deletion src/sys/socket/sockopt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -987,6 +987,25 @@ sockopt_impl!(
libc::SO_ACCEPTFILTER,
libc::accept_filter_arg
);
#[cfg(target_os = "illumos")]
sockopt_impl!(
/// Attach a named filter to this socket to be able to
/// defer when anough byte had been buffered by the kernel
FilAttach,
SetOnly,
libc::SOL_FILTER,
libc::FIL_ATTACH,
SetOsString<'static>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am thinking if this 'static lifetime would be too restrictive? I do not see a way to specify lifetime parameter using the macro, maybe we can implement the nix::sys::socket::SetSockOpt trait manually?

);
#[cfg(target_os = "illumos")]
sockopt_impl!(
/// Detach a socket filter previously attached with FIL_ATTACH
FilDetach,
SetOnly,
libc::SOL_FILTER,
libc::FIL_DETACH,
SetOsString<'static>
);
#[cfg(target_os = "linux")]
sockopt_impl!(
/// Set the mark for each packet sent through this socket (similar to the
Expand Down Expand Up @@ -1799,7 +1818,7 @@ pub struct SetOsString<'a> {
val: &'a OsStr,
}

#[cfg(any(target_os = "freebsd", linux_android))]
#[cfg(any(target_os = "freebsd", linux_android, target_os = "illumos"))]
impl<'a> Set<'a, OsString> for SetOsString<'a> {
fn new(val: &OsString) -> SetOsString {
SetOsString {
Expand Down
Loading