/src/frr/bgpd/bgp_routemap_nb_config.c
Line | Count | Source (jump to first uncovered line) |
1 | | // SPDX-License-Identifier: GPL-2.0-or-later |
2 | | /* |
3 | | * Copyright (C) 2020 Vmware |
4 | | * Sarita Patra |
5 | | */ |
6 | | |
7 | | #include <zebra.h> |
8 | | |
9 | | #include "lib/command.h" |
10 | | #include "lib/log.h" |
11 | | #include "lib/northbound.h" |
12 | | #include "lib/routemap.h" |
13 | | #include "bgpd/bgpd.h" |
14 | | #include "bgpd/bgp_routemap_nb.h" |
15 | | |
16 | | /* Add bgp route map rule. */ |
17 | | static int bgp_route_match_add(struct route_map_index *index, |
18 | | const char *command, const char *arg, |
19 | | route_map_event_t type, |
20 | | char *errmsg, size_t errmsg_len) |
21 | 0 | { |
22 | 0 | int retval = CMD_SUCCESS; |
23 | 0 | enum rmap_compile_rets ret; |
24 | |
|
25 | 0 | ret = route_map_add_match(index, command, arg, type); |
26 | 0 | switch (ret) { |
27 | 0 | case RMAP_RULE_MISSING: |
28 | 0 | snprintf(errmsg, errmsg_len, "%% BGP Can't find rule."); |
29 | 0 | retval = CMD_WARNING_CONFIG_FAILED; |
30 | 0 | break; |
31 | 0 | case RMAP_COMPILE_ERROR: |
32 | 0 | snprintf(errmsg, errmsg_len, "%% BGP Argument is malformed."); |
33 | 0 | retval = CMD_WARNING_CONFIG_FAILED; |
34 | 0 | break; |
35 | 0 | case RMAP_COMPILE_SUCCESS: |
36 | | /* |
37 | | * Intentionally doing nothing here. |
38 | | */ |
39 | 0 | break; |
40 | 0 | } |
41 | | |
42 | 0 | return retval; |
43 | 0 | } |
44 | | |
45 | | /* Delete bgp route map rule. */ |
46 | | static int bgp_route_match_delete(struct route_map_index *index, |
47 | | const char *command, const char *arg, |
48 | | route_map_event_t type, |
49 | | char *errmsg, size_t errmsg_len) |
50 | 0 | { |
51 | 0 | enum rmap_compile_rets ret; |
52 | 0 | int retval = CMD_SUCCESS; |
53 | 0 | char *dep_name = NULL; |
54 | 0 | const char *tmpstr; |
55 | 0 | char *rmap_name = NULL; |
56 | |
|
57 | 0 | if (type != RMAP_EVENT_MATCH_DELETED) { |
58 | | /* ignore the mundane, the types without any dependency */ |
59 | 0 | if (arg == NULL) { |
60 | 0 | tmpstr = route_map_get_match_arg(index, command); |
61 | 0 | if (tmpstr != NULL) |
62 | 0 | dep_name = |
63 | 0 | XSTRDUP(MTYPE_ROUTE_MAP_RULE, tmpstr); |
64 | 0 | } else { |
65 | 0 | dep_name = XSTRDUP(MTYPE_ROUTE_MAP_RULE, arg); |
66 | 0 | } |
67 | 0 | rmap_name = XSTRDUP(MTYPE_ROUTE_MAP_NAME, index->map->name); |
68 | 0 | } |
69 | |
|
70 | 0 | ret = route_map_delete_match(index, command, dep_name, type); |
71 | 0 | switch (ret) { |
72 | 0 | case RMAP_RULE_MISSING: |
73 | 0 | snprintf(errmsg, errmsg_len, "%% BGP Can't find rule."); |
74 | 0 | retval = CMD_WARNING_CONFIG_FAILED; |
75 | 0 | break; |
76 | 0 | case RMAP_COMPILE_ERROR: |
77 | 0 | snprintf(errmsg, errmsg_len, |
78 | 0 | "%% BGP Argument is malformed."); |
79 | 0 | retval = CMD_WARNING_CONFIG_FAILED; |
80 | 0 | break; |
81 | 0 | case RMAP_COMPILE_SUCCESS: |
82 | | /* |
83 | | * Nothing to do here |
84 | | */ |
85 | 0 | break; |
86 | 0 | } |
87 | | |
88 | 0 | XFREE(MTYPE_ROUTE_MAP_RULE, dep_name); |
89 | 0 | XFREE(MTYPE_ROUTE_MAP_NAME, rmap_name); |
90 | |
|
91 | 0 | return retval; |
92 | 0 | } |
93 | | |
94 | | /* |
95 | | * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:local-preference |
96 | | */ |
97 | | int |
98 | | lib_route_map_entry_match_condition_rmap_match_condition_local_preference_modify( |
99 | | struct nb_cb_modify_args *args) |
100 | 0 | { |
101 | 0 | struct routemap_hook_context *rhc; |
102 | 0 | const char *local_pref; |
103 | 0 | enum rmap_compile_rets ret; |
104 | |
|
105 | 0 | switch (args->event) { |
106 | 0 | case NB_EV_VALIDATE: |
107 | 0 | case NB_EV_PREPARE: |
108 | 0 | case NB_EV_ABORT: |
109 | 0 | break; |
110 | 0 | case NB_EV_APPLY: |
111 | | /* Add configuration. */ |
112 | 0 | rhc = nb_running_get_entry(args->dnode, NULL, true); |
113 | 0 | local_pref = yang_dnode_get_string(args->dnode, NULL); |
114 | | |
115 | | /* Set destroy information. */ |
116 | 0 | rhc->rhc_mhook = bgp_route_match_delete; |
117 | 0 | rhc->rhc_rule = "local-preference"; |
118 | 0 | rhc->rhc_event = RMAP_EVENT_MATCH_DELETED; |
119 | |
|
120 | 0 | ret = bgp_route_match_add(rhc->rhc_rmi, "local-preference", |
121 | 0 | local_pref, RMAP_EVENT_MATCH_ADDED, |
122 | 0 | args->errmsg, args->errmsg_len); |
123 | |
|
124 | 0 | if (ret != RMAP_COMPILE_SUCCESS) { |
125 | 0 | rhc->rhc_mhook = NULL; |
126 | 0 | return NB_ERR_INCONSISTENCY; |
127 | 0 | } |
128 | 0 | } |
129 | | |
130 | 0 | return NB_OK; |
131 | 0 | } |
132 | | |
133 | | int |
134 | | lib_route_map_entry_match_condition_rmap_match_condition_local_preference_destroy( |
135 | | struct nb_cb_destroy_args *args) |
136 | 0 | { |
137 | 0 | switch (args->event) { |
138 | 0 | case NB_EV_VALIDATE: |
139 | 0 | case NB_EV_PREPARE: |
140 | 0 | case NB_EV_ABORT: |
141 | 0 | break; |
142 | 0 | case NB_EV_APPLY: |
143 | 0 | return lib_route_map_entry_match_destroy(args); |
144 | 0 | } |
145 | | |
146 | 0 | return NB_OK; |
147 | 0 | } |
148 | | |
149 | | /* |
150 | | * XPath: |
151 | | * /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:alias |
152 | | */ |
153 | | int lib_route_map_entry_match_condition_rmap_match_condition_alias_modify( |
154 | | struct nb_cb_modify_args *args) |
155 | 0 | { |
156 | 0 | struct routemap_hook_context *rhc; |
157 | 0 | const char *alias; |
158 | 0 | enum rmap_compile_rets ret; |
159 | |
|
160 | 0 | switch (args->event) { |
161 | 0 | case NB_EV_VALIDATE: |
162 | 0 | case NB_EV_PREPARE: |
163 | 0 | case NB_EV_ABORT: |
164 | 0 | break; |
165 | 0 | case NB_EV_APPLY: |
166 | | /* Add configuration. */ |
167 | 0 | rhc = nb_running_get_entry(args->dnode, NULL, true); |
168 | 0 | alias = yang_dnode_get_string(args->dnode, NULL); |
169 | | |
170 | | /* Set destroy information. */ |
171 | 0 | rhc->rhc_mhook = bgp_route_match_delete; |
172 | 0 | rhc->rhc_rule = "alias"; |
173 | 0 | rhc->rhc_event = RMAP_EVENT_MATCH_DELETED; |
174 | |
|
175 | 0 | ret = bgp_route_match_add(rhc->rhc_rmi, "alias", alias, |
176 | 0 | RMAP_EVENT_MATCH_ADDED, args->errmsg, |
177 | 0 | args->errmsg_len); |
178 | |
|
179 | 0 | if (ret != RMAP_COMPILE_SUCCESS) { |
180 | 0 | rhc->rhc_mhook = NULL; |
181 | 0 | return NB_ERR_VALIDATION; |
182 | 0 | } |
183 | | |
184 | 0 | break; |
185 | 0 | } |
186 | | |
187 | 0 | return NB_OK; |
188 | 0 | } |
189 | | |
190 | | int lib_route_map_entry_match_condition_rmap_match_condition_alias_destroy( |
191 | | struct nb_cb_destroy_args *args) |
192 | 0 | { |
193 | 0 | switch (args->event) { |
194 | 0 | case NB_EV_VALIDATE: |
195 | 0 | case NB_EV_PREPARE: |
196 | 0 | case NB_EV_ABORT: |
197 | 0 | break; |
198 | 0 | case NB_EV_APPLY: |
199 | 0 | return lib_route_map_entry_match_destroy(args); |
200 | 0 | } |
201 | | |
202 | 0 | return NB_OK; |
203 | 0 | } |
204 | | |
205 | | /* |
206 | | * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:script |
207 | | */ |
208 | | int |
209 | | lib_route_map_entry_match_condition_rmap_match_condition_script_modify( |
210 | | struct nb_cb_modify_args *args) |
211 | 0 | { |
212 | 0 | struct routemap_hook_context *rhc; |
213 | 0 | const char *script; |
214 | 0 | enum rmap_compile_rets ret; |
215 | |
|
216 | 0 | switch (args->event) { |
217 | 0 | case NB_EV_VALIDATE: |
218 | 0 | case NB_EV_PREPARE: |
219 | 0 | case NB_EV_ABORT: |
220 | 0 | break; |
221 | 0 | case NB_EV_APPLY: |
222 | | /* Add configuration. */ |
223 | 0 | rhc = nb_running_get_entry(args->dnode, NULL, true); |
224 | 0 | script = yang_dnode_get_string(args->dnode, NULL); |
225 | | |
226 | | /* Set destroy information. */ |
227 | 0 | rhc->rhc_mhook = bgp_route_match_delete; |
228 | 0 | rhc->rhc_rule = "script"; |
229 | 0 | rhc->rhc_event = RMAP_EVENT_MATCH_DELETED; |
230 | |
|
231 | 0 | ret = bgp_route_match_add(rhc->rhc_rmi, "script", |
232 | 0 | script, RMAP_EVENT_MATCH_ADDED, |
233 | 0 | args->errmsg, args->errmsg_len); |
234 | |
|
235 | 0 | if (ret != RMAP_COMPILE_SUCCESS) { |
236 | 0 | rhc->rhc_mhook = NULL; |
237 | 0 | return NB_ERR_INCONSISTENCY; |
238 | 0 | } |
239 | 0 | } |
240 | | |
241 | 0 | return NB_OK; |
242 | 0 | } |
243 | | |
244 | | int |
245 | | lib_route_map_entry_match_condition_rmap_match_condition_script_destroy( |
246 | | struct nb_cb_destroy_args *args) |
247 | 0 | { |
248 | 0 | switch (args->event) { |
249 | 0 | case NB_EV_VALIDATE: |
250 | 0 | case NB_EV_PREPARE: |
251 | 0 | case NB_EV_ABORT: |
252 | 0 | break; |
253 | 0 | case NB_EV_APPLY: |
254 | 0 | return lib_route_map_entry_match_destroy(args); |
255 | 0 | } |
256 | | |
257 | 0 | return NB_OK; |
258 | 0 | } |
259 | | |
260 | | /* |
261 | | * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:origin |
262 | | */ |
263 | | int |
264 | | lib_route_map_entry_match_condition_rmap_match_condition_origin_modify( |
265 | | struct nb_cb_modify_args *args) |
266 | 0 | { |
267 | 0 | struct routemap_hook_context *rhc; |
268 | 0 | const char *origin; |
269 | 0 | enum rmap_compile_rets ret; |
270 | |
|
271 | 0 | switch (args->event) { |
272 | 0 | case NB_EV_VALIDATE: |
273 | 0 | case NB_EV_PREPARE: |
274 | 0 | case NB_EV_ABORT: |
275 | 0 | break; |
276 | 0 | case NB_EV_APPLY: |
277 | | /* Add configuration. */ |
278 | 0 | rhc = nb_running_get_entry(args->dnode, NULL, true); |
279 | 0 | origin = yang_dnode_get_string(args->dnode, NULL); |
280 | | |
281 | | /* Set destroy information. */ |
282 | 0 | rhc->rhc_mhook = bgp_route_match_delete; |
283 | 0 | rhc->rhc_rule = "origin"; |
284 | 0 | rhc->rhc_event = RMAP_EVENT_MATCH_DELETED; |
285 | |
|
286 | 0 | ret = bgp_route_match_add(rhc->rhc_rmi, "origin", origin, |
287 | 0 | RMAP_EVENT_MATCH_ADDED, |
288 | 0 | args->errmsg, args->errmsg_len); |
289 | |
|
290 | 0 | if (ret != RMAP_COMPILE_SUCCESS) { |
291 | 0 | rhc->rhc_mhook = NULL; |
292 | 0 | return NB_ERR_INCONSISTENCY; |
293 | 0 | } |
294 | 0 | } |
295 | | |
296 | 0 | return NB_OK; |
297 | 0 | } |
298 | | |
299 | | int |
300 | | lib_route_map_entry_match_condition_rmap_match_condition_origin_destroy( |
301 | | struct nb_cb_destroy_args *args) |
302 | 0 | { |
303 | 0 | switch (args->event) { |
304 | 0 | case NB_EV_VALIDATE: |
305 | 0 | case NB_EV_PREPARE: |
306 | 0 | case NB_EV_ABORT: |
307 | 0 | break; |
308 | 0 | case NB_EV_APPLY: |
309 | 0 | return lib_route_map_entry_match_destroy(args); |
310 | 0 | } |
311 | | |
312 | 0 | return NB_OK; |
313 | 0 | } |
314 | | |
315 | | /* |
316 | | * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:rpki |
317 | | */ |
318 | | int |
319 | | lib_route_map_entry_match_condition_rmap_match_condition_rpki_modify( |
320 | | struct nb_cb_modify_args *args) |
321 | 0 | { |
322 | 0 | struct routemap_hook_context *rhc; |
323 | 0 | const char *rpki; |
324 | 0 | enum rmap_compile_rets ret; |
325 | |
|
326 | 0 | switch (args->event) { |
327 | 0 | case NB_EV_VALIDATE: |
328 | 0 | case NB_EV_PREPARE: |
329 | 0 | case NB_EV_ABORT: |
330 | 0 | break; |
331 | 0 | case NB_EV_APPLY: |
332 | | /* Add configuration. */ |
333 | 0 | rhc = nb_running_get_entry(args->dnode, NULL, true); |
334 | 0 | rpki = yang_dnode_get_string(args->dnode, NULL); |
335 | | |
336 | | /* Set destroy information. */ |
337 | 0 | rhc->rhc_mhook = bgp_route_match_delete; |
338 | 0 | rhc->rhc_rule = "rpki"; |
339 | 0 | rhc->rhc_event = RMAP_EVENT_MATCH_DELETED; |
340 | |
|
341 | 0 | ret = bgp_route_match_add(rhc->rhc_rmi, "rpki", rpki, |
342 | 0 | RMAP_EVENT_MATCH_ADDED, |
343 | 0 | args->errmsg, args->errmsg_len); |
344 | |
|
345 | 0 | if (ret != RMAP_COMPILE_SUCCESS) { |
346 | 0 | rhc->rhc_mhook = NULL; |
347 | 0 | return NB_ERR_INCONSISTENCY; |
348 | 0 | } |
349 | 0 | } |
350 | | |
351 | 0 | return NB_OK; |
352 | 0 | } |
353 | | |
354 | | int |
355 | | lib_route_map_entry_match_condition_rmap_match_condition_rpki_destroy( |
356 | | struct nb_cb_destroy_args *args) |
357 | 0 | { |
358 | 0 | switch (args->event) { |
359 | 0 | case NB_EV_VALIDATE: |
360 | 0 | case NB_EV_PREPARE: |
361 | 0 | case NB_EV_ABORT: |
362 | 0 | break; |
363 | 0 | case NB_EV_APPLY: |
364 | 0 | return lib_route_map_entry_match_destroy(args); |
365 | 0 | } |
366 | | |
367 | 0 | return NB_OK; |
368 | 0 | } |
369 | | |
370 | | /* |
371 | | * XPath: |
372 | | * /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:source-protocol |
373 | | */ |
374 | | int lib_route_map_entry_match_condition_rmap_match_condition_source_protocol_modify( |
375 | | struct nb_cb_modify_args *args) |
376 | 0 | { |
377 | 0 | struct routemap_hook_context *rhc; |
378 | 0 | enum rmap_compile_rets ret; |
379 | 0 | const char *proto; |
380 | |
|
381 | 0 | switch (args->event) { |
382 | 0 | case NB_EV_VALIDATE: |
383 | 0 | case NB_EV_PREPARE: |
384 | 0 | case NB_EV_ABORT: |
385 | 0 | break; |
386 | 0 | case NB_EV_APPLY: |
387 | | /* Add configuration. */ |
388 | 0 | rhc = nb_running_get_entry(args->dnode, NULL, true); |
389 | 0 | proto = yang_dnode_get_string(args->dnode, NULL); |
390 | | |
391 | | /* Set destroy information. */ |
392 | 0 | rhc->rhc_mhook = bgp_route_match_delete; |
393 | 0 | rhc->rhc_rule = "source-protocol"; |
394 | 0 | rhc->rhc_event = RMAP_EVENT_MATCH_DELETED; |
395 | |
|
396 | 0 | ret = bgp_route_match_add(rhc->rhc_rmi, "source-protocol", |
397 | 0 | proto, RMAP_EVENT_MATCH_ADDED, |
398 | 0 | args->errmsg, args->errmsg_len); |
399 | |
|
400 | 0 | if (ret != RMAP_COMPILE_SUCCESS) { |
401 | 0 | rhc->rhc_mhook = NULL; |
402 | 0 | return NB_ERR_INCONSISTENCY; |
403 | 0 | } |
404 | 0 | } |
405 | | |
406 | 0 | return NB_OK; |
407 | 0 | } |
408 | | |
409 | | int lib_route_map_entry_match_condition_rmap_match_condition_source_protocol_destroy( |
410 | | struct nb_cb_destroy_args *args) |
411 | 0 | { |
412 | 0 | switch (args->event) { |
413 | 0 | case NB_EV_VALIDATE: |
414 | 0 | case NB_EV_PREPARE: |
415 | 0 | case NB_EV_ABORT: |
416 | 0 | break; |
417 | 0 | case NB_EV_APPLY: |
418 | 0 | return lib_route_map_entry_match_destroy(args); |
419 | 0 | } |
420 | | |
421 | 0 | return NB_OK; |
422 | 0 | } |
423 | | |
424 | | /* |
425 | | * XPath: |
426 | | * /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:rpki-extcommunity |
427 | | */ |
428 | | int lib_route_map_entry_match_condition_rmap_match_condition_rpki_extcommunity_modify( |
429 | | struct nb_cb_modify_args *args) |
430 | 0 | { |
431 | 0 | struct routemap_hook_context *rhc; |
432 | 0 | const char *rpki; |
433 | 0 | enum rmap_compile_rets ret; |
434 | |
|
435 | 0 | switch (args->event) { |
436 | 0 | case NB_EV_VALIDATE: |
437 | 0 | case NB_EV_PREPARE: |
438 | 0 | case NB_EV_ABORT: |
439 | 0 | break; |
440 | 0 | case NB_EV_APPLY: |
441 | | /* Add configuration. */ |
442 | 0 | rhc = nb_running_get_entry(args->dnode, NULL, true); |
443 | 0 | rpki = yang_dnode_get_string(args->dnode, NULL); |
444 | | |
445 | | /* Set destroy information. */ |
446 | 0 | rhc->rhc_mhook = bgp_route_match_delete; |
447 | 0 | rhc->rhc_rule = "rpki-extcommunity"; |
448 | 0 | rhc->rhc_event = RMAP_EVENT_MATCH_DELETED; |
449 | |
|
450 | 0 | ret = bgp_route_match_add(rhc->rhc_rmi, "rpki-extcommunity", |
451 | 0 | rpki, RMAP_EVENT_MATCH_ADDED, |
452 | 0 | args->errmsg, args->errmsg_len); |
453 | |
|
454 | 0 | if (ret != RMAP_COMPILE_SUCCESS) { |
455 | 0 | rhc->rhc_mhook = NULL; |
456 | 0 | return NB_ERR_INCONSISTENCY; |
457 | 0 | } |
458 | 0 | } |
459 | | |
460 | 0 | return NB_OK; |
461 | 0 | } |
462 | | |
463 | | int lib_route_map_entry_match_condition_rmap_match_condition_rpki_extcommunity_destroy( |
464 | | struct nb_cb_destroy_args *args) |
465 | 0 | { |
466 | 0 | switch (args->event) { |
467 | 0 | case NB_EV_VALIDATE: |
468 | 0 | case NB_EV_PREPARE: |
469 | 0 | case NB_EV_ABORT: |
470 | 0 | break; |
471 | 0 | case NB_EV_APPLY: |
472 | 0 | return lib_route_map_entry_match_destroy(args); |
473 | 0 | } |
474 | | |
475 | 0 | return NB_OK; |
476 | 0 | } |
477 | | |
478 | | /* |
479 | | * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:probability |
480 | | */ |
481 | | int |
482 | | lib_route_map_entry_match_condition_rmap_match_condition_probability_modify( |
483 | | struct nb_cb_modify_args *args) |
484 | 0 | { |
485 | 0 | struct routemap_hook_context *rhc; |
486 | 0 | const char *probability; |
487 | 0 | enum rmap_compile_rets ret; |
488 | |
|
489 | 0 | switch (args->event) { |
490 | 0 | case NB_EV_VALIDATE: |
491 | 0 | case NB_EV_PREPARE: |
492 | 0 | case NB_EV_ABORT: |
493 | 0 | break; |
494 | 0 | case NB_EV_APPLY: |
495 | | /* Add configuration. */ |
496 | 0 | rhc = nb_running_get_entry(args->dnode, NULL, true); |
497 | 0 | probability = yang_dnode_get_string(args->dnode, NULL); |
498 | | |
499 | | /* Set destroy information. */ |
500 | 0 | rhc->rhc_mhook = bgp_route_match_delete; |
501 | 0 | rhc->rhc_rule = "probability"; |
502 | 0 | rhc->rhc_event = RMAP_EVENT_MATCH_DELETED; |
503 | |
|
504 | 0 | ret = bgp_route_match_add(rhc->rhc_rmi, "probability", |
505 | 0 | probability, RMAP_EVENT_MATCH_ADDED, |
506 | 0 | args->errmsg, args->errmsg_len); |
507 | |
|
508 | 0 | if (ret != RMAP_COMPILE_SUCCESS) { |
509 | 0 | rhc->rhc_mhook = NULL; |
510 | 0 | return NB_ERR_INCONSISTENCY; |
511 | 0 | } |
512 | 0 | } |
513 | | |
514 | 0 | return NB_OK; |
515 | 0 | } |
516 | | |
517 | | int |
518 | | lib_route_map_entry_match_condition_rmap_match_condition_probability_destroy( |
519 | | struct nb_cb_destroy_args *args) |
520 | 0 | { |
521 | 0 | switch (args->event) { |
522 | 0 | case NB_EV_VALIDATE: |
523 | 0 | case NB_EV_PREPARE: |
524 | 0 | case NB_EV_ABORT: |
525 | 0 | case NB_EV_APPLY: |
526 | 0 | return lib_route_map_entry_match_destroy(args); |
527 | 0 | } |
528 | | |
529 | 0 | return NB_OK; |
530 | 0 | } |
531 | | |
532 | | /* |
533 | | * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:source-vrf |
534 | | */ |
535 | | int |
536 | | lib_route_map_entry_match_condition_rmap_match_condition_source_vrf_modify( |
537 | | struct nb_cb_modify_args *args) |
538 | 0 | { |
539 | 0 | struct routemap_hook_context *rhc; |
540 | 0 | const char *vrf; |
541 | 0 | enum rmap_compile_rets ret; |
542 | |
|
543 | 0 | switch (args->event) { |
544 | 0 | case NB_EV_VALIDATE: |
545 | 0 | case NB_EV_PREPARE: |
546 | 0 | case NB_EV_ABORT: |
547 | 0 | break; |
548 | 0 | case NB_EV_APPLY: |
549 | | /* Add configuration. */ |
550 | 0 | rhc = nb_running_get_entry(args->dnode, NULL, true); |
551 | 0 | vrf = yang_dnode_get_string(args->dnode, NULL); |
552 | | |
553 | | /* Set destroy information. */ |
554 | 0 | rhc->rhc_mhook = bgp_route_match_delete; |
555 | 0 | rhc->rhc_rule = "source-vrf"; |
556 | 0 | rhc->rhc_event = RMAP_EVENT_MATCH_DELETED; |
557 | |
|
558 | 0 | ret = bgp_route_match_add(rhc->rhc_rmi, "source-vrf", vrf, |
559 | 0 | RMAP_EVENT_MATCH_ADDED, |
560 | 0 | args->errmsg, args->errmsg_len); |
561 | |
|
562 | 0 | if (ret != RMAP_COMPILE_SUCCESS) { |
563 | 0 | rhc->rhc_mhook = NULL; |
564 | 0 | return NB_ERR_INCONSISTENCY; |
565 | 0 | } |
566 | 0 | } |
567 | | |
568 | 0 | return NB_OK; |
569 | 0 | } |
570 | | |
571 | | int |
572 | | lib_route_map_entry_match_condition_rmap_match_condition_source_vrf_destroy( |
573 | | struct nb_cb_destroy_args *args) |
574 | 0 | { |
575 | 0 | switch (args->event) { |
576 | 0 | case NB_EV_VALIDATE: |
577 | 0 | case NB_EV_PREPARE: |
578 | 0 | case NB_EV_ABORT: |
579 | 0 | break; |
580 | 0 | case NB_EV_APPLY: |
581 | 0 | return lib_route_map_entry_match_destroy(args); |
582 | 0 | } |
583 | | |
584 | 0 | return NB_OK; |
585 | 0 | } |
586 | | |
587 | | /* |
588 | | * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:peer-ipv4-address |
589 | | */ |
590 | | int |
591 | | lib_route_map_entry_match_condition_rmap_match_condition_peer_ipv4_address_modify( |
592 | | struct nb_cb_modify_args *args) |
593 | 0 | { |
594 | 0 | struct routemap_hook_context *rhc; |
595 | 0 | const char *peer; |
596 | 0 | enum rmap_compile_rets ret; |
597 | |
|
598 | 0 | switch (args->event) { |
599 | 0 | case NB_EV_VALIDATE: |
600 | 0 | case NB_EV_PREPARE: |
601 | 0 | case NB_EV_ABORT: |
602 | 0 | break; |
603 | 0 | case NB_EV_APPLY: |
604 | | /* Add configuration. */ |
605 | 0 | rhc = nb_running_get_entry(args->dnode, NULL, true); |
606 | 0 | peer = yang_dnode_get_string(args->dnode, NULL); |
607 | | |
608 | | /* Set destroy information. */ |
609 | 0 | rhc->rhc_mhook = bgp_route_match_delete; |
610 | 0 | rhc->rhc_rule = "peer"; |
611 | 0 | rhc->rhc_event = RMAP_EVENT_MATCH_DELETED; |
612 | |
|
613 | 0 | ret = bgp_route_match_add(rhc->rhc_rmi, "peer", peer, |
614 | 0 | RMAP_EVENT_MATCH_ADDED, |
615 | 0 | args->errmsg, args->errmsg_len); |
616 | |
|
617 | 0 | if (ret != RMAP_COMPILE_SUCCESS) { |
618 | 0 | rhc->rhc_mhook = NULL; |
619 | 0 | return NB_ERR_INCONSISTENCY; |
620 | 0 | } |
621 | 0 | } |
622 | | |
623 | 0 | return NB_OK; |
624 | 0 | } |
625 | | |
626 | | int |
627 | | lib_route_map_entry_match_condition_rmap_match_condition_peer_ipv4_address_destroy( |
628 | | struct nb_cb_destroy_args *args) |
629 | 0 | { |
630 | 0 | switch (args->event) { |
631 | 0 | case NB_EV_VALIDATE: |
632 | 0 | case NB_EV_PREPARE: |
633 | 0 | case NB_EV_ABORT: |
634 | 0 | break; |
635 | 0 | case NB_EV_APPLY: |
636 | 0 | return lib_route_map_entry_match_destroy(args); |
637 | 0 | } |
638 | | |
639 | 0 | return NB_OK; |
640 | 0 | } |
641 | | |
642 | | /* |
643 | | * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:peer-interface |
644 | | */ |
645 | | int |
646 | | lib_route_map_entry_match_condition_rmap_match_condition_peer_interface_modify( |
647 | | struct nb_cb_modify_args *args) |
648 | 0 | { |
649 | 0 | struct routemap_hook_context *rhc; |
650 | 0 | const char *peer; |
651 | 0 | enum rmap_compile_rets ret; |
652 | |
|
653 | 0 | switch (args->event) { |
654 | 0 | case NB_EV_VALIDATE: |
655 | 0 | case NB_EV_PREPARE: |
656 | 0 | case NB_EV_ABORT: |
657 | 0 | break; |
658 | 0 | case NB_EV_APPLY: |
659 | | /* Add configuration. */ |
660 | 0 | rhc = nb_running_get_entry(args->dnode, NULL, true); |
661 | 0 | peer = yang_dnode_get_string(args->dnode, NULL); |
662 | | |
663 | | /* Set destroy information. */ |
664 | 0 | rhc->rhc_mhook = bgp_route_match_delete; |
665 | 0 | rhc->rhc_rule = "peer"; |
666 | 0 | rhc->rhc_event = RMAP_EVENT_MATCH_DELETED; |
667 | |
|
668 | 0 | ret = bgp_route_match_add(rhc->rhc_rmi, "peer", peer, |
669 | 0 | RMAP_EVENT_MATCH_ADDED, |
670 | 0 | args->errmsg, args->errmsg_len); |
671 | |
|
672 | 0 | if (ret != RMAP_COMPILE_SUCCESS) { |
673 | 0 | rhc->rhc_mhook = NULL; |
674 | 0 | return NB_ERR_INCONSISTENCY; |
675 | 0 | } |
676 | 0 | } |
677 | | |
678 | 0 | return NB_OK; |
679 | 0 | } |
680 | | |
681 | | int |
682 | | lib_route_map_entry_match_condition_rmap_match_condition_peer_interface_destroy( |
683 | | struct nb_cb_destroy_args *args) |
684 | 0 | { |
685 | 0 | switch (args->event) { |
686 | 0 | case NB_EV_VALIDATE: |
687 | 0 | case NB_EV_PREPARE: |
688 | 0 | case NB_EV_ABORT: |
689 | 0 | break; |
690 | 0 | case NB_EV_APPLY: |
691 | 0 | return lib_route_map_entry_match_destroy(args); |
692 | 0 | } |
693 | | |
694 | 0 | return NB_OK; |
695 | 0 | } |
696 | | |
697 | | /* |
698 | | * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:peer-ipv6-address |
699 | | */ |
700 | | int |
701 | | lib_route_map_entry_match_condition_rmap_match_condition_peer_ipv6_address_modify( |
702 | | struct nb_cb_modify_args *args) |
703 | 0 | { |
704 | 0 | struct routemap_hook_context *rhc; |
705 | 0 | const char *peer; |
706 | 0 | enum rmap_compile_rets ret; |
707 | |
|
708 | 0 | switch (args->event) { |
709 | 0 | case NB_EV_VALIDATE: |
710 | 0 | case NB_EV_PREPARE: |
711 | 0 | case NB_EV_ABORT: |
712 | 0 | break; |
713 | 0 | case NB_EV_APPLY: |
714 | | /* Add configuration. */ |
715 | 0 | rhc = nb_running_get_entry(args->dnode, NULL, true); |
716 | 0 | peer = yang_dnode_get_string(args->dnode, NULL); |
717 | | |
718 | | /* Set destroy information. */ |
719 | 0 | rhc->rhc_mhook = bgp_route_match_delete; |
720 | 0 | rhc->rhc_rule = "peer"; |
721 | 0 | rhc->rhc_event = RMAP_EVENT_MATCH_DELETED; |
722 | |
|
723 | 0 | ret = bgp_route_match_add(rhc->rhc_rmi, "peer", peer, |
724 | 0 | RMAP_EVENT_MATCH_ADDED, |
725 | 0 | args->errmsg, args->errmsg_len); |
726 | |
|
727 | 0 | if (ret != RMAP_COMPILE_SUCCESS) { |
728 | 0 | rhc->rhc_mhook = NULL; |
729 | 0 | return NB_ERR_INCONSISTENCY; |
730 | 0 | } |
731 | 0 | } |
732 | | |
733 | 0 | return NB_OK; |
734 | 0 | } |
735 | | |
736 | | int |
737 | | lib_route_map_entry_match_condition_rmap_match_condition_peer_ipv6_address_destroy( |
738 | | struct nb_cb_destroy_args *args) |
739 | 0 | { |
740 | 0 | switch (args->event) { |
741 | 0 | case NB_EV_VALIDATE: |
742 | 0 | case NB_EV_PREPARE: |
743 | 0 | case NB_EV_ABORT: |
744 | 0 | break; |
745 | 0 | case NB_EV_APPLY: |
746 | 0 | return lib_route_map_entry_match_destroy(args); |
747 | 0 | } |
748 | | |
749 | 0 | return NB_OK; |
750 | 0 | } |
751 | | |
752 | | /* |
753 | | * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:peer-local |
754 | | */ |
755 | | int |
756 | | lib_route_map_entry_match_condition_rmap_match_condition_peer_local_modify( |
757 | | struct nb_cb_modify_args *args) |
758 | 0 | { |
759 | 0 | struct routemap_hook_context *rhc; |
760 | 0 | bool value; |
761 | 0 | enum rmap_compile_rets ret; |
762 | |
|
763 | 0 | switch (args->event) { |
764 | 0 | case NB_EV_VALIDATE: |
765 | 0 | case NB_EV_PREPARE: |
766 | 0 | case NB_EV_ABORT: |
767 | 0 | break; |
768 | 0 | case NB_EV_APPLY: |
769 | | /* Add configuration. */ |
770 | 0 | rhc = nb_running_get_entry(args->dnode, NULL, true); |
771 | 0 | value = yang_dnode_get_bool(args->dnode, NULL); |
772 | | |
773 | | /* Set destroy information. */ |
774 | 0 | rhc->rhc_mhook = bgp_route_match_delete; |
775 | 0 | rhc->rhc_rule = "peer"; |
776 | 0 | rhc->rhc_event = RMAP_EVENT_MATCH_DELETED; |
777 | |
|
778 | 0 | if (value) { |
779 | 0 | ret = bgp_route_match_add(rhc->rhc_rmi, "peer", |
780 | 0 | "local", |
781 | 0 | RMAP_EVENT_MATCH_ADDED, |
782 | 0 | args->errmsg, args->errmsg_len); |
783 | |
|
784 | 0 | if (ret != RMAP_COMPILE_SUCCESS) { |
785 | 0 | rhc->rhc_mhook = NULL; |
786 | 0 | return NB_ERR_INCONSISTENCY; |
787 | 0 | } |
788 | 0 | } |
789 | 0 | } |
790 | | |
791 | 0 | return NB_OK; |
792 | 0 | } |
793 | | |
794 | | int |
795 | | lib_route_map_entry_match_condition_rmap_match_condition_peer_local_destroy( |
796 | | struct nb_cb_destroy_args *args) |
797 | 0 | { |
798 | 0 | switch (args->event) { |
799 | 0 | case NB_EV_VALIDATE: |
800 | 0 | case NB_EV_PREPARE: |
801 | 0 | case NB_EV_ABORT: |
802 | 0 | break; |
803 | 0 | case NB_EV_APPLY: |
804 | 0 | return lib_route_map_entry_match_destroy(args); |
805 | 0 | } |
806 | | |
807 | 0 | return NB_OK; |
808 | 0 | } |
809 | | |
810 | | /* |
811 | | * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:list-name |
812 | | */ |
813 | | int |
814 | | lib_route_map_entry_match_condition_rmap_match_condition_list_name_modify( |
815 | | struct nb_cb_modify_args *args) |
816 | 0 | { |
817 | 0 | struct routemap_hook_context *rhc; |
818 | 0 | const char *list_name; |
819 | 0 | enum rmap_compile_rets ret = RMAP_COMPILE_SUCCESS; |
820 | 0 | const char *condition; |
821 | |
|
822 | 0 | switch (args->event) { |
823 | 0 | case NB_EV_VALIDATE: |
824 | 0 | case NB_EV_PREPARE: |
825 | 0 | case NB_EV_ABORT: |
826 | 0 | break; |
827 | 0 | case NB_EV_APPLY: |
828 | | /* Add configuration. */ |
829 | 0 | rhc = nb_running_get_entry(args->dnode, NULL, true); |
830 | 0 | list_name = yang_dnode_get_string(args->dnode, NULL); |
831 | 0 | condition = yang_dnode_get_string(args->dnode, |
832 | 0 | "../../frr-route-map:condition"); |
833 | |
|
834 | 0 | if (IS_MATCH_AS_LIST(condition)) { |
835 | | /* Set destroy information. */ |
836 | 0 | rhc->rhc_mhook = bgp_route_match_delete; |
837 | 0 | rhc->rhc_rule = "as-path"; |
838 | 0 | rhc->rhc_event = RMAP_EVENT_ASLIST_DELETED; |
839 | |
|
840 | 0 | ret = bgp_route_match_add(rhc->rhc_rmi, "as-path", |
841 | 0 | list_name, RMAP_EVENT_ASLIST_ADDED, |
842 | 0 | args->errmsg, args->errmsg_len); |
843 | 0 | } else if (IS_MATCH_MAC_LIST(condition)) { |
844 | | /* Set destroy information. */ |
845 | 0 | rhc->rhc_mhook = bgp_route_match_delete; |
846 | 0 | rhc->rhc_rule = "mac address"; |
847 | 0 | rhc->rhc_event = RMAP_EVENT_FILTER_DELETED; |
848 | |
|
849 | 0 | ret = bgp_route_match_add(rhc->rhc_rmi, |
850 | 0 | "mac address", |
851 | 0 | list_name, |
852 | 0 | RMAP_EVENT_FILTER_ADDED, |
853 | 0 | args->errmsg, args->errmsg_len); |
854 | 0 | } else if (IS_MATCH_ROUTE_SRC(condition)) { |
855 | | /* Set destroy information. */ |
856 | 0 | rhc->rhc_mhook = bgp_route_match_delete; |
857 | 0 | rhc->rhc_rule = "ip route-source"; |
858 | 0 | rhc->rhc_event = RMAP_EVENT_FILTER_DELETED; |
859 | |
|
860 | 0 | ret = bgp_route_match_add(rhc->rhc_rmi, |
861 | 0 | "ip route-source", |
862 | 0 | list_name, RMAP_EVENT_FILTER_ADDED, |
863 | 0 | args->errmsg, args->errmsg_len); |
864 | 0 | } else if (IS_MATCH_ROUTE_SRC_PL(condition)) { |
865 | | /* Set destroy information. */ |
866 | 0 | rhc->rhc_mhook = bgp_route_match_delete; |
867 | 0 | rhc->rhc_rule = "ip route-source prefix-list"; |
868 | 0 | rhc->rhc_event = RMAP_EVENT_PLIST_DELETED; |
869 | |
|
870 | 0 | ret = bgp_route_match_add(rhc->rhc_rmi, |
871 | 0 | "ip route-source prefix-list", |
872 | 0 | list_name, RMAP_EVENT_PLIST_ADDED, |
873 | 0 | args->errmsg, args->errmsg_len); |
874 | 0 | } |
875 | |
|
876 | 0 | if (ret != RMAP_COMPILE_SUCCESS) { |
877 | 0 | rhc->rhc_mhook = NULL; |
878 | 0 | return NB_ERR_INCONSISTENCY; |
879 | 0 | } |
880 | 0 | } |
881 | | |
882 | 0 | return NB_OK; |
883 | 0 | } |
884 | | |
885 | | int |
886 | | lib_route_map_entry_match_condition_rmap_match_condition_list_name_destroy( |
887 | | struct nb_cb_destroy_args *args) |
888 | 0 | { |
889 | 0 | switch (args->event) { |
890 | 0 | case NB_EV_VALIDATE: |
891 | 0 | case NB_EV_PREPARE: |
892 | 0 | case NB_EV_ABORT: |
893 | 0 | break; |
894 | 0 | case NB_EV_APPLY: |
895 | 0 | return lib_route_map_entry_match_destroy(args); |
896 | 0 | } |
897 | | |
898 | 0 | return NB_OK; |
899 | 0 | } |
900 | | |
901 | | /* |
902 | | * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:evpn-default-route |
903 | | */ |
904 | | int |
905 | | lib_route_map_entry_match_condition_rmap_match_condition_evpn_default_route_create( |
906 | | struct nb_cb_create_args *args) |
907 | 0 | { |
908 | 0 | struct routemap_hook_context *rhc; |
909 | 0 | enum rmap_compile_rets ret; |
910 | |
|
911 | 0 | switch (args->event) { |
912 | 0 | case NB_EV_VALIDATE: |
913 | 0 | case NB_EV_PREPARE: |
914 | 0 | case NB_EV_ABORT: |
915 | 0 | break; |
916 | 0 | case NB_EV_APPLY: |
917 | | /* Add configuration. */ |
918 | 0 | rhc = nb_running_get_entry(args->dnode, NULL, true); |
919 | | |
920 | | /* Set destroy information. */ |
921 | 0 | rhc->rhc_mhook = bgp_route_match_delete; |
922 | 0 | rhc->rhc_rule = "evpn default-route"; |
923 | 0 | rhc->rhc_event = RMAP_EVENT_MATCH_DELETED; |
924 | |
|
925 | 0 | ret = bgp_route_match_add(rhc->rhc_rmi, "evpn default-route", |
926 | 0 | NULL, RMAP_EVENT_MATCH_ADDED, |
927 | 0 | args->errmsg, args->errmsg_len); |
928 | |
|
929 | 0 | if (ret != RMAP_COMPILE_SUCCESS) { |
930 | 0 | rhc->rhc_mhook = NULL; |
931 | 0 | return NB_ERR_INCONSISTENCY; |
932 | 0 | } |
933 | 0 | } |
934 | | |
935 | 0 | return NB_OK; |
936 | 0 | } |
937 | | |
938 | | int |
939 | | lib_route_map_entry_match_condition_rmap_match_condition_evpn_default_route_destroy( |
940 | | struct nb_cb_destroy_args *args) |
941 | 0 | { |
942 | 0 | switch (args->event) { |
943 | 0 | case NB_EV_VALIDATE: |
944 | 0 | case NB_EV_PREPARE: |
945 | 0 | case NB_EV_ABORT: |
946 | 0 | break; |
947 | 0 | case NB_EV_APPLY: |
948 | 0 | return lib_route_map_entry_match_destroy(args); |
949 | 0 | } |
950 | | |
951 | 0 | return NB_OK; |
952 | 0 | } |
953 | | |
954 | | /* |
955 | | * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:evpn-vni |
956 | | */ |
957 | | int |
958 | | lib_route_map_entry_match_condition_rmap_match_condition_evpn_vni_modify( |
959 | | struct nb_cb_modify_args *args) |
960 | 0 | { |
961 | 0 | struct routemap_hook_context *rhc; |
962 | 0 | const char *vni; |
963 | 0 | enum rmap_compile_rets ret; |
964 | |
|
965 | 0 | switch (args->event) { |
966 | 0 | case NB_EV_VALIDATE: |
967 | 0 | case NB_EV_PREPARE: |
968 | 0 | case NB_EV_ABORT: |
969 | 0 | break; |
970 | 0 | case NB_EV_APPLY: |
971 | | /* Add configuration. */ |
972 | 0 | rhc = nb_running_get_entry(args->dnode, NULL, true); |
973 | 0 | vni = yang_dnode_get_string(args->dnode, NULL); |
974 | | |
975 | | /* Set destroy information. */ |
976 | 0 | rhc->rhc_mhook = bgp_route_match_delete; |
977 | 0 | rhc->rhc_rule = "evpn vni"; |
978 | 0 | rhc->rhc_event = RMAP_EVENT_MATCH_DELETED; |
979 | |
|
980 | 0 | ret = bgp_route_match_add(rhc->rhc_rmi, "evpn vni", vni, |
981 | 0 | RMAP_EVENT_MATCH_ADDED, |
982 | 0 | args->errmsg, args->errmsg_len); |
983 | |
|
984 | 0 | if (ret != RMAP_COMPILE_SUCCESS) { |
985 | 0 | rhc->rhc_mhook = NULL; |
986 | 0 | return NB_ERR_INCONSISTENCY; |
987 | 0 | } |
988 | 0 | } |
989 | | |
990 | 0 | return NB_OK; |
991 | 0 | } |
992 | | |
993 | | int |
994 | | lib_route_map_entry_match_condition_rmap_match_condition_evpn_vni_destroy( |
995 | | struct nb_cb_destroy_args *args) |
996 | 0 | { |
997 | 0 | switch (args->event) { |
998 | 0 | case NB_EV_VALIDATE: |
999 | 0 | case NB_EV_PREPARE: |
1000 | 0 | case NB_EV_ABORT: |
1001 | 0 | break; |
1002 | 0 | case NB_EV_APPLY: |
1003 | 0 | return lib_route_map_entry_match_destroy(args); |
1004 | 0 | } |
1005 | | |
1006 | 0 | return NB_OK; |
1007 | 0 | } |
1008 | | |
1009 | | /* |
1010 | | * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:evpn-route-type |
1011 | | */ |
1012 | | int |
1013 | | lib_route_map_entry_match_condition_rmap_match_condition_evpn_route_type_modify( |
1014 | | struct nb_cb_modify_args *args) |
1015 | 0 | { |
1016 | 0 | struct routemap_hook_context *rhc; |
1017 | 0 | const char *type; |
1018 | 0 | enum rmap_compile_rets ret; |
1019 | |
|
1020 | 0 | switch (args->event) { |
1021 | 0 | case NB_EV_VALIDATE: |
1022 | 0 | case NB_EV_PREPARE: |
1023 | 0 | case NB_EV_ABORT: |
1024 | 0 | break; |
1025 | 0 | case NB_EV_APPLY: |
1026 | | /* Add configuration. */ |
1027 | 0 | rhc = nb_running_get_entry(args->dnode, NULL, true); |
1028 | 0 | type = yang_dnode_get_string(args->dnode, NULL); |
1029 | | |
1030 | | /* Set destroy information. */ |
1031 | 0 | rhc->rhc_mhook = bgp_route_match_delete; |
1032 | 0 | rhc->rhc_rule = "evpn route-type"; |
1033 | 0 | rhc->rhc_event = RMAP_EVENT_MATCH_DELETED; |
1034 | |
|
1035 | 0 | ret = bgp_route_match_add(rhc->rhc_rmi, "evpn route-type", |
1036 | 0 | type, |
1037 | 0 | RMAP_EVENT_MATCH_ADDED, |
1038 | 0 | args->errmsg, args->errmsg_len); |
1039 | |
|
1040 | 0 | if (ret != RMAP_COMPILE_SUCCESS) { |
1041 | 0 | rhc->rhc_mhook = NULL; |
1042 | 0 | return NB_ERR_INCONSISTENCY; |
1043 | 0 | } |
1044 | 0 | } |
1045 | | |
1046 | 0 | return NB_OK; |
1047 | 0 | } |
1048 | | |
1049 | | int |
1050 | | lib_route_map_entry_match_condition_rmap_match_condition_evpn_route_type_destroy( |
1051 | | struct nb_cb_destroy_args *args) |
1052 | 0 | { |
1053 | 0 | switch (args->event) { |
1054 | 0 | case NB_EV_VALIDATE: |
1055 | 0 | case NB_EV_PREPARE: |
1056 | 0 | case NB_EV_ABORT: |
1057 | 0 | break; |
1058 | 0 | case NB_EV_APPLY: |
1059 | 0 | return lib_route_map_entry_match_destroy(args); |
1060 | 0 | } |
1061 | | |
1062 | 0 | return NB_OK; |
1063 | 0 | } |
1064 | | |
1065 | | /* |
1066 | | * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:route-distinguisher |
1067 | | */ |
1068 | | int |
1069 | | lib_route_map_entry_match_condition_rmap_match_condition_route_distinguisher_modify( |
1070 | | struct nb_cb_modify_args *args) |
1071 | 0 | { |
1072 | 0 | struct routemap_hook_context *rhc; |
1073 | 0 | const char *rd; |
1074 | 0 | enum rmap_compile_rets ret; |
1075 | |
|
1076 | 0 | switch (args->event) { |
1077 | 0 | case NB_EV_VALIDATE: |
1078 | 0 | case NB_EV_PREPARE: |
1079 | 0 | case NB_EV_ABORT: |
1080 | 0 | break; |
1081 | 0 | case NB_EV_APPLY: |
1082 | | /* Add configuration. */ |
1083 | 0 | rhc = nb_running_get_entry(args->dnode, NULL, true); |
1084 | 0 | rd = yang_dnode_get_string(args->dnode, NULL); |
1085 | | |
1086 | | /* Set destroy information. */ |
1087 | 0 | rhc->rhc_mhook = bgp_route_match_delete; |
1088 | 0 | rhc->rhc_rule = "evpn rd"; |
1089 | 0 | rhc->rhc_event = RMAP_EVENT_MATCH_DELETED; |
1090 | |
|
1091 | 0 | ret = bgp_route_match_add(rhc->rhc_rmi, "evpn rd", rd, |
1092 | 0 | RMAP_EVENT_MATCH_ADDED, |
1093 | 0 | args->errmsg, args->errmsg_len); |
1094 | |
|
1095 | 0 | if (ret != RMAP_COMPILE_SUCCESS) { |
1096 | 0 | rhc->rhc_mhook = NULL; |
1097 | 0 | return NB_ERR_INCONSISTENCY; |
1098 | 0 | } |
1099 | 0 | } |
1100 | | |
1101 | 0 | return NB_OK; |
1102 | 0 | } |
1103 | | |
1104 | | int |
1105 | | lib_route_map_entry_match_condition_rmap_match_condition_route_distinguisher_destroy( |
1106 | | struct nb_cb_destroy_args *args) |
1107 | 0 | { |
1108 | 0 | switch (args->event) { |
1109 | 0 | case NB_EV_VALIDATE: |
1110 | 0 | case NB_EV_PREPARE: |
1111 | 0 | case NB_EV_ABORT: |
1112 | 0 | break; |
1113 | 0 | case NB_EV_APPLY: |
1114 | 0 | return lib_route_map_entry_match_destroy(args); |
1115 | 0 | } |
1116 | | |
1117 | 0 | return NB_OK; |
1118 | 0 | } |
1119 | | |
1120 | | /* |
1121 | | * XPath = /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:comm-list |
1122 | | */ |
1123 | | void |
1124 | | lib_route_map_entry_match_condition_rmap_match_condition_comm_list_finish( |
1125 | | struct nb_cb_apply_finish_args *args) |
1126 | 0 | { |
1127 | 0 | struct routemap_hook_context *rhc; |
1128 | 0 | const char *value; |
1129 | 0 | bool exact_match = false; |
1130 | 0 | char *argstr; |
1131 | 0 | const char *condition; |
1132 | 0 | route_map_event_t event; |
1133 | 0 | int ret; |
1134 | | |
1135 | | /* Add configuration. */ |
1136 | 0 | rhc = nb_running_get_entry(args->dnode, NULL, true); |
1137 | 0 | value = yang_dnode_get_string(args->dnode, "./comm-list-name"); |
1138 | |
|
1139 | 0 | if (yang_dnode_exists(args->dnode, "./comm-list-name-exact-match")) |
1140 | 0 | exact_match = yang_dnode_get_bool( |
1141 | 0 | args->dnode, "./comm-list-name-exact-match"); |
1142 | |
|
1143 | 0 | if (exact_match) { |
1144 | 0 | argstr = XMALLOC(MTYPE_ROUTE_MAP_COMPILED, |
1145 | 0 | strlen(value) + strlen("exact-match") + 2); |
1146 | |
|
1147 | 0 | snprintf(argstr, (strlen(value) + strlen("exact-match") + 2), |
1148 | 0 | "%s exact-match", value); |
1149 | 0 | } else |
1150 | 0 | argstr = (char *)value; |
1151 | | |
1152 | | /* Set destroy information. */ |
1153 | 0 | rhc->rhc_mhook = bgp_route_match_delete; |
1154 | |
|
1155 | 0 | condition = yang_dnode_get_string(args->dnode, |
1156 | 0 | "../../frr-route-map:condition"); |
1157 | 0 | if (IS_MATCH_COMMUNITY(condition)) { |
1158 | 0 | rhc->rhc_rule = "community"; |
1159 | 0 | event = RMAP_EVENT_CLIST_ADDED; |
1160 | 0 | rhc->rhc_event = RMAP_EVENT_CLIST_DELETED; |
1161 | 0 | } else if (IS_MATCH_LCOMMUNITY(condition)) { |
1162 | 0 | rhc->rhc_rule = "large-community"; |
1163 | 0 | event = RMAP_EVENT_LLIST_ADDED; |
1164 | 0 | rhc->rhc_event = RMAP_EVENT_LLIST_DELETED; |
1165 | 0 | } else { |
1166 | 0 | rhc->rhc_rule = "extcommunity"; |
1167 | 0 | event = RMAP_EVENT_ECLIST_ADDED; |
1168 | 0 | rhc->rhc_event = RMAP_EVENT_ECLIST_DELETED; |
1169 | 0 | } |
1170 | |
|
1171 | 0 | ret = bgp_route_match_add(rhc->rhc_rmi, rhc->rhc_rule, argstr, event, |
1172 | 0 | args->errmsg, args->errmsg_len); |
1173 | | /* |
1174 | | * At this point if this is not a successful operation |
1175 | | * bgpd is about to crash. Let's just cut to the |
1176 | | * chase and do it. |
1177 | | */ |
1178 | 0 | assert(ret == RMAP_COMPILE_SUCCESS); |
1179 | | |
1180 | 0 | if (argstr != value) |
1181 | 0 | XFREE(MTYPE_ROUTE_MAP_COMPILED, argstr); |
1182 | 0 | } |
1183 | | |
1184 | | /* |
1185 | | * XPath: |
1186 | | * /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:comm-list/comm-list-name |
1187 | | */ |
1188 | | int |
1189 | | lib_route_map_entry_match_condition_rmap_match_condition_comm_list_comm_list_name_modify( |
1190 | | struct nb_cb_modify_args *args) |
1191 | 0 | { |
1192 | 0 | switch (args->event) { |
1193 | 0 | case NB_EV_VALIDATE: |
1194 | 0 | case NB_EV_PREPARE: |
1195 | 0 | case NB_EV_ABORT: |
1196 | 0 | case NB_EV_APPLY: |
1197 | 0 | break; |
1198 | 0 | } |
1199 | | |
1200 | 0 | return NB_OK; |
1201 | 0 | } |
1202 | | |
1203 | | int |
1204 | | lib_route_map_entry_match_condition_rmap_match_condition_comm_list_comm_list_name_destroy( |
1205 | | struct nb_cb_destroy_args *args) |
1206 | 0 | { |
1207 | 0 | switch (args->event) { |
1208 | 0 | case NB_EV_VALIDATE: |
1209 | 0 | case NB_EV_PREPARE: |
1210 | 0 | case NB_EV_ABORT: |
1211 | 0 | break; |
1212 | 0 | case NB_EV_APPLY: |
1213 | 0 | return lib_route_map_entry_match_destroy(args); |
1214 | 0 | } |
1215 | | |
1216 | 0 | return NB_OK; |
1217 | |
|
1218 | 0 | } |
1219 | | |
1220 | | /* |
1221 | | * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:comm-list/comm-list-name-exact-match |
1222 | | */ |
1223 | | int |
1224 | | lib_route_map_entry_match_condition_rmap_match_condition_comm_list_comm_list_name_exact_match_modify( |
1225 | | struct nb_cb_modify_args *args) |
1226 | 0 | { |
1227 | 0 | switch (args->event) { |
1228 | 0 | case NB_EV_VALIDATE: |
1229 | 0 | case NB_EV_PREPARE: |
1230 | 0 | case NB_EV_ABORT: |
1231 | 0 | case NB_EV_APPLY: |
1232 | 0 | break; |
1233 | 0 | } |
1234 | | |
1235 | 0 | return NB_OK; |
1236 | 0 | } |
1237 | | |
1238 | | int |
1239 | | lib_route_map_entry_match_condition_rmap_match_condition_comm_list_comm_list_name_exact_match_destroy( |
1240 | | struct nb_cb_destroy_args *args) |
1241 | 0 | { |
1242 | 0 | switch (args->event) { |
1243 | 0 | case NB_EV_VALIDATE: |
1244 | 0 | case NB_EV_PREPARE: |
1245 | 0 | case NB_EV_ABORT: |
1246 | 0 | break; |
1247 | 0 | case NB_EV_APPLY: |
1248 | 0 | return lib_route_map_entry_match_destroy(args); |
1249 | 0 | } |
1250 | | |
1251 | 0 | return NB_OK; |
1252 | 0 | } |
1253 | | |
1254 | | /* |
1255 | | * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:ipv4-address |
1256 | | */ |
1257 | | int |
1258 | | lib_route_map_entry_match_condition_rmap_match_condition_ipv4_address_modify( |
1259 | | struct nb_cb_modify_args *args) |
1260 | 0 | { |
1261 | 0 | struct routemap_hook_context *rhc; |
1262 | 0 | const char *peer; |
1263 | 0 | enum rmap_compile_rets ret; |
1264 | |
|
1265 | 0 | switch (args->event) { |
1266 | 0 | case NB_EV_VALIDATE: |
1267 | 0 | case NB_EV_PREPARE: |
1268 | 0 | case NB_EV_ABORT: |
1269 | 0 | break; |
1270 | 0 | case NB_EV_APPLY: |
1271 | | /* Add configuration. */ |
1272 | 0 | rhc = nb_running_get_entry(args->dnode, NULL, true); |
1273 | 0 | peer = yang_dnode_get_string(args->dnode, NULL); |
1274 | | |
1275 | | /* Set destroy information. */ |
1276 | 0 | rhc->rhc_mhook = bgp_route_match_delete; |
1277 | 0 | rhc->rhc_rule = "ip next-hop address"; |
1278 | 0 | rhc->rhc_event = RMAP_EVENT_MATCH_DELETED; |
1279 | |
|
1280 | 0 | ret = bgp_route_match_add(rhc->rhc_rmi, rhc->rhc_rule, |
1281 | 0 | peer, RMAP_EVENT_MATCH_ADDED, |
1282 | 0 | args->errmsg, args->errmsg_len); |
1283 | |
|
1284 | 0 | if (ret != RMAP_COMPILE_SUCCESS) { |
1285 | 0 | rhc->rhc_mhook = NULL; |
1286 | 0 | return NB_ERR_INCONSISTENCY; |
1287 | 0 | } |
1288 | 0 | } |
1289 | | |
1290 | 0 | return NB_OK; |
1291 | 0 | } |
1292 | | |
1293 | | int |
1294 | | lib_route_map_entry_match_condition_rmap_match_condition_ipv4_address_destroy( |
1295 | | struct nb_cb_destroy_args *args) |
1296 | 0 | { |
1297 | 0 | switch (args->event) { |
1298 | 0 | case NB_EV_VALIDATE: |
1299 | 0 | case NB_EV_PREPARE: |
1300 | 0 | case NB_EV_ABORT: |
1301 | 0 | break; |
1302 | 0 | case NB_EV_APPLY: |
1303 | 0 | return lib_route_map_entry_match_destroy(args); |
1304 | 0 | } |
1305 | | |
1306 | 0 | return NB_OK; |
1307 | 0 | } |
1308 | | |
1309 | | /* |
1310 | | * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:ipv6-address |
1311 | | */ |
1312 | | int |
1313 | | lib_route_map_entry_match_condition_rmap_match_condition_ipv6_address_modify( |
1314 | | struct nb_cb_modify_args *args) |
1315 | 0 | { |
1316 | 0 | struct routemap_hook_context *rhc; |
1317 | 0 | const char *peer; |
1318 | 0 | enum rmap_compile_rets ret; |
1319 | |
|
1320 | 0 | switch (args->event) { |
1321 | 0 | case NB_EV_VALIDATE: |
1322 | 0 | case NB_EV_PREPARE: |
1323 | 0 | case NB_EV_ABORT: |
1324 | 0 | break; |
1325 | 0 | case NB_EV_APPLY: |
1326 | | /* Add configuration. */ |
1327 | 0 | rhc = nb_running_get_entry(args->dnode, NULL, true); |
1328 | 0 | peer = yang_dnode_get_string(args->dnode, NULL); |
1329 | | |
1330 | | /* Set destroy information. */ |
1331 | 0 | rhc->rhc_mhook = bgp_route_match_delete; |
1332 | 0 | rhc->rhc_rule = "ipv6 next-hop address"; |
1333 | 0 | rhc->rhc_event = RMAP_EVENT_MATCH_DELETED; |
1334 | |
|
1335 | 0 | ret = bgp_route_match_add(rhc->rhc_rmi, rhc->rhc_rule, |
1336 | 0 | peer, RMAP_EVENT_MATCH_ADDED, |
1337 | 0 | args->errmsg, args->errmsg_len); |
1338 | |
|
1339 | 0 | if (ret != RMAP_COMPILE_SUCCESS) { |
1340 | 0 | rhc->rhc_mhook = NULL; |
1341 | 0 | return NB_ERR_INCONSISTENCY; |
1342 | 0 | } |
1343 | 0 | } |
1344 | | |
1345 | 0 | return NB_OK; |
1346 | 0 | } |
1347 | | |
1348 | | int |
1349 | | lib_route_map_entry_match_condition_rmap_match_condition_ipv6_address_destroy( |
1350 | | struct nb_cb_destroy_args *args) |
1351 | 0 | { |
1352 | 0 | switch (args->event) { |
1353 | 0 | case NB_EV_VALIDATE: |
1354 | 0 | case NB_EV_PREPARE: |
1355 | 0 | case NB_EV_ABORT: |
1356 | 0 | break; |
1357 | 0 | case NB_EV_APPLY: |
1358 | 0 | return lib_route_map_entry_match_destroy(args); |
1359 | 0 | } |
1360 | | |
1361 | 0 | return NB_OK; |
1362 | 0 | } |
1363 | | |
1364 | | /* |
1365 | | * XPath: |
1366 | | * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:distance |
1367 | | */ |
1368 | | int lib_route_map_entry_set_action_rmap_set_action_distance_modify( |
1369 | | struct nb_cb_modify_args *args) |
1370 | 0 | { |
1371 | 0 | struct routemap_hook_context *rhc; |
1372 | 0 | const char *type; |
1373 | 0 | int rv; |
1374 | |
|
1375 | 0 | switch (args->event) { |
1376 | 0 | case NB_EV_VALIDATE: |
1377 | 0 | case NB_EV_PREPARE: |
1378 | 0 | case NB_EV_ABORT: |
1379 | 0 | break; |
1380 | 0 | case NB_EV_APPLY: |
1381 | | /* Add configuration. */ |
1382 | 0 | rhc = nb_running_get_entry(args->dnode, NULL, true); |
1383 | 0 | type = yang_dnode_get_string(args->dnode, NULL); |
1384 | | |
1385 | | /* Set destroy information. */ |
1386 | 0 | rhc->rhc_shook = generic_set_delete; |
1387 | 0 | rhc->rhc_rule = "distance"; |
1388 | 0 | rhc->rhc_event = RMAP_EVENT_SET_DELETED; |
1389 | |
|
1390 | 0 | rv = generic_set_add(rhc->rhc_rmi, "distance", type, |
1391 | 0 | args->errmsg, args->errmsg_len); |
1392 | 0 | if (rv != CMD_SUCCESS) { |
1393 | 0 | rhc->rhc_shook = NULL; |
1394 | 0 | return NB_ERR_INCONSISTENCY; |
1395 | 0 | } |
1396 | 0 | } |
1397 | | |
1398 | 0 | return NB_OK; |
1399 | 0 | } |
1400 | | |
1401 | | int lib_route_map_entry_set_action_rmap_set_action_distance_destroy( |
1402 | | struct nb_cb_destroy_args *args) |
1403 | 0 | { |
1404 | 0 | switch (args->event) { |
1405 | 0 | case NB_EV_VALIDATE: |
1406 | 0 | case NB_EV_PREPARE: |
1407 | 0 | case NB_EV_ABORT: |
1408 | 0 | break; |
1409 | 0 | case NB_EV_APPLY: |
1410 | 0 | return lib_route_map_entry_match_destroy(args); |
1411 | 0 | } |
1412 | | |
1413 | 0 | return NB_OK; |
1414 | 0 | } |
1415 | | |
1416 | | /* |
1417 | | * XPath: |
1418 | | * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:extcommunity-rt |
1419 | | */ |
1420 | | int |
1421 | | lib_route_map_entry_set_action_rmap_set_action_extcommunity_rt_modify( |
1422 | | struct nb_cb_modify_args *args) |
1423 | 0 | { |
1424 | 0 | struct routemap_hook_context *rhc; |
1425 | 0 | const char *type; |
1426 | 0 | int rv; |
1427 | |
|
1428 | 0 | switch (args->event) { |
1429 | 0 | case NB_EV_VALIDATE: |
1430 | 0 | case NB_EV_PREPARE: |
1431 | 0 | case NB_EV_ABORT: |
1432 | 0 | break; |
1433 | 0 | case NB_EV_APPLY: |
1434 | | /* Add configuration. */ |
1435 | 0 | rhc = nb_running_get_entry(args->dnode, NULL, true); |
1436 | 0 | type = yang_dnode_get_string(args->dnode, NULL); |
1437 | | |
1438 | | /* Set destroy information. */ |
1439 | 0 | rhc->rhc_shook = generic_set_delete; |
1440 | 0 | rhc->rhc_rule = "extcommunity rt"; |
1441 | 0 | rhc->rhc_event = RMAP_EVENT_SET_DELETED; |
1442 | |
|
1443 | 0 | rv = generic_set_add(rhc->rhc_rmi, "extcommunity rt", type, |
1444 | 0 | args->errmsg, args->errmsg_len); |
1445 | 0 | if (rv != CMD_SUCCESS) { |
1446 | 0 | rhc->rhc_shook = NULL; |
1447 | 0 | return NB_ERR_INCONSISTENCY; |
1448 | 0 | } |
1449 | 0 | } |
1450 | | |
1451 | 0 | return NB_OK; |
1452 | 0 | } |
1453 | | |
1454 | | int |
1455 | | lib_route_map_entry_set_action_rmap_set_action_extcommunity_rt_destroy( |
1456 | | struct nb_cb_destroy_args *args) |
1457 | 0 | { |
1458 | 0 | switch (args->event) { |
1459 | 0 | case NB_EV_VALIDATE: |
1460 | 0 | case NB_EV_PREPARE: |
1461 | 0 | case NB_EV_ABORT: |
1462 | 0 | break; |
1463 | 0 | case NB_EV_APPLY: |
1464 | 0 | return lib_route_map_entry_match_destroy(args); |
1465 | 0 | } |
1466 | | |
1467 | 0 | return NB_OK; |
1468 | 0 | } |
1469 | | |
1470 | | /* |
1471 | | * XPath: |
1472 | | * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:extcommunity-nt |
1473 | | */ |
1474 | | int lib_route_map_entry_set_action_rmap_set_action_extcommunity_nt_modify( |
1475 | | struct nb_cb_modify_args *args) |
1476 | 0 | { |
1477 | 0 | struct routemap_hook_context *rhc; |
1478 | 0 | const char *str; |
1479 | 0 | int rv; |
1480 | |
|
1481 | 0 | switch (args->event) { |
1482 | 0 | case NB_EV_VALIDATE: |
1483 | 0 | case NB_EV_PREPARE: |
1484 | 0 | case NB_EV_ABORT: |
1485 | 0 | break; |
1486 | 0 | case NB_EV_APPLY: |
1487 | | /* Add configuration. */ |
1488 | 0 | rhc = nb_running_get_entry(args->dnode, NULL, true); |
1489 | 0 | str = yang_dnode_get_string(args->dnode, NULL); |
1490 | | |
1491 | | /* Set destroy information. */ |
1492 | 0 | rhc->rhc_shook = generic_set_delete; |
1493 | 0 | rhc->rhc_rule = "extcommunity nt"; |
1494 | 0 | rhc->rhc_event = RMAP_EVENT_SET_DELETED; |
1495 | |
|
1496 | 0 | rv = generic_set_add(rhc->rhc_rmi, "extcommunity nt", str, |
1497 | 0 | args->errmsg, args->errmsg_len); |
1498 | 0 | if (rv != CMD_SUCCESS) { |
1499 | 0 | rhc->rhc_shook = NULL; |
1500 | 0 | return NB_ERR_INCONSISTENCY; |
1501 | 0 | } |
1502 | 0 | } |
1503 | | |
1504 | 0 | return NB_OK; |
1505 | 0 | } |
1506 | | |
1507 | | int lib_route_map_entry_set_action_rmap_set_action_extcommunity_nt_destroy( |
1508 | | struct nb_cb_destroy_args *args) |
1509 | 0 | { |
1510 | 0 | switch (args->event) { |
1511 | 0 | case NB_EV_VALIDATE: |
1512 | 0 | case NB_EV_PREPARE: |
1513 | 0 | case NB_EV_ABORT: |
1514 | 0 | break; |
1515 | 0 | case NB_EV_APPLY: |
1516 | 0 | return lib_route_map_entry_match_destroy(args); |
1517 | 0 | } |
1518 | | |
1519 | 0 | return NB_OK; |
1520 | 0 | } |
1521 | | |
1522 | | /* |
1523 | | * XPath: |
1524 | | * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:extcommunity-soo |
1525 | | */ |
1526 | | int |
1527 | | lib_route_map_entry_set_action_rmap_set_action_extcommunity_soo_modify( |
1528 | | struct nb_cb_modify_args *args) |
1529 | 0 | { |
1530 | 0 | struct routemap_hook_context *rhc; |
1531 | 0 | const char *type; |
1532 | 0 | int rv; |
1533 | |
|
1534 | 0 | switch (args->event) { |
1535 | 0 | case NB_EV_VALIDATE: |
1536 | 0 | case NB_EV_PREPARE: |
1537 | 0 | case NB_EV_ABORT: |
1538 | 0 | break; |
1539 | 0 | case NB_EV_APPLY: |
1540 | | /* Add configuration. */ |
1541 | 0 | rhc = nb_running_get_entry(args->dnode, NULL, true); |
1542 | 0 | type = yang_dnode_get_string(args->dnode, NULL); |
1543 | | |
1544 | | /* Set destroy information. */ |
1545 | 0 | rhc->rhc_shook = generic_set_delete; |
1546 | 0 | rhc->rhc_rule = "extcommunity soo"; |
1547 | 0 | rhc->rhc_event = RMAP_EVENT_SET_DELETED; |
1548 | |
|
1549 | 0 | rv = generic_set_add(rhc->rhc_rmi, "extcommunity soo", |
1550 | 0 | type, |
1551 | 0 | args->errmsg, args->errmsg_len); |
1552 | 0 | if (rv != CMD_SUCCESS) { |
1553 | 0 | rhc->rhc_shook = NULL; |
1554 | 0 | return NB_ERR_INCONSISTENCY; |
1555 | 0 | } |
1556 | 0 | } |
1557 | | |
1558 | 0 | return NB_OK; |
1559 | 0 | } |
1560 | | |
1561 | | int |
1562 | | lib_route_map_entry_set_action_rmap_set_action_extcommunity_soo_destroy( |
1563 | | struct nb_cb_destroy_args *args) |
1564 | 0 | { |
1565 | 0 | switch (args->event) { |
1566 | 0 | case NB_EV_VALIDATE: |
1567 | 0 | case NB_EV_PREPARE: |
1568 | 0 | case NB_EV_ABORT: |
1569 | 0 | break; |
1570 | 0 | case NB_EV_APPLY: |
1571 | 0 | return lib_route_map_entry_match_destroy(args); |
1572 | 0 | } |
1573 | | |
1574 | 0 | return NB_OK; |
1575 | 0 | } |
1576 | | |
1577 | | /* |
1578 | | * XPath: |
1579 | | * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:ipv4-address |
1580 | | */ |
1581 | | int lib_route_map_entry_set_action_rmap_set_action_ipv4_address_modify( |
1582 | | struct nb_cb_modify_args *args) |
1583 | 0 | { |
1584 | 0 | struct routemap_hook_context *rhc; |
1585 | 0 | const char *addr; |
1586 | 0 | int rv = CMD_SUCCESS; |
1587 | |
|
1588 | 0 | switch (args->event) { |
1589 | 0 | case NB_EV_VALIDATE: |
1590 | 0 | case NB_EV_PREPARE: |
1591 | 0 | case NB_EV_ABORT: |
1592 | 0 | break; |
1593 | 0 | case NB_EV_APPLY: |
1594 | | /* Add configuration. */ |
1595 | 0 | rhc = nb_running_get_entry(args->dnode, NULL, true); |
1596 | 0 | addr = yang_dnode_get_string(args->dnode, NULL); |
1597 | |
|
1598 | 0 | rhc->rhc_shook = generic_set_delete; |
1599 | 0 | rhc->rhc_event = RMAP_EVENT_SET_DELETED; |
1600 | 0 | rhc->rhc_rule = "ipv4 vpn next-hop"; |
1601 | |
|
1602 | 0 | rv = generic_set_add(rhc->rhc_rmi, rhc->rhc_rule, addr, |
1603 | 0 | args->errmsg, args->errmsg_len); |
1604 | |
|
1605 | 0 | if (rv != CMD_SUCCESS) { |
1606 | 0 | rhc->rhc_shook = NULL; |
1607 | 0 | return NB_ERR_INCONSISTENCY; |
1608 | 0 | } |
1609 | 0 | } |
1610 | | |
1611 | 0 | return NB_OK; |
1612 | 0 | } |
1613 | | |
1614 | | int lib_route_map_entry_set_action_rmap_set_action_ipv4_address_destroy( |
1615 | | struct nb_cb_destroy_args *args) |
1616 | 0 | { |
1617 | 0 | switch (args->event) { |
1618 | 0 | case NB_EV_VALIDATE: |
1619 | 0 | case NB_EV_PREPARE: |
1620 | 0 | case NB_EV_ABORT: |
1621 | 0 | break; |
1622 | 0 | case NB_EV_APPLY: |
1623 | 0 | return lib_route_map_entry_set_destroy(args); |
1624 | 0 | } |
1625 | | |
1626 | 0 | return NB_OK; |
1627 | 0 | } |
1628 | | |
1629 | | /* |
1630 | | * XPath: |
1631 | | * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:ipv4-nexthop |
1632 | | */ |
1633 | | int lib_route_map_entry_set_action_rmap_set_action_ipv4_nexthop_modify( |
1634 | | struct nb_cb_modify_args *args) |
1635 | 0 | { |
1636 | 0 | struct routemap_hook_context *rhc; |
1637 | 0 | const char *type; |
1638 | 0 | int rv; |
1639 | |
|
1640 | 0 | switch (args->event) { |
1641 | 0 | case NB_EV_VALIDATE: |
1642 | 0 | case NB_EV_PREPARE: |
1643 | 0 | case NB_EV_ABORT: |
1644 | 0 | break; |
1645 | 0 | case NB_EV_APPLY: |
1646 | | /* Add configuration. */ |
1647 | 0 | rhc = nb_running_get_entry(args->dnode, NULL, true); |
1648 | 0 | type = yang_dnode_get_string(args->dnode, NULL); |
1649 | | |
1650 | | /* Set destroy information. */ |
1651 | 0 | rhc->rhc_shook = generic_set_delete; |
1652 | 0 | rhc->rhc_rule = "ip next-hop"; |
1653 | 0 | rhc->rhc_event = RMAP_EVENT_SET_DELETED; |
1654 | |
|
1655 | 0 | rv = generic_set_add(rhc->rhc_rmi, rhc->rhc_rule, type, |
1656 | 0 | args->errmsg, args->errmsg_len); |
1657 | |
|
1658 | 0 | if (rv != CMD_SUCCESS) { |
1659 | 0 | rhc->rhc_shook = NULL; |
1660 | 0 | return NB_ERR_INCONSISTENCY; |
1661 | 0 | } |
1662 | 0 | } |
1663 | | |
1664 | 0 | return NB_OK; |
1665 | 0 | } |
1666 | | |
1667 | | int lib_route_map_entry_set_action_rmap_set_action_ipv4_nexthop_destroy( |
1668 | | struct nb_cb_destroy_args *args) |
1669 | 0 | { |
1670 | 0 | switch (args->event) { |
1671 | 0 | case NB_EV_VALIDATE: |
1672 | 0 | case NB_EV_PREPARE: |
1673 | 0 | case NB_EV_ABORT: |
1674 | 0 | break; |
1675 | 0 | case NB_EV_APPLY: |
1676 | 0 | return lib_route_map_entry_set_destroy(args); |
1677 | 0 | } |
1678 | | |
1679 | 0 | return NB_OK; |
1680 | 0 | } |
1681 | | |
1682 | | /* |
1683 | | * XPath: |
1684 | | * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:ipv6-address |
1685 | | */ |
1686 | | int lib_route_map_entry_set_action_rmap_set_action_ipv6_address_modify( |
1687 | | struct nb_cb_modify_args *args) |
1688 | 0 | { |
1689 | 0 | struct routemap_hook_context *rhc; |
1690 | 0 | const char *addr; |
1691 | 0 | int rv = CMD_SUCCESS; |
1692 | 0 | const char *action = NULL; |
1693 | 0 | struct in6_addr i6a; |
1694 | |
|
1695 | 0 | action = yang_dnode_get_string(args->dnode, |
1696 | 0 | "../../frr-route-map:action"); |
1697 | 0 | switch (args->event) { |
1698 | 0 | case NB_EV_VALIDATE: |
1699 | 0 | if (action && IS_SET_IPV6_NH_GLOBAL(action)) { |
1700 | 0 | yang_dnode_get_ipv6(&i6a, args->dnode, NULL); |
1701 | 0 | if (IN6_IS_ADDR_UNSPECIFIED(&i6a) |
1702 | 0 | || IN6_IS_ADDR_LOOPBACK(&i6a) |
1703 | 0 | || IN6_IS_ADDR_MULTICAST(&i6a) |
1704 | 0 | || IN6_IS_ADDR_LINKLOCAL(&i6a)) |
1705 | 0 | return NB_ERR_VALIDATION; |
1706 | 0 | } |
1707 | | /* FALLTHROUGH */ |
1708 | 0 | case NB_EV_PREPARE: |
1709 | 0 | case NB_EV_ABORT: |
1710 | 0 | return NB_OK; |
1711 | 0 | case NB_EV_APPLY: |
1712 | 0 | break; |
1713 | 0 | } |
1714 | | |
1715 | | /* Add configuration. */ |
1716 | 0 | rhc = nb_running_get_entry(args->dnode, NULL, true); |
1717 | 0 | addr = yang_dnode_get_string(args->dnode, NULL); |
1718 | |
|
1719 | 0 | rhc->rhc_shook = generic_set_delete; |
1720 | 0 | rhc->rhc_event = RMAP_EVENT_SET_DELETED; |
1721 | |
|
1722 | 0 | if (IS_SET_IPV6_NH_GLOBAL(action)) |
1723 | | /* Set destroy information. */ |
1724 | 0 | rhc->rhc_rule = "ipv6 next-hop global"; |
1725 | 0 | else |
1726 | 0 | rhc->rhc_rule = "ipv6 vpn next-hop"; |
1727 | |
|
1728 | 0 | rv = generic_set_add(rhc->rhc_rmi, rhc->rhc_rule, addr, |
1729 | 0 | args->errmsg, args->errmsg_len); |
1730 | |
|
1731 | 0 | if (rv != CMD_SUCCESS) { |
1732 | 0 | rhc->rhc_shook = NULL; |
1733 | 0 | return NB_ERR_INCONSISTENCY; |
1734 | 0 | } |
1735 | | |
1736 | 0 | return NB_OK; |
1737 | 0 | } |
1738 | | |
1739 | | int lib_route_map_entry_set_action_rmap_set_action_ipv6_address_destroy( |
1740 | | struct nb_cb_destroy_args *args) |
1741 | 0 | { |
1742 | 0 | switch (args->event) { |
1743 | 0 | case NB_EV_VALIDATE: |
1744 | 0 | case NB_EV_PREPARE: |
1745 | 0 | case NB_EV_ABORT: |
1746 | 0 | break; |
1747 | 0 | case NB_EV_APPLY: |
1748 | 0 | return lib_route_map_entry_set_destroy(args); |
1749 | 0 | } |
1750 | | |
1751 | 0 | return NB_OK; |
1752 | 0 | } |
1753 | | |
1754 | | /* |
1755 | | * XPath: |
1756 | | * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:preference |
1757 | | */ |
1758 | | int lib_route_map_entry_set_action_rmap_set_action_preference_modify( |
1759 | | struct nb_cb_modify_args *args) |
1760 | 0 | { |
1761 | 0 | struct routemap_hook_context *rhc; |
1762 | 0 | int rv = CMD_SUCCESS; |
1763 | 0 | const char *action = NULL; |
1764 | 0 | bool value; |
1765 | |
|
1766 | 0 | switch (args->event) { |
1767 | 0 | case NB_EV_VALIDATE: |
1768 | 0 | case NB_EV_PREPARE: |
1769 | 0 | case NB_EV_ABORT: |
1770 | 0 | break; |
1771 | 0 | case NB_EV_APPLY: |
1772 | | /* Add configuration. */ |
1773 | 0 | rhc = nb_running_get_entry(args->dnode, NULL, true); |
1774 | 0 | value = yang_dnode_get_bool(args->dnode, NULL); |
1775 | |
|
1776 | 0 | rhc->rhc_shook = generic_set_delete; |
1777 | 0 | rhc->rhc_event = RMAP_EVENT_SET_DELETED; |
1778 | |
|
1779 | 0 | action = yang_dnode_get_string(args->dnode, |
1780 | 0 | "../../frr-route-map:action"); |
1781 | |
|
1782 | 0 | if (value) { |
1783 | 0 | if (IS_SET_IPV6_PEER_ADDR(action)) |
1784 | | /* Set destroy information. */ |
1785 | 0 | rhc->rhc_rule = "ipv6 next-hop peer-address"; |
1786 | 0 | else |
1787 | 0 | rhc->rhc_rule = "ipv6 next-hop prefer-global"; |
1788 | |
|
1789 | 0 | rv = generic_set_add(rhc->rhc_rmi, rhc->rhc_rule, |
1790 | 0 | NULL, |
1791 | 0 | args->errmsg, args->errmsg_len); |
1792 | 0 | } |
1793 | |
|
1794 | 0 | if (rv != CMD_SUCCESS) { |
1795 | 0 | rhc->rhc_shook = NULL; |
1796 | 0 | return NB_ERR_INCONSISTENCY; |
1797 | 0 | } |
1798 | 0 | } |
1799 | | |
1800 | 0 | return NB_OK; |
1801 | 0 | } |
1802 | | |
1803 | | int lib_route_map_entry_set_action_rmap_set_action_preference_destroy( |
1804 | | struct nb_cb_destroy_args *args) |
1805 | 0 | { |
1806 | 0 | switch (args->event) { |
1807 | 0 | case NB_EV_VALIDATE: |
1808 | 0 | case NB_EV_PREPARE: |
1809 | 0 | case NB_EV_ABORT: |
1810 | 0 | break; |
1811 | 0 | case NB_EV_APPLY: |
1812 | 0 | return lib_route_map_entry_set_destroy(args); |
1813 | 0 | } |
1814 | | |
1815 | 0 | return NB_OK; |
1816 | 0 | } |
1817 | | |
1818 | | /* |
1819 | | * XPath: |
1820 | | * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:label-index |
1821 | | */ |
1822 | | int lib_route_map_entry_set_action_rmap_set_action_label_index_modify( |
1823 | | struct nb_cb_modify_args *args) |
1824 | 0 | { |
1825 | 0 | struct routemap_hook_context *rhc; |
1826 | 0 | const char *type; |
1827 | 0 | int rv; |
1828 | |
|
1829 | 0 | switch (args->event) { |
1830 | 0 | case NB_EV_VALIDATE: |
1831 | 0 | case NB_EV_PREPARE: |
1832 | 0 | case NB_EV_ABORT: |
1833 | 0 | break; |
1834 | 0 | case NB_EV_APPLY: |
1835 | | /* Add configuration. */ |
1836 | 0 | rhc = nb_running_get_entry(args->dnode, NULL, true); |
1837 | 0 | type = yang_dnode_get_string(args->dnode, NULL); |
1838 | | |
1839 | | /* Set destroy information. */ |
1840 | 0 | rhc->rhc_shook = generic_set_delete; |
1841 | 0 | rhc->rhc_rule = "label-index"; |
1842 | 0 | rhc->rhc_event = RMAP_EVENT_SET_DELETED; |
1843 | |
|
1844 | 0 | rv = generic_set_add(rhc->rhc_rmi, "label-index", type, |
1845 | 0 | args->errmsg, args->errmsg_len); |
1846 | 0 | if (rv != CMD_SUCCESS) { |
1847 | 0 | rhc->rhc_shook = NULL; |
1848 | 0 | return NB_ERR_INCONSISTENCY; |
1849 | 0 | } |
1850 | 0 | } |
1851 | | |
1852 | 0 | return NB_OK; |
1853 | 0 | } |
1854 | | |
1855 | | int lib_route_map_entry_set_action_rmap_set_action_label_index_destroy( |
1856 | | struct nb_cb_destroy_args *args) |
1857 | 0 | { |
1858 | 0 | switch (args->event) { |
1859 | 0 | case NB_EV_VALIDATE: |
1860 | 0 | case NB_EV_PREPARE: |
1861 | 0 | case NB_EV_ABORT: |
1862 | 0 | break; |
1863 | 0 | case NB_EV_APPLY: |
1864 | 0 | return lib_route_map_entry_set_destroy(args); |
1865 | 0 | } |
1866 | | |
1867 | 0 | return NB_OK; |
1868 | 0 | } |
1869 | | |
1870 | | /* |
1871 | | * XPath: |
1872 | | * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:local-pref |
1873 | | */ |
1874 | | int lib_route_map_entry_set_action_rmap_set_action_local_pref_modify( |
1875 | | struct nb_cb_modify_args *args) |
1876 | 0 | { |
1877 | 0 | struct routemap_hook_context *rhc; |
1878 | 0 | const char *type; |
1879 | 0 | int rv; |
1880 | |
|
1881 | 0 | switch (args->event) { |
1882 | 0 | case NB_EV_VALIDATE: |
1883 | 0 | case NB_EV_PREPARE: |
1884 | 0 | case NB_EV_ABORT: |
1885 | 0 | break; |
1886 | 0 | case NB_EV_APPLY: |
1887 | | /* Add configuration. */ |
1888 | 0 | rhc = nb_running_get_entry(args->dnode, NULL, true); |
1889 | 0 | type = yang_dnode_get_string(args->dnode, NULL); |
1890 | | |
1891 | | /* Set destroy information. */ |
1892 | 0 | rhc->rhc_shook = generic_set_delete; |
1893 | 0 | rhc->rhc_rule = "local-preference"; |
1894 | 0 | rhc->rhc_event = RMAP_EVENT_SET_DELETED; |
1895 | |
|
1896 | 0 | rv = generic_set_add(rhc->rhc_rmi, "local-preference", |
1897 | 0 | type, |
1898 | 0 | args->errmsg, args->errmsg_len); |
1899 | 0 | if (rv != CMD_SUCCESS) { |
1900 | 0 | rhc->rhc_shook = NULL; |
1901 | 0 | return NB_ERR_INCONSISTENCY; |
1902 | 0 | } |
1903 | 0 | } |
1904 | | |
1905 | 0 | return NB_OK; |
1906 | 0 | } |
1907 | | |
1908 | | int lib_route_map_entry_set_action_rmap_set_action_local_pref_destroy( |
1909 | | struct nb_cb_destroy_args *args) |
1910 | 0 | { |
1911 | 0 | switch (args->event) { |
1912 | 0 | case NB_EV_VALIDATE: |
1913 | 0 | case NB_EV_PREPARE: |
1914 | 0 | case NB_EV_ABORT: |
1915 | 0 | break; |
1916 | 0 | case NB_EV_APPLY: |
1917 | 0 | return lib_route_map_entry_set_destroy(args); |
1918 | 0 | } |
1919 | | |
1920 | 0 | return NB_OK; |
1921 | 0 | } |
1922 | | |
1923 | | /* |
1924 | | * XPath: |
1925 | | * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:weight |
1926 | | */ |
1927 | | int lib_route_map_entry_set_action_rmap_set_action_weight_modify( |
1928 | | struct nb_cb_modify_args *args) |
1929 | 0 | { |
1930 | 0 | struct routemap_hook_context *rhc; |
1931 | 0 | const char *type; |
1932 | 0 | int rv; |
1933 | |
|
1934 | 0 | switch (args->event) { |
1935 | 0 | case NB_EV_VALIDATE: |
1936 | 0 | case NB_EV_PREPARE: |
1937 | 0 | case NB_EV_ABORT: |
1938 | 0 | break; |
1939 | 0 | case NB_EV_APPLY: |
1940 | | /* Add configuration. */ |
1941 | 0 | rhc = nb_running_get_entry(args->dnode, NULL, true); |
1942 | 0 | type = yang_dnode_get_string(args->dnode, NULL); |
1943 | | |
1944 | | /* Set destroy information. */ |
1945 | 0 | rhc->rhc_shook = generic_set_delete; |
1946 | 0 | rhc->rhc_rule = "weight"; |
1947 | 0 | rhc->rhc_event = RMAP_EVENT_SET_DELETED; |
1948 | |
|
1949 | 0 | rv = generic_set_add(rhc->rhc_rmi, "weight", type, |
1950 | 0 | args->errmsg, args->errmsg_len); |
1951 | 0 | if (rv != CMD_SUCCESS) { |
1952 | 0 | rhc->rhc_shook = NULL; |
1953 | 0 | return NB_ERR_INCONSISTENCY; |
1954 | 0 | } |
1955 | 0 | } |
1956 | | |
1957 | 0 | return NB_OK; |
1958 | 0 | } |
1959 | | |
1960 | | int lib_route_map_entry_set_action_rmap_set_action_weight_destroy( |
1961 | | struct nb_cb_destroy_args *args) |
1962 | 0 | { |
1963 | 0 | switch (args->event) { |
1964 | 0 | case NB_EV_VALIDATE: |
1965 | 0 | case NB_EV_PREPARE: |
1966 | 0 | case NB_EV_ABORT: |
1967 | 0 | break; |
1968 | 0 | case NB_EV_APPLY: |
1969 | 0 | return lib_route_map_entry_set_destroy(args); |
1970 | 0 | } |
1971 | | |
1972 | 0 | return NB_OK; |
1973 | 0 | } |
1974 | | |
1975 | | /* |
1976 | | * XPath: |
1977 | | * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:origin |
1978 | | */ |
1979 | | int lib_route_map_entry_set_action_rmap_set_action_origin_modify( |
1980 | | struct nb_cb_modify_args *args) |
1981 | 0 | { |
1982 | 0 | struct routemap_hook_context *rhc; |
1983 | 0 | const char *type; |
1984 | 0 | int rv; |
1985 | |
|
1986 | 0 | switch (args->event) { |
1987 | 0 | case NB_EV_VALIDATE: |
1988 | 0 | case NB_EV_PREPARE: |
1989 | 0 | case NB_EV_ABORT: |
1990 | 0 | break; |
1991 | 0 | case NB_EV_APPLY: |
1992 | | /* Add configuration. */ |
1993 | 0 | rhc = nb_running_get_entry(args->dnode, NULL, true); |
1994 | 0 | type = yang_dnode_get_string(args->dnode, NULL); |
1995 | | |
1996 | | /* Set destroy information. */ |
1997 | 0 | rhc->rhc_shook = generic_set_delete; |
1998 | 0 | rhc->rhc_rule = "origin"; |
1999 | 0 | rhc->rhc_event = RMAP_EVENT_SET_DELETED; |
2000 | |
|
2001 | 0 | rv = generic_set_add(rhc->rhc_rmi, "origin", type, |
2002 | 0 | args->errmsg, args->errmsg_len); |
2003 | 0 | if (rv != CMD_SUCCESS) { |
2004 | 0 | rhc->rhc_shook = NULL; |
2005 | 0 | return NB_ERR_INCONSISTENCY; |
2006 | 0 | } |
2007 | 0 | } |
2008 | | |
2009 | 0 | return NB_OK; |
2010 | 0 | } |
2011 | | |
2012 | | int lib_route_map_entry_set_action_rmap_set_action_origin_destroy( |
2013 | | struct nb_cb_destroy_args *args) |
2014 | 0 | { |
2015 | 0 | switch (args->event) { |
2016 | 0 | case NB_EV_VALIDATE: |
2017 | 0 | case NB_EV_PREPARE: |
2018 | 0 | case NB_EV_ABORT: |
2019 | 0 | break; |
2020 | 0 | case NB_EV_APPLY: |
2021 | 0 | return lib_route_map_entry_set_destroy(args); |
2022 | |
|
2023 | 0 | } |
2024 | | |
2025 | 0 | return NB_OK; |
2026 | 0 | } |
2027 | | |
2028 | | /* |
2029 | | * XPath: |
2030 | | * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:originator-id |
2031 | | */ |
2032 | | int lib_route_map_entry_set_action_rmap_set_action_originator_id_modify( |
2033 | | struct nb_cb_modify_args *args) |
2034 | 0 | { |
2035 | 0 | struct routemap_hook_context *rhc; |
2036 | 0 | const char *type; |
2037 | 0 | int rv; |
2038 | |
|
2039 | 0 | switch (args->event) { |
2040 | 0 | case NB_EV_VALIDATE: |
2041 | 0 | case NB_EV_PREPARE: |
2042 | 0 | case NB_EV_ABORT: |
2043 | 0 | break; |
2044 | 0 | case NB_EV_APPLY: |
2045 | | /* Add configuration. */ |
2046 | 0 | rhc = nb_running_get_entry(args->dnode, NULL, true); |
2047 | 0 | type = yang_dnode_get_string(args->dnode, NULL); |
2048 | | |
2049 | | /* Set destroy information. */ |
2050 | 0 | rhc->rhc_shook = generic_set_delete; |
2051 | 0 | rhc->rhc_rule = "originator-id"; |
2052 | 0 | rhc->rhc_event = RMAP_EVENT_SET_DELETED; |
2053 | |
|
2054 | 0 | rv = generic_set_add(rhc->rhc_rmi, "originator-id", type, |
2055 | 0 | args->errmsg, args->errmsg_len); |
2056 | 0 | if (rv != CMD_SUCCESS) { |
2057 | 0 | rhc->rhc_shook = NULL; |
2058 | 0 | return NB_ERR_INCONSISTENCY; |
2059 | 0 | } |
2060 | 0 | } |
2061 | | |
2062 | 0 | return NB_OK; |
2063 | 0 | } |
2064 | | |
2065 | | int lib_route_map_entry_set_action_rmap_set_action_originator_id_destroy( |
2066 | | struct nb_cb_destroy_args *args) |
2067 | 0 | { |
2068 | 0 | switch (args->event) { |
2069 | 0 | case NB_EV_VALIDATE: |
2070 | 0 | case NB_EV_PREPARE: |
2071 | 0 | case NB_EV_ABORT: |
2072 | 0 | break; |
2073 | 0 | case NB_EV_APPLY: |
2074 | 0 | return lib_route_map_entry_set_destroy(args); |
2075 | 0 | } |
2076 | | |
2077 | 0 | return NB_OK; |
2078 | 0 | } |
2079 | | |
2080 | | /* |
2081 | | * XPath: |
2082 | | * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:table |
2083 | | */ |
2084 | | int lib_route_map_entry_set_action_rmap_set_action_table_modify( |
2085 | | struct nb_cb_modify_args *args) |
2086 | 0 | { |
2087 | 0 | struct routemap_hook_context *rhc; |
2088 | 0 | const char *type; |
2089 | 0 | int rv; |
2090 | |
|
2091 | 0 | switch (args->event) { |
2092 | 0 | case NB_EV_VALIDATE: |
2093 | 0 | case NB_EV_PREPARE: |
2094 | 0 | case NB_EV_ABORT: |
2095 | 0 | break; |
2096 | 0 | case NB_EV_APPLY: |
2097 | | /* Add configuration. */ |
2098 | 0 | rhc = nb_running_get_entry(args->dnode, NULL, true); |
2099 | 0 | type = yang_dnode_get_string(args->dnode, NULL); |
2100 | | |
2101 | | /* Set destroy information. */ |
2102 | 0 | rhc->rhc_shook = generic_set_delete; |
2103 | 0 | rhc->rhc_rule = "table"; |
2104 | 0 | rhc->rhc_event = RMAP_EVENT_SET_DELETED; |
2105 | |
|
2106 | 0 | rv = generic_set_add(rhc->rhc_rmi, "table", type, |
2107 | 0 | args->errmsg, args->errmsg_len); |
2108 | 0 | if (rv != CMD_SUCCESS) { |
2109 | 0 | rhc->rhc_shook = NULL; |
2110 | 0 | return NB_ERR_INCONSISTENCY; |
2111 | 0 | } |
2112 | 0 | } |
2113 | | |
2114 | 0 | return NB_OK; |
2115 | 0 | } |
2116 | | |
2117 | | int lib_route_map_entry_set_action_rmap_set_action_table_destroy( |
2118 | | struct nb_cb_destroy_args *args) |
2119 | 0 | { |
2120 | 0 | switch (args->event) { |
2121 | 0 | case NB_EV_VALIDATE: |
2122 | 0 | case NB_EV_PREPARE: |
2123 | 0 | case NB_EV_ABORT: |
2124 | 0 | break; |
2125 | 0 | case NB_EV_APPLY: |
2126 | 0 | return lib_route_map_entry_set_destroy(args); |
2127 | 0 | } |
2128 | | |
2129 | 0 | return NB_OK; |
2130 | 0 | } |
2131 | | |
2132 | | /* |
2133 | | * XPath: |
2134 | | * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:atomic-aggregate |
2135 | | */ |
2136 | | int |
2137 | | lib_route_map_entry_set_action_rmap_set_action_atomic_aggregate_create( |
2138 | | struct nb_cb_create_args *args) |
2139 | 0 | { |
2140 | 0 | struct routemap_hook_context *rhc; |
2141 | 0 | int rv; |
2142 | |
|
2143 | 0 | switch (args->event) { |
2144 | 0 | case NB_EV_VALIDATE: |
2145 | 0 | case NB_EV_PREPARE: |
2146 | 0 | case NB_EV_ABORT: |
2147 | 0 | break; |
2148 | 0 | case NB_EV_APPLY: |
2149 | | /* Add configuration. */ |
2150 | 0 | rhc = nb_running_get_entry(args->dnode, NULL, true); |
2151 | | |
2152 | | /* Set destroy information. */ |
2153 | 0 | rhc->rhc_shook = generic_set_delete; |
2154 | 0 | rhc->rhc_rule = "atomic-aggregate"; |
2155 | 0 | rhc->rhc_event = RMAP_EVENT_SET_DELETED; |
2156 | |
|
2157 | 0 | rv = generic_set_add(rhc->rhc_rmi, rhc->rhc_rule, NULL, |
2158 | 0 | args->errmsg, args->errmsg_len); |
2159 | 0 | if (rv != CMD_SUCCESS) { |
2160 | 0 | rhc->rhc_shook = NULL; |
2161 | 0 | return NB_ERR_INCONSISTENCY; |
2162 | 0 | } |
2163 | 0 | } |
2164 | | |
2165 | 0 | return NB_OK; |
2166 | 0 | } |
2167 | | |
2168 | | int |
2169 | | lib_route_map_entry_set_action_rmap_set_action_atomic_aggregate_destroy( |
2170 | | struct nb_cb_destroy_args *args) |
2171 | 0 | { |
2172 | 0 | switch (args->event) { |
2173 | 0 | case NB_EV_VALIDATE: |
2174 | 0 | case NB_EV_PREPARE: |
2175 | 0 | case NB_EV_ABORT: |
2176 | 0 | break; |
2177 | 0 | case NB_EV_APPLY: |
2178 | 0 | return lib_route_map_entry_set_destroy(args); |
2179 | 0 | } |
2180 | | |
2181 | 0 | return NB_OK; |
2182 | 0 | } |
2183 | | |
2184 | | /* |
2185 | | * XPath: |
2186 | | * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:aigp-metric |
2187 | | */ |
2188 | | int lib_route_map_entry_set_action_rmap_set_action_aigp_metric_modify( |
2189 | | struct nb_cb_modify_args *args) |
2190 | 0 | { |
2191 | 0 | struct routemap_hook_context *rhc; |
2192 | 0 | const char *aigp; |
2193 | 0 | int rv; |
2194 | |
|
2195 | 0 | switch (args->event) { |
2196 | 0 | case NB_EV_VALIDATE: |
2197 | 0 | case NB_EV_PREPARE: |
2198 | 0 | case NB_EV_ABORT: |
2199 | 0 | break; |
2200 | 0 | case NB_EV_APPLY: |
2201 | | /* Add configuration. */ |
2202 | 0 | rhc = nb_running_get_entry(args->dnode, NULL, true); |
2203 | 0 | aigp = yang_dnode_get_string(args->dnode, NULL); |
2204 | | |
2205 | | /* Set destroy information. */ |
2206 | 0 | rhc->rhc_shook = generic_set_delete; |
2207 | 0 | rhc->rhc_rule = "aigp-metric"; |
2208 | 0 | rhc->rhc_event = RMAP_EVENT_SET_DELETED; |
2209 | |
|
2210 | 0 | rv = generic_set_add(rhc->rhc_rmi, rhc->rhc_rule, aigp, |
2211 | 0 | args->errmsg, args->errmsg_len); |
2212 | 0 | if (rv != CMD_SUCCESS) { |
2213 | 0 | rhc->rhc_shook = NULL; |
2214 | 0 | return NB_ERR_INCONSISTENCY; |
2215 | 0 | } |
2216 | 0 | } |
2217 | | |
2218 | 0 | return NB_OK; |
2219 | 0 | } |
2220 | | |
2221 | | int lib_route_map_entry_set_action_rmap_set_action_aigp_metric_destroy( |
2222 | | struct nb_cb_destroy_args *args) |
2223 | 0 | { |
2224 | 0 | switch (args->event) { |
2225 | 0 | case NB_EV_VALIDATE: |
2226 | 0 | case NB_EV_PREPARE: |
2227 | 0 | case NB_EV_ABORT: |
2228 | 0 | break; |
2229 | 0 | case NB_EV_APPLY: |
2230 | 0 | return lib_route_map_entry_set_destroy(args); |
2231 | 0 | } |
2232 | | |
2233 | 0 | return NB_OK; |
2234 | 0 | } |
2235 | | |
2236 | | /* |
2237 | | * XPath: |
2238 | | * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:prepend-as-path |
2239 | | */ |
2240 | | int |
2241 | | lib_route_map_entry_set_action_rmap_set_action_prepend_as_path_modify( |
2242 | | struct nb_cb_modify_args *args) |
2243 | 0 | { |
2244 | 0 | struct routemap_hook_context *rhc; |
2245 | 0 | const char *type; |
2246 | 0 | int rv; |
2247 | |
|
2248 | 0 | switch (args->event) { |
2249 | 0 | case NB_EV_VALIDATE: |
2250 | 0 | case NB_EV_PREPARE: |
2251 | 0 | case NB_EV_ABORT: |
2252 | 0 | break; |
2253 | 0 | case NB_EV_APPLY: |
2254 | | /* Add configuration. */ |
2255 | 0 | rhc = nb_running_get_entry(args->dnode, NULL, true); |
2256 | 0 | type = yang_dnode_get_string(args->dnode, NULL); |
2257 | | |
2258 | | /* Set destroy information. */ |
2259 | 0 | rhc->rhc_shook = generic_set_delete; |
2260 | 0 | rhc->rhc_rule = "as-path prepend"; |
2261 | 0 | rhc->rhc_event = RMAP_EVENT_SET_DELETED; |
2262 | |
|
2263 | 0 | rv = generic_set_add(rhc->rhc_rmi, "as-path prepend", |
2264 | 0 | type, |
2265 | 0 | args->errmsg, args->errmsg_len); |
2266 | 0 | if (rv != CMD_SUCCESS) { |
2267 | 0 | rhc->rhc_shook = NULL; |
2268 | 0 | return NB_ERR_INCONSISTENCY; |
2269 | 0 | } |
2270 | 0 | } |
2271 | | |
2272 | 0 | return NB_OK; |
2273 | 0 | } |
2274 | | |
2275 | | int |
2276 | | lib_route_map_entry_set_action_rmap_set_action_prepend_as_path_destroy( |
2277 | | struct nb_cb_destroy_args *args) |
2278 | 0 | { |
2279 | 0 | switch (args->event) { |
2280 | 0 | case NB_EV_VALIDATE: |
2281 | 0 | case NB_EV_PREPARE: |
2282 | 0 | case NB_EV_ABORT: |
2283 | 0 | break; |
2284 | 0 | case NB_EV_APPLY: |
2285 | 0 | return lib_route_map_entry_set_destroy(args); |
2286 | 0 | } |
2287 | | |
2288 | 0 | return NB_OK; |
2289 | 0 | } |
2290 | | |
2291 | | /* |
2292 | | * XPath: |
2293 | | * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:last-as |
2294 | | */ |
2295 | | int lib_route_map_entry_set_action_rmap_set_action_last_as_modify( |
2296 | | struct nb_cb_modify_args *args) |
2297 | 0 | { |
2298 | 0 | struct routemap_hook_context *rhc; |
2299 | 0 | const char *value; |
2300 | 0 | char *argstr; |
2301 | 0 | int rv; |
2302 | |
|
2303 | 0 | switch (args->event) { |
2304 | 0 | case NB_EV_VALIDATE: |
2305 | 0 | case NB_EV_PREPARE: |
2306 | 0 | case NB_EV_ABORT: |
2307 | 0 | break; |
2308 | 0 | case NB_EV_APPLY: |
2309 | | /* Add configuration. */ |
2310 | 0 | rhc = nb_running_get_entry(args->dnode, NULL, true); |
2311 | 0 | value = yang_dnode_get_string(args->dnode, NULL); |
2312 | | |
2313 | | /* Set destroy information. */ |
2314 | 0 | rhc->rhc_shook = generic_set_delete; |
2315 | 0 | rhc->rhc_rule = "as-path prepend"; |
2316 | 0 | rhc->rhc_event = RMAP_EVENT_SET_DELETED; |
2317 | |
|
2318 | 0 | argstr = XMALLOC(MTYPE_ROUTE_MAP_COMPILED, |
2319 | 0 | strlen(value) + strlen("last-as") + 2); |
2320 | |
|
2321 | 0 | snprintf(argstr, (strlen(value) + strlen("last-as") + 2), |
2322 | 0 | "last-as %s", value); |
2323 | |
|
2324 | 0 | rv = generic_set_add(rhc->rhc_rmi, "as-path prepend", |
2325 | 0 | argstr, |
2326 | 0 | args->errmsg, args->errmsg_len); |
2327 | 0 | if (rv != CMD_SUCCESS) { |
2328 | 0 | rhc->rhc_shook = NULL; |
2329 | 0 | XFREE(MTYPE_ROUTE_MAP_COMPILED, argstr); |
2330 | 0 | return NB_ERR_INCONSISTENCY; |
2331 | 0 | } |
2332 | | |
2333 | 0 | XFREE(MTYPE_ROUTE_MAP_COMPILED, argstr); |
2334 | 0 | } |
2335 | | |
2336 | 0 | return NB_OK; |
2337 | 0 | } |
2338 | | |
2339 | | int lib_route_map_entry_set_action_rmap_set_action_last_as_destroy( |
2340 | | struct nb_cb_destroy_args *args) |
2341 | 0 | { |
2342 | 0 | switch (args->event) { |
2343 | 0 | case NB_EV_VALIDATE: |
2344 | 0 | case NB_EV_PREPARE: |
2345 | 0 | case NB_EV_ABORT: |
2346 | 0 | break; |
2347 | 0 | case NB_EV_APPLY: |
2348 | 0 | return lib_route_map_entry_set_destroy(args); |
2349 | 0 | } |
2350 | | |
2351 | 0 | return NB_OK; |
2352 | 0 | } |
2353 | | |
2354 | | /* |
2355 | | * XPath: |
2356 | | * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:exclude-as-path |
2357 | | */ |
2358 | | int |
2359 | | lib_route_map_entry_set_action_rmap_set_action_exclude_as_path_modify( |
2360 | | struct nb_cb_modify_args *args) |
2361 | 0 | { |
2362 | 0 | struct routemap_hook_context *rhc; |
2363 | 0 | const char *type; |
2364 | 0 | int rv; |
2365 | |
|
2366 | 0 | switch (args->event) { |
2367 | 0 | case NB_EV_VALIDATE: |
2368 | 0 | case NB_EV_PREPARE: |
2369 | 0 | case NB_EV_ABORT: |
2370 | 0 | break; |
2371 | 0 | case NB_EV_APPLY: |
2372 | | /* Add configuration. */ |
2373 | 0 | rhc = nb_running_get_entry(args->dnode, NULL, true); |
2374 | 0 | type = yang_dnode_get_string(args->dnode, NULL); |
2375 | | |
2376 | | /* Set destroy information. */ |
2377 | 0 | rhc->rhc_shook = generic_set_delete; |
2378 | 0 | rhc->rhc_rule = "as-path exclude"; |
2379 | 0 | rhc->rhc_event = RMAP_EVENT_SET_DELETED; |
2380 | |
|
2381 | 0 | rv = generic_set_add(rhc->rhc_rmi, "as-path exclude", |
2382 | 0 | type, |
2383 | 0 | args->errmsg, args->errmsg_len); |
2384 | 0 | if (rv != CMD_SUCCESS) { |
2385 | 0 | rhc->rhc_shook = NULL; |
2386 | 0 | return NB_ERR_INCONSISTENCY; |
2387 | 0 | } |
2388 | 0 | } |
2389 | | |
2390 | 0 | return NB_OK; |
2391 | 0 | } |
2392 | | |
2393 | | int |
2394 | | lib_route_map_entry_set_action_rmap_set_action_exclude_as_path_destroy( |
2395 | | struct nb_cb_destroy_args *args) |
2396 | 0 | { |
2397 | 0 | switch (args->event) { |
2398 | 0 | case NB_EV_VALIDATE: |
2399 | 0 | case NB_EV_PREPARE: |
2400 | 0 | case NB_EV_ABORT: |
2401 | 0 | break; |
2402 | 0 | case NB_EV_APPLY: |
2403 | 0 | return lib_route_map_entry_set_destroy(args); |
2404 | 0 | } |
2405 | | |
2406 | 0 | return NB_OK; |
2407 | 0 | } |
2408 | | |
2409 | | /* |
2410 | | * XPath: |
2411 | | * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:replace-as-path |
2412 | | */ |
2413 | | int lib_route_map_entry_set_action_rmap_set_action_replace_as_path_modify( |
2414 | | struct nb_cb_modify_args *args) |
2415 | 0 | { |
2416 | 0 | struct routemap_hook_context *rhc; |
2417 | 0 | const char *type; |
2418 | 0 | int rv; |
2419 | |
|
2420 | 0 | switch (args->event) { |
2421 | 0 | case NB_EV_VALIDATE: |
2422 | 0 | case NB_EV_PREPARE: |
2423 | 0 | case NB_EV_ABORT: |
2424 | 0 | break; |
2425 | 0 | case NB_EV_APPLY: |
2426 | | /* Add configuration. */ |
2427 | 0 | rhc = nb_running_get_entry(args->dnode, NULL, true); |
2428 | 0 | type = yang_dnode_get_string(args->dnode, NULL); |
2429 | | |
2430 | | /* Set destroy information. */ |
2431 | 0 | rhc->rhc_shook = generic_set_delete; |
2432 | 0 | rhc->rhc_rule = "as-path replace"; |
2433 | 0 | rhc->rhc_event = RMAP_EVENT_SET_DELETED; |
2434 | |
|
2435 | 0 | rv = generic_set_add(rhc->rhc_rmi, "as-path replace", type, |
2436 | 0 | args->errmsg, args->errmsg_len); |
2437 | 0 | if (rv != CMD_SUCCESS) { |
2438 | 0 | rhc->rhc_shook = NULL; |
2439 | 0 | return NB_ERR_INCONSISTENCY; |
2440 | 0 | } |
2441 | 0 | } |
2442 | | |
2443 | 0 | return NB_OK; |
2444 | 0 | } |
2445 | | |
2446 | | int lib_route_map_entry_set_action_rmap_set_action_replace_as_path_destroy( |
2447 | | struct nb_cb_destroy_args *args) |
2448 | 0 | { |
2449 | 0 | switch (args->event) { |
2450 | 0 | case NB_EV_VALIDATE: |
2451 | 0 | case NB_EV_PREPARE: |
2452 | 0 | case NB_EV_ABORT: |
2453 | 0 | break; |
2454 | 0 | case NB_EV_APPLY: |
2455 | 0 | return lib_route_map_entry_set_destroy(args); |
2456 | 0 | } |
2457 | | |
2458 | 0 | return NB_OK; |
2459 | 0 | } |
2460 | | |
2461 | | /* |
2462 | | * XPath: |
2463 | | * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:community-none |
2464 | | */ |
2465 | | int lib_route_map_entry_set_action_rmap_set_action_community_none_modify( |
2466 | | struct nb_cb_modify_args *args) |
2467 | 0 | { |
2468 | 0 | struct routemap_hook_context *rhc; |
2469 | 0 | bool none = false; |
2470 | 0 | int rv; |
2471 | |
|
2472 | 0 | switch (args->event) { |
2473 | 0 | case NB_EV_VALIDATE: |
2474 | 0 | case NB_EV_PREPARE: |
2475 | 0 | case NB_EV_ABORT: |
2476 | 0 | break; |
2477 | 0 | case NB_EV_APPLY: |
2478 | | /* Add configuration. */ |
2479 | 0 | rhc = nb_running_get_entry(args->dnode, NULL, true); |
2480 | 0 | none = yang_dnode_get_bool(args->dnode, NULL); |
2481 | | |
2482 | | /* Set destroy information. */ |
2483 | 0 | rhc->rhc_shook = generic_set_delete; |
2484 | 0 | rhc->rhc_rule = "community"; |
2485 | 0 | rhc->rhc_event = RMAP_EVENT_SET_DELETED; |
2486 | |
|
2487 | 0 | if (none) { |
2488 | 0 | rv = generic_set_add(rhc->rhc_rmi, "community", |
2489 | 0 | "none", |
2490 | 0 | args->errmsg, args->errmsg_len); |
2491 | 0 | if (rv != CMD_SUCCESS) { |
2492 | 0 | rhc->rhc_shook = NULL; |
2493 | 0 | return NB_ERR_INCONSISTENCY; |
2494 | 0 | } |
2495 | 0 | return NB_OK; |
2496 | 0 | } |
2497 | | |
2498 | 0 | return NB_ERR_INCONSISTENCY; |
2499 | 0 | } |
2500 | | |
2501 | 0 | return NB_OK; |
2502 | 0 | } |
2503 | | |
2504 | | int |
2505 | | lib_route_map_entry_set_action_rmap_set_action_community_none_destroy( |
2506 | | struct nb_cb_destroy_args *args) |
2507 | 0 | { |
2508 | 0 | switch (args->event) { |
2509 | 0 | case NB_EV_VALIDATE: |
2510 | 0 | case NB_EV_PREPARE: |
2511 | 0 | case NB_EV_ABORT: |
2512 | 0 | break; |
2513 | 0 | case NB_EV_APPLY: |
2514 | 0 | return lib_route_map_entry_set_destroy(args); |
2515 | 0 | } |
2516 | | |
2517 | 0 | return NB_OK; |
2518 | 0 | } |
2519 | | |
2520 | | /* |
2521 | | * XPath: |
2522 | | * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:community-string |
2523 | | */ |
2524 | | int |
2525 | | lib_route_map_entry_set_action_rmap_set_action_community_string_modify( |
2526 | | struct nb_cb_modify_args *args) |
2527 | 0 | { |
2528 | 0 | struct routemap_hook_context *rhc; |
2529 | 0 | const char *type; |
2530 | 0 | int rv; |
2531 | |
|
2532 | 0 | switch (args->event) { |
2533 | 0 | case NB_EV_VALIDATE: |
2534 | 0 | case NB_EV_PREPARE: |
2535 | 0 | case NB_EV_ABORT: |
2536 | 0 | break; |
2537 | 0 | case NB_EV_APPLY: |
2538 | | /* Add configuration. */ |
2539 | 0 | rhc = nb_running_get_entry(args->dnode, NULL, true); |
2540 | 0 | type = yang_dnode_get_string(args->dnode, NULL); |
2541 | | |
2542 | | /* Set destroy information. */ |
2543 | 0 | rhc->rhc_shook = generic_set_delete; |
2544 | 0 | rhc->rhc_rule = "community"; |
2545 | 0 | rhc->rhc_event = RMAP_EVENT_SET_DELETED; |
2546 | |
|
2547 | 0 | rv = generic_set_add(rhc->rhc_rmi, "community", type, |
2548 | 0 | args->errmsg, args->errmsg_len); |
2549 | 0 | if (rv != CMD_SUCCESS) { |
2550 | 0 | rhc->rhc_shook = NULL; |
2551 | 0 | return NB_ERR_INCONSISTENCY; |
2552 | 0 | } |
2553 | 0 | } |
2554 | | |
2555 | 0 | return NB_OK; |
2556 | 0 | } |
2557 | | |
2558 | | int |
2559 | | lib_route_map_entry_set_action_rmap_set_action_community_string_destroy( |
2560 | | struct nb_cb_destroy_args *args) |
2561 | 0 | { |
2562 | 0 | switch (args->event) { |
2563 | 0 | case NB_EV_VALIDATE: |
2564 | 0 | case NB_EV_PREPARE: |
2565 | 0 | case NB_EV_ABORT: |
2566 | 0 | break; |
2567 | 0 | case NB_EV_APPLY: |
2568 | 0 | return lib_route_map_entry_set_destroy(args); |
2569 | 0 | } |
2570 | | |
2571 | 0 | return NB_OK; |
2572 | 0 | } |
2573 | | |
2574 | | /* |
2575 | | * XPath: |
2576 | | * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:large-community-none |
2577 | | */ |
2578 | | int |
2579 | | lib_route_map_entry_set_action_rmap_set_action_large_community_none_modify( |
2580 | | struct nb_cb_modify_args *args) |
2581 | 0 | { |
2582 | 0 | struct routemap_hook_context *rhc; |
2583 | 0 | bool none = false; |
2584 | 0 | int rv; |
2585 | |
|
2586 | 0 | switch (args->event) { |
2587 | 0 | case NB_EV_VALIDATE: |
2588 | 0 | case NB_EV_PREPARE: |
2589 | 0 | case NB_EV_ABORT: |
2590 | 0 | break; |
2591 | 0 | case NB_EV_APPLY: |
2592 | | /* Add configuration. */ |
2593 | 0 | rhc = nb_running_get_entry(args->dnode, NULL, true); |
2594 | 0 | none = yang_dnode_get_bool(args->dnode, NULL); |
2595 | | |
2596 | | /* Set destroy information. */ |
2597 | 0 | rhc->rhc_shook = generic_set_delete; |
2598 | 0 | rhc->rhc_rule = "large-community"; |
2599 | 0 | rhc->rhc_event = RMAP_EVENT_SET_DELETED; |
2600 | |
|
2601 | 0 | if (none) { |
2602 | 0 | rv = generic_set_add(rhc->rhc_rmi, |
2603 | 0 | "large-community", |
2604 | 0 | "none", |
2605 | 0 | args->errmsg, args->errmsg_len); |
2606 | 0 | if (rv != CMD_SUCCESS) { |
2607 | 0 | rhc->rhc_shook = NULL; |
2608 | 0 | return NB_ERR_INCONSISTENCY; |
2609 | 0 | } |
2610 | 0 | return NB_OK; |
2611 | 0 | } |
2612 | | |
2613 | 0 | return NB_ERR_INCONSISTENCY; |
2614 | 0 | } |
2615 | | |
2616 | 0 | return NB_OK; |
2617 | 0 | } |
2618 | | |
2619 | | int |
2620 | | lib_route_map_entry_set_action_rmap_set_action_large_community_none_destroy( |
2621 | | struct nb_cb_destroy_args *args) |
2622 | 0 | { |
2623 | 0 | switch (args->event) { |
2624 | 0 | case NB_EV_VALIDATE: |
2625 | 0 | case NB_EV_PREPARE: |
2626 | 0 | case NB_EV_ABORT: |
2627 | 0 | break; |
2628 | 0 | case NB_EV_APPLY: |
2629 | 0 | return lib_route_map_entry_set_destroy(args); |
2630 | 0 | } |
2631 | | |
2632 | 0 | return NB_OK; |
2633 | 0 | } |
2634 | | |
2635 | | /* |
2636 | | * XPath: |
2637 | | * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:large-community-string |
2638 | | */ |
2639 | | int |
2640 | | lib_route_map_entry_set_action_rmap_set_action_large_community_string_modify( |
2641 | | struct nb_cb_modify_args *args) |
2642 | 0 | { |
2643 | 0 | struct routemap_hook_context *rhc; |
2644 | 0 | const char *type; |
2645 | 0 | int rv; |
2646 | |
|
2647 | 0 | switch (args->event) { |
2648 | 0 | case NB_EV_VALIDATE: |
2649 | 0 | case NB_EV_PREPARE: |
2650 | 0 | case NB_EV_ABORT: |
2651 | 0 | break; |
2652 | 0 | case NB_EV_APPLY: |
2653 | | /* Add configuration. */ |
2654 | 0 | rhc = nb_running_get_entry(args->dnode, NULL, true); |
2655 | 0 | type = yang_dnode_get_string(args->dnode, NULL); |
2656 | | |
2657 | | /* Set destroy information. */ |
2658 | 0 | rhc->rhc_shook = generic_set_delete; |
2659 | 0 | rhc->rhc_rule = "large-community"; |
2660 | 0 | rhc->rhc_event = RMAP_EVENT_SET_DELETED; |
2661 | |
|
2662 | 0 | rv = generic_set_add(rhc->rhc_rmi, "large-community", |
2663 | 0 | type, |
2664 | 0 | args->errmsg, args->errmsg_len); |
2665 | 0 | if (rv != CMD_SUCCESS) { |
2666 | 0 | rhc->rhc_shook = NULL; |
2667 | 0 | return NB_ERR_INCONSISTENCY; |
2668 | 0 | } |
2669 | 0 | } |
2670 | | |
2671 | 0 | return NB_OK; |
2672 | 0 | } |
2673 | | |
2674 | | int |
2675 | | lib_route_map_entry_set_action_rmap_set_action_large_community_string_destroy( |
2676 | | struct nb_cb_destroy_args *args) |
2677 | 0 | { |
2678 | 0 | switch (args->event) { |
2679 | 0 | case NB_EV_VALIDATE: |
2680 | 0 | case NB_EV_PREPARE: |
2681 | 0 | case NB_EV_ABORT: |
2682 | 0 | break; |
2683 | 0 | case NB_EV_APPLY: |
2684 | 0 | return lib_route_map_entry_set_destroy(args); |
2685 | 0 | } |
2686 | | |
2687 | 0 | return NB_OK; |
2688 | 0 | } |
2689 | | |
2690 | | /* |
2691 | | * xpath = |
2692 | | * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:aggregator |
2693 | | */ |
2694 | | void lib_route_map_entry_set_action_rmap_set_action_aggregator_finish( |
2695 | | struct nb_cb_apply_finish_args *args) |
2696 | 0 | { |
2697 | 0 | struct routemap_hook_context *rhc; |
2698 | 0 | const char *asn; |
2699 | 0 | const char *addr; |
2700 | 0 | char *argstr; |
2701 | 0 | int ret; |
2702 | | |
2703 | | /* Add configuration. */ |
2704 | 0 | rhc = nb_running_get_entry(args->dnode, NULL, true); |
2705 | 0 | asn = yang_dnode_get_string(args->dnode, "./aggregator-asn"); |
2706 | 0 | addr = yang_dnode_get_string(args->dnode, "./aggregator-address"); |
2707 | |
|
2708 | 0 | argstr = XMALLOC(MTYPE_ROUTE_MAP_COMPILED, |
2709 | 0 | strlen(asn) + strlen(addr) + 2); |
2710 | |
|
2711 | 0 | snprintf(argstr, (strlen(asn) + strlen(addr) + 2), "%s %s", asn, addr); |
2712 | | |
2713 | | /* Set destroy information. */ |
2714 | 0 | rhc->rhc_shook = generic_set_delete; |
2715 | 0 | rhc->rhc_rule = "aggregator as"; |
2716 | 0 | rhc->rhc_event = RMAP_EVENT_SET_DELETED; |
2717 | |
|
2718 | 0 | ret = generic_set_add(rhc->rhc_rmi, rhc->rhc_rule, argstr, args->errmsg, |
2719 | 0 | args->errmsg_len); |
2720 | | /* |
2721 | | * At this point if this is not a successful operation |
2722 | | * bgpd is about to crash. Let's just cut to the |
2723 | | * chase and do it. |
2724 | | */ |
2725 | 0 | assert(ret == CMD_SUCCESS); |
2726 | | |
2727 | 0 | XFREE(MTYPE_ROUTE_MAP_COMPILED, argstr); |
2728 | 0 | } |
2729 | | /* |
2730 | | * XPath: |
2731 | | * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:aggregator/aggregator-asn |
2732 | | */ |
2733 | | int |
2734 | | lib_route_map_entry_set_action_rmap_set_action_aggregator_aggregator_asn_modify( |
2735 | | struct nb_cb_modify_args *args) |
2736 | 0 | { |
2737 | 0 | const char *asn; |
2738 | 0 | enum match_type match; |
2739 | |
|
2740 | 0 | switch (args->event) { |
2741 | 0 | case NB_EV_VALIDATE: |
2742 | 0 | asn = yang_dnode_get_string(args->dnode, NULL); |
2743 | 0 | if (!asn) |
2744 | 0 | return NB_ERR_VALIDATION; |
2745 | 0 | match = asn_str2asn_match(asn); |
2746 | 0 | if (match == exact_match) |
2747 | 0 | return NB_OK; |
2748 | 0 | return NB_ERR_VALIDATION; |
2749 | 0 | case NB_EV_PREPARE: |
2750 | 0 | case NB_EV_ABORT: |
2751 | 0 | case NB_EV_APPLY: |
2752 | 0 | break; |
2753 | 0 | } |
2754 | | |
2755 | 0 | return NB_OK; |
2756 | 0 | } |
2757 | | |
2758 | | int |
2759 | | lib_route_map_entry_set_action_rmap_set_action_aggregator_aggregator_asn_destroy( |
2760 | | struct nb_cb_destroy_args *args) |
2761 | 0 | { |
2762 | 0 | switch (args->event) { |
2763 | 0 | case NB_EV_VALIDATE: |
2764 | 0 | case NB_EV_PREPARE: |
2765 | 0 | case NB_EV_ABORT: |
2766 | 0 | break; |
2767 | 0 | case NB_EV_APPLY: |
2768 | 0 | return lib_route_map_entry_set_destroy(args); |
2769 | 0 | } |
2770 | | |
2771 | 0 | return NB_OK; |
2772 | 0 | } |
2773 | | |
2774 | | /* |
2775 | | * XPath: |
2776 | | * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:aggregator/aggregator-address |
2777 | | */ |
2778 | | int |
2779 | | lib_route_map_entry_set_action_rmap_set_action_aggregator_aggregator_address_modify( |
2780 | | struct nb_cb_modify_args *args) |
2781 | 0 | { |
2782 | 0 | switch (args->event) { |
2783 | 0 | case NB_EV_VALIDATE: |
2784 | 0 | case NB_EV_PREPARE: |
2785 | 0 | case NB_EV_ABORT: |
2786 | 0 | case NB_EV_APPLY: |
2787 | 0 | break; |
2788 | 0 | } |
2789 | | |
2790 | 0 | return NB_OK; |
2791 | 0 | } |
2792 | | |
2793 | | int |
2794 | | lib_route_map_entry_set_action_rmap_set_action_aggregator_aggregator_address_destroy( |
2795 | | struct nb_cb_destroy_args *args) |
2796 | 0 | { |
2797 | 0 | switch (args->event) { |
2798 | 0 | case NB_EV_VALIDATE: |
2799 | 0 | case NB_EV_PREPARE: |
2800 | 0 | case NB_EV_ABORT: |
2801 | 0 | break; |
2802 | 0 | case NB_EV_APPLY: |
2803 | 0 | return lib_route_map_entry_set_destroy(args); |
2804 | 0 | } |
2805 | | |
2806 | 0 | return NB_OK; |
2807 | 0 | } |
2808 | | |
2809 | | /* |
2810 | | * XPath: |
2811 | | * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:comm-list-name |
2812 | | */ |
2813 | | int lib_route_map_entry_set_action_rmap_set_action_comm_list_name_modify( |
2814 | | struct nb_cb_modify_args *args) |
2815 | 0 | { |
2816 | 0 | struct routemap_hook_context *rhc; |
2817 | 0 | const char *value; |
2818 | 0 | const char *action; |
2819 | 0 | int rv = CMD_SUCCESS; |
2820 | |
|
2821 | 0 | switch (args->event) { |
2822 | 0 | case NB_EV_VALIDATE: |
2823 | 0 | case NB_EV_PREPARE: |
2824 | 0 | case NB_EV_ABORT: |
2825 | 0 | break; |
2826 | 0 | case NB_EV_APPLY: |
2827 | | /* Add configuration. */ |
2828 | 0 | rhc = nb_running_get_entry(args->dnode, NULL, true); |
2829 | 0 | value = yang_dnode_get_string(args->dnode, NULL); |
2830 | | |
2831 | | /* Set destroy information. */ |
2832 | 0 | rhc->rhc_shook = generic_set_delete; |
2833 | |
|
2834 | 0 | action = yang_dnode_get_string(args->dnode, |
2835 | 0 | "../../frr-route-map:action"); |
2836 | 0 | if (IS_SET_COMM_LIST_DEL(action)) |
2837 | 0 | rhc->rhc_rule = "comm-list"; |
2838 | 0 | else |
2839 | 0 | rhc->rhc_rule = "large-comm-list"; |
2840 | |
|
2841 | 0 | rhc->rhc_event = RMAP_EVENT_SET_DELETED; |
2842 | |
|
2843 | 0 | rv = generic_set_add(rhc->rhc_rmi, rhc->rhc_rule, value, |
2844 | 0 | args->errmsg, args->errmsg_len); |
2845 | |
|
2846 | 0 | if (rv != CMD_SUCCESS) { |
2847 | 0 | rhc->rhc_shook = NULL; |
2848 | 0 | return NB_ERR_INCONSISTENCY; |
2849 | 0 | } |
2850 | 0 | } |
2851 | | |
2852 | 0 | return NB_OK; |
2853 | 0 | } |
2854 | | |
2855 | | int |
2856 | | lib_route_map_entry_set_action_rmap_set_action_comm_list_name_destroy( |
2857 | | struct nb_cb_destroy_args *args) |
2858 | 0 | { |
2859 | 0 | switch (args->event) { |
2860 | 0 | case NB_EV_VALIDATE: |
2861 | 0 | case NB_EV_PREPARE: |
2862 | 0 | case NB_EV_ABORT: |
2863 | 0 | break; |
2864 | 0 | case NB_EV_APPLY: |
2865 | 0 | return lib_route_map_entry_set_destroy(args); |
2866 | 0 | } |
2867 | | |
2868 | 0 | return NB_OK; |
2869 | 0 | } |
2870 | | |
2871 | | /* |
2872 | | * XPath: |
2873 | | * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:extcommunity-lb |
2874 | | */ |
2875 | | void |
2876 | | lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_finish( |
2877 | | struct nb_cb_apply_finish_args *args) |
2878 | 0 | { |
2879 | 0 | struct routemap_hook_context *rhc; |
2880 | 0 | enum ecommunity_lb_type lb_type; |
2881 | 0 | char str[VTY_BUFSIZ]; |
2882 | 0 | uint16_t bandwidth; |
2883 | 0 | int ret; |
2884 | | |
2885 | | /* Add configuration. */ |
2886 | 0 | rhc = nb_running_get_entry(args->dnode, NULL, true); |
2887 | 0 | lb_type = yang_dnode_get_enum(args->dnode, "./lb-type"); |
2888 | | |
2889 | | /* Set destroy information. */ |
2890 | 0 | rhc->rhc_shook = generic_set_delete; |
2891 | 0 | rhc->rhc_rule = "extcommunity bandwidth"; |
2892 | 0 | rhc->rhc_event = RMAP_EVENT_SET_DELETED; |
2893 | |
|
2894 | 0 | switch (lb_type) { |
2895 | 0 | case EXPLICIT_BANDWIDTH: |
2896 | 0 | bandwidth = yang_dnode_get_uint16(args->dnode, "./bandwidth"); |
2897 | 0 | snprintf(str, sizeof(str), "%d", bandwidth); |
2898 | 0 | break; |
2899 | 0 | case CUMULATIVE_BANDWIDTH: |
2900 | 0 | snprintf(str, sizeof(str), "%s", "cumulative"); |
2901 | 0 | break; |
2902 | 0 | case COMPUTED_BANDWIDTH: |
2903 | 0 | snprintf(str, sizeof(str), "%s", "num-multipaths"); |
2904 | 0 | } |
2905 | | |
2906 | 0 | if (yang_dnode_get_bool(args->dnode, "./two-octet-as-specific")) |
2907 | 0 | strlcat(str, " non-transitive", sizeof(str)); |
2908 | |
|
2909 | 0 | ret = generic_set_add(rhc->rhc_rmi, "extcommunity bandwidth", str, |
2910 | 0 | args->errmsg, args->errmsg_len); |
2911 | | /* |
2912 | | * At this point if this is not a successful operation |
2913 | | * bgpd is about to crash. Let's just cut to the |
2914 | | * chase and do it. |
2915 | | */ |
2916 | 0 | assert(ret == CMD_SUCCESS); |
2917 | 0 | } |
2918 | | |
2919 | | /* |
2920 | | * XPath: |
2921 | | * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:extcommunity-lb/lb-type |
2922 | | */ |
2923 | | int |
2924 | | lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_lb_type_modify( |
2925 | | struct nb_cb_modify_args *args) |
2926 | 0 | { |
2927 | 0 | return NB_OK; |
2928 | 0 | } |
2929 | | |
2930 | | int |
2931 | | lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_lb_type_destroy( |
2932 | | struct nb_cb_destroy_args *args) |
2933 | 0 | { |
2934 | 0 | return lib_route_map_entry_set_destroy(args); |
2935 | 0 | } |
2936 | | |
2937 | | /* |
2938 | | * XPath: |
2939 | | * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:extcommunity-lb/bandwidth |
2940 | | */ |
2941 | | int |
2942 | | lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_bandwidth_modify( |
2943 | | struct nb_cb_modify_args *args) |
2944 | 0 | { |
2945 | 0 | return NB_OK; |
2946 | 0 | } |
2947 | | |
2948 | | int |
2949 | | lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_bandwidth_destroy( |
2950 | | struct nb_cb_destroy_args *args) |
2951 | 0 | { |
2952 | 0 | return lib_route_map_entry_set_destroy(args); |
2953 | 0 | } |
2954 | | |
2955 | | /* |
2956 | | * XPath: |
2957 | | * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:extcommunity-lb/two-octet-as-specific |
2958 | | */ |
2959 | | int |
2960 | | lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_two_octet_as_specific_modify( |
2961 | | struct nb_cb_modify_args *args) |
2962 | 0 | { |
2963 | 0 | return NB_OK; |
2964 | 0 | } |
2965 | | |
2966 | | int |
2967 | | lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_two_octet_as_specific_destroy( |
2968 | | struct nb_cb_destroy_args *args) |
2969 | 0 | { |
2970 | 0 | return lib_route_map_entry_set_destroy(args); |
2971 | 0 | } |
2972 | | |
2973 | | /* |
2974 | | * XPath: |
2975 | | * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:extcommunity-none |
2976 | | */ |
2977 | | int lib_route_map_entry_set_action_rmap_set_action_extcommunity_none_modify( |
2978 | | struct nb_cb_modify_args *args) |
2979 | 0 | { |
2980 | 0 | struct routemap_hook_context *rhc; |
2981 | 0 | bool none = false; |
2982 | 0 | int rv; |
2983 | |
|
2984 | 0 | switch (args->event) { |
2985 | 0 | case NB_EV_VALIDATE: |
2986 | 0 | case NB_EV_PREPARE: |
2987 | 0 | case NB_EV_ABORT: |
2988 | 0 | break; |
2989 | 0 | case NB_EV_APPLY: |
2990 | | /* Add configuration. */ |
2991 | 0 | rhc = nb_running_get_entry(args->dnode, NULL, true); |
2992 | 0 | none = yang_dnode_get_bool(args->dnode, NULL); |
2993 | | |
2994 | | /* Set destroy information. */ |
2995 | 0 | rhc->rhc_shook = generic_set_delete; |
2996 | 0 | rhc->rhc_rule = "extcommunity"; |
2997 | 0 | rhc->rhc_event = RMAP_EVENT_SET_DELETED; |
2998 | |
|
2999 | 0 | if (none) { |
3000 | 0 | rv = generic_set_add(rhc->rhc_rmi, "extcommunity", |
3001 | 0 | "none", args->errmsg, |
3002 | 0 | args->errmsg_len); |
3003 | 0 | if (rv != CMD_SUCCESS) { |
3004 | 0 | rhc->rhc_shook = NULL; |
3005 | 0 | return NB_ERR_INCONSISTENCY; |
3006 | 0 | } |
3007 | 0 | return NB_OK; |
3008 | 0 | } |
3009 | | |
3010 | 0 | return NB_ERR_INCONSISTENCY; |
3011 | 0 | } |
3012 | | |
3013 | 0 | return NB_OK; |
3014 | 0 | } |
3015 | | |
3016 | | int lib_route_map_entry_set_action_rmap_set_action_extcommunity_none_destroy( |
3017 | | struct nb_cb_destroy_args *args) |
3018 | 0 | { |
3019 | 0 | switch (args->event) { |
3020 | 0 | case NB_EV_VALIDATE: |
3021 | 0 | case NB_EV_PREPARE: |
3022 | 0 | case NB_EV_ABORT: |
3023 | 0 | break; |
3024 | 0 | case NB_EV_APPLY: |
3025 | 0 | return lib_route_map_entry_set_destroy(args); |
3026 | 0 | } |
3027 | | |
3028 | 0 | return NB_OK; |
3029 | 0 | } |
3030 | | |
3031 | | /* |
3032 | | * XPath: |
3033 | | * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:evpn-gateway-ip-ipv4 |
3034 | | */ |
3035 | | int lib_route_map_entry_set_action_rmap_set_action_evpn_gateway_ip_ipv4_modify( |
3036 | | struct nb_cb_modify_args *args) |
3037 | 0 | { |
3038 | 0 | struct routemap_hook_context *rhc; |
3039 | 0 | const char *type; |
3040 | 0 | int rv; |
3041 | |
|
3042 | 0 | switch (args->event) { |
3043 | 0 | case NB_EV_VALIDATE: |
3044 | 0 | case NB_EV_PREPARE: |
3045 | 0 | case NB_EV_ABORT: |
3046 | 0 | break; |
3047 | 0 | case NB_EV_APPLY: |
3048 | | /* Add configuration. */ |
3049 | 0 | rhc = nb_running_get_entry(args->dnode, NULL, true); |
3050 | 0 | type = yang_dnode_get_string(args->dnode, NULL); |
3051 | | |
3052 | | /* Set destroy information. */ |
3053 | 0 | rhc->rhc_shook = generic_set_delete; |
3054 | 0 | rhc->rhc_rule = "evpn gateway-ip ipv4"; |
3055 | 0 | rhc->rhc_event = RMAP_EVENT_SET_DELETED; |
3056 | |
|
3057 | 0 | rv = generic_set_add(rhc->rhc_rmi, "evpn gateway-ip ipv4", type, |
3058 | 0 | args->errmsg, args->errmsg_len); |
3059 | 0 | if (rv != CMD_SUCCESS) { |
3060 | 0 | rhc->rhc_shook = NULL; |
3061 | 0 | return NB_ERR_INCONSISTENCY; |
3062 | 0 | } |
3063 | 0 | } |
3064 | | |
3065 | 0 | return NB_OK; |
3066 | 0 | } |
3067 | | |
3068 | | int lib_route_map_entry_set_action_rmap_set_action_evpn_gateway_ip_ipv4_destroy( |
3069 | | struct nb_cb_destroy_args *args) |
3070 | 0 | { |
3071 | 0 | switch (args->event) { |
3072 | 0 | case NB_EV_VALIDATE: |
3073 | 0 | case NB_EV_PREPARE: |
3074 | 0 | case NB_EV_ABORT: |
3075 | 0 | break; |
3076 | 0 | case NB_EV_APPLY: |
3077 | 0 | return lib_route_map_entry_set_destroy(args); |
3078 | 0 | } |
3079 | | |
3080 | 0 | return NB_OK; |
3081 | 0 | } |
3082 | | |
3083 | | /* |
3084 | | * XPath: |
3085 | | * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:evpn-gateway-ip-ipv6 |
3086 | | */ |
3087 | | int lib_route_map_entry_set_action_rmap_set_action_evpn_gateway_ip_ipv6_modify( |
3088 | | struct nb_cb_modify_args *args) |
3089 | 0 | { |
3090 | 0 | struct routemap_hook_context *rhc; |
3091 | 0 | const char *type; |
3092 | 0 | int rv; |
3093 | |
|
3094 | 0 | switch (args->event) { |
3095 | 0 | case NB_EV_VALIDATE: |
3096 | 0 | case NB_EV_PREPARE: |
3097 | 0 | case NB_EV_ABORT: |
3098 | 0 | break; |
3099 | 0 | case NB_EV_APPLY: |
3100 | | /* Add configuration. */ |
3101 | 0 | rhc = nb_running_get_entry(args->dnode, NULL, true); |
3102 | 0 | type = yang_dnode_get_string(args->dnode, NULL); |
3103 | | |
3104 | | /* Set destroy information. */ |
3105 | 0 | rhc->rhc_shook = generic_set_delete; |
3106 | 0 | rhc->rhc_rule = "evpn gateway-ip ipv6"; |
3107 | 0 | rhc->rhc_event = RMAP_EVENT_SET_DELETED; |
3108 | |
|
3109 | 0 | rv = generic_set_add(rhc->rhc_rmi, "evpn gateway-ip ipv6", type, |
3110 | 0 | args->errmsg, args->errmsg_len); |
3111 | 0 | if (rv != CMD_SUCCESS) { |
3112 | 0 | rhc->rhc_shook = NULL; |
3113 | 0 | return NB_ERR_INCONSISTENCY; |
3114 | 0 | } |
3115 | 0 | } |
3116 | | |
3117 | 0 | return NB_OK; |
3118 | 0 | } |
3119 | | |
3120 | | int lib_route_map_entry_set_action_rmap_set_action_evpn_gateway_ip_ipv6_destroy( |
3121 | | struct nb_cb_destroy_args *args) |
3122 | 0 | { |
3123 | 0 | switch (args->event) { |
3124 | 0 | case NB_EV_VALIDATE: |
3125 | 0 | case NB_EV_PREPARE: |
3126 | 0 | case NB_EV_ABORT: |
3127 | 0 | break; |
3128 | 0 | case NB_EV_APPLY: |
3129 | 0 | return lib_route_map_entry_set_destroy(args); |
3130 | 0 | } |
3131 | | |
3132 | 0 | return NB_OK; |
3133 | 0 | } |
3134 | | |
3135 | | /* |
3136 | | * XPath: |
3137 | | * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/l3vpn-nexthop-encapsulation |
3138 | | */ |
3139 | | int lib_route_map_entry_set_action_rmap_set_action_l3vpn_nexthop_encapsulation_modify( |
3140 | | struct nb_cb_modify_args *args) |
3141 | 0 | { |
3142 | 0 | struct routemap_hook_context *rhc; |
3143 | 0 | const char *type; |
3144 | 0 | int rv; |
3145 | |
|
3146 | 0 | switch (args->event) { |
3147 | 0 | case NB_EV_VALIDATE: |
3148 | 0 | case NB_EV_PREPARE: |
3149 | 0 | case NB_EV_ABORT: |
3150 | 0 | break; |
3151 | 0 | case NB_EV_APPLY: |
3152 | | /* Add configuration. */ |
3153 | 0 | rhc = nb_running_get_entry(args->dnode, NULL, true); |
3154 | 0 | type = yang_dnode_get_string(args->dnode, NULL); |
3155 | | |
3156 | | /* Set destroy information. */ |
3157 | 0 | rhc->rhc_shook = generic_set_delete; |
3158 | 0 | rhc->rhc_rule = "l3vpn next-hop encapsulation"; |
3159 | 0 | rhc->rhc_event = RMAP_EVENT_SET_DELETED; |
3160 | |
|
3161 | 0 | rv = generic_set_add(rhc->rhc_rmi, |
3162 | 0 | "l3vpn next-hop encapsulation", type, |
3163 | 0 | args->errmsg, args->errmsg_len); |
3164 | 0 | if (rv != CMD_SUCCESS) { |
3165 | 0 | rhc->rhc_shook = NULL; |
3166 | 0 | return NB_ERR_INCONSISTENCY; |
3167 | 0 | } |
3168 | 0 | } |
3169 | | |
3170 | 0 | return NB_OK; |
3171 | 0 | } |
3172 | | |
3173 | | int lib_route_map_entry_set_action_rmap_set_action_l3vpn_nexthop_encapsulation_destroy( |
3174 | | struct nb_cb_destroy_args *args) |
3175 | 0 | { |
3176 | 0 | switch (args->event) { |
3177 | 0 | case NB_EV_VALIDATE: |
3178 | 0 | case NB_EV_PREPARE: |
3179 | 0 | case NB_EV_ABORT: |
3180 | 0 | break; |
3181 | 0 | case NB_EV_APPLY: |
3182 | 0 | return lib_route_map_entry_set_destroy(args); |
3183 | 0 | } |
3184 | | |
3185 | 0 | return NB_OK; |
3186 | 0 | } |