diff --git a/cni/azure-windows-swift-overlay-dualstack.conflist b/cni/azure-windows-swift-overlay-dualstack.conflist index cd5003c8d..4b4e06e59 100644 --- a/cni/azure-windows-swift-overlay-dualstack.conflist +++ b/cni/azure-windows-swift-overlay-dualstack.conflist @@ -5,7 +5,6 @@ "plugins": [ { "type": "azure-vnet", - "mode": "bridge", "bridge": "azure0", "capabilities": { "portMappings": true, diff --git a/cni/azure-windows-swift-overlay.conflist b/cni/azure-windows-swift-overlay.conflist index cd5003c8d..4b4e06e59 100644 --- a/cni/azure-windows-swift-overlay.conflist +++ b/cni/azure-windows-swift-overlay.conflist @@ -5,7 +5,6 @@ "plugins": [ { "type": "azure-vnet", - "mode": "bridge", "bridge": "azure0", "capabilities": { "portMappings": true, diff --git a/cni/azure-windows-swift.conflist b/cni/azure-windows-swift.conflist index 8f9fafee3..962a9cab6 100644 --- a/cni/azure-windows-swift.conflist +++ b/cni/azure-windows-swift.conflist @@ -5,7 +5,6 @@ "plugins": [ { "type": "azure-vnet", - "mode": "bridge", "bridge": "azure0", "executionMode": "v4swift", "capabilities": { diff --git a/cns/hnsclient/hnsclient_windows.go b/cns/hnsclient/hnsclient_windows.go index 58bf884b7..991e2c490 100644 --- a/cns/hnsclient/hnsclient_windows.go +++ b/cns/hnsclient/hnsclient_windows.go @@ -30,7 +30,6 @@ const ( // HNS network types hnsL2Bridge = "l2bridge" - hnsL2Tunnel = "l2tunnel" // hcnSchemaVersionMajor indicates major version number for hcn schema hcnSchemaVersionMajor = 2 @@ -145,7 +144,7 @@ func CreateDefaultExtNetwork(networkType string) error { return nil } - if networkType != hnsL2Bridge && networkType != hnsL2Tunnel { + if networkType != hnsL2Bridge { return fmt.Errorf("Invalid hns network type %s", networkType) } diff --git a/cns/service/main.go b/cns/service/main.go index 5d0855b39..ffe51ca9c 100644 --- a/cns/service/main.go +++ b/cns/service/main.go @@ -244,7 +244,7 @@ var args = acn.ArgumentList{ { Name: acn.OptCreateDefaultExtNetworkType, Shorthand: acn.OptCreateDefaultExtNetworkTypeAlias, - Description: "Create default external network for windows platform with the specified type (l2bridge or l2tunnel)", + Description: "Create default external network for windows platform with the specified type (l2bridge)", Type: "string", DefaultValue: "", }, diff --git a/network/network_windows.go b/network/network_windows.go index 4d870827c..a467b2098 100644 --- a/network/network_windows.go +++ b/network/network_windows.go @@ -24,7 +24,6 @@ import ( const ( // HNS network types. hnsL2bridge = "l2bridge" - hnsL2tunnel = "l2tunnel" CnetAddressSpace = "cnetAddressSpace" vEthernetAdapterPrefix = "vEthernet" baseDecimal = 10 @@ -113,6 +112,7 @@ func (nm *networkManager) newNetworkImplHnsV1(nwInfo *EndpointInfo, extIf *exter // Initialize HNS network. hnsNetwork := &hcsshim.HNSNetwork{ Name: nwInfo.NetworkID, + Type: hnsL2bridge, NetworkAdapterName: networkAdapterName, Policies: policy.SerializePolicies(policy.NetworkPolicy, nwInfo.NetworkPolicies, nil, false, false), } @@ -132,16 +132,6 @@ func (nm *networkManager) newNetworkImplHnsV1(nwInfo *EndpointInfo, extIf *exter vlanid = (int)(vlanPolicy.VLAN) } - // Set network mode. - switch nwInfo.Mode { - case opModeBridge: - hnsNetwork.Type = hnsL2bridge - case opModeTunnel: - hnsNetwork.Type = hnsL2tunnel - default: - return nil, errNetworkModeInvalid - } - // Populate subnets. for _, subnet := range nwInfo.Subnets { hnsSubnet := hcsshim.Subnet{ @@ -233,6 +223,7 @@ func (nm *networkManager) configureHcnNetwork(nwInfo *EndpointInfo, extIf *exter // Initialize HNS network. hcnNetwork := &hcn.HostComputeNetwork{ Name: nwInfo.NetworkID, + Type: hcn.L2Bridge, Ipams: []hcn.Ipam{ { Type: hcnIpamTypeStatic, @@ -287,16 +278,6 @@ func (nm *networkManager) configureHcnNetwork(nwInfo *EndpointInfo, extIf *exter vlanid = (int)(vlanID) } - // Set network mode. - switch nwInfo.Mode { - case opModeBridge: - hcnNetwork.Type = hcn.L2Bridge - case opModeTunnel: - hcnNetwork.Type = hcn.L2Tunnel - default: - return nil, errNetworkModeInvalid - } - // AccelnetNIC flag: hcn.EnableIov(9216) - treat Delegated/FrontendNIC also the same as Accelnet // For L1VH with accelnet, hcn.DisableHostPort and hcn.EnableIov must be configured if nwInfo.NICType == cns.NodeNetworkInterfaceFrontendNIC { diff --git a/network/network_windows_test.go b/network/network_windows_test.go index ac9f111c0..eabe11464 100644 --- a/network/network_windows_test.go +++ b/network/network_windows_test.go @@ -60,7 +60,6 @@ func TestNewAndDeleteNetworkImplHnsV2(t *testing.T) { } err = nm.deleteNetworkImplHnsV2(network) - if err != nil { fmt.Printf("+%v", err) t.Fatal(err) @@ -95,7 +94,6 @@ func TestSuccesfulNetworkCreationWhenAlreadyExists(t *testing.T) { } _, err = nm.newNetworkImplHnsV2(nwInfo, extInterface) - if err != nil { fmt.Printf("+%v", err) t.Fatal(err) @@ -468,7 +466,6 @@ func TestNewAndDeleteNetworkImplHnsV2ForDelegated(t *testing.T) { } err = nm.deleteNetworkImpl(network, cns.NodeNetworkInterfaceFrontendNIC) - if err != nil { fmt.Printf("+%v", err) t.Fatal(err) @@ -522,6 +519,47 @@ func TestTransparentNetworkCreationForDelegated(t *testing.T) { } } +// Test Configure HNC network for infraNIC ensuring the hcn network type is always l2 bridge +func TestConfigureHCNNetworkInfraNIC(t *testing.T) { + expectedHcnNetworkType := hcn.L2Bridge + + nm := &networkManager{ + ExternalInterfaces: map[string]*externalInterface{}, + } + + extIf := externalInterface{ + Name: "eth0", + } + + nwInfo := &EndpointInfo{ + AdapterName: "eth0", + NetworkID: "d3e97a83-ba4c-45d5-ba88-dc56757ece28", + MasterIfName: "eth0", + NICType: cns.InfraNIC, + IfIndex: 1, + EndpointID: "753d3fb6-e9b3-49e2-a109-2acc5dda61f1", + ContainerID: "545055c2-1462-42c8-b222-e75d0b291632", + NetNsPath: "fakeNameSpace", + IfName: "eth0", + Data: make(map[string]interface{}), + EndpointDNS: DNSInfo{ + Suffix: "10.0.0.0", + Servers: []string{"10.0.0.1, 10.0.0.2"}, + Options: nil, + }, + HNSNetworkID: "853d3fb6-e9b3-49e2-a109-2acc5dda61f1", + } + + hostComputeNetwork, err := nm.configureHcnNetwork(nwInfo, &extIf) + if err != nil { + t.Fatalf("Failed to configure hcn network for infraNIC interface due to: %v", err) + } + + if hostComputeNetwork.Type != expectedHcnNetworkType { + t.Fatalf("Host network mode is not configured as %v mode when interface NIC type is infraNIC", expectedHcnNetworkType) + } +} + // Test Configure HCN Network for Swiftv2 DelegatedNIC HostComputeNetwork fields func TestConfigureHCNNetworkSwiftv2DelegatedNIC(t *testing.T) { expectedSwiftv2NetworkMode := hcn.Transparent