diff --git a/cmd/bio-rd/config/bgp.go b/cmd/bio-rd/config/bgp.go index 2b1d6096..f28b1fa2 100644 --- a/cmd/bio-rd/config/bgp.go +++ b/cmd/bio-rd/config/bgp.go @@ -41,8 +41,10 @@ type BGPGroup struct { ImportFilterChain filter.Chain Export []string `yaml:"export"` ExportFilterChain filter.Chain - RouteServerClient *bool `yaml:"route_server_client"` - RouteReflectorClient *bool `yaml:"route_reflector_client"` + RouteServerClient *bool `yaml:"route_server_client"` + RouteReflectorClient *bool `yaml:"route_reflector_client"` + ClusterID string `yaml:"cluster_id"` + ClusterIDIP *bnet.IP Passive *bool `yaml:"passive"` Neighbors []*BGPNeighbor `yaml:"neighbors"` IPv4 *AddressFamilyConfig `yaml:"ipv4"` @@ -64,6 +66,15 @@ func (bg *BGPGroup) load(localAS uint32, policyOptions *PolicyOptions) error { bg.LocalAddressIP = a.Dedup() } + if bg.ClusterID != "" { + a, err := bnet.IPFromString(bg.ClusterID) + if err != nil { + return fmt.Errorf("unable to parse BGP cluster identifier: %w", err) + } + + bg.ClusterIDIP = a.Dedup() + } + if bg.HoldTime == 0 { bg.HoldTime = DefaultHoldTimeSeconds } @@ -99,6 +110,10 @@ func (bg *BGPGroup) load(localAS uint32, policyOptions *PolicyOptions) error { bn.LocalAddressIP = bg.LocalAddressIP } + if bn.ClusterID == "" { + bn.ClusterIDIP = bg.ClusterIDIP + } + if bn.TTL == 0 { bn.TTL = bg.TTL } diff --git a/cmd/bio-rd/config/bgp_test.go b/cmd/bio-rd/config/bgp_test.go index ba62dd01..d460923e 100644 --- a/cmd/bio-rd/config/bgp_test.go +++ b/cmd/bio-rd/config/bgp_test.go @@ -27,6 +27,7 @@ groups: routing_instance: main import: ["ACCEPT_ALL"] export: ["REJECT_ALL"] + cluster_id: 100.65.1.1 neighbors: - peer_address: 100.64.0.2 cluster_id: 100.64.0.0 @@ -123,7 +124,7 @@ func TestBGPLoad(t *testing.T) { assert.Equal(t, "test", n2.RoutingInstance, "neighbor 2 VRF") assert.Equal(t, filter.Chain{reject_all}, n2.ImportFilterChain, "neighbor 2 import") assert.Equal(t, filter.Chain{accept_all}, n2.ExportFilterChain, "neighbor 2 export") - assert.Nil(t, n2.ClusterIDIP, "neighbor 2 cluster ID") + assert.Equal(t, n2.ClusterIDIP, bnet.IPv4FromOctets(100, 65, 1, 1).Dedup(), "neighbor 2 cluster ID") assert.Nil(t, n2.IPv4, "neighbor 2 IPv4") assert.True(t, n2.IPv6.AddPath.Receive, "neighbor 2 IPv6 add path receive") assert.Equal(t, uint8(2), n2.IPv6.AddPath.Send.PathCount, "neighbor 2 IPv6 add path send count")