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

Separate TcpKeepAliveIdle and TcpKeepAliveInterval check logic #1484

Merged
merged 2 commits into from Jan 16, 2022
Merged

Separate TcpKeepAliveIdle and TcpKeepAliveInterval check logic #1484

merged 2 commits into from Jan 16, 2022

Conversation

ValdikSS
Copy link
Contributor

This patch allows to separately configure both parameters.

@codecov-commenter
Copy link

codecov-commenter commented Dec 23, 2021

Codecov Report

Merging #1484 (7dda322) into master (423d566) will increase coverage by 0.04%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1484      +/-   ##
==========================================
+ Coverage   39.52%   39.56%   +0.04%     
==========================================
  Files         598      595       -3     
  Lines       35068    34944     -124     
==========================================
- Hits        13860    13827      -33     
+ Misses      19681    19603      -78     
+ Partials     1527     1514      -13     
Impacted Files Coverage Δ
transport/internet/sockopt_darwin.go 36.36% <0.00%> (-8.09%) ⬇️
transport/internet/sockopt_windows.go 38.70% <0.00%> (ø)
transport/internet/domainsocket/config.go 52.63% <0.00%> (-10.53%) ⬇️
transport/internet/config.go 27.02% <0.00%> (-2.71%) ⬇️
transport/internet/kcp/connection.go 71.82% <0.00%> (-0.56%) ⬇️
transport/internet/sockopt_linux.go
transport/internet/udp/hub_linux.go
transport/internet/tcp/sockopt_linux.go
transport/internet/kcp/dialer.go 84.31% <0.00%> (+3.92%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 423d566...7dda322. Read the comment docs.

@@ -9,6 +9,8 @@ const (
TCP_FASTOPEN_SERVER = 0x01 // nolint: revive,stylecheck
// TCP_FASTOPEN_CLIENT is the value to enable TCP fast open on darwin for client connections.
TCP_FASTOPEN_CLIENT = 0x02 // nolint: revive,stylecheck
// syscall.TCP_KEEPINTVL is missing on some darwin architectures.
sysTCP_KEEPINTVL = 0x101 // nolint: revive,stylecheck
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which darwin architectures are missing TCP_KEEPINTVL? We are using x/sys/unix here, not syscall, please double check.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not where you should be looking at.

https://github.com/golang/sys/blob/1d35b9e2eb4edf581781c7f3e2a36fac701f0a24/unix/zerrors_darwin_amd64.go#L1459

https://github.com/golang/sys/blob/1d35b9e2eb4edf581781c7f3e2a36fac701f0a24/unix/zerrors_darwin_arm64.go#L1459

TCP_KEEPINTVL is present for both darwin-amd64 and darwin-arm64. You can safely use unix.TCP_KEEPINTVL.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your recommendation have been adapted at 406e0f7.

if config.TcpKeepAliveInterval > 0 {
if err := unix.SetsockoptInt(int(fd), unix.IPPROTO_TCP, sysTCP_KEEPINTVL, int(config.TcpKeepAliveIdle)); err != nil {
return newError("failed to set TCP_KEEPIDLE", err)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think moving setsockopt(TCP_KEEPALIVE) and setsockopt(TCP_KEEPINTVL) out of the if config.TcpKeepAliveIdle > 0 || config.TcpKeepAliveInterval > 0 block would make it more readable.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your recommendation have been adapted at 406e0f7.

@xiaokangwang xiaokangwang merged commit 84c428c into v2fly:master Jan 16, 2022
@ValdikSS
Copy link
Contributor Author

@xiaokangwang, thanks for the fix. I'll adapt it for #1483 and update shortly.

dyhkwong pushed a commit to dyhkwong/v2ray-core that referenced this pull request Jan 22, 2022
dyhkwong pushed a commit to dyhkwong/v2ray-core that referenced this pull request Apr 3, 2022
dyhkwong pushed a commit to dyhkwong/v2ray-core that referenced this pull request Apr 3, 2022
dyhkwong pushed a commit to dyhkwong/v2ray-core that referenced this pull request Apr 3, 2022
dyhkwong pushed a commit to dyhkwong/v2ray-core that referenced this pull request Apr 3, 2022
dyhkwong pushed a commit to dyhkwong/v2ray-core that referenced this pull request Apr 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants