Skip to content

virtualnetwork: configure TCP time-wait timeout - #759

Open
sairex53 wants to merge 2 commits into
containers:mainfrom
sairex53:codex/issue-757-tcp-timewait
Open

sairex53 wants to merge 2 commits into
containers:mainfrom
sairex53:codex/issue-757-tcp-timewait

Conversation

@sairex53

@sairex53 sairex53 commented Oct 24, 2026 •

Copy link
Copy Markdown

Summary

Expose the TCP TIME-WAIT timeout through stack.tcpTimeWaitTimeout and the -tcp-time-wait-timeout CLI flag to address connection stalls caused by stale 4-tuples. An omitted value retains gVisor's 60-second default; an explicit zero is passed through to gVisor. Reject negative and overflowing values before creating the network endpoint or capture file.

Fixes #757.

Testing

  • go test ./pkg/... ./cmd/gvproxy/... -count=1
  • go vet ./pkg/virtualnetwork ./cmd/gvproxy
  • git diff --check

The CLI regression test fails on the original PR revision because the flag is undefined and passes with this revision.

Signed-off-by: Eduard Zateev <hackerowskiy@gmail.com>
@openshift-ci

openshift-ci Bot commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: sairex53
Once this PR has been reviewed and has the lgtm label, please assign baude for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@evidolob
evidolob self-requested a review October 28, 2026 09:45
Comment thread pkg/virtualnetwork/virtualnetwork.go Outdated
},
})

if timeWaitTimeout > 0 {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

gvisor accepts 0 as timeout value

Comment thread pkg/types/configuration.go Outdated
TCPConnectTimeout int `yaml:"tcpConnectTimeout,omitempty"`

// Timeout in seconds for TCP connections in TIME-WAIT (default: 60)
TCPTimeWaitTimeout int `yaml:"tcpTimeWaitTimeout,omitempty"`

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

we need to have cli parameter for this, as not all users use YAML for configuration

Comment thread pkg/virtualnetwork/virtualnetwork.go Outdated
}

func New(configuration *types.Configuration) (*VirtualNetwork, error) {
if _, err := parseTCPTimeWaitTimeout(configuration.TCPTimeWaitTimeout); err != nil {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We don't need to validate the timeout here since it's already being validated in createStack()

Comment thread pkg/virtualnetwork/virtualnetwork.go Outdated
if timeoutSeconds < 0 {
return 0, errors.New("TCP time-wait timeout must not be negative")
}
if int64(timeoutSeconds) > (1<<63-1)/int64(time.Second) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
if int64(timeoutSeconds) > (1<<63-1)/int64(time.Second) {
if int64(timeoutSeconds) > math.MaxInt64 / int64(time.Second) {

Signed-off-by: Eduard Zateev <hackerowskiy@gmail.com>
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.

A SYN that reopens a TIME_WAIT 4-tuple is dropped for 60 s: allow a short TCP TIME_WAIT (types.Configuration)

3 participants