Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cni/azure-windows.conflist
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"cniVersion": "0.3.0",
"name": "azure",
"adapterName" : "",
"plugins": [
{
"type": "azure-vnet",
Expand Down
1 change: 1 addition & 0 deletions cni/netconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ type NetworkConfig struct {
Type string `json:"type,omitempty"`
Mode string `json:"mode,omitempty"`
Master string `json:"master,omitempty"`
AdapterName string `json:"adapterName,omitempty"`
Bridge string `json:"bridge,omitempty"`
LogLevel string `json:"logLevel,omitempty"`
LogTarget string `json:"logTarget,omitempty"`
Expand Down
1 change: 1 addition & 0 deletions cni/network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,7 @@ func (plugin *netPlugin) Add(args *cniSkel.CmdArgs) error {
Id: networkId,
Mode: nwCfg.Mode,
MasterIfName: masterIfName,
AdapterName: nwCfg.AdapterName,
Subnets: []network.SubnetInfo{
{
Family: platform.AfINET,
Expand Down
1 change: 1 addition & 0 deletions network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ type network struct {
// NetworkInfo contains read-only information about a container network.
type NetworkInfo struct {
MasterIfName string
AdapterName string
Id string
Mode string
Subnets []SubnetInfo
Expand Down
28 changes: 26 additions & 2 deletions network/network_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,22 @@ func (nm *networkManager) newNetworkImplHnsV1(nwInfo *NetworkInfo, extIf *extern
)

networkAdapterName := extIf.Name

// Pass adapter name here if it is not empty, this is cause if we don't tell HNS which adapter to use
// it will just pick one randomly, this is a problem for customers that have multiple adapters
if nwInfo.AdapterName != "" {
networkAdapterName = nwInfo.AdapterName
}

// FixMe: Find a better way to check if a nic that is selected is not part of a vSwitch
// per hns team, the hns calls fails if passed a vSwitch interface
if strings.HasPrefix(networkAdapterName, vEthernetAdapterPrefix) {
log.Printf("[net] vSwitch detected, setting adapter name to empty")
networkAdapterName = ""
}

log.Printf("[net] Adapter name used with HNS is : %s", networkAdapterName)

// Initialize HNS network.
hnsNetwork := &hcsshim.HNSNetwork{
Name: nwInfo.Id,
Expand Down Expand Up @@ -216,8 +228,20 @@ func (nm *networkManager) configureHcnNetwork(nwInfo *NetworkInfo, extIf *extern

// Set hcn network adaptor name policy
// FixMe: Find a better way to check if a nic that is selected is not part of a vSwitch
if !strings.HasPrefix(extIf.Name, vEthernetAdapterPrefix) {
netAdapterNamePolicy, err := policy.GetHcnNetAdapterPolicy(extIf.Name)
// per hns team, the hns calls fails if passed a vSwitch interface
// Pass adapter name here if it is not empty, this is cause if we don't tell HNS which adapter to use
// it will just pick one randomly, this is a problem for customers that have multiple adapters
if nwInfo.AdapterName != "" || !strings.HasPrefix(extIf.Name, vEthernetAdapterPrefix) {
var adapterName string
if nwInfo.AdapterName != "" {
adapterName = nwInfo.AdapterName
} else {
adapterName = extIf.Name
}

log.Printf("[net] Adapter name used with HNS is : %s", adapterName)

netAdapterNamePolicy, err := policy.GetHcnNetAdapterPolicy(adapterName)
if err != nil {
log.Printf("[net] Failed to serialize network adapter policy due to error: %v", err)
return nil, err
Expand Down