Skip to content

Commit

Permalink
Merge pull request #9114 from mstansberry/route_filter_prefix
Browse files Browse the repository at this point in the history
BGPFilter: Add prefixLength to BGPFilter to match on min/max prefix length
  • Loading branch information
caseydavenport authored Aug 19, 2024
2 parents f747905 + 154de3f commit 3bca322
Show file tree
Hide file tree
Showing 21 changed files with 977 additions and 45 deletions.
22 changes: 22 additions & 0 deletions api/pkg/apis/projectcalico/v3/bgpfilter.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ type BGPFilterSpec struct {
type BGPFilterRuleV4 struct {
CIDR string `json:"cidr,omitempty" validate:"omitempty,netv4"`

PrefixLength *BGPFilterPrefixLengthV4 `json:"prefixLength,omitempty" validate:"omitempty"`

Source BGPFilterMatchSource `json:"source,omitempty" validate:"omitempty,oneof=RemotePeers"`

Interface string `json:"interface,omitempty" validate:"omitempty,bgpFilterInterface"`
Expand All @@ -77,6 +79,8 @@ type BGPFilterRuleV4 struct {
type BGPFilterRuleV6 struct {
CIDR string `json:"cidr,omitempty" validate:"omitempty,netv6"`

PrefixLength *BGPFilterPrefixLengthV6 `json:"prefixLength,omitempty" validate:"omitempty"`

Source BGPFilterMatchSource `json:"source,omitempty" validate:"omitempty,oneof=RemotePeers"`

Interface string `json:"interface,omitempty" validate:"omitempty,bgpFilterInterface"`
Expand All @@ -86,6 +90,24 @@ type BGPFilterRuleV6 struct {
Action BGPFilterAction `json:"action" validate:"required,filterAction"`
}

type BGPFilterPrefixLengthV4 struct {
// +kubebuilder:validation:Minimum=0
// +kubebuilder:validation:Maximum=32
Min *int32 `json:"min,omitempty" validate:"omitempty,bgpFilterPrefixLengthV4"`
// +kubebuilder:validation:Minimum=0
// +kubebuilder:validation:Maximum=32
Max *int32 `json:"max,omitempty" validate:"omitempty,bgpFilterPrefixLengthV4"`
}

type BGPFilterPrefixLengthV6 struct {
// +kubebuilder:validation:Minimum=0
// +kubebuilder:validation:Maximum=128
Min *int32 `json:"min,omitempty" validate:"omitempty,bgpFilterPrefixLengthV6"`
// +kubebuilder:validation:Minimum=0
// +kubebuilder:validation:Maximum=128
Max *int32 `json:"max,omitempty" validate:"omitempty,bgpFilterPrefixLengthV6"`
}

type BGPFilterMatchSource string

const (
Expand Down
78 changes: 74 additions & 4 deletions api/pkg/apis/projectcalico/v3/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

64 changes: 64 additions & 0 deletions api/pkg/openapi/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 3bca322

Please sign in to comment.