In in_pcb_lport_dest(), if an IPv6 socket does not match any other IPv6
socket using in6_pcblookup_local(), and if the socket can also connect
to IPv4 (the INP_IPV4 vflag is set), check for IPv4 matches as well.
Otherwise, we can allocate a port that is used by an IPv4 socket
(possibly one created from IPv6 via the same procedure), and then
connect() can fail with EADDRINUSE, when it could have succeeded if
the bound port was not in use.
Details
Details
used test program and Go test that pointed out the problem
Diff Detail
Diff Detail
- Repository
- rG FreeBSD src repository
- Lint
Lint Not Applicable - Unit
Tests Not Applicable
Event Timeline
Comment Actions
Notes:
PR https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=265064
Based on fix by firk@cantconnect.ru in that PR, but simplified a little and without the fix for PR 210726 (using NULL credentials).
Comment Actions
It looks great, my only concern is that this case it easily forgotten - personally I'm pretty sure I may forget this special case when touching pcb hash.
Would it be possible to add a small test so we have automation to monitor if that's still working?
Comment Actions
I'll take a look at that. The PR has a substantial test program, but I'd want something simpler (e.g. without threads). The test program will need to manipulate the portrange so it runs in a small time. I'll try to do this soon.