diff --git a/backend/vxlan/vxlan_windows.go b/backend/vxlan/vxlan_windows.go index fd72f4c9f3..5f4c663b4e 100644 --- a/backend/vxlan/vxlan_windows.go +++ b/backend/vxlan/vxlan_windows.go @@ -33,7 +33,6 @@ import ( "golang.org/x/net/context" - "github.com/Microsoft/hcsshim" "github.com/Microsoft/hcsshim/hcn" "github.com/coreos/flannel/backend" "github.com/coreos/flannel/pkg/ip" @@ -123,17 +122,16 @@ func (be *VXLANBackend) RegisterNetwork(ctx context.Context, wg sync.WaitGroup, } log.Infof("VXLAN config: Name=%s MacPrefix=%s VNI=%d Port=%d GBP=%v DirectRouting=%v", cfg.Name, cfg.MacPrefix, cfg.VNI, cfg.Port, cfg.GBP, cfg.DirectRouting) - hnsNetworks, err := hcsshim.HNSListNetworkRequest("GET", "", "") + hnsNetworks, err := hcn.ListNetworks() if err != nil { - log.Infof("Cannot get HNS networks [%+v]", err) + return nil, fmt.Errorf("Cannot get HNS networks [%+v]", err) } var remoteDrMac string for _, hnsnetwork := range hnsNetworks { - if hnsnetwork.ManagementIP == be.extIface.ExtAddr.String() { - hcnnetwork, err := hcn.GetNetworkByID(hnsnetwork.Id) - policies := hcnnetwork.Policies - for _, policy := range policies { + if len(remoteDrMac) == 0 { + var providerAddress string + for _, policy := range hnsnetwork.Policies { if policy.Type == hcn.DrMacAddress { policySettings := hcn.DrMacAddressNetworkPolicySetting{} err = json.Unmarshal(policy.Settings, &policySettings) @@ -142,6 +140,17 @@ func (be *VXLANBackend) RegisterNetwork(ctx context.Context, wg sync.WaitGroup, } remoteDrMac = policySettings.Address } + if policy.Type == hcn.ProviderAddress { + policySettings := hcn.ProviderAddressEndpointPolicySetting{} + err = json.Unmarshal(policy.Settings, &policySettings) + if err != nil { + return nil, fmt.Errorf("Failed to unmarshal settings") + } + providerAddress = policySettings.ProviderAddress + } + } + if providerAddress != be.extIface.ExtAddr.String() { + remoteDrMac = "" } } }