Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: cap max X11 forwarding ports and evict old#18561

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
spikecurtis wants to merge1 commit intomain
base:main
Choose a base branch
Loading
fromspike/18263-cap-x11-forwarding-ports

Conversation

spikecurtis
Copy link
Contributor

@spikecurtisspikecurtis commentedJun 25, 2025
edited
Loading

partial for#18263

Caps the X11 forwarding sessions at a maximum port of 6200, and evicts the oldest session if we create new sessions while at the max.

Unit tests included higher in the stack.

@spikecurtisspikecurtisforce-pushed thespike/18263-cap-x11-forwarding-ports branch fromd6cba82 to77f7937CompareJune 25, 2025 10:37
Copy link
Member

@mafredrimafredri left a comment

Choose a reason for hiding this comment

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

This is a good refactor, nice work 👍🏻. I'm however not entirely sold on the lru eviction policy since it's based on connection establishment time and not connection usage (i.e. we may end evicting a busy connection). (See related comment for additional context.)

// the X11 TCP listener port for a new X11 forwarding session. If we left the SSH session up, then graphical apps
// started in that session could potentially connect to an unintended X11 Server (i.e. the display on a different
// computer than the one that started the SSH session). Most likely, this session is a zombie anyway if we've
// reached the maximum number of X11 forwarding sessions.
Copy link
Member

Choose a reason for hiding this comment

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

Do we know of any cases where customers use up this many X11 forwarding ports? Another alternative would simply be to error out which might be preferable. I imagine a user could start one main session early, then play around with different behaviors and depleting the pool, only to have the main session evicted.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

#18263 has a description from the customer. He has like 15 sessions open at a time, gets disconnected, and reconnects all 15. Since we have long server-side timeouts, they end up accumulating.

This LRU thing is definitely a band-aid and we need to fix the fact that his SSH sessions don't recover and/or don't get cleaned up server side, but that's likely involved.

Erroring out is not preferrable in this case, since once the SSH sessions are orphaned on the server there is nothing you can do to force them down early other than restarting the workspace which is not acceptable.

Wecould instrument the bicopy to periodically bump the usage time of the session, so that "active" X11 forwarding would be less likely to be evicted, but I'm not sure it's worth it, given our understanding of the problem. My working hypothesis is that you're just never going to be creating over 200 X11 forwarding sessions on purpose unless you're getting repeatedly disconnected, in which case the early sessions are toast.

Copy link
Member

Choose a reason for hiding this comment

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

Alright, thanks for the detailed explanation! I think your reasoning makes sense, and considering we have some ideas on how to improve this in the future if the need arises, I’m ok with the approach. I’ll go through the rest of the PRs tomorrow.


return display, true
// cleanSession closes and cleans up the session.
func (x *x11Forwarder) cleanSession(x11session *x11Session) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggestion:closeSession sounds a bit more informative to me than clean. I guess it's a matter of implicit close vs implicit clean, and which is the primary action.

display int
err error
)
// retry up to 10 times
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Comment isn't informative and could be removed or describe why.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@mafredrimafredrimafredri left review comments

At least 1 approving review is required to merge this pull request.

Assignees

@spikecurtisspikecurtis

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@spikecurtis@mafredri

[8]ページ先頭

©2009-2025 Movatter.jp