# Generated by confd
function reject_disabled_pools ()
{
{{range ls "/v1/ipam/v6/pool"}}{{$data := json (getv (printf "/v1/ipam/v6/pool/%s" .))}}
{{- if $data.disableBGPExport}}
  if ( net ~ {{$data.cidr}} ) then { reject; }
{{- end}}
{{- end}}
}

filter calico_export_to_bgp_peers {
  # filter code terminates when it calls `accept;` or `reject;`, call reject_disabled_pools() first, then apply_communities() and then calico_aggr()
  reject_disabled_pools();
  apply_communities();
  calico_aggr();
{{- $static_key := "/staticroutesv6"}}
{{- if ls $static_key}}

  # Export static routes.
  {{- range ls $static_key}}
    {{- $parts := split . "-"}}
    {{- $cidr := join $parts "/"}}
  if ( net ~ {{$cidr}} ) then { accept; }
  {{- end}}
{{- end}}
{{range ls "/v1/ipam/v6/pool"}}{{$data := json (getv (printf "/v1/ipam/v6/pool/%s" .))}}
{{- if $data.disableBGPExport}}
  # Skip {{$data.cidr}} as BGP export is disabled for it
{{- else}}
  if ( net ~ {{$data.cidr}} ) then {
    accept;
  }
{{- end}}
{{- end}}
  reject;
}

filter calico_kernel_programming {
{{- $reject_key := "/rejectcidrsv6"}}
{{- if ls $reject_key}}

  # Don't program static routes into kernel.
  {{- range ls $reject_key}}
    {{- $parts := split . "-"}}
    {{- $cidr := join $parts "/"}}
  if ( net ~ {{$cidr}} ) then { reject; }
  {{- end}}

{{- end}}
{{range ls "/v1/ipam/v6/pool"}}{{$data := json (getv (printf "/v1/ipam/v6/pool/%s" .))}}
{{- if $data.vxlan_mode}}
  if ( net ~ {{$data.cidr}} ) then {
    # Don't program VXLAN routes into the kernel - these are handled by Felix.
    reject;
  }
{{- end}}{{/* End of '$data.vxlan_mode' */}}
{{- end}}{{/* End of 'range ls...' */}}
  accept;                                  {{- /* Destination is not in any ipPool, accept  */}}
}
