File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -116,6 +116,17 @@ impl UdpSocket {
116
116
self . io . set_broadcast ( broadcast)
117
117
}
118
118
119
+ /// Opportunistically try to enable GRO support for this socket. This is
120
+ /// only supported on Linux platforms.
121
+ #[ cfg( target_os = "linux" ) ]
122
+ pub fn set_gro ( & self , enable : bool ) -> io:: Result < ( ) > {
123
+ // See gro::gro_segments().
124
+ const OPTION_OFF : libc:: c_int = 0 ;
125
+
126
+ let value = if enable { OPTION_ON } else { OPTION_OFF } ;
127
+ set_socket_option ( & self . io , libc:: SOL_UDP , libc:: UDP_GRO , value)
128
+ }
129
+
119
130
pub async fn connect < A : ToSocketAddrs > ( & self , addrs : A ) -> io:: Result < ( ) > {
120
131
self . io . connect ( addrs) . await
121
132
}
@@ -609,9 +620,6 @@ fn init(io: SockRef<'_>) -> io::Result<()> {
609
620
}
610
621
#[ cfg( target_os = "linux" ) ]
611
622
{
612
- // opportunistically try to enable GRO. See gro::gro_segments().
613
- let _ = set_socket_option ( & * io, libc:: SOL_UDP , libc:: UDP_GRO , OPTION_ON ) ;
614
-
615
623
// Forbid IPv4 fragmentation. Set even for IPv6 to account for IPv6 mapped IPv4 addresses.
616
624
set_socket_option (
617
625
& * io,
You can’t perform that action at this time.
0 commit comments