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 Apr 30, 2024
1 parent 361d573 commit 6f056ff
Show file tree
Hide file tree
Showing 3 changed files with 22 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 @@ -33,6 +33,8 @@ type NetConf struct {
// restart.
AllowPersistentIPs bool `json:"allowPersistentIPs,omitempty"`

Alias string `json:"alias,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
11 changes: 8 additions & 3 deletions go-controller/pkg/ovn/secondary_localnet_network_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,16 +116,21 @@ func (oc *SecondaryLocalnetNetworkController) Init() error {
return err
}

localnetPortNetNameOption := map[string]string{
"network_name": oc.GetNetworkName(),
}
if oc.NetInfo.Alias() != "" {
localnetPortNetNameOption["network_name"] = oc.NetInfo.Alias()
}

// Add external interface as a logical port to external_switch.
// This is a learning switch port with "unknown" address. The external
// world is accessed via this port.
logicalSwitchPort := nbdb.LogicalSwitchPort{
Name: oc.GetNetworkScopedName(types.OVNLocalnetPort),
Addresses: []string{"unknown"},
Type: "localnet",
Options: map[string]string{
"network_name": oc.GetNetworkName(),
},
Options: localnetPortNetNameOption,
}
intVlanID := int(oc.Vlan())
if intVlanID != 0 {
Expand Down
12 changes: 12 additions & 0 deletions go-controller/pkg/util/multi_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type BasicNetInfo interface {
ExcludeSubnets() []*net.IPNet
Vlan() uint
AllowsPersistentIPs() bool
Alias() string

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

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

// SecondaryNetInfo holds the network name information for secondary network if non-nil
type secondaryNetInfo struct {
netName string
Expand All @@ -148,6 +153,8 @@ type secondaryNetInfo struct {
// all net-attach-def NAD names for this network, used to determine if a pod needs
// to be plumbed for this network
nadNames sync.Map

localnetAlias string
}

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

func (nInfo *secondaryNetInfo) Alias() 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 @@ -305,6 +316,7 @@ func newLocalnetNetConfInfo(netconf *ovncnitypes.NetConf) (NetInfo, error) {
mtu: netconf.MTU,
vlan: uint(netconf.VLANID),
allowPersistentIPs: netconf.AllowPersistentIPs,
localnetAlias: netconf.Alias,
}
ni.ipv4mode, ni.ipv6mode = getIPMode(subnets)
return ni, nil
Expand Down

0 comments on commit 6f056ff

Please sign in to comment.