瀏覽代碼

Purge vniTbl after cleaning up network sandbox

If we cleaned up a stale network sandbox and an entry for that exists in
vniTbl, then purge it from vniTbl. Otherwise when a new vxlan for that
vni is added to the network, we might destroy the network sandbox
created in the current life.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
Jana Radhakrishnan 9 年之前
父節點
當前提交
c79a49235d
共有 1 個文件被更改,包括 13 次插入0 次删除
  1. 13 0
      libnetwork/drivers/overlay/ov_network.go

+ 13 - 0
libnetwork/drivers/overlay/ov_network.go

@@ -475,6 +475,19 @@ func (n *network) cleanupStaleSandboxes() {
 				deleteVxlanByVNI(path, 0)
 				syscall.Unmount(path, syscall.MNT_DETACH)
 				os.Remove(path)
+
+				// Now that we have destroyed this
+				// sandbox, remove all references to
+				// it in vniTbl so that we don't
+				// inadvertently destroy the sandbox
+				// created in this life.
+				networkMu.Lock()
+				for vni, tblPath := range vniTbl {
+					if tblPath == path {
+						delete(vniTbl, vni)
+					}
+				}
+				networkMu.Unlock()
 			}
 
 			return nil