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

Collision Possible When Assigning Port For Libvirt #201

Open
ndonegan opened this issue Jan 27, 2016 · 1 comment
Open

Collision Possible When Assigning Port For Libvirt #201

ndonegan opened this issue Jan 27, 2016 · 1 comment

Comments

@ndonegan
Copy link
Contributor

At the moment, there's a rare condition when the random port chosen by OZ for libvirt can conflict with already used ports. The chances of it happening are low, but it does happen. See https://github.com/clalancette/oz/blob/master/oz/Guest.py#L229

Suggested fix would be to use socket to bind to port 0 first, which will choose a random free port which can be used by listen_port. There's still the slight chance of a race condition where something listens between the bind and libvirt starting up, but the odds are a lot less. At the very least, it's not going to conflict with long running processes listening on tcp ports in that range.

clalancette pushed a commit that referenced this issue Jan 28, 2016
This reduces the chance of conflicting with another process, and possibly fixes clalancette/oz/#201
@clalancette
Copy link
Owner

I've applied your patch, which hopefully should improve things. I'm actually going to leave this open to investigate having libvirt open the port for us, which would close the remaining race.

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

No branches or pull requests

2 participants