diff --git a/templates/global.tmpl b/templates/global.tmpl index 744e3f69..221d0c40 100644 --- a/templates/global.tmpl +++ b/templates/global.tmpl @@ -11,7 +11,7 @@ define LOCAL_v4 = [ protocol static static4 { ipv4; {{- range $i, $prefix := .OriginSet4 }} - route {{ $prefix }} reject { bgp_large_community.add((ASN,0,100)); }; + route {{ $prefix }} reject; {{- end }} } {{- end }} @@ -24,7 +24,7 @@ define LOCAL_v6 = [ protocol static static6 { ipv6; {{- range $i, $prefix := .OriginSet6 }} - route {{ $prefix }} reject { bgp_large_community.add((ASN,0,100)); }; + route {{ $prefix }} reject; {{- end }} } {{- end }} @@ -212,6 +212,22 @@ function strip_communities() { bgp_large_community.delete([(ASN, *, *)]); } +function accept_local() { + {{ if .OriginSet4 -}} + if (net ~ LOCAL_v4 ) then { + bgp_large_community.add((ASN,0,100)); # Originated + accept; + } + {{- end }} + + {{ if .OriginSet6 -}} + if (net ~ LOCAL_v6 ) then { + bgp_large_community.add((ASN,0,100)); # Originated + accept; + } + {{- end }} +} + function process_prepends() { if ((ASN,0,401) ~ bgp_community) then { print "Adding single prepend for ", net; diff --git a/templates/peer.tmpl b/templates/peer.tmpl index 20a3b59b..1cc0e629 100644 --- a/templates/peer.tmpl +++ b/templates/peer.tmpl @@ -74,7 +74,7 @@ protocol bgp {{ $peer.Name }}v{{ $af }}_{{ $i }} { {{ $peer.PreExport -}} {{- if or $global.OriginSet4 $global.OriginSet6 }} - if ((ASN,0,100) ~ bgp_large_community) then accept; # Originated + accept_local(); # Originated {{ end -}} {{ if eq $peer.Type "upstream" -}}