1
0
Fork 0
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:
Sebastiaan van Stijn 2022-10-01 22:39:23 +02:00
parent 50a7c67363
commit f0be4d126d
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C
2 changed files with 19 additions and 20 deletions

View file

@ -539,25 +539,23 @@ func checkOverlap(nw *net.IPNet) error {
}
func (n *network) restoreSubnetSandbox(s *subnet, brName, vxlanName string) error {
sbox := n.sbox
// restore overlay osl sandbox
Ifaces := make(map[string][]osl.IfaceOption)
brIfaceOption := make([]osl.IfaceOption, 2)
brIfaceOption = append(brIfaceOption, sbox.InterfaceOptions().Address(s.gwIP))
brIfaceOption = append(brIfaceOption, sbox.InterfaceOptions().Bridge(true))
Ifaces[brName+"+br"] = brIfaceOption
err := sbox.Restore(Ifaces, nil, nil, nil)
if err != nil {
ifaces := map[string][]osl.IfaceOption{
brName + "+br": {
n.sbox.InterfaceOptions().Address(s.gwIP),
n.sbox.InterfaceOptions().Bridge(true),
},
}
if err := n.sbox.Restore(ifaces, nil, nil, nil); err != nil {
return err
}
Ifaces = make(map[string][]osl.IfaceOption)
vxlanIfaceOption := make([]osl.IfaceOption, 1)
vxlanIfaceOption = append(vxlanIfaceOption, sbox.InterfaceOptions().Master(brName))
Ifaces[vxlanName+"+vxlan"] = vxlanIfaceOption
return sbox.Restore(Ifaces, nil, nil, nil)
ifaces = map[string][]osl.IfaceOption{
vxlanName + "+vxlan": {
n.sbox.InterfaceOptions().Master(brName),
},
}
return n.sbox.Restore(ifaces, nil, nil, nil)
}
func (n *network) setupSubnetSandbox(s *subnet, brName, vxlanName string) error {

View file

@ -795,7 +795,6 @@ func (sb *sandbox) restoreOslSandbox() error {
// restore osl sandbox
Ifaces := make(map[string][]osl.IfaceOption)
for _, ep := range sb.endpoints {
var ifaceOptions []osl.IfaceOption
ep.Lock()
joinInfo := ep.joinInfo
i := ep.iface
@ -806,7 +805,10 @@ func (sb *sandbox) restoreOslSandbox() error {
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 {
ifaceOptions = append(ifaceOptions, sb.osSbox.InterfaceOptions().AddressIPv6(i.addrv6))
}
@ -816,7 +818,7 @@ func (sb *sandbox) restoreOslSandbox() error {
if len(i.llAddrs) != 0 {
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 {
routes = append(routes, joinInfo.StaticRoutes...)
}
@ -831,8 +833,7 @@ func (sb *sandbox) restoreOslSandbox() error {
}
// restore osl sandbox
err := sb.osSbox.Restore(Ifaces, routes, gwep.joinInfo.gw, gwep.joinInfo.gw6)
return err
return sb.osSbox.Restore(Ifaces, routes, gwep.joinInfo.gw, gwep.joinInfo.gw6)
}
func (sb *sandbox) populateNetworkResources(ep *endpoint) error {