mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
libnetwork: use object-literal for some structs
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
50a7c67363
commit
f0be4d126d
2 changed files with 19 additions and 20 deletions
|
@ -539,25 +539,23 @@ func checkOverlap(nw *net.IPNet) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *network) restoreSubnetSandbox(s *subnet, brName, vxlanName string) error {
|
func (n *network) restoreSubnetSandbox(s *subnet, brName, vxlanName string) error {
|
||||||
sbox := n.sbox
|
|
||||||
|
|
||||||
// restore overlay osl sandbox
|
// restore overlay osl sandbox
|
||||||
Ifaces := make(map[string][]osl.IfaceOption)
|
ifaces := map[string][]osl.IfaceOption{
|
||||||
brIfaceOption := make([]osl.IfaceOption, 2)
|
brName + "+br": {
|
||||||
brIfaceOption = append(brIfaceOption, sbox.InterfaceOptions().Address(s.gwIP))
|
n.sbox.InterfaceOptions().Address(s.gwIP),
|
||||||
brIfaceOption = append(brIfaceOption, sbox.InterfaceOptions().Bridge(true))
|
n.sbox.InterfaceOptions().Bridge(true),
|
||||||
Ifaces[brName+"+br"] = brIfaceOption
|
},
|
||||||
|
}
|
||||||
err := sbox.Restore(Ifaces, nil, nil, nil)
|
if err := n.sbox.Restore(ifaces, nil, nil, nil); err != nil {
|
||||||
if err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
Ifaces = make(map[string][]osl.IfaceOption)
|
ifaces = map[string][]osl.IfaceOption{
|
||||||
vxlanIfaceOption := make([]osl.IfaceOption, 1)
|
vxlanName + "+vxlan": {
|
||||||
vxlanIfaceOption = append(vxlanIfaceOption, sbox.InterfaceOptions().Master(brName))
|
n.sbox.InterfaceOptions().Master(brName),
|
||||||
Ifaces[vxlanName+"+vxlan"] = vxlanIfaceOption
|
},
|
||||||
return sbox.Restore(Ifaces, nil, nil, nil)
|
}
|
||||||
|
return n.sbox.Restore(ifaces, nil, nil, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *network) setupSubnetSandbox(s *subnet, brName, vxlanName string) error {
|
func (n *network) setupSubnetSandbox(s *subnet, brName, vxlanName string) error {
|
||||||
|
|
|
@ -795,7 +795,6 @@ func (sb *sandbox) restoreOslSandbox() error {
|
||||||
// restore osl sandbox
|
// restore osl sandbox
|
||||||
Ifaces := make(map[string][]osl.IfaceOption)
|
Ifaces := make(map[string][]osl.IfaceOption)
|
||||||
for _, ep := range sb.endpoints {
|
for _, ep := range sb.endpoints {
|
||||||
var ifaceOptions []osl.IfaceOption
|
|
||||||
ep.Lock()
|
ep.Lock()
|
||||||
joinInfo := ep.joinInfo
|
joinInfo := ep.joinInfo
|
||||||
i := ep.iface
|
i := ep.iface
|
||||||
|
@ -806,7 +805,10 @@ func (sb *sandbox) restoreOslSandbox() error {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
ifaceOptions = append(ifaceOptions, sb.osSbox.InterfaceOptions().Address(i.addr), sb.osSbox.InterfaceOptions().Routes(i.routes))
|
ifaceOptions := []osl.IfaceOption{
|
||||||
|
sb.osSbox.InterfaceOptions().Address(i.addr),
|
||||||
|
sb.osSbox.InterfaceOptions().Routes(i.routes),
|
||||||
|
}
|
||||||
if i.addrv6 != nil && i.addrv6.IP.To16() != nil {
|
if i.addrv6 != nil && i.addrv6.IP.To16() != nil {
|
||||||
ifaceOptions = append(ifaceOptions, sb.osSbox.InterfaceOptions().AddressIPv6(i.addrv6))
|
ifaceOptions = append(ifaceOptions, sb.osSbox.InterfaceOptions().AddressIPv6(i.addrv6))
|
||||||
}
|
}
|
||||||
|
@ -816,7 +818,7 @@ func (sb *sandbox) restoreOslSandbox() error {
|
||||||
if len(i.llAddrs) != 0 {
|
if len(i.llAddrs) != 0 {
|
||||||
ifaceOptions = append(ifaceOptions, sb.osSbox.InterfaceOptions().LinkLocalAddresses(i.llAddrs))
|
ifaceOptions = append(ifaceOptions, sb.osSbox.InterfaceOptions().LinkLocalAddresses(i.llAddrs))
|
||||||
}
|
}
|
||||||
Ifaces[fmt.Sprintf("%s+%s", i.srcName, i.dstPrefix)] = ifaceOptions
|
Ifaces[i.srcName+i.dstPrefix] = ifaceOptions
|
||||||
if joinInfo != nil {
|
if joinInfo != nil {
|
||||||
routes = append(routes, joinInfo.StaticRoutes...)
|
routes = append(routes, joinInfo.StaticRoutes...)
|
||||||
}
|
}
|
||||||
|
@ -831,8 +833,7 @@ func (sb *sandbox) restoreOslSandbox() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// restore osl sandbox
|
// restore osl sandbox
|
||||||
err := sb.osSbox.Restore(Ifaces, routes, gwep.joinInfo.gw, gwep.joinInfo.gw6)
|
return sb.osSbox.Restore(Ifaces, routes, gwep.joinInfo.gw, gwep.joinInfo.gw6)
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sb *sandbox) populateNetworkResources(ep *endpoint) error {
|
func (sb *sandbox) populateNetworkResources(ep *endpoint) error {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue