Skip to content

Commit

Permalink
Fallback option for MCLAG/ESLAG
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeymatov committed Feb 28, 2024
1 parent 5f42542 commit 8ca218c
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 8 deletions.
4 changes: 4 additions & 0 deletions api/wiring/v1alpha2/connection_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ type ConnMCLAG struct {
Links []ServerToSwitchLink `json:"links,omitempty"`
// ServerFacingConnectionConfig defines any server-facing connection (unbundled, bundled, mclag, etc.) configuration
ServerFacingConnectionConfig `json:",inline"`
// Fallback is the optional flag that used to idicate one of the links in LACP port channel to be used as a fallback link
Fallback bool `json:"fallback,omitempty"`
}

// ConnESLAG defines the ESLAG connection (port channel, single server to 2-4 switches with multiple links)
Expand All @@ -138,6 +140,8 @@ type ConnESLAG struct {
Links []ServerToSwitchLink `json:"links,omitempty"`
// ServerFacingConnectionConfig defines any server-facing connection (unbundled, bundled, eslag, etc.) configuration
ServerFacingConnectionConfig `json:",inline"`
// Fallback is the optional flag that used to idicate one of the links in LACP port channel to be used as a fallback link
Fallback bool `json:"fallback,omitempty"`
}

// SwitchToSwitchLink defines the switch-to-switch link
Expand Down
10 changes: 10 additions & 0 deletions config/crd/bases/agent.githedgehog.com_agents.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,11 @@ spec:
description: ESLAG defines the ESLAG connection (port channel,
single server to 2-4 switches with multiple links)
properties:
fallback:
description: Fallback is the optional flag that used to
idicate one of the links in LACP port channel to be used
as a fallback link
type: boolean
links:
description: Links is the list of server-to-switch links
items:
Expand Down Expand Up @@ -399,6 +404,11 @@ spec:
description: MCLAG defines the MCLAG connection (port channel,
single server to pair of switches with multiple links)
properties:
fallback:
description: Fallback is the optional flag that used to
idicate one of the links in LACP port channel to be used
as a fallback link
type: boolean
links:
description: Links is the list of server-to-switch links
items:
Expand Down
10 changes: 10 additions & 0 deletions config/crd/bases/wiring.githedgehog.com_connections.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ spec:
description: ESLAG defines the ESLAG connection (port channel, single
server to 2-4 switches with multiple links)
properties:
fallback:
description: Fallback is the optional flag that used to idicate
one of the links in LACP port channel to be used as a fallback
link
type: boolean
links:
description: Links is the list of server-to-switch links
items:
Expand Down Expand Up @@ -244,6 +249,11 @@ spec:
description: MCLAG defines the MCLAG connection (port channel, single
server to pair of switches with multiple links)
properties:
fallback:
description: Fallback is the optional flag that used to idicate
one of the links in LACP port channel to be used as a fallback
link
type: boolean
links:
description: Links is the list of server-to-switch links
items:
Expand Down
2 changes: 2 additions & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,7 @@ _Appears in:_
| --- | --- |
| `links` _[ServerToSwitchLink](#servertoswitchlink) array_ | Links is the list of server-to-switch links |
| `mtu` _integer_ | MTU is the MTU to be configured on the switch port or port channel |
| `fallback` _boolean_ | Fallback is the optional flag that used to idicate one of the links in LACP port channel to be used as a fallback link |


#### ConnExternal
Expand Down Expand Up @@ -783,6 +784,7 @@ _Appears in:_
| --- | --- |
| `links` _[ServerToSwitchLink](#servertoswitchlink) array_ | Links is the list of server-to-switch links |
| `mtu` _integer_ | MTU is the MTU to be configured on the switch port or port channel |
| `fallback` _boolean_ | Fallback is the optional flag that used to idicate one of the links in LACP port channel to be used as a fallback link |


#### ConnMCLAGDomain
Expand Down
8 changes: 7 additions & 1 deletion pkg/agent/dozer/bcm/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -894,12 +894,14 @@ func planServerConnections(agent *agentapi.Agent, spec *dozer.Spec) error {
connType := ""
var mtu *uint16
var links []wiringapi.ServerToSwitchLink
var fallback bool

if conn.MCLAG != nil {
connType = "MCLAG"
if conn.MCLAG.MTU != 0 {
mtu = uint16Ptr(conn.MCLAG.MTU)
}
fallback = conn.MCLAG.Fallback
links = conn.MCLAG.Links
} else if conn.Bundled != nil {
connType = "Bundled"
Expand All @@ -912,6 +914,7 @@ func planServerConnections(agent *agentapi.Agent, spec *dozer.Spec) error {
if conn.ESLAG.MTU != 0 {
mtu = uint16Ptr(conn.ESLAG.MTU)
}
fallback = conn.ESLAG.Fallback
links = conn.ESLAG.Links
} else {
continue
Expand Down Expand Up @@ -950,6 +953,9 @@ func planServerConnections(agent *agentapi.Agent, spec *dozer.Spec) error {
spec.MCLAGInterfaces[connPortChannelName] = &dozer.SpecMCLAGInterface{
DomainID: MCLAG_DOMAIN_ID,
}
spec.PortChannelConfigs[connPortChannelName] = &dozer.SpecPortChannelConfig{
Fallback: boolPtr(fallback),
}
} else if connType == "ESLAG" {
mac, err := net.ParseMAC(agent.Spec.Config.ESLAGMACBase)
if err != nil {
Expand All @@ -967,9 +973,9 @@ func planServerConnections(agent *agentapi.Agent, spec *dozer.Spec) error {
binary.BigEndian.PutUint64(newMACVal, macVal)

mac = newMACVal[2:]

spec.PortChannelConfigs[connPortChannelName] = &dozer.SpecPortChannelConfig{
SystemMAC: stringPtr(mac.String()),
Fallback: boolPtr(fallback),
}

esi := strings.ReplaceAll(agent.Spec.Config.ESLAGESIPrefix+mac.String(), ":", "")
Expand Down
15 changes: 8 additions & 7 deletions pkg/agent/dozer/bcm/spec_pc_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,16 @@ var specPortChannelConfigsEnforcer = &DefaultMapEnforcer[string, *dozer.SpecPort

var specPortChannelConfigEnforcer = &DefaultValueEnforcer[string, *dozer.SpecPortChannelConfig]{
Summary: "PortChannel Config %s",
Path: "/sonic-portchannel/PORTCHANNEL/PORTCHANNEL_LIST[name=%s]/system_mac",
Path: "/sonic-portchannel/PORTCHANNEL/PORTCHANNEL_LIST[name=%s]",
UpdateWeight: ActionWeightPortChannelConfigUpdate,
DeleteWeight: ActionWeightPortChannelConfigDelete,
Marshal: func(key string, value *dozer.SpecPortChannelConfig) (ygot.ValidatedGoStruct, error) {
return &oc.SonicPortchannel_SonicPortchannel_PORTCHANNEL_PORTCHANNEL_LIST{
SystemMac: value.SystemMAC,
}, nil
ret := &oc.SonicPortchannel_SonicPortchannel_PORTCHANNEL_PORTCHANNEL_LIST{}
if value.SystemMAC != nil {
ret.SystemMac = value.SystemMAC
}
ret.Fallback = value.Fallback
return ret, nil
},
}

Expand All @@ -50,12 +53,10 @@ func unmarshalActualPortChannelConfigs(ocVal *oc.SonicPortchannel_SonicPortchann
}

for name, portChannel := range ocVal.PORTCHANNEL.PORTCHANNEL_LIST {
if portChannel.SystemMac == nil {
continue
}

portChannelConfigs[name] = &dozer.SpecPortChannelConfig{
SystemMAC: portChannel.SystemMac,
Fallback: portChannel.Fallback,
}
}

Expand Down
1 change: 1 addition & 0 deletions pkg/agent/dozer/dozer.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ type SpecSuppressVLANNeigh struct{}

type SpecPortChannelConfig struct {
SystemMAC *string `json:"systemMAC,omitempty"`
Fallback *bool `json:"fallback,omitempty"`
}

type SpecLSTGroup struct {
Expand Down

0 comments on commit 8ca218c

Please sign in to comment.