]> git.proxmox.com Git - mirror_frr.git/blame - bgpd/bgp_routemap_nb.c
bgpd: North-bound implementation for bgp rmaps
[mirror_frr.git] / bgpd / bgp_routemap_nb.c
CommitLineData
48cb7ea9
SP
1/*
2 * Copyright (C) 2020 Vmware
3 * Sarita Patra
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the Free
7 * Software Foundation; either version 2 of the License, or (at your option)
8 * any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; see the file COPYING; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20
21#include "lib/command.h"
22#include "lib/log.h"
23#include "lib/northbound.h"
24#include "lib/routemap.h"
25#include "bgpd/bgpd.h"
26#include "bgpd/bgp_routemap_nb.h"
27
28/* clang-format off */
29const struct frr_yang_module_info frr_bgp_route_map_info = {
30 .name = "frr-bgp-route-map",
31 .nodes = {
32 {
33 .xpath = "/frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:local-preference",
34 .cbs = {
35 .modify = lib_route_map_entry_match_condition_rmap_match_condition_local_preference_modify,
36 .destroy = lib_route_map_entry_match_condition_rmap_match_condition_local_preference_destroy,
37 }
38 },
39 {
40 .xpath = "/frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:script",
41 .cbs = {
42 .modify = lib_route_map_entry_match_condition_rmap_match_condition_script_modify,
43 .destroy = lib_route_map_entry_match_condition_rmap_match_condition_script_destroy,
44 }
45 },
46 {
47 .xpath = "/frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:origin",
48 .cbs = {
49 .modify = lib_route_map_entry_match_condition_rmap_match_condition_origin_modify,
50 .destroy = lib_route_map_entry_match_condition_rmap_match_condition_origin_destroy,
51 }
52 },
53 {
54 .xpath = "/frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:rpki",
55 .cbs = {
56 .modify = lib_route_map_entry_match_condition_rmap_match_condition_rpki_modify,
57 .destroy = lib_route_map_entry_match_condition_rmap_match_condition_rpki_destroy,
58 }
59 },
60 {
61 .xpath = "/frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:probability",
62 .cbs = {
63 .modify = lib_route_map_entry_match_condition_rmap_match_condition_probability_modify,
64 .destroy = lib_route_map_entry_match_condition_rmap_match_condition_probability_destroy,
65 }
66 },
67 {
68 .xpath = "/frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:source-vrf",
69 .cbs = {
70 .modify = lib_route_map_entry_match_condition_rmap_match_condition_source_vrf_modify,
71 .destroy = lib_route_map_entry_match_condition_rmap_match_condition_source_vrf_destroy,
72 }
73 },
74 {
75 .xpath = "/frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:peer-ipv4-address",
76 .cbs = {
77 .modify = lib_route_map_entry_match_condition_rmap_match_condition_peer_ipv4_address_modify,
78 .destroy = lib_route_map_entry_match_condition_rmap_match_condition_peer_ipv4_address_destroy,
79 }
80 },
81 {
82 .xpath = "/frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:peer-interface",
83 .cbs = {
84 .modify = lib_route_map_entry_match_condition_rmap_match_condition_peer_interface_modify,
85 .destroy = lib_route_map_entry_match_condition_rmap_match_condition_peer_interface_destroy,
86 }
87 },
88 {
89 .xpath = "/frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:peer-ipv6-address",
90 .cbs = {
91 .modify = lib_route_map_entry_match_condition_rmap_match_condition_peer_ipv6_address_modify,
92 .destroy = lib_route_map_entry_match_condition_rmap_match_condition_peer_ipv6_address_destroy,
93 }
94 },
95 {
96 .xpath = "/frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:peer-local",
97 .cbs = {
98 .modify = lib_route_map_entry_match_condition_rmap_match_condition_peer_local_modify,
99 .destroy = lib_route_map_entry_match_condition_rmap_match_condition_peer_local_destroy,
100 }
101 },
102 {
103 .xpath = "/frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:list-name",
104 .cbs = {
105 .modify = lib_route_map_entry_match_condition_rmap_match_condition_list_name_modify,
106 .destroy = lib_route_map_entry_match_condition_rmap_match_condition_list_name_destroy,
107 }
108 },
109 {
110 .xpath = "/frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:evpn-default-route",
111 .cbs = {
112 .create = lib_route_map_entry_match_condition_rmap_match_condition_evpn_default_route_create,
113 .destroy = lib_route_map_entry_match_condition_rmap_match_condition_evpn_default_route_destroy,
114 }
115 },
116 {
117 .xpath = "/frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:evpn-vni",
118 .cbs = {
119 .modify = lib_route_map_entry_match_condition_rmap_match_condition_evpn_vni_modify,
120 .destroy = lib_route_map_entry_match_condition_rmap_match_condition_evpn_vni_destroy,
121 }
122 },
123 {
124 .xpath = "/frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:evpn-route-type",
125 .cbs = {
126 .modify = lib_route_map_entry_match_condition_rmap_match_condition_evpn_route_type_modify,
127 .destroy = lib_route_map_entry_match_condition_rmap_match_condition_evpn_route_type_destroy,
128 }
129 },
130 {
131 .xpath = "/frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:route-distinguisher",
132 .cbs = {
133 .modify = lib_route_map_entry_match_condition_rmap_match_condition_route_distinguisher_modify,
134 .destroy = lib_route_map_entry_match_condition_rmap_match_condition_route_distinguisher_destroy,
135 }
136 },
137 {
138 .xpath = "/frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:comm-list",
139 .cbs = {
140 .apply_finish = lib_route_map_entry_match_condition_rmap_match_condition_comm_list_finish,
141 }
142 },
143 {
144 .xpath = "/frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:comm-list/comm-list-name",
145 .cbs = {
146 .modify = lib_route_map_entry_match_condition_rmap_match_condition_comm_list_comm_list_name_modify,
147 .destroy = lib_route_map_entry_match_condition_rmap_match_condition_comm_list_comm_list_name_destroy,
148 }
149 },
150 {
151 .xpath = "/frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:comm-list/comm-list-name-exact-match",
152 .cbs = {
153 .modify = lib_route_map_entry_match_condition_rmap_match_condition_comm_list_comm_list_name_exact_match_modify,
154 .destroy = lib_route_map_entry_match_condition_rmap_match_condition_comm_list_comm_list_name_exact_match_destroy,
155 }
156 },
157 {
158 .xpath = "/frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:ipv4-address",
159 .cbs = {
160 .modify = lib_route_map_entry_match_condition_rmap_match_condition_ipv4_address_modify,
161 .destroy = lib_route_map_entry_match_condition_rmap_match_condition_ipv4_address_destroy,
162 }
163 },
164 {
165 .xpath = "/frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:ipv6-address",
166 .cbs = {
167 .modify = lib_route_map_entry_match_condition_rmap_match_condition_ipv6_address_modify,
168 .destroy = lib_route_map_entry_match_condition_rmap_match_condition_ipv6_address_destroy,
169 }
170 },
171 {
172 .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:distance",
173 .cbs = {
174 .modify = lib_route_map_entry_set_action_rmap_set_action_distance_modify,
175 .destroy = lib_route_map_entry_set_action_rmap_set_action_distance_destroy,
176 }
177 },
178 {
179 .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:extcommunity-rt",
180 .cbs = {
181 .modify = lib_route_map_entry_set_action_rmap_set_action_extcommunity_rt_modify,
182 .destroy = lib_route_map_entry_set_action_rmap_set_action_extcommunity_rt_destroy,
183 }
184 },
185 {
186 .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:extcommunity-soo",
187 .cbs = {
188 .modify = lib_route_map_entry_set_action_rmap_set_action_extcommunity_soo_modify,
189 .destroy = lib_route_map_entry_set_action_rmap_set_action_extcommunity_soo_destroy,
190 }
191 },
192 {
193 .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:ipv4-address",
194 .cbs = {
195 .modify = lib_route_map_entry_set_action_rmap_set_action_ipv4_address_modify,
196 .destroy = lib_route_map_entry_set_action_rmap_set_action_ipv4_address_destroy,
197 }
198 },
199 {
200 .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:ipv4-nexthop",
201 .cbs = {
202 .modify = lib_route_map_entry_set_action_rmap_set_action_ipv4_nexthop_modify,
203 .destroy = lib_route_map_entry_set_action_rmap_set_action_ipv4_nexthop_destroy,
204 }
205 },
206 {
207 .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:ipv6-address",
208 .cbs = {
209 .modify = lib_route_map_entry_set_action_rmap_set_action_ipv6_address_modify,
210 .destroy = lib_route_map_entry_set_action_rmap_set_action_ipv6_address_destroy,
211 }
212 },
213 {
214 .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:preference",
215 .cbs = {
216 .modify = lib_route_map_entry_set_action_rmap_set_action_preference_modify,
217 .destroy = lib_route_map_entry_set_action_rmap_set_action_preference_destroy,
218 }
219 },
220 {
221 .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:label-index",
222 .cbs = {
223 .modify = lib_route_map_entry_set_action_rmap_set_action_label_index_modify,
224 .destroy = lib_route_map_entry_set_action_rmap_set_action_label_index_destroy,
225 }
226 },
227 {
228 .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:local-pref",
229 .cbs = {
230 .modify = lib_route_map_entry_set_action_rmap_set_action_local_pref_modify,
231 .destroy = lib_route_map_entry_set_action_rmap_set_action_local_pref_destroy,
232 }
233 },
234 {
235 .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:weight",
236 .cbs = {
237 .modify = lib_route_map_entry_set_action_rmap_set_action_weight_modify,
238 .destroy = lib_route_map_entry_set_action_rmap_set_action_weight_destroy,
239 }
240 },
241 {
242 .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:origin",
243 .cbs = {
244 .modify = lib_route_map_entry_set_action_rmap_set_action_origin_modify,
245 .destroy = lib_route_map_entry_set_action_rmap_set_action_origin_destroy,
246 }
247 },
248 {
249 .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:originator-id",
250 .cbs = {
251 .modify = lib_route_map_entry_set_action_rmap_set_action_originator_id_modify,
252 .destroy = lib_route_map_entry_set_action_rmap_set_action_originator_id_destroy,
253 }
254 },
255 {
256 .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:table",
257 .cbs = {
258 .modify = lib_route_map_entry_set_action_rmap_set_action_table_modify,
259 .destroy = lib_route_map_entry_set_action_rmap_set_action_table_destroy,
260 }
261 },
262 {
263 .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:atomic-aggregate",
264 .cbs = {
265 .create = lib_route_map_entry_set_action_rmap_set_action_atomic_aggregate_create,
266 .destroy = lib_route_map_entry_set_action_rmap_set_action_atomic_aggregate_destroy,
267 }
268 },
269 {
270 .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:prepend-as-path",
271 .cbs = {
272 .modify = lib_route_map_entry_set_action_rmap_set_action_prepend_as_path_modify,
273 .destroy = lib_route_map_entry_set_action_rmap_set_action_prepend_as_path_destroy,
274 }
275 },
276 {
277 .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:last-as",
278 .cbs = {
279 .modify = lib_route_map_entry_set_action_rmap_set_action_last_as_modify,
280 .destroy = lib_route_map_entry_set_action_rmap_set_action_last_as_destroy,
281 }
282 },
283 {
284 .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:exclude-as-path",
285 .cbs = {
286 .modify = lib_route_map_entry_set_action_rmap_set_action_exclude_as_path_modify,
287 .destroy = lib_route_map_entry_set_action_rmap_set_action_exclude_as_path_destroy,
288 }
289 },
290 {
291 .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:community-none",
292 .cbs = {
293 .modify = lib_route_map_entry_set_action_rmap_set_action_community_none_modify,
294 .destroy = lib_route_map_entry_set_action_rmap_set_action_community_none_destroy,
295 }
296 },
297 {
298 .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:community-string",
299 .cbs = {
300 .modify = lib_route_map_entry_set_action_rmap_set_action_community_string_modify,
301 .destroy = lib_route_map_entry_set_action_rmap_set_action_community_string_destroy,
302 }
303 },
304 {
305 .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:large-community-none",
306 .cbs = {
307 .modify = lib_route_map_entry_set_action_rmap_set_action_large_community_none_modify,
308 .destroy = lib_route_map_entry_set_action_rmap_set_action_large_community_none_destroy,
309 }
310 },
311 {
312 .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:large-community-string",
313 .cbs = {
314 .modify = lib_route_map_entry_set_action_rmap_set_action_large_community_string_modify,
315 .destroy = lib_route_map_entry_set_action_rmap_set_action_large_community_string_destroy,
316 }
317 },
318 {
319 .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:aggregator",
320 .cbs = {
321 .apply_finish = lib_route_map_entry_set_action_rmap_set_action_aggregator_finish,
322 }
323 },
324 {
325 .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:aggregator/aggregator-asn",
326 .cbs = {
327 .modify = lib_route_map_entry_set_action_rmap_set_action_aggregator_aggregator_asn_modify,
328 .destroy = lib_route_map_entry_set_action_rmap_set_action_aggregator_aggregator_asn_destroy,
329 }
330 },
331 {
332 .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:aggregator/aggregator-address",
333 .cbs = {
334 .modify = lib_route_map_entry_set_action_rmap_set_action_aggregator_aggregator_address_modify,
335 .destroy = lib_route_map_entry_set_action_rmap_set_action_aggregator_aggregator_address_destroy,
336 }
337 },
338 {
339 .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:comm-list-name",
340 .cbs = {
341 .modify = lib_route_map_entry_set_action_rmap_set_action_comm_list_name_modify,
342 .destroy = lib_route_map_entry_set_action_rmap_set_action_comm_list_name_destroy,
343 }
344 },
345 {
346 .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:extcommunity-lb",
347 .cbs = {
348 .apply_finish = lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_finish,
349 }
350 },
351 {
352 .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:extcommunity-lb/lb-type",
353 .cbs = {
354 .modify = lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_lb_type_modify,
355 .destroy = lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_lb_type_destroy,
356 }
357 },
358 {
359 .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:extcommunity-lb/bandwidth",
360 .cbs = {
361 .modify = lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_bandwidth_modify,
362 .destroy = lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_bandwidth_destroy,
363 }
364 },
365 {
366 .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:extcommunity-lb/two-octet-as-specific",
367 .cbs = {
368 .modify = lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_two_octet_as_specific_modify,
369 .destroy = lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_two_octet_as_specific_destroy,
370 }
371 },
372 {
373 .xpath = NULL,
374 },
375 }
376};