Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

incusd/network/bgp: Only advertise networks with BGP configuration #1325

Merged
merged 1 commit into from
Oct 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions internal/server/network/driver_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -637,17 +637,30 @@ func (n *common) bgpValidationRules(config map[string]string) (map[string]func(v

// bgpSetup initializes BGP peers and prefixes.
func (n *common) bgpSetup(oldConfig map[string]string) error {
currentPeers := n.bgpGetPeers(n.config)
oldPeers := n.bgpGetPeers(oldConfig)

// Don't set up BGP when no peers are configured.
if len(currentPeers) == 0 {
if len(oldPeers) > 0 {
return n.bgpClear(oldConfig)
}

return nil
}

// Set up the peers.
err := n.bgpSetupPeers(oldConfig)
if err != nil {
return fmt.Errorf("Failed setting up BGP peers: %w", err)
}

// Export the prefixes.
err = n.bgpSetupPrefixes(oldConfig)
if err != nil {
return fmt.Errorf("Failed setting up BGP prefixes: %w", err)
}

// Refresh exported BGP prefixes on local member.
err = n.forwardBGPSetupPrefixes()
if err != nil {
return fmt.Errorf("Failed applying BGP prefixes for address forwards: %w", err)
Expand All @@ -661,7 +674,7 @@ func (n *common) bgpSetup(oldConfig map[string]string) error {
return nil
}

// bgpClear initializes BGP peers and prefixes.
// bgpClear clears BGP peers and prefixes.
func (n *common) bgpClear(config map[string]string) error {
// Clear all peers.
err := n.bgpClearPeers(config)
Expand Down
Loading