File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -1983,6 +1983,35 @@ impl crate::Socket {
1983
1983
}
1984
1984
}
1985
1985
1986
+ /// Get the value of the `SO_REUSEPORT_LB` option on this socket.
1987
+ ///
1988
+ /// For more information about this option, see [`set_reuse_port_lb`].
1989
+ ///
1990
+ /// [`set_reuse_port_lb`]: crate::Socket::set_reuse_port_lb
1991
+ #[ cfg( all( feature = "all" , target_os = "freebsd" ) ) ]
1992
+ pub fn reuse_port_lb ( & self ) -> io:: Result < bool > {
1993
+ unsafe {
1994
+ getsockopt :: < c_int > ( self . as_raw ( ) , libc:: SOL_SOCKET , libc:: SO_REUSEPORT_LB )
1995
+ . map ( |reuse| reuse != 0 )
1996
+ }
1997
+ }
1998
+
1999
+ /// Set value for the `SO_REUSEPORT_LB` option on this socket.
2000
+ ///
2001
+ /// This allows multiple programs or threads to bind to the same port and
2002
+ /// incoming connections will be load balanced using a hash function.
2003
+ #[ cfg( all( feature = "all" , target_os = "freebsd" ) ) ]
2004
+ pub fn set_reuse_port_lb ( & self , reuse : bool ) -> io:: Result < ( ) > {
2005
+ unsafe {
2006
+ setsockopt (
2007
+ self . as_raw ( ) ,
2008
+ libc:: SOL_SOCKET ,
2009
+ libc:: SO_REUSEPORT_LB ,
2010
+ reuse as c_int ,
2011
+ )
2012
+ }
2013
+ }
2014
+
1986
2015
/// Get the value of the `IP_FREEBIND` option on this socket.
1987
2016
///
1988
2017
/// For more information about this option, see [`set_freebind`].
Original file line number Diff line number Diff line change @@ -1228,6 +1228,8 @@ test!(reuse_address, set_reuse_address(true));
1228
1228
not( any( windows, target_os = "solaris" , target_os = "illumos" ) )
1229
1229
) ) ]
1230
1230
test ! ( reuse_port, set_reuse_port( true ) ) ;
1231
+ #[ cfg( all( feature = "all" , target_os = "freebsd" ) ) ]
1232
+ test ! ( reuse_port_lb, set_reuse_port_lb( true ) ) ;
1231
1233
#[ cfg( all( feature = "all" , unix, not( target_os = "redox" ) ) ) ]
1232
1234
test ! (
1233
1235
#[ cfg_attr( target_os = "linux" , ignore = "Different value returned" ) ]
You can’t perform that action at this time.
0 commit comments