Skip to content

Commit

Permalink
Enable local host to local pod connectivity in Windows VXLAN
Browse files Browse the repository at this point in the history
  • Loading branch information
ksubrmnn committed Feb 4, 2019
1 parent 403cffd commit fc9cdb1
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
26 changes: 25 additions & 1 deletion backend/vxlan/device_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"encoding/json"
"fmt"
"github.com/Microsoft/hcsshim"
"github.com/Microsoft/hcsshim/hcn"
"github.com/buger/jsonparser"
"github.com/coreos/flannel/pkg/ip"
log "github.com/golang/glog"
Expand Down Expand Up @@ -129,7 +130,30 @@ func ensureNetwork(expectedNetwork *hcsshim.HNSNetwork, expectedVSID int64, expe
}

log.Infof("Created HNSNetwork %s", networkName)
return newNetwork, nil
existingNetwork = newNetwork
}

existingNetworkV2, err := hcn.GetNetworkByID(existingNetwork.Id)
if err != nil {
return nil, errors.Annotatef(err, "Could not find vxlan0 in V2")
}

addHostRoute := true
for _, policy := range existingNetworkV2.Policies {
if policy.Type == hcn.HostRoute {
addHostRoute = false
}
}
if addHostRoute {
hostRoutePolicy := hcn.NetworkPolicy{
Type: hcn.HostRoute,
Settings: []byte("{}"),
}

networkRequest := hcn.PolicyNetworkRequest{
Policies: []hcn.NetworkPolicy{hostRoutePolicy},
}
existingNetworkV2.AddPolicy(networkRequest)
}

return existingNetwork, nil
Expand Down
5 changes: 5 additions & 0 deletions backend/vxlan/vxlan_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ func (be *VXLANBackend) RegisterNetwork(ctx context.Context, wg sync.WaitGroup,
return nil, fmt.Errorf("Cannot get HNS networks [%+v]", err)
}

err = hcn.RemoteSubnetSupported()
if err != nil {
return nil, err
}

var remoteDrMac string
var providerAddress string
for _, hnsNetwork := range hnsNetworks {
Expand Down

0 comments on commit fc9cdb1

Please sign in to comment.