Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove l2bridge checker on windows and l2tunnel mode #3113

Merged
merged 4 commits into from
Nov 12, 2024
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: 0 additions & 1 deletion cni/azure-windows-swift-overlay-dualstack.conflist
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"plugins": [
{
"type": "azure-vnet",
"mode": "bridge",
"bridge": "azure0",
"capabilities": {
"portMappings": true,
Expand Down
1 change: 0 additions & 1 deletion cni/azure-windows-swift-overlay.conflist
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"plugins": [
{
"type": "azure-vnet",
"mode": "bridge",
"bridge": "azure0",
"capabilities": {
"portMappings": true,
Expand Down
1 change: 0 additions & 1 deletion cni/azure-windows-swift.conflist
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"plugins": [
{
"type": "azure-vnet",
"mode": "bridge",
"bridge": "azure0",
"executionMode": "v4swift",
"capabilities": {
Expand Down
3 changes: 1 addition & 2 deletions cns/hnsclient/hnsclient_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ const (

// HNS network types
hnsL2Bridge = "l2bridge"
hnsL2Tunnel = "l2tunnel"

// hcnSchemaVersionMajor indicates major version number for hcn schema
hcnSchemaVersionMajor = 2
Expand Down Expand Up @@ -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)
}

Expand Down
2 changes: 1 addition & 1 deletion cns/service/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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: "",
},
Expand Down
23 changes: 2 additions & 21 deletions network/network_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
const (
// HNS network types.
hnsL2bridge = "l2bridge"
hnsL2tunnel = "l2tunnel"
CnetAddressSpace = "cnetAddressSpace"
vEthernetAdapterPrefix = "vEthernet"
baseDecimal = 10
Expand Down Expand Up @@ -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),
}
Expand All @@ -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{
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down
44 changes: 41 additions & 3 deletions network/network_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ func TestNewAndDeleteNetworkImplHnsV2(t *testing.T) {
}

err = nm.deleteNetworkImplHnsV2(network)

if err != nil {
fmt.Printf("+%v", err)
t.Fatal(err)
Expand Down Expand Up @@ -95,7 +94,6 @@ func TestSuccesfulNetworkCreationWhenAlreadyExists(t *testing.T) {
}

_, err = nm.newNetworkImplHnsV2(nwInfo, extInterface)

if err != nil {
fmt.Printf("+%v", err)
t.Fatal(err)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
Loading