|
2 | 2 |
|
3 | 3 | let |
4 | 4 | cfg = config.networking.dn42; |
| 5 | + useVrf = cfg.vrf.name != null && cfg.vrf.table != null; |
5 | 6 | in |
6 | 7 | { |
7 | 8 | config = lib.mkIf cfg.enable { |
|
35 | 36 | return net ~ [${builtins.concatStringsSep ", " cfg.nets.v6}]; |
36 | 37 | } |
37 | 38 |
|
38 | | - roa4 table dnroa4; |
39 | | - roa6 table dnroa6; |
| 39 | + ${lib.optionalString useVrf '' |
| 40 | + ipv4 table ${cfg.vrf.name}_4; |
| 41 | + ipv6 table ${cfg.vrf.name}_6; |
| 42 | + ''} |
| 43 | + roa4 table dnroa_4; |
| 44 | + roa6 table dnroa_6; |
40 | 45 |
|
41 | 46 | include "${../resources/community_filter.conf}"; |
42 | 47 | include "${../resources/filters.conf}"; |
|
62 | 67 | protocols = { |
63 | 68 |
|
64 | 69 | rpki.roa_dn42 = lib.mkIf config.networking.dn42.stayrtr.enable '' |
65 | | - roa4 { table dnroa4; }; |
66 | | - roa6 { table dnroa6; }; |
| 70 | + roa4 { table dnroa_4; }; |
| 71 | + roa6 { table dnroa_6; }; |
67 | 72 | remote 127.0.0.1; |
68 | 73 | port 8082; |
69 | 74 | refresh 600; |
|
73 | 78 |
|
74 | 79 | static = { |
75 | 80 | static_roa_4 = lib.mkIf config.networking.dn42.roagen.enable '' |
76 | | - roa4 { table dnroa4; }; |
| 81 | + roa4 { table dnroa_4; }; |
77 | 82 | include "${config.networking.dn42.roagen.outputDir}/dn42-roa4.conf"; |
78 | 83 | ''; |
79 | 84 | static_roa_6 = lib.mkIf config.networking.dn42.roagen.enable '' |
80 | | - roa6 { table dnroa6; }; |
| 85 | + roa6 { table dnroa_6; }; |
81 | 86 | include "${config.networking.dn42.roagen.outputDir}/dn42-roa6.conf"; |
82 | 87 | ''; |
83 | 88 | static_4 = '' |
84 | | - ipv4; |
| 89 | + ${lib.optionalString useVrf "vrf \"${cfg.vrf.name}\";"} |
| 90 | + ipv4 { |
| 91 | + ${lib.optionalString useVrf "table ${cfg.vrf.name}_4;"} |
| 92 | + }; |
85 | 93 |
|
86 | 94 | ${lib.concatMapStrings (net: '' |
87 | 95 | route ${net} unreachable; |
88 | 96 | '') cfg.nets.v4} |
89 | 97 | ''; |
90 | 98 | static_6 = '' |
91 | | - ipv6; |
| 99 | + ${lib.optionalString useVrf "vrf \"${cfg.vrf.name}\";"} |
| 100 | + ipv6 { |
| 101 | + ${lib.optionalString useVrf "table ${cfg.vrf.name}_6;"} |
| 102 | + }; |
92 | 103 |
|
93 | 104 | ${lib.concatMapStrings (net: '' |
94 | 105 | route ${net} unreachable; |
|
102 | 113 |
|
103 | 114 | kernel = { |
104 | 115 | kernel_4 = '' |
| 116 | + ${lib.optionalString useVrf '' |
| 117 | + vrf "${cfg.vrf.name}"; |
| 118 | + kernel table ${toString cfg.vrf.table}; |
| 119 | + ''} |
105 | 120 | scan time 20; |
106 | 121 |
|
107 | 122 | ipv4 { |
| 123 | + ${lib.optionalString useVrf "table ${cfg.vrf.name}_4;"} |
| 124 | +
|
108 | 125 | import none; |
109 | 126 | export filter { |
110 | 127 | if source = RTS_STATIC then reject; |
|
115 | 132 | ''; |
116 | 133 |
|
117 | 134 | kernel_6 = '' |
| 135 | + ${lib.optionalString useVrf '' |
| 136 | + vrf "${cfg.vrf.name}"; |
| 137 | + kernel table ${toString cfg.vrf.table}; |
| 138 | + ''} |
118 | 139 | scan time 20; |
119 | 140 |
|
120 | 141 | ipv6 { |
| 142 | + ${lib.optionalString useVrf "table ${cfg.vrf.name}_6;"} |
| 143 | + |
121 | 144 | import none; |
122 | 145 | export filter { |
123 | 146 | if source = RTS_STATIC then reject; |
|
133 | 156 | (name: conf: |
134 | 157 | { |
135 | 158 | "${name}_4 from dn42_peer" = lib.mkIf (!conf.extendedNextHop) '' |
| 159 | + ${lib.optionalString useVrf "vrf \"${cfg.vrf.name}\";"} |
136 | 160 | neighbor ${conf.addr.v4} as ${builtins.toString conf.as}; |
137 | 161 | source address ${conf.srcAddr.v4}; |
138 | 162 |
|
139 | 163 | ipv4 { |
| 164 | + ${lib.optionalString useVrf "table ${cfg.vrf.name}_4;"} |
140 | 165 | import limit 9000 action block; |
141 | 166 | import table on; |
142 | 167 | import where dn_import_filter4(${toString conf.latency}, ${toString conf.bandwidth}, ${toString conf.crypto}); |
|
145 | 170 | ''; |
146 | 171 |
|
147 | 172 | "${name}_6 from dn42_peer" = '' |
| 173 | + ${lib.optionalString useVrf "vrf \"${cfg.vrf.name}\";"} |
| 174 | + neighbor ${conf.addr.v6}%'${conf.interface}' as ${builtins.toString conf.as}; |
| 175 | + source address ${conf.srcAddr.v6}; |
| 176 | +
|
148 | 177 | ${lib.optionalString conf.extendedNextHop '' |
149 | 178 | enable extended messages on; |
150 | 179 |
|
151 | 180 | ipv4 { |
| 181 | + ${lib.optionalString useVrf "table ${cfg.vrf.name}_4;"} |
152 | 182 | import limit 9000 action block; |
153 | 183 | import table on; |
154 | 184 |
|
|
159 | 189 | ''} |
160 | 190 |
|
161 | 191 | ipv6 { |
| 192 | + ${lib.optionalString useVrf "table ${cfg.vrf.name}_6;"} |
162 | 193 | import limit 9000 action block; |
163 | 194 | import table on; |
164 | 195 |
|
165 | 196 | import where dn_import_filter6(${toString conf.latency}, ${toString conf.bandwidth}, ${toString conf.crypto}); |
166 | 197 | export where dn_export_filter6(${toString conf.latency}, ${toString conf.bandwidth}, ${toString conf.crypto}, ${lib.boolToString conf.transit}); |
167 | 198 | }; |
168 | | -
|
169 | | - neighbor ${conf.addr.v6}%'${conf.interface}' as ${builtins.toString conf.as}; |
170 | | - source address ${conf.srcAddr.v6}; |
171 | 199 | ''; |
172 | 200 | }) |
173 | 201 | cfg.peers) |
174 | 202 | ++ [{ |
175 | 203 | "collector_6 from dn42_peer" = '' |
| 204 | + ${lib.optionalString useVrf "vrf \"${cfg.vrf.name}\";"} |
176 | 205 | neighbor fd42:4242:2601:ac12::1 as 4242422602; |
177 | 206 | source address ${cfg.addr.v6}; |
178 | 207 |
|
179 | 208 | # enable multihop as the collector is not locally connected |
180 | 209 | multihop; |
181 | 210 |
|
182 | 211 | ipv4 { |
| 212 | + ${lib.optionalString useVrf "table ${cfg.vrf.name}_4;"} |
183 | 213 | # export all available paths to the collector |
184 | 214 | add paths tx; |
185 | 215 |
|
|
189 | 219 | }; |
190 | 220 |
|
191 | 221 | ipv6 { |
| 222 | + ${lib.optionalString useVrf "table ${cfg.vrf.name}_6;"} |
192 | 223 | # export all available paths to the collector |
193 | 224 | add paths tx; |
194 | 225 |
|
|
0 commit comments