Ver código fonte

Merge pull request #1803 from fcrisciani/ipvs-hardening

IPVS fix
Madhu Venugopal 8 anos atrás
pai
commit
a5747af4c2
1 arquivos alterados com 3 adições e 2 exclusões
  1. 3 2
      libnetwork/service_common.go

+ 3 - 2
libnetwork/service_common.go

@@ -237,6 +237,8 @@ func (c *controller) addServiceBinding(svcName, svcID, nID, eID, containerName s
 		// Create a new load balancer if we are seeing this
 		// Create a new load balancer if we are seeing this
 		// network attachment on the service for the first
 		// network attachment on the service for the first
 		// time.
 		// time.
+		fwMarkCtrMu.Lock()
+
 		lb = &loadBalancer{
 		lb = &loadBalancer{
 			vip:      vip,
 			vip:      vip,
 			fwMark:   fwMarkCtr,
 			fwMark:   fwMarkCtr,
@@ -244,7 +246,6 @@ func (c *controller) addServiceBinding(svcName, svcID, nID, eID, containerName s
 			service:  s,
 			service:  s,
 		}
 		}
 
 
-		fwMarkCtrMu.Lock()
 		fwMarkCtr++
 		fwMarkCtr++
 		fwMarkCtrMu.Unlock()
 		fwMarkCtrMu.Unlock()
 
 
@@ -342,7 +343,7 @@ func (c *controller) rmServiceBinding(svcName, svcID, nID, eID, containerName st
 
 
 	// Remove loadbalancer service(if needed) and backend in all
 	// Remove loadbalancer service(if needed) and backend in all
 	// sandboxes in the network only if the vip is valid.
 	// sandboxes in the network only if the vip is valid.
-	if len(vip) != 0 {
+	if len(vip) != 0 && entries == 0 {
 		n.(*network).rmLBBackend(ip, vip, lb.fwMark, ingressPorts, rmService)
 		n.(*network).rmLBBackend(ip, vip, lb.fwMark, ingressPorts, rmService)
 	}
 	}