HomeFreeBSD

IPv6: fix problem with duplicate port assignment with v4-mapped addrs

Description

IPv6: fix problem with duplicate port assignment with v4-mapped addrs

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.

PR: 265064
Submitted by: firk at cantconnect.ru (with modifications)
Reviewed by: bz, melifaro
Differential Revision: https://reviews.freebsd.org/D36012

Details

Provenance
karelsAuthored on Jul 29 2022, 2:23 PM
Reviewer
bz
Differential Revision
D36012: IPv6: fix problem with duplicate port assignment with v4-mapped addrs
Parents
rG190c4c2499e6: diff3: Use ranges for new and old diffedits in ed scripts
Branches
Unknown
Tags
Unknown