summaryrefslogtreecommitdiff
path: root/roles/uvok_bird/templates/clearnet.conf.j2
blob: 8f17d68812d45d7f76834430dc2df442e326aa5f (plain)
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# {{ ansible_managed }}

include "/etc/bird/clear_defines.conf";
include "/etc/bird/clear_functions.conf";
include "/etc/bird/clear_rpki.conf";
include "/etc/bird/clear_filters.conf";

define CLEARNET_PREFIP = {{ uvok_bird_opts.preferred_ip }};

# trs=transit
ipv6 table t_myas_unfiltered;
ipv6 table t_myas_trs;
ipv6 table t_myas_babel;

protocol static myprefix {
{% for prefix in uvok_bird_opts.clear_prefixes %}
    route {{ prefix }} reject;
{% endfor %};

    ipv6 {
        # needs to be in unfiltered - because that's where I'm exporting from
        table t_myas_unfiltered;
        import all;
        export none;
    };
}

protocol direct {
    ipv6 { table t_myas_babel; };
    interface "myas_int";
};

template bgp pt_clearnet {
    local as CLEARNET_ASN;

    graceful restart on;
    long lived graceful restart on;

    prefer older on;

    # Neighbor as must be first route as
    enforce first as on;
    # faster updates
    enable extended messages on;

    # defaults anyway
    enable route refresh on;
    interpret communities on;
    direct;

    # higher better
    default bgp_local_pref 100;

    # my value - lower better
    default bgp_med 100;

    ipv6 {
        # start by importing into the unfiltered table
        table t_myas_unfiltered;

        # for inspection who's evil
        import keep filtered;
        # for RPKI / ROA
        import table on;

        import filter {
            clearnet_import_transit();
            clearnet_common_import();
            accept;
        };

        export filter myas_export;
    };
}

# route collector
template bgp pt_rc from pt_clearnet {
    multihop;

    # yes, use unfiltered table for export
    ipv6 {
        add paths tx;
        import none;
        export filter myas_f_rc;
    };
}

{% if uvok_bird_opts.babel_if_name %}
protocol babel p_myas_babel {
  ipv6 {
    table t_myas_babel;
    import where source ~ [RTS_DEVICE, RTS_BABEL];
    export where source ~ [RTS_DEVICE, RTS_BABEL];
  };

  interface "{{ uvok_bird_opts.babel_if_name }}" {
  };
}
{% endif %}

# pipe babel table => bgp table for next-hop resolution?
protocol pipe {
    table t_myas_babel;
    peer table t_myas_trs;
    import none;
    export where source ~ [RTS_BABEL];
}

# EXPORT FROM unfilteed TO filtered trs table
protocol pipe {
    table t_myas_unfiltered;
    peer table t_myas_trs;
    import none;
    export filter {
        if ( bgp_large_community ~ [(CLEARNET_ASN, LC_FILTERED, *)] ) then {
            reject;
        }
        accept;
    };
}

protocol kernel p_myas_i {
#    scan time 20;
    kernel table 150;

    ipv6 {
        table t_myas_babel;
        import none;
        export filter {
            if (source != RTS_BABEL) then {
                print "SHOULD NOT HAPPEN: export babel to kernel: ", net, " from", source;
                reject;
            }
            krt_prefsrc = CLEARNET_PREFIP;
            accept;
        };
    };
};

protocol kernel pk_myas_out {
    kernel table 100;

    ipv6 {
        table t_myas_trs;
        import none;
        export filter {
            krt_prefsrc = CLEARNET_PREFIP;
            if (source = RTS_BGP) then {
                accept;
            }
{% if uvok_bird_opts.use_fallback %}
            if (proto = "myas_def_fallb") then {
                accept;
            }
{% endif %}
            reject;
        };
    };
};

include "/etc/bird/clear_peers/*.conf";
{% if uvok_bird_opts.use_fallback %}
include "clear_fallback.conf";
{% endif %}