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

bio-rd BGP configuration refactoring #455

Merged
merged 22 commits into from
Dec 10, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
b109345
add dockerfile
czerwonk Nov 29, 2023
5d8f84d
add dockerfile
czerwonk Dec 4, 2023
0a2329d
prepare cleanup of daemon config
czerwonk Dec 4, 2023
bdcc3a0
improve readability in bgp.go
czerwonk Dec 5, 2023
1330851
add AFI configuration following the internal structure
czerwonk Dec 5, 2023
8031d54
do not assume legacy IP session
czerwonk Dec 5, 2023
1cf35b8
improve readability of filter replacements
czerwonk Dec 5, 2023
00111ea
extract magic figure DefaultReconnectInterval
czerwonk Dec 6, 2023
c7e388b
support AdvertiseIPv4MultiProtocol setting in config
czerwonk Dec 6, 2023
8b1ccf3
simplify BGP session configuration code, respect configured VRF
czerwonk Dec 7, 2023
6b09b9a
improve configuration error messages
czerwonk Dec 7, 2023
fc7c203
inherit multipath and routing instance
czerwonk Dec 7, 2023
310eaa3
move responsibility to inherit filter chain to config package, add in…
czerwonk Dec 7, 2023
d50607a
run unprivileged
czerwonk Dec 7, 2023
291c87f
add missing configuration for route reflection
czerwonk Dec 7, 2023
9e8742c
add tests for loading group
czerwonk Dec 7, 2023
87853b5
parse BGP instead of BGPGroup in test to increase coverage
czerwonk Dec 8, 2023
4105284
cover add_path configuration
czerwonk Dec 8, 2023
dbd29e3
cover disabled
czerwonk Dec 8, 2023
0b33ddd
improve readability for deconfigureRemovedSessions
czerwonk Dec 8, 2023
5cc0ae0
move deconfigure to last step
czerwonk Dec 8, 2023
fe6445c
add cluster id to group, test overriding group cluster id
czerwonk Dec 10, 2023
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
8 changes: 8 additions & 0 deletions cmd/bio-rd/bgp.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,14 @@ func (c *bgpConfigurator) newPeerConfig(bn *config.BGPNeighbor, bg *config.BGPGr
p.RouteServerClient = *bn.RouteServerClient
}

if bn.RouteReflectorClient != nil {
p.RouteReflectorClient = *bn.RouteReflectorClient
}

if bn.ClusterIDIP != nil {
p.RouteReflectorClusterID = bn.ClusterIDIP.ToUint32()
}

return p
}

Expand Down
53 changes: 34 additions & 19 deletions cmd/bio-rd/config/bgp.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,26 @@ func (b *BGP) load(localAS uint32, policyOptions *PolicyOptions) error {
}

type BGPGroup struct {
Name string `yaml:"name"`
LocalAddress string `yaml:"local_address"`
LocalAddressIP *bnet.IP
TTL uint8 `yaml:"ttl"`
AuthenticationKey string `yaml:"authentication_key"`
PeerAS uint32 `yaml:"peer_as"`
LocalAS uint32 `yaml:"local_as"`
HoldTime uint16 `yaml:"hold_time"`
Multipath *Multipath `yaml:"multipath"`
Import []string `yaml:"import"`
ImportFilterChain filter.Chain
Export []string `yaml:"export"`
ExportFilterChain filter.Chain
RouteServerClient *bool `yaml:"route_server_client"`
Passive *bool `yaml:"passive"`
Neighbors []*BGPNeighbor `yaml:"neighbors"`
IPv4 *AddressFamilyConfig `yaml:"ipv4"`
IPv6 *AddressFamilyConfig `yaml:"ipv6"`
RoutingInstance string `yaml:"routing_instance"`
Name string `yaml:"name"`
LocalAddress string `yaml:"local_address"`
LocalAddressIP *bnet.IP
TTL uint8 `yaml:"ttl"`
AuthenticationKey string `yaml:"authentication_key"`
PeerAS uint32 `yaml:"peer_as"`
LocalAS uint32 `yaml:"local_as"`
HoldTime uint16 `yaml:"hold_time"`
Multipath *Multipath `yaml:"multipath"`
Import []string `yaml:"import"`
ImportFilterChain filter.Chain
Export []string `yaml:"export"`
ExportFilterChain filter.Chain
RouteServerClient *bool `yaml:"route_server_client"`
RouteReflectorClient *bool `yaml:"route_reflector_client"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason not to add the ClusterID to the group, too? :-D

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, just added the Cluster ID :-)

Passive *bool `yaml:"passive"`
Neighbors []*BGPNeighbor `yaml:"neighbors"`
IPv4 *AddressFamilyConfig `yaml:"ipv4"`
IPv6 *AddressFamilyConfig `yaml:"ipv6"`
RoutingInstance string `yaml:"routing_instance"`
}

func (bg *BGPGroup) load(localAS uint32, policyOptions *PolicyOptions) error {
Expand Down Expand Up @@ -142,6 +143,10 @@ func (bg *BGPGroup) load(localAS uint32, policyOptions *PolicyOptions) error {
bn.IPv6 = bg.IPv6
}

if bn.RouteReflectorClient == nil {
bn.RouteReflectorClient = bg.RouteReflectorClient
}

bn.ImportFilterChain = bg.ImportFilterChain
bn.ExportFilterChain = bg.ExportFilterChain

Expand Down Expand Up @@ -177,6 +182,7 @@ type BGPNeighbor struct {
Export []string `yaml:"export"`
ExportFilterChain filter.Chain
RouteServerClient *bool `yaml:"route_server_client"`
RouteReflectorClient *bool `yaml:"route_reflector_client"`
Passive *bool `yaml:"passive"`
ClusterID string `yaml:"cluster_id"`
ClusterIDIP *bnet.IP
Expand Down Expand Up @@ -204,6 +210,15 @@ func (bn *BGPNeighbor) load(policyOptions *PolicyOptions) error {
bn.LocalAddressIP = a.Dedup()
}

if bn.ClusterID != "" {
a, err := bnet.IPFromString(bn.ClusterID)
if err != nil {
return fmt.Errorf("unable to parse BGP cluster identifier: %w", err)
}

bn.ClusterIDIP = a.Dedup()
}

b, err := bnet.IPFromString(bn.PeerAddress)
if err != nil {
return fmt.Errorf("unable to parse BGP peer address: %w", err)
Expand Down
Loading