Skip to content

Commit

Permalink
Allow multiple phy dev support for secondary network bridge
Browse files Browse the repository at this point in the history
Given that most SR-IOV have 8 queues, this commit allows adding
at-most 8 physical interfaces to the secondary OVS Bride.

Signed-off-by: Daman Arora <aroradaman@gmail.com>
  • Loading branch information
aroradaman committed Feb 28, 2024
1 parent 23aba7c commit cc8e5bb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 21 deletions.
4 changes: 2 additions & 2 deletions cmd/antrea-agent/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -739,8 +739,8 @@ func (o *Options) validateSecondaryNetworkConfig() error {
if brConfig.BridgeName == "" {
return fmt.Errorf("bridge name is not provided for the secondary network OVS bridge")
}
if len(brConfig.PhysicalInterfaces) > 1 {
return fmt.Errorf("at most one physical interface can be specified for the secondary network OVS bridge")
if len(brConfig.PhysicalInterfaces) > 8 {
return fmt.Errorf("at most eight physical interface can be specified for the secondary network OVS bridge")
}

return nil
Expand Down
4 changes: 2 additions & 2 deletions cmd/antrea-agent/options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,8 @@ func TestOptionsValidateSecondaryNetworkConfig(t *testing.T) {
name: "two interfaces",
featureGateValue: true,
ovsBridges: []string{"br1"},
physicalInterfaces: []string{"eth1", "eth2"},
expectedErr: "at most one physical interface can be specified for the secondary network OVS bridge",
physicalInterfaces: []string{"eth1", "eth2", "eth3", "eth4", "eth5", "eth6", "eth7", "eth8", "eth9"},
expectedErr: "at most eight physical interface can be specified for the secondary network OVS bridge",
},
}
for _, tc := range tests {
Expand Down
28 changes: 11 additions & 17 deletions pkg/agent/secondarynetwork/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import (
)

var (
// Funcs which will be orridden with mock funcs in tests.
// Funcs which will be overridden with mock funcs in tests.
interfaceByNameFn = net.InterfaceByName
newOVSBridgeFn = ovsconfig.NewOVSBridge
)
Expand Down Expand Up @@ -82,9 +82,7 @@ func createOVSBridge(bridges []agentconfig.OVSBridgeConfig, ovsdb *ovsdb.OVSDB)
// Only one OVS bridge is supported.
bridgeConfig := bridges[0]

phyInterface := ""
if len(bridgeConfig.PhysicalInterfaces) > 0 {
phyInterface = bridgeConfig.PhysicalInterfaces[0]
for _, phyInterface := range bridgeConfig.PhysicalInterfaces {
if _, err := interfaceByNameFn(phyInterface); err != nil {
return nil, fmt.Errorf("failed to get interface %s: %v", phyInterface, err)
}
Expand All @@ -96,21 +94,17 @@ func createOVSBridge(bridges []agentconfig.OVSBridgeConfig, ovsdb *ovsdb.OVSDB)
}
klog.InfoS("OVS bridge created", "bridge", bridgeConfig.BridgeName)

if phyInterface == "" {
return ovsBridgeClient, nil
}

if _, err := ovsBridgeClient.GetOFPort(phyInterface, false); err == nil {
klog.V(2).InfoS("Physical interface already connected to OVS bridge, skip the configuration", "device", phyInterface, "bridge", bridgeConfig.BridgeName)
return ovsBridgeClient, nil
}
for i, phyInterface := range bridgeConfig.PhysicalInterfaces {
if _, err := ovsBridgeClient.GetOFPort(phyInterface, false); err == nil {
klog.V(2).InfoS("Physical interface already connected to OVS bridge, skip the configuration", "device", phyInterface, "bridge", bridgeConfig.BridgeName)
continue
}

_, err := ovsBridgeClient.CreateUplinkPort(phyInterface, 0, map[string]interface{}{interfacestore.AntreaInterfaceTypeKey: interfacestore.AntreaUplink})
if err != nil {
return nil, fmt.Errorf("failed to create OVS uplink port %s: %v", phyInterface, err)
if _, err := ovsBridgeClient.CreateUplinkPort(phyInterface, int32(i), map[string]interface{}{interfacestore.AntreaInterfaceTypeKey: interfacestore.AntreaUplink}); err != nil {
return nil, fmt.Errorf("failed to create OVS uplink port %s: %v", phyInterface, err)
}
klog.InfoS("Physical interface added to OVS bridge", "device", phyInterface, "bridge", bridgeConfig.BridgeName)
}
klog.InfoS("Physical interface added to OVS bridge", "device", phyInterface, "bridge", bridgeConfig.BridgeName)

return ovsBridgeClient, nil
}

Expand Down

0 comments on commit cc8e5bb

Please sign in to comment.