Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net: setKeepAlivePeriod may be wrong on Solaris #9614

Closed
ianlancetaylor opened this issue Jan 16, 2015 · 8 comments
Closed

net: setKeepAlivePeriod may be wrong on Solaris #9614

ianlancetaylor opened this issue Jan 16, 2015 · 8 comments
Assignees
Labels
FixPending Issues that have a fix which has not yet been reviewed or submitted. NeedsFix The path to resolution is known, but the work has not been done. OS-Solaris
Milestone

Comments

@ianlancetaylor
Copy link
Contributor

In revision f956740 the function setKeepAlivePeriod in the net package was changed on Solaris to use TCP_KEEPIDLE and TCP_KEEPINTVL. However, I am told that on Solaris 11.2, those symbols are not defined. They are defined in our syscall package because they are defined on Illumos, which is derived from OpenSolaris. If we want Go to have support for Solaris proper, not just OpenSolaris, we should probably go back to the earlier Solaris-specific version of setKeepAlivePeriod.

@4ad
Copy link
Member

4ad commented Mar 17, 2015

The problem here is that it impossible to perfectly emulate TCP_KEEPINTVL + TCP_KEEPIDLE using TCP_KEEPALIVE_THRESHOLD and TCP_KEEPALIVE_ABORT_THRESHOLD.

Generally speaking, TCP_KEEPALIVE_ABORT_THRESHOLD = TCP_KEEPCNT * TCP_KEEPINTVL, however, when using TCP_KEEPALIVE_ABORT_THRESHOLD, Solaris will not send probes at equal intervals, but will use an exponential backoff algorithm. That is not what we want.

If it's "good enough", and we decide to go with it, we need to find a good value for TCP_KEEPCNT. I don't know what a good value is.

@4ad 4ad assigned mikioh and 4ad and unassigned 4ad and mikioh Mar 17, 2015
@4ad
Copy link
Member

4ad commented Mar 17, 2015

Mikio, do you know what a good TCP_KEEPCNT value is?

@mikioh
Copy link
Contributor

mikioh commented Mar 22, 2015

Maybe 2^3? Agree that TCP_KEEPALIVE_THRESHOLD is equivalent to TCP_KEEPIDLE, TCP_KEEPALIVE_ABORT_THRESHOLD is equivalent to TCP_KEEPINTVL x TCP_KEEPCNT.

@rsc rsc added OS-Solaris and removed os-solaris labels Apr 10, 2015
@gopherbot
Copy link

CL https://golang.org/cl/7690 mentions this issue.

4ad added a commit that referenced this issue May 6, 2015
Unfortunately Oracle Solaris does not have TCP_KEEPIDLE and
TCP_KEEPINTVL. TCP_KEEPIDLE is equivalent to TCP_KEEPALIVE_THRESHOLD,
but TCP_KEEPINTVL does not have a direct equivalent, so we don't set
TCP_KEEPINTVL any more.

Old Darwin versions also lack TCP_KEEPINTVL, but the code tries to set
it anyway so that it works on newer versions. We can't do that because
Oracle might assign the number illumos uses for TCP_KEEPINTVL to a
constant with a different meaning.

Unfortunately there's nothing we can do if we want to support both
illumos and Oracle Solaris with the same GOOS.

Updates #9614.

Change-Id: Id39eb5147f7afa8e951f886c0bf529d00f0e1bd4
Reviewed-on: https://go-review.googlesource.com/7690
Reviewed-by: Minux Ma <minux@golang.org>
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
@mikioh mikioh modified the milestones: Unplanned, Go1.5 Jun 21, 2015
@binarycrusader
Copy link
Contributor

A future release of Solaris now supports these interfaces in a Linux-compatible way, so perhaps once a path for issue #15227 is figured out, we can figure out a way to use these on Solaris as well if they are available.

As an example, the values on a development version of Solaris are currently:

TCP_KEEPIDLE            0x1D
TCP_KEEPINTVL           0x1E

...while they are this on some OpenSolaris-based derivatives:

TCP_KEEPIDLE            0x22
TCP_KEEPINTVL           0x24

@gopherbot
Copy link

Change https://go.dev/cl/577195 mentions this issue: net: implement TCP_KEEPIDLE, TCP_KEEPINTVL, and TCP_KEEPCNT on Solaris 11.4

@panjf2000
Copy link
Member

A future release of Solaris now supports these interfaces in a Linux-compatible way, so perhaps once a path for issue #15227 is figured out, we can figure out a way to use these on Solaris as well if they are available.

As an example, the values on a development version of Solaris are currently:

TCP_KEEPIDLE            0x1D
TCP_KEEPINTVL           0x1E

...while they are this on some OpenSolaris-based derivatives:

TCP_KEEPIDLE            0x22
TCP_KEEPINTVL           0x24

Hi @binarycrusader, first thank you for the helpful tips!

I'm working on CL 577195 that sets TCP_KEEPIDLE, TCP_KEEPINTVL, and TCP_KEEPCNT on Solaris 11.4 and falls back to TCP_KEEPALIVE_THRESHOLD + TCP_KEEPALIVE_ABORT_THRESHOLD when Solaris kernel <11.4. It turns out that the TCP_KEEPCNT on Solaris 11.4 is also inconsistent with the OpenSolaris-based derivatives, check out this failed test. Unfortunately, I don't have a machine with Solaris 11.4 installed where I can seek out these three macros. I've searched the entire Internet for the <sys/socket.h>, <netinet/in.h>, and <netinet/tcp.h> header files and got nothing. Could you please share how you looked up these macros on Solaris in the first place? Also, if you could provided the value of TCP_KEEPCNT, it would be a big help, thanks!

@panjf2000 panjf2000 self-assigned this Apr 8, 2024
@panjf2000 panjf2000 modified the milestones: Unplanned, Go1.23 Apr 8, 2024
@panjf2000
Copy link
Member

Never mind, I've found it in Rust libc.

@panjf2000 panjf2000 added NeedsFix The path to resolution is known, but the work has not been done. FixPending Issues that have a fix which has not yet been reviewed or submitted. labels Apr 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FixPending Issues that have a fix which has not yet been reviewed or submitted. NeedsFix The path to resolution is known, but the work has not been done. OS-Solaris
Projects
None yet
Development

No branches or pull requests

7 participants