@@ -2812,6 +2812,36 @@ impl crate::Socket {
28122812 )
28132813 }
28142814 }
2815+
2816+ /// Get the value of the `UDP_GRO` option on this socket.
2817+ ///
2818+ /// For more information about this option, see [`set_udp_gro`].
2819+ ///
2820+ /// [`set_udp_gro`]: Socket::set_udp_gro
2821+ #[ cfg( all( feature = "all" , any( target_os = "android" , target_os = "linux" ) ) ) ]
2822+ #[ cfg_attr(
2823+ docsrs,
2824+ doc( cfg( all( feature = "all" , any( target_os = "android" , target_os = "linux" ) ) ) )
2825+ ) ]
2826+ pub fn udp_gro ( & self ) -> io:: Result < bool > {
2827+ unsafe {
2828+ getsockopt :: < c_int > ( self . as_raw ( ) , libc:: SOL_UDP , libc:: UDP_GRO ) . map ( |reuse| reuse != 0 )
2829+ }
2830+ }
2831+
2832+ /// Set value for the `UDP_GRO` option on this socket.
2833+ ///
2834+ /// This indicates that the kernel can combine multiple datagrams into a
2835+ /// single buffer, this needs to be used in combination with [`Self::recvmsg`]
2836+ /// to get the number of segments in the buffer from the [`MsgHdr`].
2837+ #[ cfg( all( feature = "all" , any( target_os = "android" , target_os = "linux" ) ) ) ]
2838+ #[ cfg_attr(
2839+ docsrs,
2840+ doc( cfg( all( feature = "all" , any( target_os = "android" , target_os = "linux" ) ) ) )
2841+ ) ]
2842+ pub fn set_udp_gro ( & self , reuse : bool ) -> io:: Result < ( ) > {
2843+ unsafe { setsockopt ( self . as_raw ( ) , libc:: SOL_UDP , libc:: UDP_GRO , reuse as c_int ) }
2844+ }
28152845}
28162846
28172847/// See [`Socket::dccp_available_ccids`].
0 commit comments