/
community-filter.foil.php
88 lines (78 loc) · 3.03 KB
/
community-filter.foil.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
/*
* Bird Route Server Configuration Template
*
*
* You should not need to edit these files - instead use your own custom skins. If
* you can't effect the changes you need with skinning, consider posting to the mailing
* list to see if it can be achieved / incorporated.
*
* Skinning: https://ixp-manager.readthedocs.io/en/latest/features/skinning.html
*
* Copyright (C) 2009 - 2019 Internet Neutral Exchange Association Company Limited By Guarantee.
* All Rights Reserved.
*
* This file is part of IXP Manager.
*
* IXP Manager is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, version v2.0 of the License.
*
* IXP Manager is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License v2.0
* along with IXP Manager. If not, see:
*
* http://www.gnu.org/licenses/gpl-2.0.html
*/
?>
########################################################################################
########################################################################################
#
# Standard IXP community filter
#
########################################################################################
########################################################################################
function ixp_community_filter(int peerasn)
{
if !(source = RTS_BGP) then
return false;
<?php if( $t->router->bgp_lc ): ?>
# AS path prepending
if (routeserverasn, 103, peerasn) ~ bgp_large_community then {
bgp_path.prepend( bgp_path.first );
bgp_path.prepend( bgp_path.first );
bgp_path.prepend( bgp_path.first );
} else if (routeserverasn, 102, peerasn) ~ bgp_large_community then {
bgp_path.prepend( bgp_path.first );
bgp_path.prepend( bgp_path.first );
} else if (routeserverasn, 101, peerasn) ~ bgp_large_community then {
bgp_path.prepend( bgp_path.first );
}
# support for BGP Large Communities
if (routeserverasn, 0, peerasn) ~ bgp_large_community then
return false;
if (routeserverasn, 1, peerasn) ~ bgp_large_community then
return true;
if (routeserverasn, 0, 0) ~ bgp_large_community then
return false;
if (routeserverasn, 1, 0) ~ bgp_large_community then
return true;
<?php endif; ?>
# it's unwise to conduct a 32-bit check on a 16-bit value
if routeserverasn > 65535 || peerasn > 65535 then
return true;
<?php if( $t->router->asn <= 65535 ): ?>
# Implement widely used community filtering schema.
if (0, peerasn) ~ bgp_community then
return false;
if (routeserverasn, peerasn) ~ bgp_community then
return true;
if (0, routeserverasn) ~ bgp_community then
return false;
<?php endif; ?>
return true;
}