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