NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

bin/59865: ftp should not set socket send/receive buffers unless told to



>Number:         59865
>Category:       bin
>Synopsis:       ftp should not set socket send/receive buffers unless told to
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Dec 26 22:50:01 +0000 2025
>Originator:     Christof Meerwald
>Release:        10.1
>Organization:
>Environment:
NetBSD linveo.cmeerw.net 10.1_STABLE NetBSD 10.1_STABLE (GENERIC) #0: Mon Oct 20 14:07:22 UTC 2025  mkrepro%mkrepro.NetBSD.org@localhost:/usr/src/sys/arch/amd64/compile/GENERIC amd64

>Description:
Even if no socket buffer sizes are specified, ftp still gets and sets the socket buffer sizes. This has the side-effect that it disables auto-sizing of the socket buffers, resulting in slow file transfers (particularly over high-latency connections).

See setupsockbufsize in https://nxr.netbsd.org/xref/src/usr.bin/ftp/util.c#1086

Presumably, the set socket buffer size calls should be moved into else-branches of the respective "== 0" checks.

FreeBSD has done something similar a few years ago in https://reviews.freebsd.org/D23732
>How-To-Repeat:
This mainly affects systems where net.inet.tcp.recvbuf_max is significantly larger than net.inet.tcp.recvspace. Downloading a file with ftp will not increase the receive window size above net.inet.tcp.recvspace (as setting the receive buffer size will disable auto-sizing).
>Fix:
In setupsockbufsize (src/usr.bin/ftp/util.c) do something like:

  if (0 == rcvbuf_size) {
    getsockopt(sock, SOL_SOCKET, SO_RCVBUF, ...);
  } else {
    setsockopt(sock, SOL_SOCKET, SO_RCVBUF, ...);
  }

  if (0 == sndbuf_size) {
    getsockopt(sock, SOL_SOCKET, SO_SNDBUF, ...);
  } else {
    setsockopt(sock, SOL_SOCKET, SO_SNDBUF, ...);
  }



Home | Main Index | Thread Index | Old Index