OS-5173: lxbrand setsockopt(2) interacts improperly with shutdown(2)


Issue Type:Bug
Priority:4 - Normal
Created at:2016-02-19T20:15:12.000Z
Updated at:2019-08-28T17:19:02.084Z


Created by:Former user
Reported by:Former user




During the course of debugging OS-4699, the customer found information regarding differences in setsockopt(SO_LINGER) between Linux/UNIX platforms. Since SunOS diverges from Linux, particularly around the use of shutdown, it would be valuable to investigate a work-around for LX.

I investigated case with SO_LINGER and below are the results. Here is an amazing write up on cross-platform testing of SO_LINGER: https://www.nybek.com/blog/2015/03/05/cross-platform-testing-of-so_linger/#test_platform_overview and https://www.nybek.com/blog/2015/04/29/so_linger-on-non-blocking-sockets/.

There is a lot of useful information there, most useful information is about differences between Illumos and Linux. Two are especially interesting:
1. If SO_LINGER is set to any value > 0, Illumos will serve data in background until client finishes loading it.
2. Illumos returns EINVAL (Invalid argument) if SO_LINGER is set after shutdown() was called. This is one the most distinctive differences between Linux and Illumos in regards to SO_LINGER.

I downloaded the source, built it and run on same instances where I was getting errors. And what I got was that LINUX JESSIE ON TRITON BEHAVES LIKE ILLUMOS IN BOTH CASES DESCRIBED ABOVE.

From what I've seen it seems that the way to get EINVAL when setting SO_LINGER is to do it after shutdown(). This should not have any effect on Debian Jessie because Linux simply ignores this situation but on Triton socket behaves like in Illumos.

I checked application for which setting of SO_LINGER was failing and it's not causing connection to be broken or anything like that, just warning pops up. I didn't go further and debug with tcpdump.

I would be very keen to hear why Linux sockets behave as Illumos/Solaris, well I guess I know why but still want to know if this is expected.