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)
Wed, Nov 13, 10:06 PM
Unknown Object (File)
Oct 1 2024, 4:34 PM
Unknown Object (File)
Sep 24 2024, 8:10 AM
Unknown Object (File)
Sep 21 2024, 7:44 AM
Unknown Object (File)
Sep 16 2024, 7:27 PM
Unknown Object (File)
Sep 16 2024, 9:55 AM
Unknown Object (File)
Sep 3 2024, 9:44 PM
Unknown Object (File)
Sep 2 2024, 1:24 AM

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