From 2d278dece07e432b1246fb286ee1c67be7187d86 Mon Sep 17 00:00:00 2001 From: Sandeep Bansal Date: Thu, 15 Jun 2017 13:24:46 -0700 Subject: [PATCH] Fixes docker daemon not restarting after endpoint leak on windows with transaprent network Signed-off-by: Sandeep Bansal --- libnetwork/drivers/windows/windows_store.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/libnetwork/drivers/windows/windows_store.go b/libnetwork/drivers/windows/windows_store.go index 3c5cb04e21..bbed5aeaa2 100644 --- a/libnetwork/drivers/windows/windows_store.go +++ b/libnetwork/drivers/windows/windows_store.go @@ -232,9 +232,12 @@ func (ep *hnsEndpoint) MarshalJSON() ([]byte, error) { epMap["Type"] = ep.Type epMap["profileID"] = ep.profileID epMap["MacAddress"] = ep.macAddress.String() - epMap["Addr"] = ep.addr.String() - epMap["gateway"] = ep.gateway.String() - + if ep.addr.IP != nil { + epMap["Addr"] = ep.addr.String() + } + if ep.gateway != nil { + epMap["gateway"] = ep.gateway.String() + } epMap["epOption"] = ep.epOption epMap["epConnectivity"] = ep.epConnectivity epMap["PortMapping"] = ep.portMapping @@ -251,7 +254,6 @@ func (ep *hnsEndpoint) UnmarshalJSON(b []byte) error { if err = json.Unmarshal(b, &epMap); err != nil { return fmt.Errorf("Failed to unmarshal to endpoint: %v", err) } - if v, ok := epMap["MacAddress"]; ok { if ep.macAddress, err = net.ParseMAC(v.(string)); err != nil { return types.InternalErrorf("failed to decode endpoint MAC address (%s) after json unmarshal: %v", v.(string), err) @@ -262,7 +264,9 @@ func (ep *hnsEndpoint) UnmarshalJSON(b []byte) error { return types.InternalErrorf("failed to decode endpoint IPv4 address (%s) after json unmarshal: %v", v.(string), err) } } - + if v, ok := epMap["gateway"]; ok { + ep.gateway = net.ParseIP(v.(string)) + } ep.id = epMap["id"].(string) ep.Type = epMap["Type"].(string) ep.nid = epMap["nid"].(string)