mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
4ceec05f1b
Added support to add a bridge the same way as any other interface into the namespace. The only difference is linux does not support creating the bridge in one namespace and moving it into another namespace. So for a bridge the sandbox code also does the creation of the bridge inside the sandbox. Also added an optional argument to interface which can now select one of the already existing interfaces as it's master. For this option to succeed the master interface should be of type bridge. Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
41 lines
763 B
Go
41 lines
763 B
Go
package sandbox
|
|
|
|
import "net"
|
|
|
|
func (i *nwIface) processInterfaceOptions(options ...IfaceOption) {
|
|
for _, opt := range options {
|
|
if opt != nil {
|
|
opt(i)
|
|
}
|
|
}
|
|
}
|
|
|
|
func (n *networkNamespace) Bridge(isBridge bool) IfaceOption {
|
|
return func(i *nwIface) {
|
|
i.bridge = isBridge
|
|
}
|
|
}
|
|
|
|
func (n *networkNamespace) Master(name string) IfaceOption {
|
|
return func(i *nwIface) {
|
|
i.master = name
|
|
}
|
|
}
|
|
|
|
func (n *networkNamespace) Address(addr *net.IPNet) IfaceOption {
|
|
return func(i *nwIface) {
|
|
i.address = addr
|
|
}
|
|
}
|
|
|
|
func (n *networkNamespace) AddressIPv6(addr *net.IPNet) IfaceOption {
|
|
return func(i *nwIface) {
|
|
i.addressIPv6 = addr
|
|
}
|
|
}
|
|
|
|
func (n *networkNamespace) Routes(routes []*net.IPNet) IfaceOption {
|
|
return func(i *nwIface) {
|
|
i.routes = routes
|
|
}
|
|
}
|