Page MenuHomeFreeBSD

ktls tests: Relax error checking for shutdown(2) a bit
ClosedPublic

Authored by markj on Oct 18 2023, 3:09 PM.
Tags
None
Referenced Files
Unknown Object (File)
Apr 30 2024, 6:17 AM
Unknown Object (File)
Apr 30 2024, 5:50 AM
Unknown Object (File)
Apr 30 2024, 5:08 AM
Unknown Object (File)
Apr 29 2024, 9:55 PM
Unknown Object (File)
Mar 9 2024, 12:39 PM
Unknown Object (File)
Mar 9 2024, 12:39 PM
Unknown Object (File)
Mar 8 2024, 11:14 PM
Unknown Object (File)
Mar 8 2024, 11:02 PM

Details

Summary

In my test suite runs I occasionally see shutdown(2) fail with
ECONNRESET rather than ENOTCONN. soshutdown(2) will return ENOTCONN if
the socket has been disconnected (synchronized by the socket lock), and
tcp_usr_shutdown() will return ECONNRESET if the inpcb has been dropped
(synchronized by the inpcb lock). I think it's possible to pass the
first check in soshutdown() but fail the second check in
tcp_usr_shutdown(), so modify the KTLS tests to permit this.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

markj requested review of this revision.Oct 18 2023, 3:09 PM

The proper solution might be for tcp_usr_shutdown() to return ENOTCONN in this case instead of ECONNRESET. @glebius do you have any opinions there?

The proper solution might be for tcp_usr_shutdown() to return ENOTCONN in this case instead of ECONNRESET. @glebius do you have any opinions there?

I didn't do full investigation, but it seems that the inpcb would be dropped if the remote side had reset the connection before we made the shutdown and thus it is ECONNRESET. And if we ourselves had already closed the connection (or never opened it) then it is ENOTCONN. So, if the current code behavior matches the above description, then I think the behavior is correct.

I'll add more subscribers to confirm or refute me. @rrs @tuexen

The proper solution might be for tcp_usr_shutdown() to return ENOTCONN in this case instead of ECONNRESET. @glebius do you have any opinions there?

I didn't do full investigation, but it seems that the inpcb would be dropped if the remote side had reset the connection before we made the shutdown and thus it is ECONNRESET. And if we ourselves had already closed the connection (or never opened it) then it is ENOTCONN. So, if the current code behavior matches the above description, then I think the behavior is correct.

Then I think the behaviour is correct, but the shutdown(2) documentation doesn't mention this error. If there is no objection, I'll write a patch to fix that.

I'll add more subscribers to confirm or refute me. @rrs @tuexen

jhb added inline comments.
tests/sys/kern/ktls_test.c
1907–1909

And maybe rewrap the last line?

This revision is now accepted and ready to land.Nov 17 2023, 12:37 AM