The defer was set after the switch, but various code-paths inside the switch could return with an error after the port was allocated / reserved, which could result in those ports not being released. This patch moves the defer into each individual branch of the switch to set it immediately after succesfully reserving the port. We can also remove a redundant ReleasePort from the cleanup function, as it's only called if an error occurs, and the defers already take care of that. Note that the cleanup function was handling errors returned by ReleasePort, but this function never returns an error, so it was fully redundant. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
libnetwork - networking for containers
Libnetwork provides a native Go implementation for connecting containers
The goal of libnetwork is to deliver a robust Container Network Model that provides a consistent programming interface and the required network abstractions for applications.
Design
Please refer to the design for more information.
Using libnetwork
There are many networking solutions available to suit a broad range of use-cases. libnetwork uses a driver / plugin model to support all of these solutions while abstracting the complexity of the driver implementations by exposing a simple and consistent Network Model to users.
Contributing
Want to hack on libnetwork? Docker's contributions guidelines apply.
Copyright and license
Code and documentation copyright 2015 Docker, inc. Code released under the Apache 2.0 license. Docs released under Creative commons.