All callers of in_pcbdisconnect() clear the local address, so let's just
do that in the function itself. No functional change intended.
Details
Diff Detail
- Repository
- rG FreeBSD src repository
- Lint
Lint Not Applicable - Unit
Tests Not Applicable
Event Timeline
I'd like to revert this revision. I think the logic of clearing local address at the protocol level makes sense. It is feature of UDP, not of any protocol, that local address is cleared on disconnect. As you noted this code can be tracked down to pre-FreeBSD times.
For example, for TCP we want a disconnected socket to return previously used local address with getsockname(). The TCP has successfully evaded that by not calling in_pcbdisconnect() and calling in_pcbdetach() in the very old code and in_pcbdrop() in the newer code. In my current branch I have TCP started to use in_pcbdisconnect(), however it still evades clearing of local address for a different reason.
The other thing I'm about to do in branch is to make raw IP to make more use of the generic inpcb code. Yep, decided to give up with trees and follow your advice. So, raw IP starts to use in_pcbdisconnect(). For raw IP it is more than getsockname()! A raw socket may be bound with bind(2) and then connect(2)ed, and then disconnected, e.g. connect(INADDR_ANY). So, when we run raw IP socket through in_pcbdisconnect() we don't want to lose local address.
Er, chaps, there is RFC 9622 to digest, the end of the BSD sockets API as we know it perhaps.
But that RFC needs a healthy dose of "Cui Bono?" to it. Some suggested it was just a Google land grab.
The thing that should be at the back of all our heads is: Cloudflare saw fit to bypass traditional inpcb semantics as well.