Skip to content

Commit

Permalink
Use V2 to get networks
Browse files Browse the repository at this point in the history
  • Loading branch information
ksubrmnn committed Jan 2, 2019
1 parent ee48092 commit 5c142c2
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions backend/vxlan/vxlan_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand All @@ -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 = ""
}
}
}
Expand Down

0 comments on commit 5c142c2

Please sign in to comment.