frrouting: exclude prefixes from connected redistribution (#575)
The frr.conf template cannot filter `redistribute connected` except for k8s CIDRs, so a puppet run on prodnxsr0020 drops its hand-written default-route filter and leaks the WAN default route into OSPF. - add `frrouting::ospf_connected_exclude` to render a REDIST-BLOCK prefix-list and CONNECTED-EXCLUDE-REDIST route-map on `redistribute connected` - fail when combined with `ospf_exclude_k8s_enable` - exclude `0.0.0.0/0` on prodnxsr0020 Reviewed-on: #575 Co-authored-by: unkin-agent <unkin-agent@unkin.net> Co-committed-by: unkin-agent <unkin-agent@unkin.net>
This commit was merged in pull request #575.
This commit is contained in:
@@ -19,6 +19,7 @@ class frrouting (
|
||||
Boolean $ospf_exclude_k8s_enable = false,
|
||||
Optional[Stdlib::IP::Address::V4::CIDR] $k8s_cluster_cidr = undef, # pod/cluster CIDR (e.g. 10.42.0.0/16)
|
||||
Optional[Stdlib::IP::Address::V4::CIDR] $k8s_service_cidr = undef, # service CIDR (e.g. 10.43.0.0/16)
|
||||
Array[Stdlib::IP::Address::V4::CIDR] $ospf_connected_exclude = [], # exact-match prefixes kept out of redistribute connected
|
||||
) {
|
||||
|
||||
# sanity check
|
||||
@@ -26,6 +27,10 @@ class frrouting (
|
||||
warning('frrouting: ospf_exclude_k8s_enable is true but no k8s_*_cidr provided; nothing will be filtered.')
|
||||
}
|
||||
|
||||
if $ospf_exclude_k8s_enable and !empty($ospf_connected_exclude) {
|
||||
fail('frrouting: ospf_exclude_k8s_enable and ospf_connected_exclude are mutually exclusive.')
|
||||
}
|
||||
|
||||
$daemons_defaults = {
|
||||
'bgpd' => false,
|
||||
'ospfd' => true,
|
||||
|
||||
@@ -27,6 +27,18 @@ exit
|
||||
route-map CONNECTED-NON-K8S permit 100
|
||||
exit
|
||||
<% end -%>
|
||||
<% if @ospf_connected_exclude.any? -%>
|
||||
! Do not redistribute default route
|
||||
<% @ospf_connected_exclude.each_with_index do |prefix, i| -%>
|
||||
ip prefix-list REDIST-BLOCK seq <%= (i + 1) * 5 %> permit <%= prefix %>
|
||||
<% end -%>
|
||||
|
||||
route-map CONNECTED-EXCLUDE-REDIST deny 5
|
||||
match ip address prefix-list REDIST-BLOCK
|
||||
exit
|
||||
route-map CONNECTED-EXCLUDE-REDIST permit 100
|
||||
exit
|
||||
<% end -%>
|
||||
|
||||
router ospf
|
||||
ospf router-id <%= @ospfd_router_id %>
|
||||
@@ -34,6 +46,8 @@ router ospf
|
||||
<% @ospfd_redistribute.each do |type| -%>
|
||||
<% if @ospf_exclude_k8s_enable && type == 'connected' && (@k8s_cluster_cidr || @k8s_service_cidr) -%>
|
||||
redistribute connected route-map CONNECTED-NON-K8S
|
||||
<% elsif type == 'connected' && @ospf_connected_exclude.any? -%>
|
||||
redistribute connected route-map CONNECTED-EXCLUDE-REDIST
|
||||
<% else -%>
|
||||
redistribute <%= type %>
|
||||
<% end -%>
|
||||
|
||||
Reference in New Issue
Block a user