Skip to content

Commit

Permalink
add cluster id to group, test overriding group cluster id
Browse files Browse the repository at this point in the history
  • Loading branch information
czerwonk committed Dec 10, 2023
1 parent 5cc0ae0 commit fe6445c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
19 changes: 17 additions & 2 deletions cmd/bio-rd/config/bgp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand All @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down
3 changes: 2 additions & 1 deletion cmd/bio-rd/config/bgp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit fe6445c

Please sign in to comment.