Skip to content

Commit

Permalink
Allow multiple phy dev support for secondary network bridge (#5959)
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, assuming
they are connected to different underlay L2 networks.

Signed-off-by: Daman Arora <aroradaman@gmail.com>
  • Loading branch information
aroradaman committed Mar 4, 2024
1 parent 393d186 commit 75205ef
Show file tree
Hide file tree
Showing 6 changed files with 20 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 @@ -734,8 +734,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
2 changes: 2 additions & 0 deletions pkg/agent/secondarynetwork/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ func TestCreateOVSBridge(t *testing.T) {
m.EXPECT().Create().Return(nil)
m.EXPECT().GetOFPort("eth1", false).Return(int32(0), ovsconfig.InvalidArgumentsError("port not found"))
m.EXPECT().CreateUplinkPort("eth1", int32(0), map[string]interface{}{"antrea-type": "uplink"}).Return("", nil)
m.EXPECT().GetOFPort("eth2", false).Return(int32(1), ovsconfig.InvalidArgumentsError("port not found"))
m.EXPECT().CreateUplinkPort("eth2", int32(1), map[string]interface{}{"antrea-type": "uplink"}).Return("", 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 @@ -398,7 +398,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 75205ef

Please sign in to comment.