From 5a5b7fee330867bc313a7b33a2e9611ffeea6328 Mon Sep 17 00:00:00 2001 From: Cheng-mean Liu Date: Tue, 21 Nov 2017 11:35:32 -0800 Subject: [PATCH] Added a new network creation driver option (disable_gatewaydns) for the Windows driver Signed-off-by: Cheng-mean Liu --- libnetwork/drivers/windows/labels.go | 3 +++ libnetwork/drivers/windows/windows.go | 14 ++++++++++++++ libnetwork/drivers/windows/windows_store.go | 2 +- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/libnetwork/drivers/windows/labels.go b/libnetwork/drivers/windows/labels.go index 6cb077cb4f..ead3ee6ddc 100644 --- a/libnetwork/drivers/windows/labels.go +++ b/libnetwork/drivers/windows/labels.go @@ -39,4 +39,7 @@ const ( // DisableDNS label DisableDNS = "com.docker.network.windowsshim.disable_dns" + + // DisableGatewayDNS label + DisableGatewayDNS = "com.docker.network.windowsshim.disable_gatewaydns" ) diff --git a/libnetwork/drivers/windows/windows.go b/libnetwork/drivers/windows/windows.go index 4a03e72d4a..964099cc36 100644 --- a/libnetwork/drivers/windows/windows.go +++ b/libnetwork/drivers/windows/windows.go @@ -44,6 +44,7 @@ type networkConfiguration struct { NetworkAdapterName string dbIndex uint64 dbExists bool + DisableGatewayDNS bool } // endpointConfiguration represents the user specified configuration for the sandbox endpoint @@ -177,6 +178,12 @@ func (d *driver) parseNetworkOptions(id string, genericOptions map[string]string config.DNSSuffix = value case DNSServers: config.DNSServers = value + case DisableGatewayDNS: + b, err := strconv.ParseBool(value) + if err != nil { + return nil, err + } + config.DisableGatewayDNS = b case MacPool: config.MacPools = make([]hcsshim.MacPool, 0) s := strings.Split(value, ",") @@ -589,7 +596,14 @@ func (d *driver) CreateEndpoint(nid, eid string, ifInfo driverapi.InterfaceInfo, endpointStruct.DNSServerList = strings.Join(epOption.DNSServers, ",") + // overwrite the ep DisableDNS option if DisableGatewayDNS was set to true during the network creation option + if n.config.DisableGatewayDNS { + logrus.Debugf("n.config.DisableGatewayDNS[%v] overwrites epOption.DisableDNS[%v]", n.config.DisableGatewayDNS, epOption.DisableDNS) + epOption.DisableDNS = n.config.DisableGatewayDNS + } + if n.driver.name == "nat" && !epOption.DisableDNS { + logrus.Debugf("endpointStruct.EnableInternalDNS =[%v]", endpointStruct.EnableInternalDNS) endpointStruct.EnableInternalDNS = true } diff --git a/libnetwork/drivers/windows/windows_store.go b/libnetwork/drivers/windows/windows_store.go index caa93c68fb..9f8a7b18f5 100644 --- a/libnetwork/drivers/windows/windows_store.go +++ b/libnetwork/drivers/windows/windows_store.go @@ -64,7 +64,7 @@ func (d *driver) populateNetworks() error { if err = d.createNetwork(ncfg); err != nil { logrus.Warnf("could not create windows network for id %s hnsid %s while booting up from persistent state: %v", ncfg.ID, ncfg.HnsID, err) } - logrus.Debugf("Network (%s) restored", ncfg.ID[0:7]) + logrus.Debugf("Network %v (%s) restored", d.name, ncfg.ID[0:7]) } return nil