Skip to content

Commit

Permalink
localnet, multi-homing: introduce localnet alias
Browse files Browse the repository at this point in the history
Having a different parameter to use as the network_name option of the
localnet logical switch port allows the admin to create multiple
physical network attachment without having to reconfigure the physical
OVN bridge mappings.

This improves the admin's UX (less operations) and solution scalability
(since a single mapping can be re-used) and thus the size of the
ovn-bridge-mappings string can be kept low.

Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
  • Loading branch information
maiqueb committed Oct 1, 2024
1 parent a83b6be commit 8bf02f3
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
2 changes: 2 additions & 0 deletions go-controller/pkg/cni/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ type NetConf struct {
// restart.
AllowPersistentIPs bool `json:"allowPersistentIPs,omitempty"`

Alias string `json:"localnetPortAlias,omitempty"`

// PciAddrs in case of using sriov or Auxiliry device name in case of SF
DeviceID string `json:"deviceID,omitempty"`
// LogFile to log all the messages from cni shim binary to
Expand Down
14 changes: 11 additions & 3 deletions go-controller/pkg/ovn/secondary_localnet_network_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,7 @@ func (oc *SecondaryLocalnetNetworkController) Init() error {
Name: oc.GetNetworkScopedName(types.OVNLocalnetPort),
Addresses: []string{"unknown"},
Type: "localnet",
Options: map[string]string{
"network_name": oc.GetNetworkName(),
},
Options: oc.localnetPortNetworkNameOptions(),
}
intVlanID := int(oc.Vlan())
if intVlanID != 0 {
Expand Down Expand Up @@ -342,3 +340,13 @@ func (oc *SecondaryLocalnetNetworkController) newRetryFramework(
resourceHandler,
)
}

func (oc *SecondaryLocalnetNetworkController) localnetPortNetworkNameOptions() map[string]string {
localnetLSPOptions := map[string]string{
"network_name": oc.GetNetworkName(),
}
if oc.PhysicalNetworkNameAlias() != "" {
localnetLSPOptions["network_name"] = oc.PhysicalNetworkNameAlias()
}
return localnetLSPOptions
}
13 changes: 13 additions & 0 deletions go-controller/pkg/util/multi_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ type BasicNetInfo interface {
JoinSubnets() []*net.IPNet
Vlan() uint
AllowsPersistentIPs() bool
PhysicalNetworkNameAlias() string

// utility methods
Equals(BasicNetInfo) bool
Expand Down Expand Up @@ -258,6 +259,10 @@ func (nInfo *DefaultNetInfo) AllowsPersistentIPs() bool {
return false
}

func (nInfo *DefaultNetInfo) PhysicalNetworkNameAlias() string {
return ""
}

// SecondaryNetInfo holds the network name information for secondary network if non-nil
type secondaryNetInfo struct {
netName string
Expand All @@ -278,6 +283,8 @@ type secondaryNetInfo struct {
// to be plumbed for this network
sync.Mutex
nadNames sets.Set[string]

localnetAlias string
}

// GetNetworkName returns the network name
Expand Down Expand Up @@ -416,6 +423,10 @@ func (nInfo *secondaryNetInfo) AllowsPersistentIPs() bool {
return nInfo.allowPersistentIPs
}

func (nInfo *secondaryNetInfo) PhysicalNetworkNameAlias() string {
return nInfo.localnetAlias
}

// IPMode returns the ipv4/ipv6 mode
func (nInfo *secondaryNetInfo) IPMode() (bool, bool) {
return nInfo.ipv4mode, nInfo.ipv6mode
Expand Down Expand Up @@ -513,6 +524,7 @@ func (nInfo *secondaryNetInfo) copy() *secondaryNetInfo {
excludeSubnets: nInfo.excludeSubnets,
joinSubnets: nInfo.joinSubnets,
nadNames: nInfo.nadNames.Clone(),
localnetAlias: nInfo.localnetAlias,
}

return c
Expand Down Expand Up @@ -579,6 +591,7 @@ func newLocalnetNetConfInfo(netconf *ovncnitypes.NetConf) (NetInfo, error) {
vlan: uint(netconf.VLANID),
allowPersistentIPs: netconf.AllowPersistentIPs,
nadNames: sets.Set[string]{},
localnetAlias: netconf.Alias,
}
ni.ipv4mode, ni.ipv6mode = getIPMode(subnets)
return ni, nil
Expand Down

0 comments on commit 8bf02f3

Please sign in to comment.