Not only is this a more common idiom, it'll make finding bugs easier,
and it'll make porting to Go 1.1 easier.
Go 1.1 will not require the final return or panic because it has a
notion of terminating statements.
Upstream-commit: 22f1cc955dbf25132e69d126f8db0e5498bffbd2
Component: engine
Instead of allocating all possible IPs in advance, generate them as
needed.
A loop will cycle through all possible IPs in sequential order,
allocating them as needed and marking them as in use. Once the loop
exhausts all IPs, it will wrap back to the beginning. IPs that are
already in use will be skipped. When an IP is released, it will be
cleared and be available for allocation again.
Two decisions went into this design:
1) Minimize memory footprint by only allocating IPs that are actually
in use
2) Minimize reuse of released IP addresses to avoid sending traffic to
the wrong containers
As a side effect, the functions for IP/Mask<->int conversion have been
rewritten to never be able to fail in order to reduce the amount of
error returns.
Fixes gh-231
Upstream-commit: 6f9a67a7c7cb717ad1a575df3e4c0fd2ec8bc651
Component: engine
example:
2013/03/22 21:42:55 Unable to setup port networking: Failed to create DOCKER chain
(which was possibly introduced by commit 3c6b8bb88)
Upstream-commit: 371225520fc86fa58fadd182730b958a0f7ef9ab
Component: engine
Current Go tip (+74e65f07a0c8) and likely Go 1.1 does not build docker since net.TCPAddr struct has an additional field now for IPv6:
type TCPAddr struct {
IP IP
Port int
Zone string // IPv6 scoped addressing zone
}
Initializing the struct with named fields resolves this problem.
Upstream-commit: fac32cda5af7adcf0400f1fd8763764a498149f3
Component: engine
Implemented a port allocator and a port mapper that is able to forward TCP ports
from the host to the container.
Upstream-commit: 799ffa176399877e610ff2049dbf84610037a2be
Component: engine
is assigned to each container upon Start and released whenever the
container exits.
Upstream-commit: c08f5b2b8460f13f2094bae2a496bf308f7645bb
Component: engine