NetBSD-Bugs archive

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

Re: kern/22522 (connect(2) may fail with EINVAL which isn't undocumented.)



Synopsis: connect(2) may fail with EINVAL which isn't undocumented.

State-Changed-From-To: closed->open
State-Changed-By: riastradh%NetBSD.org@localhost
State-Changed-When: Sun, 27 Sep 2026 00:17:17 +0000
State-Changed-Why:
This was actually not really addressed.  If you don't trash len (e.g.,
use a local variable `int optlen' for the socket option length), and if
you add a case for EALREADY to continue the loop, you hit two problems:

1. Eventually, connect() fails with EINVAL.
2. getsockopt(SO_ERROR) _does not_ return ECONNREFUSED after that.

connect to family = 2, port = 12345, addr = 192.168.1.1
connect: Operation now in progress
getsockopt => 0
connect to family = 2, port = 12345, addr = 192.168.1.1
connect: Operation already in progress
getsockopt => 0
...
connect to family = 2, port = 12345, addr = 192.168.1.1
connect: Operation already in progress
getsockopt => Connection refused
connect to family = 2, port = 12345, addr = 192.168.1.1
connect: Invalid argument
getsockopt => 0

See also:

PR kern/58874: nonblocking connect() and getsockname() error conditions
https://gnats.netbsd.org/58874

(OK, I guess we only need one of these PRs open, so we could
legitimately close the other as a duplicate.)






Home | Main Index | Thread Index | Old Index