On Tue, Mar 11, 2025 at 12:37:31PM +0300, Vitaliy Makkoveev wrote:
> On Mon, Mar 10, 2025 at 03:47:42PM -0600, Maximo Pech wrote:
> > Hi,
> > 
> > I'm running ipfs and for best performance it requires increasing the
> > udp receive buffer size as explained below
> > 
> > https://github.com/quic-go/quic-go/wiki/UDP-Buffer-Sizes
> > 
> > However, I've noticed that setting net.inet.udp.recvspace above
> > 2097152 results in socket(2) failing with ENOBUF. It doesn't matter
> > what the actual resource usage is, just setting it makes many programs
> > that call socket() to fail, for example ifconfig, netstat.
> > 
> > I believe that probably I'm hitting another system limit, so I would
> > need to increase that as well but I don't know what it would be. I've
> > tested this on two different systems, with 1G memory and 2G memory and
> > the behavior is the same.
> > 
> > Any advice would be appreciated.
> > 
> 
> Yes, this is the limit for max bytes in socket buffer. The
> *.{send,recv}space sysctl values should not exceed this limit. Thanks
> for pointing.
> 
> The UNIX sockets already have the SB_MAX for upper limit.

OK claudio@

Another option would be to accept larger numbers but clip them to SB_MAX.
The sysctl interface does not really offer that in an easy way so I think
it is not worth adding a lot of code for that.
 
> Index: sys/netinet/ip_divert.c
> ===================================================================
> RCS file: /cvs/src/sys/netinet/ip_divert.c,v
> diff -u -p -r1.100 ip_divert.c
> --- sys/netinet/ip_divert.c   2 Mar 2025 21:28:32 -0000       1.100
> +++ sys/netinet/ip_divert.c   11 Mar 2025 09:32:17 -0000
> @@ -63,8 +63,8 @@ u_int   divert_recvspace = DIVERT_RECVSP
>  #endif
>  
>  const struct sysctl_bounded_args divertctl_vars[] = {
> -     { DIVERTCTL_RECVSPACE, &divert_recvspace, 0, INT_MAX },
> -     { DIVERTCTL_SENDSPACE, &divert_sendspace, 0, INT_MAX },
> +     { DIVERTCTL_RECVSPACE, &divert_recvspace, 0, SB_MAX },
> +     { DIVERTCTL_SENDSPACE, &divert_sendspace, 0, SB_MAX },
>  };
>  
>  const struct pr_usrreqs divert_usrreqs = {
> Index: sys/netinet/udp_usrreq.c
> ===================================================================
> RCS file: /cvs/src/sys/netinet/udp_usrreq.c,v
> diff -u -p -r1.334 udp_usrreq.c
> --- sys/netinet/udp_usrreq.c  2 Mar 2025 21:28:32 -0000       1.334
> +++ sys/netinet/udp_usrreq.c  11 Mar 2025 09:32:17 -0000
> @@ -159,8 +159,8 @@ const struct pr_usrreqs udp6_usrreqs = {
>  
>  const struct sysctl_bounded_args udpctl_vars[] = {
>       { UDPCTL_CHECKSUM, &udpcksum, 0, 1 },
> -     { UDPCTL_RECVSPACE, &udp_recvspace, 0, INT_MAX },
> -     { UDPCTL_SENDSPACE, &udp_sendspace, 0, INT_MAX },
> +     { UDPCTL_RECVSPACE, &udp_recvspace, 0, SB_MAX },
> +     { UDPCTL_SENDSPACE, &udp_sendspace, 0, SB_MAX },
>  };
>  
>  struct       inpcbtable udbtable;
> Index: sys/netinet6/ip6_divert.c
> ===================================================================
> RCS file: /cvs/src/sys/netinet6/ip6_divert.c,v
> diff -u -p -r1.99 ip6_divert.c
> --- sys/netinet6/ip6_divert.c 2 Mar 2025 21:28:32 -0000       1.99
> +++ sys/netinet6/ip6_divert.c 11 Mar 2025 09:32:17 -0000
> @@ -66,8 +66,8 @@ u_int   divert6_recvspace = DIVERT_RECVS
>  #endif
>  
>  const struct sysctl_bounded_args divert6ctl_vars[] = {
> -     { DIVERT6CTL_RECVSPACE, &divert6_recvspace, 0, INT_MAX },
> -     { DIVERT6CTL_SENDSPACE, &divert6_sendspace, 0, INT_MAX },
> +     { DIVERT6CTL_RECVSPACE, &divert6_recvspace, 0, SB_MAX },
> +     { DIVERT6CTL_SENDSPACE, &divert6_sendspace, 0, SB_MAX },
>  };
>  
>  const struct pr_usrreqs divert6_usrreqs = {

-- 
:wq Claudio

Reply via email to