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
Add TCP keepalive socket options support #17
Conversation
Thanks for submitting a patch. What kernel version did you test this with? |
Distribution kernel 4.15:
|
|
Thanks. IIUC, zero values for those option mean that the kernel uses the default specified by the |
@veithen Yes, if they are not overridden (set to 0) sysctls values are fetched instead: https://elixir.bootlin.com/linux/v4.15.18/source/include/net/tcp.h#L1312
I think we could hide them if they contained non-zero values or we could say something like Another improvement would be to avoid printing these values in case SO_KEEPALIVE is 0 ( https://elixir.bootlin.com/linux/v4.15.18/source/net/core/sock.c#L1148
So, in summary, I would settle on:
Thoughts? |
I would keep it simple and just suppress the output for each |
Pull-request updated, HEAD is now 234a906 |
Add support for printing tcp_keepalive_intvl, tcp_keepalive_probes and tcp_keepalive_time. keepalive_time and keepalive_intvl have to be divided by HZ as they are multiplied by that value in the kernel code before being stored: net/ipv4/tcp.c: tp->keepalive_time = val * HZ; tp->keepalive_intvl = val * HZ; This is quite useful to inspect if an application overrides default keepalive values somewhere in its code from system defaults which are usually quite high (2 hours for tcp_keepalive_time by default). If a given value is 0 the kernel takes a sysctl value for that parameter instead and knetstat will not print that value at all with this change. Example: tcp_keepalive_intvl = 15 tcp_keepalive_probes = 2 tcp_keepalive_time = 15 output: // ... SO_KEEPALIVE=1,TCP_KEEPIDLE=15,TCP_KEEPCNT=2,TCP_KEEPINTVL=15
Pull-request updated, HEAD is now 8798664 |
Alright, let's keep it that way. I made some comments about that in the commit message and readme. |
Thanks @veithen |
Add support for printing tcp_keepalive_intvl, tcp_keepalive_probes and
tcp_keepalive_time.
keepalive_time and keepalive_intvl have to be divided by HZ as they are
multiplied by that value in the kernel code before being stored:
net/ipv4/tcp.c:
tp->keepalive_time = val * HZ;
tp->keepalive_intvl = val * HZ;
This is quite useful to inspect if an application overrides default
keepalive values somewhere in its code from system defaults which are
usually quite high (2 hours for tcp_keepalive_time by default).
Example:
tcp_keepalive_intvl = 15
tcp_keepalive_probes = 2
tcp_keepalive_time = 15
output:
// ... SO_KEEPALIVE=1,TCP_KEEPIDLE=15,TCP_KEEPCNT=2,TCP_KEEPINTVL=15