daemon: buildEndpointInfo: minor refactor
store network.Name() in a variable to reduce repeatedly locking/unlocking of the network (although this is very, very minimal in the grand scheme of things). Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
eb3ace962d
commit
d1aa1979b4
1 changed files with 10 additions and 9 deletions
|
@ -1030,13 +1030,14 @@ func buildEndpointInfo(networkSettings *internalnetwork.Settings, n *libnetwork.
|
|||
return nil
|
||||
}
|
||||
|
||||
if _, ok := networkSettings.Networks[n.Name()]; !ok {
|
||||
networkSettings.Networks[n.Name()] = &internalnetwork.EndpointSettings{
|
||||
nwName := n.Name()
|
||||
if _, ok := networkSettings.Networks[nwName]; !ok {
|
||||
networkSettings.Networks[nwName] = &internalnetwork.EndpointSettings{
|
||||
EndpointSettings: &network.EndpointSettings{},
|
||||
}
|
||||
}
|
||||
networkSettings.Networks[n.Name()].NetworkID = n.ID()
|
||||
networkSettings.Networks[n.Name()].EndpointID = ep.ID()
|
||||
networkSettings.Networks[nwName].NetworkID = n.ID()
|
||||
networkSettings.Networks[nwName].EndpointID = ep.ID()
|
||||
|
||||
iface := epInfo.Iface()
|
||||
if iface == nil {
|
||||
|
@ -1044,19 +1045,19 @@ func buildEndpointInfo(networkSettings *internalnetwork.Settings, n *libnetwork.
|
|||
}
|
||||
|
||||
if iface.MacAddress() != nil {
|
||||
networkSettings.Networks[n.Name()].MacAddress = iface.MacAddress().String()
|
||||
networkSettings.Networks[nwName].MacAddress = iface.MacAddress().String()
|
||||
}
|
||||
|
||||
if iface.Address() != nil {
|
||||
ones, _ := iface.Address().Mask.Size()
|
||||
networkSettings.Networks[n.Name()].IPAddress = iface.Address().IP.String()
|
||||
networkSettings.Networks[n.Name()].IPPrefixLen = ones
|
||||
networkSettings.Networks[nwName].IPAddress = iface.Address().IP.String()
|
||||
networkSettings.Networks[nwName].IPPrefixLen = ones
|
||||
}
|
||||
|
||||
if iface.AddressIPv6() != nil && iface.AddressIPv6().IP.To16() != nil {
|
||||
onesv6, _ := iface.AddressIPv6().Mask.Size()
|
||||
networkSettings.Networks[n.Name()].GlobalIPv6Address = iface.AddressIPv6().IP.String()
|
||||
networkSettings.Networks[n.Name()].GlobalIPv6PrefixLen = onesv6
|
||||
networkSettings.Networks[nwName].GlobalIPv6Address = iface.AddressIPv6().IP.String()
|
||||
networkSettings.Networks[nwName].GlobalIPv6PrefixLen = onesv6
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
Loading…
Add table
Reference in a new issue