diff --git a/go-controller/pkg/cni/types/types.go b/go-controller/pkg/cni/types/types.go index 28013aa1774..05ed6167c3f 100644 --- a/go-controller/pkg/cni/types/types.go +++ b/go-controller/pkg/cni/types/types.go @@ -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 diff --git a/go-controller/pkg/ovn/secondary_localnet_network_controller.go b/go-controller/pkg/ovn/secondary_localnet_network_controller.go index 33ba6e65314..9ccffa66d10 100644 --- a/go-controller/pkg/ovn/secondary_localnet_network_controller.go +++ b/go-controller/pkg/ovn/secondary_localnet_network_controller.go @@ -116,6 +116,13 @@ 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. @@ -123,9 +130,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: localnetPortNetNameOption, } intVlanID := int(oc.Vlan()) if intVlanID != 0 { diff --git a/go-controller/pkg/util/multi_network.go b/go-controller/pkg/util/multi_network.go index 19c5ec0a317..9b48d7251f9 100644 --- a/go-controller/pkg/util/multi_network.go +++ b/go-controller/pkg/util/multi_network.go @@ -36,6 +36,7 @@ type BasicNetInfo interface { ExcludeSubnets() []*net.IPNet Vlan() uint AllowsPersistentIPs() bool + Alias() string // utility methods CompareNetInfo(BasicNetInfo) bool @@ -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 @@ -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 @@ -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 @@ -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