File tree Expand file tree Collapse file tree 3 files changed +22
-1
lines changed Expand file tree Collapse file tree 3 files changed +22
-1
lines changed Original file line number Diff line number Diff line change
1
+ Add the ` TCP_FUNCTION_ALIAS ` sockopt, on FreeBSD.
Original file line number Diff line number Diff line change @@ -330,6 +330,19 @@ sockopt_impl!(
330
330
libc:: TCP_FUNCTION_BLK ,
331
331
libc:: tcp_function_set
332
332
) ;
333
+ #[ cfg( target_os = "freebsd" ) ]
334
+ #[ cfg( feature = "net" ) ]
335
+ sockopt_impl ! (
336
+ #[ cfg_attr( docsrs, doc( cfg( feature = "net" ) ) ) ]
337
+ /// Query the alias name of the set of function of the socket's TCP stack.
338
+ /// Uses the same field for the main name when getting from TCP_FUNCTION_BLK.
339
+ /// Empty if no alias.
340
+ TcpFunctionAlias ,
341
+ GetOnly ,
342
+ libc:: IPPROTO_TCP ,
343
+ libc:: TCP_FUNCTION_ALIAS ,
344
+ libc:: tcp_function_set
345
+ ) ;
333
346
sockopt_impl ! (
334
347
#[ cfg_attr( docsrs, doc( cfg( feature = "net" ) ) ) ]
335
348
/// Used to disable Nagle's algorithm.
Original file line number Diff line number Diff line change @@ -291,7 +291,7 @@ fn test_tcp_congestion() {
291
291
292
292
#[ test]
293
293
#[ cfg( target_os = "freebsd" ) ]
294
- fn test_tcp_function_blk ( ) {
294
+ fn test_tcp_function_blk_alias ( ) {
295
295
use std:: ffi:: CStr ;
296
296
297
297
let fd = socket (
@@ -306,8 +306,15 @@ fn test_tcp_function_blk() {
306
306
let name = unsafe { CStr :: from_ptr ( tfs. function_set_name . as_ptr ( ) ) } ;
307
307
assert ! ( !name. to_bytes( ) . is_empty( ) ) ;
308
308
309
+ let aliastfs = getsockopt ( & fd, sockopt:: TcpFunctionAlias ) . unwrap ( ) ;
310
+ let aliasname =
311
+ unsafe { CStr :: from_ptr ( aliastfs. function_set_name . as_ptr ( ) ) } ;
312
+ // freebsd default tcp stack has no alias.
313
+ assert ! ( aliasname. to_bytes( ) . is_empty( ) ) ;
314
+
309
315
// We can't know at compile time what options are available. So just test the setter by a
310
316
// no-op set.
317
+ // TODO: test if we can load for example BBR tcp stack kernel module.
311
318
setsockopt ( & fd, sockopt:: TcpFunctionBlk , & tfs) . unwrap ( ) ;
312
319
}
313
320
You can’t perform that action at this time.
0 commit comments