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