Skip to content

Commit

Permalink
Merge pull request moby#46365 from thaJeztah/libnetwork_endpoint_nits
Browse files Browse the repository at this point in the history
libnetwork: Endpoint: fixing some nits
  • Loading branch information
thaJeztah authored Sep 20, 2023
2 parents 4dbfe7e + 8c6a46f commit 1ed5d91
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions libnetwork/endpoint_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,28 +272,24 @@ func (epi *EndpointInterface) SetNames(srcName string, dstPrefix string) error {
func (ep *Endpoint) InterfaceName() driverapi.InterfaceNameInfo {
ep.mu.Lock()
defer ep.mu.Unlock()

if ep.iface != nil {
return ep.iface
}

return nil
return ep.iface
}

// AddStaticRoute adds a route to the sandbox.
// It may be used in addition to or instead of a default gateway (as above).
func (ep *Endpoint) AddStaticRoute(destination *net.IPNet, routeType int, nextHop net.IP) error {
ep.mu.Lock()
defer ep.mu.Unlock()

r := types.StaticRoute{Destination: destination, RouteType: routeType, NextHop: nextHop}

if routeType == types.NEXTHOP {
// If the route specifies a next-hop, then it's loosely routed (i.e. not bound to a particular interface).
ep.joinInfo.StaticRoutes = append(ep.joinInfo.StaticRoutes, &r)
ep.joinInfo.StaticRoutes = append(ep.joinInfo.StaticRoutes, &types.StaticRoute{
Destination: destination,
RouteType: routeType,
NextHop: nextHop,
})
} else {
// If the route doesn't specify a next-hop, it must be a connected route, bound to an interface.
ep.iface.routes = append(ep.iface.routes, r.Destination)
ep.iface.routes = append(ep.iface.routes, destination)
}
return nil
}
Expand Down

0 comments on commit 1ed5d91

Please sign in to comment.