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 bridge.

Signed-off-by: Daman Arora <aroradaman@gmail.com>
  • Loading branch information
aroradaman committed Feb 28, 2024
1 parent 23aba7c commit 911dc7f
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 25 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 interfaces 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 interfaces can be specified for the secondary network OVS bridge",
},
}
for _, tc := range tests {
Expand Down
4 changes: 2 additions & 2 deletions docs/secondary-network.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ data:
```

At the moment, Antrea supports only a single OVS bridge for secondary networks,
and supports only a single physical interface on the bridge. The physical
interface cannot be the Node's management interface, otherwise the Node's
and supports upto eight physical interfaces on the bridge. The physical
interfaces cannot be the Node's management interface, otherwise the Node's
management network connectivity can be broken after `antrea-agent` creates the
OVS bridge and moves the management interface to the bridge.

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
3 changes: 1 addition & 2 deletions pkg/config/agent/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,6 @@ type SecondaryNetworkConfig struct {

type OVSBridgeConfig struct {
BridgeName string `yaml:"bridgeName"`
// Names of physical interfaces to be connected to the bridge. At the moment,
// only a single physical interface is supported.
// Names of physical interfaces to be connected to the bridge.
PhysicalInterfaces []string `yaml:"physicalInterfaces,omitempty"`
}

0 comments on commit 911dc7f

Please sign in to comment.