Issue with socket-wrapper socketpair()

Andreas Schneider asn at samba.org
Tue Apr 11 09:02:09 UTC 2023


On Saturday, 8 April 2023 12:25:10 CEST Wouter Verhelst via samba-technical 
wrote:
> Hi,

Hi Wouter,
 
> Currently, the NBD[1] test suite starts nbd-server with a generated
> configuration file, and then runs a special test client against that
> server. This works great, except if you are already running nbd-server
> on the machine where the test is run, in which case (obviously) the
> tester client runs its tests against the wrong server and then things go
> haywire.
> 
> Someone pointed out cwrap to me a while ago, so I had a look at using
> socket-wrapper to isolate nbd-server, and it works great! except for the
> GnuTLS-using tests, and I *think* it's because of how the GnuTLS things
> are implemented in the "test" client: rather than adding an abstraction
> layer which directs a read or write to either a "plain" or a TLS-using
> write, we instead call socketpair(), then fork(), and then on one end of
> the socketpair we implement an encrypting/decrypting proxy. This keeps
> the tester client straightforward (everything continues to use regular
> reads and writes etc on a regular socket) and has no effect on the
> software under test (it's not as efficient, but for a test suite, that's
> fine).

I'm not aware of any issues with socketpair(). We wrap the function but only 
to detect stale file descriptors. So the socketpair() always goes directly to 
libc.

> However, it looks like this setup may not work correctly with
> socket-wrapper. I see that my tester client, after a bit of back and
> forth with the server which functions correctly, loses connectivity.
> This is *not* immediately upon connection, only after a few messages
> have been sent back and forth.

This sounds like a similar issue we had with libssh. Jakub also thought the 
issue is with SOCKET_WRAPPER's small MTU size, but it turned out to be an 
issue in libssh polling code!

https://gitlab.com/cwrap/socket_wrapper/-/merge_requests/34

> Does it seem likely to people here that this is a problem in
> socket-wrapper, or should I be looking at something "odd" I'm doing
> myself?

If it is an issue in socket_wrapper we need a test/reproducer for it. We 
already use socketpair() in tests and those work just fine.


Best regards


	Andreas

-- 
Andreas Schneider                      asn at samba.org
Samba Team                             www.samba.org
GPG-ID:     8DFF53E18F2ABC8D8F3C92237EE0FC4DCC014E3D





More information about the samba-technical mailing list