frr

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 23, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeriveAddresses

func DeriveAddresses(cfg *network.Config) (underlayIP, overlayIP, bridgeMAC string, err error)

DeriveAddresses computes underlay IP, overlay IP, and bridge MAC from IPMI information and network configuration.

func DeriveBridgeMAC

func DeriveBridgeMAC(ipmiMAC string) string

DeriveBridgeMAC creates a locally-administered MAC from the IPMI MAC.

func DeriveIPFromOffset

func DeriveIPFromOffset(sourceIP, sourceSubnet, targetSubnet string) (string, error)

DeriveIPFromOffset calculates a target IP by applying the host offset from sourceIP within sourceSubnet to targetSubnet.

func RenderConfig

func RenderConfig(cfg *network.Config, underlayIP, overlayIP string, nics []string) (string, error)

RenderConfig generates the FRR configuration file content using a template. overlayIP is used to detect IPv6 and conditionally add the IPv6 address-family.

Types

type Commander

type Commander interface {
	Run(ctx context.Context, name string, args ...string) ([]byte, error)
}

Commander abstracts command execution for testing.

type ExecCommander

type ExecCommander struct{}

ExecCommander executes real system commands.

func (*ExecCommander) Run

func (e *ExecCommander) Run(ctx context.Context, name string, args ...string) ([]byte, error)

Run executes a command and returns combined output.

type FRRConfigBuilder

type FRRConfigBuilder struct {
	// contains filtered or unexported fields
}

FRRConfigBuilder constructs an FRR configuration programmatically. Methods can be called in any order; Build() emits sections in canonical FRR order regardless.

func NewFRRConfigBuilder

func NewFRRConfigBuilder(asn uint32, routerID string) *FRRConfigBuilder

NewFRRConfigBuilder creates a new builder with required BGP ASN and router-id.

func (*FRRConfigBuilder) Build

func (b *FRRConfigBuilder) Build() string

Build generates the complete FRR configuration string. Sections are emitted in canonical FRR order.

func (*FRRConfigBuilder) WithAddressFamily

func (b *FRRConfigBuilder) WithAddressFamily(afi, safi string) *FRRConfigBuilder

WithAddressFamily adds a BGP address-family (e.g. "ipv4"/"unicast", "l2vpn"/"evpn").

func (*FRRConfigBuilder) WithBFDProfile

func (b *FRRConfigBuilder) WithBFDProfile(name string, transmitMS, receiveMS uint32) *FRRConfigBuilder

WithBFDProfile adds a named BFD profile with transmit/receive intervals.

func (*FRRConfigBuilder) WithBGPTimers

func (b *FRRConfigBuilder) WithBGPTimers(keepalive, hold uint32) *FRRConfigBuilder

WithBGPTimers sets BGP keepalive and hold timers (seconds). If zero, FRR datacenter defaults are used (3s/9s).

func (*FRRConfigBuilder) WithNICs

func (b *FRRConfigBuilder) WithNICs(nics []string) *FRRConfigBuilder

WithNICs configures interfaces as BGP unnumbered peers in the peer-group.

func (*FRRConfigBuilder) WithOnefabric

func (b *FRRConfigBuilder) WithOnefabric(dcgwIPs []string, aggregate, vpnRT string) *FRRConfigBuilder

WithOnefabric enables onefabric mode with DCGW peering, route aggregation, and VPN RT.

func (*FRRConfigBuilder) WithVRF

func (b *FRRConfigBuilder) WithVRF(name string, tableID uint32) *FRRConfigBuilder

WithVRF sets VRF name and routing table ID.

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager handles FRR/EVPN network setup and teardown.

func NewManager

func NewManager(commander Commander) *Manager

NewManager creates an FRR manager.

func (*Manager) DumpFRRState

func (m *Manager) DumpFRRState()

DumpFRRState logs FRR diagnostic state via the commander abstraction. Called on FRR setup failure or connectivity timeout to capture BGP/EVPN state.

func (*Manager) Setup

func (m *Manager) Setup(ctx context.Context, cfg *network.Config) error

Setup configures the full FRR/EVPN network stack.

func (*Manager) Teardown

func (m *Manager) Teardown(ctx context.Context) error

Teardown removes the FRR network configuration.

func (*Manager) WaitForConnectivity

func (m *Manager) WaitForConnectivity(ctx context.Context, target string, timeout time.Duration) error

WaitForConnectivity polls the target URL until reachable, restarting FRR periodically.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL