Pārlūkot izejas kodu

Merge pull request #46365 from thaJeztah/libnetwork_endpoint_nits

libnetwork: Endpoint: fixing some nits
Sebastiaan van Stijn 1 gadu atpakaļ
vecāks
revīzija
1ed5d91555
1 mainītis faili ar 7 papildinājumiem un 11 dzēšanām
  1. 7 11
      libnetwork/endpoint_info.go

+ 7 - 11
libnetwork/endpoint_info.go

@@ -272,12 +272,7 @@ 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.
@@ -285,15 +280,16 @@ func (ep *Endpoint) InterfaceName() driverapi.InterfaceNameInfo {
 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
 }