2fdbb5c2c7afc678b485fc563c1706d7258e988c
howto/BGP-communities.md
| ... | ... | @@ -193,7 +193,7 @@ function update_crypto(int link_crypto) -> int { |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | function update_topology(int link_topology) -> int { |
| 196 | - bgp_community.add((64511, update_topology)); |
|
| 196 | + bgp_community.add((64511, link_topology)); |
|
| 197 | 197 | if (64511, 89) ~ bgp_community then { bgp_community.delete([(64511, 81..88)]); return 89; } |
| 198 | 198 | else if (64511, 85) ~ bgp_community then { bgp_community.delete([(64511, 81..84)]); return 85; } |
| 199 | 199 | else if (64511, 84) ~ bgp_community then { bgp_community.delete([(64511, 81..83)]); return 84; } |
| ... | ... | @@ -237,9 +237,23 @@ int dn42_packetloss; |
| 237 | 237 | return true; |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | + |
|
| 241 | +function dn42_import_filter_internal(int link_latency; int link_bandwidth; int link_crypto; int link_topology; int link_packetloss) { |
|
| 242 | + if is_valid_network() then { |
|
| 243 | + update_flags(link_latency, link_bandwidth, link_crypto, link_topology, link_packetloss); |
|
| 244 | + accept; # no +500 bonus — local_pref already set by the originating peer |
|
| 245 | + } |
|
| 246 | + if is_valid_network_v6() then { |
|
| 247 | + update_flags(link_latency, link_bandwidth, link_crypto, link_topology, link_packetloss); |
|
| 248 | + accept; |
|
| 249 | + } |
|
| 250 | + reject; |
|
| 251 | +} |
|
| 252 | + |
|
| 253 | + |
|
| 240 | 254 | #Uses ROA, which means it should be imported before these functions |
| 241 | 255 | |
| 242 | -function dn42_import_filter(int link_latency; int link_bandwidth; int link_crypto) { |
|
| 256 | +function dn42_import_filter(int link_latency; int link_bandwidth; int link_crypto; int link_topology; int link_packetloss) { |
|
| 243 | 257 | # IPv4 routes with ROA |
| 244 | 258 | if is_valid_network() && !is_self_net() then { |
| 245 | 259 | if (roa_check(dn42_roa, net, bgp_path.last) != ROA_VALID) then { |
| ... | ... | @@ -248,7 +262,7 @@ function dn42_import_filter(int link_latency; int link_bandwidth; int link_crypt |
| 248 | 262 | reject; |
| 249 | 263 | } |
| 250 | 264 | |
| 251 | - update_flags(link_latency, link_bandwidth, link_crypto); |
|
| 265 | + update_flags(link_latency, link_bandwidth, link_crypto, link_topology, link_packetloss); |
|
| 252 | 266 | |
| 253 | 267 | if (bgp_path.len = 1) then |
| 254 | 268 | bgp_local_pref = bgp_local_pref + 500; |
| ... | ... | @@ -264,7 +278,7 @@ function dn42_import_filter(int link_latency; int link_bandwidth; int link_crypt |
| 264 | 278 | reject; |
| 265 | 279 | } |
| 266 | 280 | |
| 267 | - update_flags(link_latency, link_bandwidth, link_crypto); |
|
| 281 | + update_flags(link_latency, link_bandwidth, link_crypto, link_topology, link_packetloss); |
|
| 268 | 282 | |
| 269 | 283 | if (bgp_path.len = 1) then |
| 270 | 284 | bgp_local_pref = bgp_local_pref + 500; |
| ... | ... | @@ -275,9 +289,10 @@ function dn42_import_filter(int link_latency; int link_bandwidth; int link_crypt |
| 275 | 289 | # Re |
| 276 | 290 | reject; |
| 277 | 291 | } |
| 278 | -function dn42_export_filter(int link_latency; int link_bandwidth; int link_crypto) { |
|
| 292 | +function dn42_export_filter(int link_latency; int link_bandwidth; int link_crypto; int link_topology; int link_packetloss) { |
|
| 279 | 293 | if is_valid_network() || is_valid_network_v6() then { |
| 280 | - update_flags(link_latency, link_bandwidth, link_crypto); |
|
| 294 | + if source = RTS_STATIC then bgp_community.add((64511, DN_REGION_GEO)); |
|
| 295 | + update_flags(link_latency, link_bandwidth, link_crypto, link_topology, link_packetloss); |
|
| 281 | 296 | update_geo_flags(); |
| 282 | 297 | bgp_med = 0; |
| 283 | 298 | bgp_med = bgp_med + ( ( 4 - ( link_crypto - 30 ) ) * 600 ); |