Skip to content

Commit

Permalink
Cilium BGPv1 - Support updated CRD field for CIDR definition on Ciliu…
Browse files Browse the repository at this point in the history
…mLoadBalancerIPPool
  • Loading branch information
dswaffordcw committed May 23, 2024
1 parent 2460a97 commit 971fe08
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pkg/bgpv1/manager/reconciler/route_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,18 @@ func (r *RoutePolicyReconciler) pathAttributesToPolicy(attrs v2alpha1api.CiliumB
if attrs.Selector != nil && !labelSelector.Matches(labels.Set(pool.Labels)) {
continue
}
for _, cidrBlock := range pool.Spec.Blocks {
cidr, err := netip.ParsePrefix(string(cidrBlock.Cidr))
if err != nil {
return nil, fmt.Errorf("failed to parse IPAM pool CIDR %s: %w", cidrBlock.Cidr, err)
}
if cidr.Addr().Is4() {
v4Prefixes = append(v4Prefixes, &types.RoutePolicyPrefixMatch{CIDR: cidr, PrefixLenMin: maxPrefixLenIPv4, PrefixLenMax: maxPrefixLenIPv4})
} else {
v6Prefixes = append(v6Prefixes, &types.RoutePolicyPrefixMatch{CIDR: cidr, PrefixLenMin: maxPrefixLenIPv6, PrefixLenMax: maxPrefixLenIPv6})
}
}
// Spec.Cidrs is a deprecated field
for _, cidrBlock := range pool.Spec.Cidrs {
cidr, err := netip.ParsePrefix(string(cidrBlock.Cidr))
if err != nil {
Expand Down

0 comments on commit 971fe08

Please sign in to comment.