1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (C) 2020 Vmware
9 #include "lib/command.h"
11 #include "lib/northbound.h"
12 #include "lib/routemap.h"
13 #include "bgpd/bgpd.h"
14 #include "bgpd/bgp_routemap_nb.h"
16 /* Add bgp route map rule. */
17 static int bgp_route_match_add(struct route_map_index
*index
,
18 const char *command
, const char *arg
,
19 route_map_event_t type
,
20 char *errmsg
, size_t errmsg_len
)
22 int retval
= CMD_SUCCESS
;
23 enum rmap_compile_rets ret
;
25 ret
= route_map_add_match(index
, command
, arg
, type
);
27 case RMAP_RULE_MISSING
:
28 snprintf(errmsg
, errmsg_len
, "%% BGP Can't find rule.");
29 retval
= CMD_WARNING_CONFIG_FAILED
;
31 case RMAP_COMPILE_ERROR
:
32 snprintf(errmsg
, errmsg_len
, "%% BGP Argument is malformed.");
33 retval
= CMD_WARNING_CONFIG_FAILED
;
35 case RMAP_COMPILE_SUCCESS
:
37 * Intentionally doing nothing here.
45 /* Delete bgp route map rule. */
46 static int bgp_route_match_delete(struct route_map_index
*index
,
47 const char *command
, const char *arg
,
48 route_map_event_t type
,
49 char *errmsg
, size_t errmsg_len
)
51 enum rmap_compile_rets ret
;
52 int retval
= CMD_SUCCESS
;
53 char *dep_name
= NULL
;
55 char *rmap_name
= NULL
;
57 if (type
!= RMAP_EVENT_MATCH_DELETED
) {
58 /* ignore the mundane, the types without any dependency */
60 tmpstr
= route_map_get_match_arg(index
, command
);
63 XSTRDUP(MTYPE_ROUTE_MAP_RULE
, tmpstr
);
65 dep_name
= XSTRDUP(MTYPE_ROUTE_MAP_RULE
, arg
);
67 rmap_name
= XSTRDUP(MTYPE_ROUTE_MAP_NAME
, index
->map
->name
);
70 ret
= route_map_delete_match(index
, command
, dep_name
, type
);
72 case RMAP_RULE_MISSING
:
73 snprintf(errmsg
, errmsg_len
, "%% BGP Can't find rule.");
74 retval
= CMD_WARNING_CONFIG_FAILED
;
76 case RMAP_COMPILE_ERROR
:
77 snprintf(errmsg
, errmsg_len
,
78 "%% BGP Argument is malformed.");
79 retval
= CMD_WARNING_CONFIG_FAILED
;
81 case RMAP_COMPILE_SUCCESS
:
88 XFREE(MTYPE_ROUTE_MAP_RULE
, dep_name
);
89 XFREE(MTYPE_ROUTE_MAP_NAME
, rmap_name
);
95 * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:local-preference
98 lib_route_map_entry_match_condition_rmap_match_condition_local_preference_modify(
99 struct nb_cb_modify_args
*args
)
101 struct routemap_hook_context
*rhc
;
102 const char *local_pref
;
103 enum rmap_compile_rets ret
;
105 switch (args
->event
) {
111 /* Add configuration. */
112 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
113 local_pref
= yang_dnode_get_string(args
->dnode
, NULL
);
115 /* Set destroy information. */
116 rhc
->rhc_mhook
= bgp_route_match_delete
;
117 rhc
->rhc_rule
= "local-preference";
118 rhc
->rhc_event
= RMAP_EVENT_MATCH_DELETED
;
120 ret
= bgp_route_match_add(rhc
->rhc_rmi
, "local-preference",
121 local_pref
, RMAP_EVENT_MATCH_ADDED
,
122 args
->errmsg
, args
->errmsg_len
);
124 if (ret
!= RMAP_COMPILE_SUCCESS
) {
125 rhc
->rhc_mhook
= NULL
;
126 return NB_ERR_INCONSISTENCY
;
134 lib_route_map_entry_match_condition_rmap_match_condition_local_preference_destroy(
135 struct nb_cb_destroy_args
*args
)
137 switch (args
->event
) {
143 return lib_route_map_entry_match_destroy(args
);
151 * /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:alias
153 int lib_route_map_entry_match_condition_rmap_match_condition_alias_modify(
154 struct nb_cb_modify_args
*args
)
156 struct routemap_hook_context
*rhc
;
158 enum rmap_compile_rets ret
;
160 switch (args
->event
) {
166 /* Add configuration. */
167 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
168 alias
= yang_dnode_get_string(args
->dnode
, NULL
);
170 /* Set destroy information. */
171 rhc
->rhc_mhook
= bgp_route_match_delete
;
172 rhc
->rhc_rule
= "alias";
173 rhc
->rhc_event
= RMAP_EVENT_MATCH_DELETED
;
175 ret
= bgp_route_match_add(rhc
->rhc_rmi
, "alias", alias
,
176 RMAP_EVENT_MATCH_ADDED
, args
->errmsg
,
179 if (ret
!= RMAP_COMPILE_SUCCESS
) {
180 rhc
->rhc_mhook
= NULL
;
181 return NB_ERR_VALIDATION
;
190 int lib_route_map_entry_match_condition_rmap_match_condition_alias_destroy(
191 struct nb_cb_destroy_args
*args
)
193 switch (args
->event
) {
199 return lib_route_map_entry_match_destroy(args
);
206 * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:script
209 lib_route_map_entry_match_condition_rmap_match_condition_script_modify(
210 struct nb_cb_modify_args
*args
)
212 struct routemap_hook_context
*rhc
;
214 enum rmap_compile_rets ret
;
216 switch (args
->event
) {
222 /* Add configuration. */
223 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
224 script
= yang_dnode_get_string(args
->dnode
, NULL
);
226 /* Set destroy information. */
227 rhc
->rhc_mhook
= bgp_route_match_delete
;
228 rhc
->rhc_rule
= "script";
229 rhc
->rhc_event
= RMAP_EVENT_MATCH_DELETED
;
231 ret
= bgp_route_match_add(rhc
->rhc_rmi
, "script",
232 script
, RMAP_EVENT_MATCH_ADDED
,
233 args
->errmsg
, args
->errmsg_len
);
235 if (ret
!= RMAP_COMPILE_SUCCESS
) {
236 rhc
->rhc_mhook
= NULL
;
237 return NB_ERR_INCONSISTENCY
;
245 lib_route_map_entry_match_condition_rmap_match_condition_script_destroy(
246 struct nb_cb_destroy_args
*args
)
248 switch (args
->event
) {
254 return lib_route_map_entry_match_destroy(args
);
261 * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:origin
264 lib_route_map_entry_match_condition_rmap_match_condition_origin_modify(
265 struct nb_cb_modify_args
*args
)
267 struct routemap_hook_context
*rhc
;
269 enum rmap_compile_rets ret
;
271 switch (args
->event
) {
277 /* Add configuration. */
278 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
279 origin
= yang_dnode_get_string(args
->dnode
, NULL
);
281 /* Set destroy information. */
282 rhc
->rhc_mhook
= bgp_route_match_delete
;
283 rhc
->rhc_rule
= "origin";
284 rhc
->rhc_event
= RMAP_EVENT_MATCH_DELETED
;
286 ret
= bgp_route_match_add(rhc
->rhc_rmi
, "origin", origin
,
287 RMAP_EVENT_MATCH_ADDED
,
288 args
->errmsg
, args
->errmsg_len
);
290 if (ret
!= RMAP_COMPILE_SUCCESS
) {
291 rhc
->rhc_mhook
= NULL
;
292 return NB_ERR_INCONSISTENCY
;
300 lib_route_map_entry_match_condition_rmap_match_condition_origin_destroy(
301 struct nb_cb_destroy_args
*args
)
303 switch (args
->event
) {
309 return lib_route_map_entry_match_destroy(args
);
316 * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:rpki
319 lib_route_map_entry_match_condition_rmap_match_condition_rpki_modify(
320 struct nb_cb_modify_args
*args
)
322 struct routemap_hook_context
*rhc
;
324 enum rmap_compile_rets ret
;
326 switch (args
->event
) {
332 /* Add configuration. */
333 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
334 rpki
= yang_dnode_get_string(args
->dnode
, NULL
);
336 /* Set destroy information. */
337 rhc
->rhc_mhook
= bgp_route_match_delete
;
338 rhc
->rhc_rule
= "rpki";
339 rhc
->rhc_event
= RMAP_EVENT_MATCH_DELETED
;
341 ret
= bgp_route_match_add(rhc
->rhc_rmi
, "rpki", rpki
,
342 RMAP_EVENT_MATCH_ADDED
,
343 args
->errmsg
, args
->errmsg_len
);
345 if (ret
!= RMAP_COMPILE_SUCCESS
) {
346 rhc
->rhc_mhook
= NULL
;
347 return NB_ERR_INCONSISTENCY
;
355 lib_route_map_entry_match_condition_rmap_match_condition_rpki_destroy(
356 struct nb_cb_destroy_args
*args
)
358 switch (args
->event
) {
364 return lib_route_map_entry_match_destroy(args
);
372 * /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:rpki-extcommunity
374 int lib_route_map_entry_match_condition_rmap_match_condition_rpki_extcommunity_modify(
375 struct nb_cb_modify_args
*args
)
377 struct routemap_hook_context
*rhc
;
379 enum rmap_compile_rets ret
;
381 switch (args
->event
) {
387 /* Add configuration. */
388 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
389 rpki
= yang_dnode_get_string(args
->dnode
, NULL
);
391 /* Set destroy information. */
392 rhc
->rhc_mhook
= bgp_route_match_delete
;
393 rhc
->rhc_rule
= "rpki-extcommunity";
394 rhc
->rhc_event
= RMAP_EVENT_MATCH_DELETED
;
396 ret
= bgp_route_match_add(rhc
->rhc_rmi
, "rpki-extcommunity",
397 rpki
, RMAP_EVENT_MATCH_ADDED
,
398 args
->errmsg
, args
->errmsg_len
);
400 if (ret
!= RMAP_COMPILE_SUCCESS
) {
401 rhc
->rhc_mhook
= NULL
;
402 return NB_ERR_INCONSISTENCY
;
409 int lib_route_map_entry_match_condition_rmap_match_condition_rpki_extcommunity_destroy(
410 struct nb_cb_destroy_args
*args
)
412 switch (args
->event
) {
418 return lib_route_map_entry_match_destroy(args
);
425 * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:probability
428 lib_route_map_entry_match_condition_rmap_match_condition_probability_modify(
429 struct nb_cb_modify_args
*args
)
431 struct routemap_hook_context
*rhc
;
432 const char *probability
;
433 enum rmap_compile_rets ret
;
435 switch (args
->event
) {
441 /* Add configuration. */
442 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
443 probability
= yang_dnode_get_string(args
->dnode
, NULL
);
445 /* Set destroy information. */
446 rhc
->rhc_mhook
= bgp_route_match_delete
;
447 rhc
->rhc_rule
= "probability";
448 rhc
->rhc_event
= RMAP_EVENT_MATCH_DELETED
;
450 ret
= bgp_route_match_add(rhc
->rhc_rmi
, "probability",
451 probability
, RMAP_EVENT_MATCH_ADDED
,
452 args
->errmsg
, args
->errmsg_len
);
454 if (ret
!= RMAP_COMPILE_SUCCESS
) {
455 rhc
->rhc_mhook
= NULL
;
456 return NB_ERR_INCONSISTENCY
;
464 lib_route_map_entry_match_condition_rmap_match_condition_probability_destroy(
465 struct nb_cb_destroy_args
*args
)
467 switch (args
->event
) {
472 return lib_route_map_entry_match_destroy(args
);
479 * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:source-vrf
482 lib_route_map_entry_match_condition_rmap_match_condition_source_vrf_modify(
483 struct nb_cb_modify_args
*args
)
485 struct routemap_hook_context
*rhc
;
487 enum rmap_compile_rets ret
;
489 switch (args
->event
) {
495 /* Add configuration. */
496 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
497 vrf
= yang_dnode_get_string(args
->dnode
, NULL
);
499 /* Set destroy information. */
500 rhc
->rhc_mhook
= bgp_route_match_delete
;
501 rhc
->rhc_rule
= "source-vrf";
502 rhc
->rhc_event
= RMAP_EVENT_MATCH_DELETED
;
504 ret
= bgp_route_match_add(rhc
->rhc_rmi
, "source-vrf", vrf
,
505 RMAP_EVENT_MATCH_ADDED
,
506 args
->errmsg
, args
->errmsg_len
);
508 if (ret
!= RMAP_COMPILE_SUCCESS
) {
509 rhc
->rhc_mhook
= NULL
;
510 return NB_ERR_INCONSISTENCY
;
518 lib_route_map_entry_match_condition_rmap_match_condition_source_vrf_destroy(
519 struct nb_cb_destroy_args
*args
)
521 switch (args
->event
) {
527 return lib_route_map_entry_match_destroy(args
);
534 * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:peer-ipv4-address
537 lib_route_map_entry_match_condition_rmap_match_condition_peer_ipv4_address_modify(
538 struct nb_cb_modify_args
*args
)
540 struct routemap_hook_context
*rhc
;
542 enum rmap_compile_rets ret
;
544 switch (args
->event
) {
550 /* Add configuration. */
551 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
552 peer
= yang_dnode_get_string(args
->dnode
, NULL
);
554 /* Set destroy information. */
555 rhc
->rhc_mhook
= bgp_route_match_delete
;
556 rhc
->rhc_rule
= "peer";
557 rhc
->rhc_event
= RMAP_EVENT_MATCH_DELETED
;
559 ret
= bgp_route_match_add(rhc
->rhc_rmi
, "peer", peer
,
560 RMAP_EVENT_MATCH_ADDED
,
561 args
->errmsg
, args
->errmsg_len
);
563 if (ret
!= RMAP_COMPILE_SUCCESS
) {
564 rhc
->rhc_mhook
= NULL
;
565 return NB_ERR_INCONSISTENCY
;
573 lib_route_map_entry_match_condition_rmap_match_condition_peer_ipv4_address_destroy(
574 struct nb_cb_destroy_args
*args
)
576 switch (args
->event
) {
582 return lib_route_map_entry_match_destroy(args
);
589 * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:peer-interface
592 lib_route_map_entry_match_condition_rmap_match_condition_peer_interface_modify(
593 struct nb_cb_modify_args
*args
)
595 struct routemap_hook_context
*rhc
;
597 enum rmap_compile_rets ret
;
599 switch (args
->event
) {
605 /* Add configuration. */
606 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
607 peer
= yang_dnode_get_string(args
->dnode
, NULL
);
609 /* Set destroy information. */
610 rhc
->rhc_mhook
= bgp_route_match_delete
;
611 rhc
->rhc_rule
= "peer";
612 rhc
->rhc_event
= RMAP_EVENT_MATCH_DELETED
;
614 ret
= bgp_route_match_add(rhc
->rhc_rmi
, "peer", peer
,
615 RMAP_EVENT_MATCH_ADDED
,
616 args
->errmsg
, args
->errmsg_len
);
618 if (ret
!= RMAP_COMPILE_SUCCESS
) {
619 rhc
->rhc_mhook
= NULL
;
620 return NB_ERR_INCONSISTENCY
;
628 lib_route_map_entry_match_condition_rmap_match_condition_peer_interface_destroy(
629 struct nb_cb_destroy_args
*args
)
631 switch (args
->event
) {
637 return lib_route_map_entry_match_destroy(args
);
644 * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:peer-ipv6-address
647 lib_route_map_entry_match_condition_rmap_match_condition_peer_ipv6_address_modify(
648 struct nb_cb_modify_args
*args
)
650 struct routemap_hook_context
*rhc
;
652 enum rmap_compile_rets ret
;
654 switch (args
->event
) {
660 /* Add configuration. */
661 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
662 peer
= yang_dnode_get_string(args
->dnode
, NULL
);
664 /* Set destroy information. */
665 rhc
->rhc_mhook
= bgp_route_match_delete
;
666 rhc
->rhc_rule
= "peer";
667 rhc
->rhc_event
= RMAP_EVENT_MATCH_DELETED
;
669 ret
= bgp_route_match_add(rhc
->rhc_rmi
, "peer", peer
,
670 RMAP_EVENT_MATCH_ADDED
,
671 args
->errmsg
, args
->errmsg_len
);
673 if (ret
!= RMAP_COMPILE_SUCCESS
) {
674 rhc
->rhc_mhook
= NULL
;
675 return NB_ERR_INCONSISTENCY
;
683 lib_route_map_entry_match_condition_rmap_match_condition_peer_ipv6_address_destroy(
684 struct nb_cb_destroy_args
*args
)
686 switch (args
->event
) {
692 return lib_route_map_entry_match_destroy(args
);
699 * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:peer-local
702 lib_route_map_entry_match_condition_rmap_match_condition_peer_local_modify(
703 struct nb_cb_modify_args
*args
)
705 struct routemap_hook_context
*rhc
;
707 enum rmap_compile_rets ret
;
709 switch (args
->event
) {
715 /* Add configuration. */
716 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
717 value
= yang_dnode_get_bool(args
->dnode
, NULL
);
719 /* Set destroy information. */
720 rhc
->rhc_mhook
= bgp_route_match_delete
;
721 rhc
->rhc_rule
= "peer";
722 rhc
->rhc_event
= RMAP_EVENT_MATCH_DELETED
;
725 ret
= bgp_route_match_add(rhc
->rhc_rmi
, "peer",
727 RMAP_EVENT_MATCH_ADDED
,
728 args
->errmsg
, args
->errmsg_len
);
730 if (ret
!= RMAP_COMPILE_SUCCESS
) {
731 rhc
->rhc_mhook
= NULL
;
732 return NB_ERR_INCONSISTENCY
;
741 lib_route_map_entry_match_condition_rmap_match_condition_peer_local_destroy(
742 struct nb_cb_destroy_args
*args
)
744 switch (args
->event
) {
750 return lib_route_map_entry_match_destroy(args
);
757 * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:list-name
760 lib_route_map_entry_match_condition_rmap_match_condition_list_name_modify(
761 struct nb_cb_modify_args
*args
)
763 struct routemap_hook_context
*rhc
;
764 const char *list_name
;
765 enum rmap_compile_rets ret
= RMAP_COMPILE_SUCCESS
;
766 const char *condition
;
768 switch (args
->event
) {
774 /* Add configuration. */
775 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
776 list_name
= yang_dnode_get_string(args
->dnode
, NULL
);
777 condition
= yang_dnode_get_string(args
->dnode
,
778 "../../frr-route-map:condition");
780 if (IS_MATCH_AS_LIST(condition
)) {
781 /* Set destroy information. */
782 rhc
->rhc_mhook
= bgp_route_match_delete
;
783 rhc
->rhc_rule
= "as-path";
784 rhc
->rhc_event
= RMAP_EVENT_ASLIST_DELETED
;
786 ret
= bgp_route_match_add(rhc
->rhc_rmi
, "as-path",
787 list_name
, RMAP_EVENT_ASLIST_ADDED
,
788 args
->errmsg
, args
->errmsg_len
);
789 } else if (IS_MATCH_MAC_LIST(condition
)) {
790 /* Set destroy information. */
791 rhc
->rhc_mhook
= bgp_route_match_delete
;
792 rhc
->rhc_rule
= "mac address";
793 rhc
->rhc_event
= RMAP_EVENT_FILTER_DELETED
;
795 ret
= bgp_route_match_add(rhc
->rhc_rmi
,
798 RMAP_EVENT_FILTER_ADDED
,
799 args
->errmsg
, args
->errmsg_len
);
800 } else if (IS_MATCH_ROUTE_SRC(condition
)) {
801 /* Set destroy information. */
802 rhc
->rhc_mhook
= bgp_route_match_delete
;
803 rhc
->rhc_rule
= "ip route-source";
804 rhc
->rhc_event
= RMAP_EVENT_FILTER_DELETED
;
806 ret
= bgp_route_match_add(rhc
->rhc_rmi
,
808 list_name
, RMAP_EVENT_FILTER_ADDED
,
809 args
->errmsg
, args
->errmsg_len
);
810 } else if (IS_MATCH_ROUTE_SRC_PL(condition
)) {
811 /* Set destroy information. */
812 rhc
->rhc_mhook
= bgp_route_match_delete
;
813 rhc
->rhc_rule
= "ip route-source prefix-list";
814 rhc
->rhc_event
= RMAP_EVENT_PLIST_DELETED
;
816 ret
= bgp_route_match_add(rhc
->rhc_rmi
,
817 "ip route-source prefix-list",
818 list_name
, RMAP_EVENT_PLIST_ADDED
,
819 args
->errmsg
, args
->errmsg_len
);
822 if (ret
!= RMAP_COMPILE_SUCCESS
) {
823 rhc
->rhc_mhook
= NULL
;
824 return NB_ERR_INCONSISTENCY
;
832 lib_route_map_entry_match_condition_rmap_match_condition_list_name_destroy(
833 struct nb_cb_destroy_args
*args
)
835 switch (args
->event
) {
841 return lib_route_map_entry_match_destroy(args
);
848 * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:evpn-default-route
851 lib_route_map_entry_match_condition_rmap_match_condition_evpn_default_route_create(
852 struct nb_cb_create_args
*args
)
854 struct routemap_hook_context
*rhc
;
855 enum rmap_compile_rets ret
;
857 switch (args
->event
) {
863 /* Add configuration. */
864 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
866 /* Set destroy information. */
867 rhc
->rhc_mhook
= bgp_route_match_delete
;
868 rhc
->rhc_rule
= "evpn default-route";
869 rhc
->rhc_event
= RMAP_EVENT_MATCH_DELETED
;
871 ret
= bgp_route_match_add(rhc
->rhc_rmi
, "evpn default-route",
872 NULL
, RMAP_EVENT_MATCH_ADDED
,
873 args
->errmsg
, args
->errmsg_len
);
875 if (ret
!= RMAP_COMPILE_SUCCESS
) {
876 rhc
->rhc_mhook
= NULL
;
877 return NB_ERR_INCONSISTENCY
;
885 lib_route_map_entry_match_condition_rmap_match_condition_evpn_default_route_destroy(
886 struct nb_cb_destroy_args
*args
)
888 switch (args
->event
) {
894 return lib_route_map_entry_match_destroy(args
);
901 * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:evpn-vni
904 lib_route_map_entry_match_condition_rmap_match_condition_evpn_vni_modify(
905 struct nb_cb_modify_args
*args
)
907 struct routemap_hook_context
*rhc
;
909 enum rmap_compile_rets ret
;
911 switch (args
->event
) {
917 /* Add configuration. */
918 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
919 vni
= yang_dnode_get_string(args
->dnode
, NULL
);
921 /* Set destroy information. */
922 rhc
->rhc_mhook
= bgp_route_match_delete
;
923 rhc
->rhc_rule
= "evpn vni";
924 rhc
->rhc_event
= RMAP_EVENT_MATCH_DELETED
;
926 ret
= bgp_route_match_add(rhc
->rhc_rmi
, "evpn vni", vni
,
927 RMAP_EVENT_MATCH_ADDED
,
928 args
->errmsg
, args
->errmsg_len
);
930 if (ret
!= RMAP_COMPILE_SUCCESS
) {
931 rhc
->rhc_mhook
= NULL
;
932 return NB_ERR_INCONSISTENCY
;
940 lib_route_map_entry_match_condition_rmap_match_condition_evpn_vni_destroy(
941 struct nb_cb_destroy_args
*args
)
943 switch (args
->event
) {
949 return lib_route_map_entry_match_destroy(args
);
956 * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:evpn-route-type
959 lib_route_map_entry_match_condition_rmap_match_condition_evpn_route_type_modify(
960 struct nb_cb_modify_args
*args
)
962 struct routemap_hook_context
*rhc
;
964 enum rmap_compile_rets ret
;
966 switch (args
->event
) {
972 /* Add configuration. */
973 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
974 type
= yang_dnode_get_string(args
->dnode
, NULL
);
976 /* Set destroy information. */
977 rhc
->rhc_mhook
= bgp_route_match_delete
;
978 rhc
->rhc_rule
= "evpn route-type";
979 rhc
->rhc_event
= RMAP_EVENT_MATCH_DELETED
;
981 ret
= bgp_route_match_add(rhc
->rhc_rmi
, "evpn route-type",
983 RMAP_EVENT_MATCH_ADDED
,
984 args
->errmsg
, args
->errmsg_len
);
986 if (ret
!= RMAP_COMPILE_SUCCESS
) {
987 rhc
->rhc_mhook
= NULL
;
988 return NB_ERR_INCONSISTENCY
;
996 lib_route_map_entry_match_condition_rmap_match_condition_evpn_route_type_destroy(
997 struct nb_cb_destroy_args
*args
)
999 switch (args
->event
) {
1000 case NB_EV_VALIDATE
:
1005 return lib_route_map_entry_match_destroy(args
);
1012 * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:route-distinguisher
1015 lib_route_map_entry_match_condition_rmap_match_condition_route_distinguisher_modify(
1016 struct nb_cb_modify_args
*args
)
1018 struct routemap_hook_context
*rhc
;
1020 enum rmap_compile_rets ret
;
1022 switch (args
->event
) {
1023 case NB_EV_VALIDATE
:
1028 /* Add configuration. */
1029 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
1030 rd
= yang_dnode_get_string(args
->dnode
, NULL
);
1032 /* Set destroy information. */
1033 rhc
->rhc_mhook
= bgp_route_match_delete
;
1034 rhc
->rhc_rule
= "evpn rd";
1035 rhc
->rhc_event
= RMAP_EVENT_MATCH_DELETED
;
1037 ret
= bgp_route_match_add(rhc
->rhc_rmi
, "evpn rd", rd
,
1038 RMAP_EVENT_MATCH_ADDED
,
1039 args
->errmsg
, args
->errmsg_len
);
1041 if (ret
!= RMAP_COMPILE_SUCCESS
) {
1042 rhc
->rhc_mhook
= NULL
;
1043 return NB_ERR_INCONSISTENCY
;
1051 lib_route_map_entry_match_condition_rmap_match_condition_route_distinguisher_destroy(
1052 struct nb_cb_destroy_args
*args
)
1054 switch (args
->event
) {
1055 case NB_EV_VALIDATE
:
1060 return lib_route_map_entry_match_destroy(args
);
1067 * XPath = /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:comm-list
1070 lib_route_map_entry_match_condition_rmap_match_condition_comm_list_finish(
1071 struct nb_cb_apply_finish_args
*args
)
1073 struct routemap_hook_context
*rhc
;
1075 bool exact_match
= false;
1077 const char *condition
;
1078 route_map_event_t event
;
1081 /* Add configuration. */
1082 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
1083 value
= yang_dnode_get_string(args
->dnode
, "./comm-list-name");
1085 if (yang_dnode_exists(args
->dnode
, "./comm-list-name-exact-match"))
1086 exact_match
= yang_dnode_get_bool(
1087 args
->dnode
, "./comm-list-name-exact-match");
1090 argstr
= XMALLOC(MTYPE_ROUTE_MAP_COMPILED
,
1091 strlen(value
) + strlen("exact-match") + 2);
1093 snprintf(argstr
, (strlen(value
) + strlen("exact-match") + 2),
1094 "%s exact-match", value
);
1096 argstr
= (char *)value
;
1098 /* Set destroy information. */
1099 rhc
->rhc_mhook
= bgp_route_match_delete
;
1101 condition
= yang_dnode_get_string(args
->dnode
,
1102 "../../frr-route-map:condition");
1103 if (IS_MATCH_COMMUNITY(condition
)) {
1104 rhc
->rhc_rule
= "community";
1105 event
= RMAP_EVENT_CLIST_ADDED
;
1106 rhc
->rhc_event
= RMAP_EVENT_CLIST_DELETED
;
1107 } else if (IS_MATCH_LCOMMUNITY(condition
)) {
1108 rhc
->rhc_rule
= "large-community";
1109 event
= RMAP_EVENT_LLIST_ADDED
;
1110 rhc
->rhc_event
= RMAP_EVENT_LLIST_DELETED
;
1112 rhc
->rhc_rule
= "extcommunity";
1113 event
= RMAP_EVENT_ECLIST_ADDED
;
1114 rhc
->rhc_event
= RMAP_EVENT_ECLIST_DELETED
;
1117 ret
= bgp_route_match_add(rhc
->rhc_rmi
, rhc
->rhc_rule
, argstr
, event
,
1118 args
->errmsg
, args
->errmsg_len
);
1120 * At this point if this is not a successful operation
1121 * bgpd is about to crash. Let's just cut to the
1124 assert(ret
== RMAP_COMPILE_SUCCESS
);
1126 if (argstr
!= value
)
1127 XFREE(MTYPE_ROUTE_MAP_COMPILED
, argstr
);
1132 * /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:comm-list/comm-list-name
1135 lib_route_map_entry_match_condition_rmap_match_condition_comm_list_comm_list_name_modify(
1136 struct nb_cb_modify_args
*args
)
1138 switch (args
->event
) {
1139 case NB_EV_VALIDATE
:
1150 lib_route_map_entry_match_condition_rmap_match_condition_comm_list_comm_list_name_destroy(
1151 struct nb_cb_destroy_args
*args
)
1153 switch (args
->event
) {
1154 case NB_EV_VALIDATE
:
1159 return lib_route_map_entry_match_destroy(args
);
1167 * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:comm-list/comm-list-name-exact-match
1170 lib_route_map_entry_match_condition_rmap_match_condition_comm_list_comm_list_name_exact_match_modify(
1171 struct nb_cb_modify_args
*args
)
1173 switch (args
->event
) {
1174 case NB_EV_VALIDATE
:
1185 lib_route_map_entry_match_condition_rmap_match_condition_comm_list_comm_list_name_exact_match_destroy(
1186 struct nb_cb_destroy_args
*args
)
1188 switch (args
->event
) {
1189 case NB_EV_VALIDATE
:
1194 return lib_route_map_entry_match_destroy(args
);
1201 * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:ipv4-address
1204 lib_route_map_entry_match_condition_rmap_match_condition_ipv4_address_modify(
1205 struct nb_cb_modify_args
*args
)
1207 struct routemap_hook_context
*rhc
;
1209 enum rmap_compile_rets ret
;
1211 switch (args
->event
) {
1212 case NB_EV_VALIDATE
:
1217 /* Add configuration. */
1218 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
1219 peer
= yang_dnode_get_string(args
->dnode
, NULL
);
1221 /* Set destroy information. */
1222 rhc
->rhc_mhook
= bgp_route_match_delete
;
1223 rhc
->rhc_rule
= "ip next-hop address";
1224 rhc
->rhc_event
= RMAP_EVENT_MATCH_DELETED
;
1226 ret
= bgp_route_match_add(rhc
->rhc_rmi
, rhc
->rhc_rule
,
1227 peer
, RMAP_EVENT_MATCH_ADDED
,
1228 args
->errmsg
, args
->errmsg_len
);
1230 if (ret
!= RMAP_COMPILE_SUCCESS
) {
1231 rhc
->rhc_mhook
= NULL
;
1232 return NB_ERR_INCONSISTENCY
;
1240 lib_route_map_entry_match_condition_rmap_match_condition_ipv4_address_destroy(
1241 struct nb_cb_destroy_args
*args
)
1243 switch (args
->event
) {
1244 case NB_EV_VALIDATE
:
1249 return lib_route_map_entry_match_destroy(args
);
1256 * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:ipv6-address
1259 lib_route_map_entry_match_condition_rmap_match_condition_ipv6_address_modify(
1260 struct nb_cb_modify_args
*args
)
1262 struct routemap_hook_context
*rhc
;
1264 enum rmap_compile_rets ret
;
1266 switch (args
->event
) {
1267 case NB_EV_VALIDATE
:
1272 /* Add configuration. */
1273 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
1274 peer
= yang_dnode_get_string(args
->dnode
, NULL
);
1276 /* Set destroy information. */
1277 rhc
->rhc_mhook
= bgp_route_match_delete
;
1278 rhc
->rhc_rule
= "ipv6 next-hop address";
1279 rhc
->rhc_event
= RMAP_EVENT_MATCH_DELETED
;
1281 ret
= bgp_route_match_add(rhc
->rhc_rmi
, rhc
->rhc_rule
,
1282 peer
, RMAP_EVENT_MATCH_ADDED
,
1283 args
->errmsg
, args
->errmsg_len
);
1285 if (ret
!= RMAP_COMPILE_SUCCESS
) {
1286 rhc
->rhc_mhook
= NULL
;
1287 return NB_ERR_INCONSISTENCY
;
1295 lib_route_map_entry_match_condition_rmap_match_condition_ipv6_address_destroy(
1296 struct nb_cb_destroy_args
*args
)
1298 switch (args
->event
) {
1299 case NB_EV_VALIDATE
:
1304 return lib_route_map_entry_match_destroy(args
);
1312 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:distance
1314 int lib_route_map_entry_set_action_rmap_set_action_distance_modify(
1315 struct nb_cb_modify_args
*args
)
1317 struct routemap_hook_context
*rhc
;
1321 switch (args
->event
) {
1322 case NB_EV_VALIDATE
:
1327 /* Add configuration. */
1328 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
1329 type
= yang_dnode_get_string(args
->dnode
, NULL
);
1331 /* Set destroy information. */
1332 rhc
->rhc_shook
= generic_set_delete
;
1333 rhc
->rhc_rule
= "distance";
1334 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
1336 rv
= generic_set_add(rhc
->rhc_rmi
, "distance", type
,
1337 args
->errmsg
, args
->errmsg_len
);
1338 if (rv
!= CMD_SUCCESS
) {
1339 rhc
->rhc_shook
= NULL
;
1340 return NB_ERR_INCONSISTENCY
;
1347 int lib_route_map_entry_set_action_rmap_set_action_distance_destroy(
1348 struct nb_cb_destroy_args
*args
)
1350 switch (args
->event
) {
1351 case NB_EV_VALIDATE
:
1356 return lib_route_map_entry_match_destroy(args
);
1364 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:extcommunity-rt
1367 lib_route_map_entry_set_action_rmap_set_action_extcommunity_rt_modify(
1368 struct nb_cb_modify_args
*args
)
1370 struct routemap_hook_context
*rhc
;
1374 switch (args
->event
) {
1375 case NB_EV_VALIDATE
:
1380 /* Add configuration. */
1381 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
1382 type
= yang_dnode_get_string(args
->dnode
, NULL
);
1384 /* Set destroy information. */
1385 rhc
->rhc_shook
= generic_set_delete
;
1386 rhc
->rhc_rule
= "extcommunity rt";
1387 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
1389 rv
= generic_set_add(rhc
->rhc_rmi
, "extcommunity rt", type
,
1390 args
->errmsg
, args
->errmsg_len
);
1391 if (rv
!= CMD_SUCCESS
) {
1392 rhc
->rhc_shook
= NULL
;
1393 return NB_ERR_INCONSISTENCY
;
1401 lib_route_map_entry_set_action_rmap_set_action_extcommunity_rt_destroy(
1402 struct nb_cb_destroy_args
*args
)
1404 switch (args
->event
) {
1405 case NB_EV_VALIDATE
:
1410 return lib_route_map_entry_match_destroy(args
);
1418 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:extcommunity-soo
1421 lib_route_map_entry_set_action_rmap_set_action_extcommunity_soo_modify(
1422 struct nb_cb_modify_args
*args
)
1424 struct routemap_hook_context
*rhc
;
1428 switch (args
->event
) {
1429 case NB_EV_VALIDATE
:
1434 /* Add configuration. */
1435 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
1436 type
= yang_dnode_get_string(args
->dnode
, NULL
);
1438 /* Set destroy information. */
1439 rhc
->rhc_shook
= generic_set_delete
;
1440 rhc
->rhc_rule
= "extcommunity soo";
1441 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
1443 rv
= generic_set_add(rhc
->rhc_rmi
, "extcommunity soo",
1445 args
->errmsg
, args
->errmsg_len
);
1446 if (rv
!= CMD_SUCCESS
) {
1447 rhc
->rhc_shook
= NULL
;
1448 return NB_ERR_INCONSISTENCY
;
1456 lib_route_map_entry_set_action_rmap_set_action_extcommunity_soo_destroy(
1457 struct nb_cb_destroy_args
*args
)
1459 switch (args
->event
) {
1460 case NB_EV_VALIDATE
:
1465 return lib_route_map_entry_match_destroy(args
);
1473 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:ipv4-address
1475 int lib_route_map_entry_set_action_rmap_set_action_ipv4_address_modify(
1476 struct nb_cb_modify_args
*args
)
1478 struct routemap_hook_context
*rhc
;
1480 int rv
= CMD_SUCCESS
;
1482 switch (args
->event
) {
1483 case NB_EV_VALIDATE
:
1488 /* Add configuration. */
1489 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
1490 addr
= yang_dnode_get_string(args
->dnode
, NULL
);
1492 rhc
->rhc_shook
= generic_set_delete
;
1493 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
1494 rhc
->rhc_rule
= "ipv4 vpn next-hop";
1496 rv
= generic_set_add(rhc
->rhc_rmi
, rhc
->rhc_rule
, addr
,
1497 args
->errmsg
, args
->errmsg_len
);
1499 if (rv
!= CMD_SUCCESS
) {
1500 rhc
->rhc_shook
= NULL
;
1501 return NB_ERR_INCONSISTENCY
;
1508 int lib_route_map_entry_set_action_rmap_set_action_ipv4_address_destroy(
1509 struct nb_cb_destroy_args
*args
)
1511 switch (args
->event
) {
1512 case NB_EV_VALIDATE
:
1517 return lib_route_map_entry_set_destroy(args
);
1525 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:ipv4-nexthop
1527 int lib_route_map_entry_set_action_rmap_set_action_ipv4_nexthop_modify(
1528 struct nb_cb_modify_args
*args
)
1530 struct routemap_hook_context
*rhc
;
1534 switch (args
->event
) {
1535 case NB_EV_VALIDATE
:
1540 /* Add configuration. */
1541 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
1542 type
= yang_dnode_get_string(args
->dnode
, NULL
);
1544 /* Set destroy information. */
1545 rhc
->rhc_shook
= generic_set_delete
;
1546 rhc
->rhc_rule
= "ip next-hop";
1547 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
1549 rv
= generic_set_add(rhc
->rhc_rmi
, rhc
->rhc_rule
, type
,
1550 args
->errmsg
, args
->errmsg_len
);
1552 if (rv
!= CMD_SUCCESS
) {
1553 rhc
->rhc_shook
= NULL
;
1554 return NB_ERR_INCONSISTENCY
;
1561 int lib_route_map_entry_set_action_rmap_set_action_ipv4_nexthop_destroy(
1562 struct nb_cb_destroy_args
*args
)
1564 switch (args
->event
) {
1565 case NB_EV_VALIDATE
:
1570 return lib_route_map_entry_set_destroy(args
);
1578 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:ipv6-address
1580 int lib_route_map_entry_set_action_rmap_set_action_ipv6_address_modify(
1581 struct nb_cb_modify_args
*args
)
1583 struct routemap_hook_context
*rhc
;
1585 int rv
= CMD_SUCCESS
;
1586 const char *action
= NULL
;
1587 struct in6_addr i6a
;
1589 action
= yang_dnode_get_string(args
->dnode
,
1590 "../../frr-route-map:action");
1591 switch (args
->event
) {
1592 case NB_EV_VALIDATE
:
1593 if (action
&& IS_SET_IPV6_NH_GLOBAL(action
)) {
1594 yang_dnode_get_ipv6(&i6a
, args
->dnode
, NULL
);
1595 if (IN6_IS_ADDR_UNSPECIFIED(&i6a
)
1596 || IN6_IS_ADDR_LOOPBACK(&i6a
)
1597 || IN6_IS_ADDR_MULTICAST(&i6a
)
1598 || IN6_IS_ADDR_LINKLOCAL(&i6a
))
1599 return NB_ERR_VALIDATION
;
1609 /* Add configuration. */
1610 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
1611 addr
= yang_dnode_get_string(args
->dnode
, NULL
);
1613 rhc
->rhc_shook
= generic_set_delete
;
1614 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
1616 if (IS_SET_IPV6_NH_GLOBAL(action
))
1617 /* Set destroy information. */
1618 rhc
->rhc_rule
= "ipv6 next-hop global";
1620 rhc
->rhc_rule
= "ipv6 vpn next-hop";
1622 rv
= generic_set_add(rhc
->rhc_rmi
, rhc
->rhc_rule
, addr
,
1623 args
->errmsg
, args
->errmsg_len
);
1625 if (rv
!= CMD_SUCCESS
) {
1626 rhc
->rhc_shook
= NULL
;
1627 return NB_ERR_INCONSISTENCY
;
1633 int lib_route_map_entry_set_action_rmap_set_action_ipv6_address_destroy(
1634 struct nb_cb_destroy_args
*args
)
1636 switch (args
->event
) {
1637 case NB_EV_VALIDATE
:
1642 return lib_route_map_entry_set_destroy(args
);
1650 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:preference
1652 int lib_route_map_entry_set_action_rmap_set_action_preference_modify(
1653 struct nb_cb_modify_args
*args
)
1655 struct routemap_hook_context
*rhc
;
1656 int rv
= CMD_SUCCESS
;
1657 const char *action
= NULL
;
1660 switch (args
->event
) {
1661 case NB_EV_VALIDATE
:
1666 /* Add configuration. */
1667 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
1668 value
= yang_dnode_get_bool(args
->dnode
, NULL
);
1670 rhc
->rhc_shook
= generic_set_delete
;
1671 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
1673 action
= yang_dnode_get_string(args
->dnode
,
1674 "../../frr-route-map:action");
1677 if (IS_SET_IPV6_PEER_ADDR(action
))
1678 /* Set destroy information. */
1679 rhc
->rhc_rule
= "ipv6 next-hop peer-address";
1681 rhc
->rhc_rule
= "ipv6 next-hop prefer-global";
1683 rv
= generic_set_add(rhc
->rhc_rmi
, rhc
->rhc_rule
,
1685 args
->errmsg
, args
->errmsg_len
);
1688 if (rv
!= CMD_SUCCESS
) {
1689 rhc
->rhc_shook
= NULL
;
1690 return NB_ERR_INCONSISTENCY
;
1697 int lib_route_map_entry_set_action_rmap_set_action_preference_destroy(
1698 struct nb_cb_destroy_args
*args
)
1700 switch (args
->event
) {
1701 case NB_EV_VALIDATE
:
1706 return lib_route_map_entry_set_destroy(args
);
1714 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:label-index
1716 int lib_route_map_entry_set_action_rmap_set_action_label_index_modify(
1717 struct nb_cb_modify_args
*args
)
1719 struct routemap_hook_context
*rhc
;
1723 switch (args
->event
) {
1724 case NB_EV_VALIDATE
:
1729 /* Add configuration. */
1730 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
1731 type
= yang_dnode_get_string(args
->dnode
, NULL
);
1733 /* Set destroy information. */
1734 rhc
->rhc_shook
= generic_set_delete
;
1735 rhc
->rhc_rule
= "label-index";
1736 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
1738 rv
= generic_set_add(rhc
->rhc_rmi
, "label-index", type
,
1739 args
->errmsg
, args
->errmsg_len
);
1740 if (rv
!= CMD_SUCCESS
) {
1741 rhc
->rhc_shook
= NULL
;
1742 return NB_ERR_INCONSISTENCY
;
1749 int lib_route_map_entry_set_action_rmap_set_action_label_index_destroy(
1750 struct nb_cb_destroy_args
*args
)
1752 switch (args
->event
) {
1753 case NB_EV_VALIDATE
:
1758 return lib_route_map_entry_set_destroy(args
);
1766 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:local-pref
1768 int lib_route_map_entry_set_action_rmap_set_action_local_pref_modify(
1769 struct nb_cb_modify_args
*args
)
1771 struct routemap_hook_context
*rhc
;
1775 switch (args
->event
) {
1776 case NB_EV_VALIDATE
:
1781 /* Add configuration. */
1782 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
1783 type
= yang_dnode_get_string(args
->dnode
, NULL
);
1785 /* Set destroy information. */
1786 rhc
->rhc_shook
= generic_set_delete
;
1787 rhc
->rhc_rule
= "local-preference";
1788 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
1790 rv
= generic_set_add(rhc
->rhc_rmi
, "local-preference",
1792 args
->errmsg
, args
->errmsg_len
);
1793 if (rv
!= CMD_SUCCESS
) {
1794 rhc
->rhc_shook
= NULL
;
1795 return NB_ERR_INCONSISTENCY
;
1802 int lib_route_map_entry_set_action_rmap_set_action_local_pref_destroy(
1803 struct nb_cb_destroy_args
*args
)
1805 switch (args
->event
) {
1806 case NB_EV_VALIDATE
:
1811 return lib_route_map_entry_set_destroy(args
);
1819 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:weight
1821 int lib_route_map_entry_set_action_rmap_set_action_weight_modify(
1822 struct nb_cb_modify_args
*args
)
1824 struct routemap_hook_context
*rhc
;
1828 switch (args
->event
) {
1829 case NB_EV_VALIDATE
:
1834 /* Add configuration. */
1835 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
1836 type
= yang_dnode_get_string(args
->dnode
, NULL
);
1838 /* Set destroy information. */
1839 rhc
->rhc_shook
= generic_set_delete
;
1840 rhc
->rhc_rule
= "weight";
1841 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
1843 rv
= generic_set_add(rhc
->rhc_rmi
, "weight", type
,
1844 args
->errmsg
, args
->errmsg_len
);
1845 if (rv
!= CMD_SUCCESS
) {
1846 rhc
->rhc_shook
= NULL
;
1847 return NB_ERR_INCONSISTENCY
;
1854 int lib_route_map_entry_set_action_rmap_set_action_weight_destroy(
1855 struct nb_cb_destroy_args
*args
)
1857 switch (args
->event
) {
1858 case NB_EV_VALIDATE
:
1863 return lib_route_map_entry_set_destroy(args
);
1871 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:origin
1873 int lib_route_map_entry_set_action_rmap_set_action_origin_modify(
1874 struct nb_cb_modify_args
*args
)
1876 struct routemap_hook_context
*rhc
;
1880 switch (args
->event
) {
1881 case NB_EV_VALIDATE
:
1886 /* Add configuration. */
1887 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
1888 type
= yang_dnode_get_string(args
->dnode
, NULL
);
1890 /* Set destroy information. */
1891 rhc
->rhc_shook
= generic_set_delete
;
1892 rhc
->rhc_rule
= "origin";
1893 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
1895 rv
= generic_set_add(rhc
->rhc_rmi
, "origin", type
,
1896 args
->errmsg
, args
->errmsg_len
);
1897 if (rv
!= CMD_SUCCESS
) {
1898 rhc
->rhc_shook
= NULL
;
1899 return NB_ERR_INCONSISTENCY
;
1906 int lib_route_map_entry_set_action_rmap_set_action_origin_destroy(
1907 struct nb_cb_destroy_args
*args
)
1909 switch (args
->event
) {
1910 case NB_EV_VALIDATE
:
1915 return lib_route_map_entry_set_destroy(args
);
1924 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:originator-id
1926 int lib_route_map_entry_set_action_rmap_set_action_originator_id_modify(
1927 struct nb_cb_modify_args
*args
)
1929 struct routemap_hook_context
*rhc
;
1933 switch (args
->event
) {
1934 case NB_EV_VALIDATE
:
1939 /* Add configuration. */
1940 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
1941 type
= yang_dnode_get_string(args
->dnode
, NULL
);
1943 /* Set destroy information. */
1944 rhc
->rhc_shook
= generic_set_delete
;
1945 rhc
->rhc_rule
= "originator-id";
1946 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
1948 rv
= generic_set_add(rhc
->rhc_rmi
, "originator-id", type
,
1949 args
->errmsg
, args
->errmsg_len
);
1950 if (rv
!= CMD_SUCCESS
) {
1951 rhc
->rhc_shook
= NULL
;
1952 return NB_ERR_INCONSISTENCY
;
1959 int lib_route_map_entry_set_action_rmap_set_action_originator_id_destroy(
1960 struct nb_cb_destroy_args
*args
)
1962 switch (args
->event
) {
1963 case NB_EV_VALIDATE
:
1968 return lib_route_map_entry_set_destroy(args
);
1976 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:table
1978 int lib_route_map_entry_set_action_rmap_set_action_table_modify(
1979 struct nb_cb_modify_args
*args
)
1981 struct routemap_hook_context
*rhc
;
1985 switch (args
->event
) {
1986 case NB_EV_VALIDATE
:
1991 /* Add configuration. */
1992 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
1993 type
= yang_dnode_get_string(args
->dnode
, NULL
);
1995 /* Set destroy information. */
1996 rhc
->rhc_shook
= generic_set_delete
;
1997 rhc
->rhc_rule
= "table";
1998 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
2000 rv
= generic_set_add(rhc
->rhc_rmi
, "table", type
,
2001 args
->errmsg
, args
->errmsg_len
);
2002 if (rv
!= CMD_SUCCESS
) {
2003 rhc
->rhc_shook
= NULL
;
2004 return NB_ERR_INCONSISTENCY
;
2011 int lib_route_map_entry_set_action_rmap_set_action_table_destroy(
2012 struct nb_cb_destroy_args
*args
)
2014 switch (args
->event
) {
2015 case NB_EV_VALIDATE
:
2020 return lib_route_map_entry_set_destroy(args
);
2028 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:atomic-aggregate
2031 lib_route_map_entry_set_action_rmap_set_action_atomic_aggregate_create(
2032 struct nb_cb_create_args
*args
)
2034 struct routemap_hook_context
*rhc
;
2037 switch (args
->event
) {
2038 case NB_EV_VALIDATE
:
2043 /* Add configuration. */
2044 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
2046 /* Set destroy information. */
2047 rhc
->rhc_shook
= generic_set_delete
;
2048 rhc
->rhc_rule
= "atomic-aggregate";
2049 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
2051 rv
= generic_set_add(rhc
->rhc_rmi
, rhc
->rhc_rule
, NULL
,
2052 args
->errmsg
, args
->errmsg_len
);
2053 if (rv
!= CMD_SUCCESS
) {
2054 rhc
->rhc_shook
= NULL
;
2055 return NB_ERR_INCONSISTENCY
;
2063 lib_route_map_entry_set_action_rmap_set_action_atomic_aggregate_destroy(
2064 struct nb_cb_destroy_args
*args
)
2066 switch (args
->event
) {
2067 case NB_EV_VALIDATE
:
2072 return lib_route_map_entry_set_destroy(args
);
2080 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:aigp-metric
2082 int lib_route_map_entry_set_action_rmap_set_action_aigp_metric_modify(
2083 struct nb_cb_modify_args
*args
)
2085 struct routemap_hook_context
*rhc
;
2089 switch (args
->event
) {
2090 case NB_EV_VALIDATE
:
2095 /* Add configuration. */
2096 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
2097 aigp
= yang_dnode_get_string(args
->dnode
, NULL
);
2099 /* Set destroy information. */
2100 rhc
->rhc_shook
= generic_set_delete
;
2101 rhc
->rhc_rule
= "aigp-metric";
2102 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
2104 rv
= generic_set_add(rhc
->rhc_rmi
, rhc
->rhc_rule
, aigp
,
2105 args
->errmsg
, args
->errmsg_len
);
2106 if (rv
!= CMD_SUCCESS
) {
2107 rhc
->rhc_shook
= NULL
;
2108 return NB_ERR_INCONSISTENCY
;
2115 int lib_route_map_entry_set_action_rmap_set_action_aigp_metric_destroy(
2116 struct nb_cb_destroy_args
*args
)
2118 switch (args
->event
) {
2119 case NB_EV_VALIDATE
:
2124 return lib_route_map_entry_set_destroy(args
);
2132 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:prepend-as-path
2135 lib_route_map_entry_set_action_rmap_set_action_prepend_as_path_modify(
2136 struct nb_cb_modify_args
*args
)
2138 struct routemap_hook_context
*rhc
;
2142 switch (args
->event
) {
2143 case NB_EV_VALIDATE
:
2148 /* Add configuration. */
2149 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
2150 type
= yang_dnode_get_string(args
->dnode
, NULL
);
2152 /* Set destroy information. */
2153 rhc
->rhc_shook
= generic_set_delete
;
2154 rhc
->rhc_rule
= "as-path prepend";
2155 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
2157 rv
= generic_set_add(rhc
->rhc_rmi
, "as-path prepend",
2159 args
->errmsg
, args
->errmsg_len
);
2160 if (rv
!= CMD_SUCCESS
) {
2161 rhc
->rhc_shook
= NULL
;
2162 return NB_ERR_INCONSISTENCY
;
2170 lib_route_map_entry_set_action_rmap_set_action_prepend_as_path_destroy(
2171 struct nb_cb_destroy_args
*args
)
2173 switch (args
->event
) {
2174 case NB_EV_VALIDATE
:
2179 return lib_route_map_entry_set_destroy(args
);
2187 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:last-as
2189 int lib_route_map_entry_set_action_rmap_set_action_last_as_modify(
2190 struct nb_cb_modify_args
*args
)
2192 struct routemap_hook_context
*rhc
;
2197 switch (args
->event
) {
2198 case NB_EV_VALIDATE
:
2203 /* Add configuration. */
2204 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
2205 value
= yang_dnode_get_string(args
->dnode
, NULL
);
2207 /* Set destroy information. */
2208 rhc
->rhc_shook
= generic_set_delete
;
2209 rhc
->rhc_rule
= "as-path prepend";
2210 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
2212 argstr
= XMALLOC(MTYPE_ROUTE_MAP_COMPILED
,
2213 strlen(value
) + strlen("last-as") + 2);
2215 snprintf(argstr
, (strlen(value
) + strlen("last-as") + 2),
2216 "last-as %s", value
);
2218 rv
= generic_set_add(rhc
->rhc_rmi
, "as-path prepend",
2220 args
->errmsg
, args
->errmsg_len
);
2221 if (rv
!= CMD_SUCCESS
) {
2222 rhc
->rhc_shook
= NULL
;
2223 XFREE(MTYPE_ROUTE_MAP_COMPILED
, argstr
);
2224 return NB_ERR_INCONSISTENCY
;
2227 XFREE(MTYPE_ROUTE_MAP_COMPILED
, argstr
);
2233 int lib_route_map_entry_set_action_rmap_set_action_last_as_destroy(
2234 struct nb_cb_destroy_args
*args
)
2236 switch (args
->event
) {
2237 case NB_EV_VALIDATE
:
2242 return lib_route_map_entry_set_destroy(args
);
2250 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:exclude-as-path
2253 lib_route_map_entry_set_action_rmap_set_action_exclude_as_path_modify(
2254 struct nb_cb_modify_args
*args
)
2256 struct routemap_hook_context
*rhc
;
2260 switch (args
->event
) {
2261 case NB_EV_VALIDATE
:
2266 /* Add configuration. */
2267 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
2268 type
= yang_dnode_get_string(args
->dnode
, NULL
);
2270 /* Set destroy information. */
2271 rhc
->rhc_shook
= generic_set_delete
;
2272 rhc
->rhc_rule
= "as-path exclude";
2273 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
2275 rv
= generic_set_add(rhc
->rhc_rmi
, "as-path exclude",
2277 args
->errmsg
, args
->errmsg_len
);
2278 if (rv
!= CMD_SUCCESS
) {
2279 rhc
->rhc_shook
= NULL
;
2280 return NB_ERR_INCONSISTENCY
;
2288 lib_route_map_entry_set_action_rmap_set_action_exclude_as_path_destroy(
2289 struct nb_cb_destroy_args
*args
)
2291 switch (args
->event
) {
2292 case NB_EV_VALIDATE
:
2297 return lib_route_map_entry_set_destroy(args
);
2305 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:replace-as-path
2307 int lib_route_map_entry_set_action_rmap_set_action_replace_as_path_modify(
2308 struct nb_cb_modify_args
*args
)
2310 struct routemap_hook_context
*rhc
;
2314 switch (args
->event
) {
2315 case NB_EV_VALIDATE
:
2320 /* Add configuration. */
2321 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
2322 type
= yang_dnode_get_string(args
->dnode
, NULL
);
2324 /* Set destroy information. */
2325 rhc
->rhc_shook
= generic_set_delete
;
2326 rhc
->rhc_rule
= "as-path replace";
2327 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
2329 rv
= generic_set_add(rhc
->rhc_rmi
, "as-path replace", type
,
2330 args
->errmsg
, args
->errmsg_len
);
2331 if (rv
!= CMD_SUCCESS
) {
2332 rhc
->rhc_shook
= NULL
;
2333 return NB_ERR_INCONSISTENCY
;
2340 int lib_route_map_entry_set_action_rmap_set_action_replace_as_path_destroy(
2341 struct nb_cb_destroy_args
*args
)
2343 switch (args
->event
) {
2344 case NB_EV_VALIDATE
:
2349 return lib_route_map_entry_set_destroy(args
);
2357 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:community-none
2359 int lib_route_map_entry_set_action_rmap_set_action_community_none_modify(
2360 struct nb_cb_modify_args
*args
)
2362 struct routemap_hook_context
*rhc
;
2366 switch (args
->event
) {
2367 case NB_EV_VALIDATE
:
2372 /* Add configuration. */
2373 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
2374 none
= yang_dnode_get_bool(args
->dnode
, NULL
);
2376 /* Set destroy information. */
2377 rhc
->rhc_shook
= generic_set_delete
;
2378 rhc
->rhc_rule
= "community";
2379 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
2382 rv
= generic_set_add(rhc
->rhc_rmi
, "community",
2384 args
->errmsg
, args
->errmsg_len
);
2385 if (rv
!= CMD_SUCCESS
) {
2386 rhc
->rhc_shook
= NULL
;
2387 return NB_ERR_INCONSISTENCY
;
2392 return NB_ERR_INCONSISTENCY
;
2399 lib_route_map_entry_set_action_rmap_set_action_community_none_destroy(
2400 struct nb_cb_destroy_args
*args
)
2402 switch (args
->event
) {
2403 case NB_EV_VALIDATE
:
2408 return lib_route_map_entry_set_destroy(args
);
2416 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:community-string
2419 lib_route_map_entry_set_action_rmap_set_action_community_string_modify(
2420 struct nb_cb_modify_args
*args
)
2422 struct routemap_hook_context
*rhc
;
2426 switch (args
->event
) {
2427 case NB_EV_VALIDATE
:
2432 /* Add configuration. */
2433 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
2434 type
= yang_dnode_get_string(args
->dnode
, NULL
);
2436 /* Set destroy information. */
2437 rhc
->rhc_shook
= generic_set_delete
;
2438 rhc
->rhc_rule
= "community";
2439 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
2441 rv
= generic_set_add(rhc
->rhc_rmi
, "community", type
,
2442 args
->errmsg
, args
->errmsg_len
);
2443 if (rv
!= CMD_SUCCESS
) {
2444 rhc
->rhc_shook
= NULL
;
2445 return NB_ERR_INCONSISTENCY
;
2453 lib_route_map_entry_set_action_rmap_set_action_community_string_destroy(
2454 struct nb_cb_destroy_args
*args
)
2456 switch (args
->event
) {
2457 case NB_EV_VALIDATE
:
2462 return lib_route_map_entry_set_destroy(args
);
2470 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:large-community-none
2473 lib_route_map_entry_set_action_rmap_set_action_large_community_none_modify(
2474 struct nb_cb_modify_args
*args
)
2476 struct routemap_hook_context
*rhc
;
2480 switch (args
->event
) {
2481 case NB_EV_VALIDATE
:
2486 /* Add configuration. */
2487 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
2488 none
= yang_dnode_get_bool(args
->dnode
, NULL
);
2490 /* Set destroy information. */
2491 rhc
->rhc_shook
= generic_set_delete
;
2492 rhc
->rhc_rule
= "large-community";
2493 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
2496 rv
= generic_set_add(rhc
->rhc_rmi
,
2499 args
->errmsg
, args
->errmsg_len
);
2500 if (rv
!= CMD_SUCCESS
) {
2501 rhc
->rhc_shook
= NULL
;
2502 return NB_ERR_INCONSISTENCY
;
2507 return NB_ERR_INCONSISTENCY
;
2514 lib_route_map_entry_set_action_rmap_set_action_large_community_none_destroy(
2515 struct nb_cb_destroy_args
*args
)
2517 switch (args
->event
) {
2518 case NB_EV_VALIDATE
:
2523 return lib_route_map_entry_set_destroy(args
);
2531 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:large-community-string
2534 lib_route_map_entry_set_action_rmap_set_action_large_community_string_modify(
2535 struct nb_cb_modify_args
*args
)
2537 struct routemap_hook_context
*rhc
;
2541 switch (args
->event
) {
2542 case NB_EV_VALIDATE
:
2547 /* Add configuration. */
2548 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
2549 type
= yang_dnode_get_string(args
->dnode
, NULL
);
2551 /* Set destroy information. */
2552 rhc
->rhc_shook
= generic_set_delete
;
2553 rhc
->rhc_rule
= "large-community";
2554 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
2556 rv
= generic_set_add(rhc
->rhc_rmi
, "large-community",
2558 args
->errmsg
, args
->errmsg_len
);
2559 if (rv
!= CMD_SUCCESS
) {
2560 rhc
->rhc_shook
= NULL
;
2561 return NB_ERR_INCONSISTENCY
;
2569 lib_route_map_entry_set_action_rmap_set_action_large_community_string_destroy(
2570 struct nb_cb_destroy_args
*args
)
2572 switch (args
->event
) {
2573 case NB_EV_VALIDATE
:
2578 return lib_route_map_entry_set_destroy(args
);
2586 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:aggregator
2588 void lib_route_map_entry_set_action_rmap_set_action_aggregator_finish(
2589 struct nb_cb_apply_finish_args
*args
)
2591 struct routemap_hook_context
*rhc
;
2597 /* Add configuration. */
2598 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
2599 asn
= yang_dnode_get_string(args
->dnode
, "./aggregator-asn");
2600 addr
= yang_dnode_get_string(args
->dnode
, "./aggregator-address");
2602 argstr
= XMALLOC(MTYPE_ROUTE_MAP_COMPILED
,
2603 strlen(asn
) + strlen(addr
) + 2);
2605 snprintf(argstr
, (strlen(asn
) + strlen(addr
) + 2), "%s %s", asn
, addr
);
2607 /* Set destroy information. */
2608 rhc
->rhc_shook
= generic_set_delete
;
2609 rhc
->rhc_rule
= "aggregator as";
2610 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
2612 ret
= generic_set_add(rhc
->rhc_rmi
, rhc
->rhc_rule
, argstr
, args
->errmsg
,
2615 * At this point if this is not a successful operation
2616 * bgpd is about to crash. Let's just cut to the
2619 assert(ret
== CMD_SUCCESS
);
2621 XFREE(MTYPE_ROUTE_MAP_COMPILED
, argstr
);
2625 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:aggregator/aggregator-asn
2628 lib_route_map_entry_set_action_rmap_set_action_aggregator_aggregator_asn_modify(
2629 struct nb_cb_modify_args
*args
)
2631 switch (args
->event
) {
2632 case NB_EV_VALIDATE
:
2643 lib_route_map_entry_set_action_rmap_set_action_aggregator_aggregator_asn_destroy(
2644 struct nb_cb_destroy_args
*args
)
2646 switch (args
->event
) {
2647 case NB_EV_VALIDATE
:
2652 return lib_route_map_entry_set_destroy(args
);
2660 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:aggregator/aggregator-address
2663 lib_route_map_entry_set_action_rmap_set_action_aggregator_aggregator_address_modify(
2664 struct nb_cb_modify_args
*args
)
2666 switch (args
->event
) {
2667 case NB_EV_VALIDATE
:
2678 lib_route_map_entry_set_action_rmap_set_action_aggregator_aggregator_address_destroy(
2679 struct nb_cb_destroy_args
*args
)
2681 switch (args
->event
) {
2682 case NB_EV_VALIDATE
:
2687 return lib_route_map_entry_set_destroy(args
);
2695 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:comm-list-name
2697 int lib_route_map_entry_set_action_rmap_set_action_comm_list_name_modify(
2698 struct nb_cb_modify_args
*args
)
2700 struct routemap_hook_context
*rhc
;
2703 int rv
= CMD_SUCCESS
;
2705 switch (args
->event
) {
2706 case NB_EV_VALIDATE
:
2711 /* Add configuration. */
2712 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
2713 value
= yang_dnode_get_string(args
->dnode
, NULL
);
2715 /* Set destroy information. */
2716 rhc
->rhc_shook
= generic_set_delete
;
2718 action
= yang_dnode_get_string(args
->dnode
,
2719 "../../frr-route-map:action");
2720 if (IS_SET_COMM_LIST_DEL(action
))
2721 rhc
->rhc_rule
= "comm-list";
2723 rhc
->rhc_rule
= "large-comm-list";
2725 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
2727 rv
= generic_set_add(rhc
->rhc_rmi
, rhc
->rhc_rule
, value
,
2728 args
->errmsg
, args
->errmsg_len
);
2730 if (rv
!= CMD_SUCCESS
) {
2731 rhc
->rhc_shook
= NULL
;
2732 return NB_ERR_INCONSISTENCY
;
2740 lib_route_map_entry_set_action_rmap_set_action_comm_list_name_destroy(
2741 struct nb_cb_destroy_args
*args
)
2743 switch (args
->event
) {
2744 case NB_EV_VALIDATE
:
2749 return lib_route_map_entry_set_destroy(args
);
2757 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:extcommunity-lb
2760 lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_finish(
2761 struct nb_cb_apply_finish_args
*args
)
2763 struct routemap_hook_context
*rhc
;
2764 enum ecommunity_lb_type lb_type
;
2765 char str
[VTY_BUFSIZ
];
2769 /* Add configuration. */
2770 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
2771 lb_type
= yang_dnode_get_enum(args
->dnode
, "./lb-type");
2773 /* Set destroy information. */
2774 rhc
->rhc_shook
= generic_set_delete
;
2775 rhc
->rhc_rule
= "extcommunity bandwidth";
2776 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
2779 case EXPLICIT_BANDWIDTH
:
2780 bandwidth
= yang_dnode_get_uint16(args
->dnode
, "./bandwidth");
2781 snprintf(str
, sizeof(str
), "%d", bandwidth
);
2783 case CUMULATIVE_BANDWIDTH
:
2784 snprintf(str
, sizeof(str
), "%s", "cumulative");
2786 case COMPUTED_BANDWIDTH
:
2787 snprintf(str
, sizeof(str
), "%s", "num-multipaths");
2790 if (yang_dnode_get_bool(args
->dnode
, "./two-octet-as-specific"))
2791 strlcat(str
, " non-transitive", sizeof(str
));
2793 ret
= generic_set_add(rhc
->rhc_rmi
, "extcommunity bandwidth", str
,
2794 args
->errmsg
, args
->errmsg_len
);
2796 * At this point if this is not a successful operation
2797 * bgpd is about to crash. Let's just cut to the
2800 assert(ret
== CMD_SUCCESS
);
2805 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:extcommunity-lb/lb-type
2808 lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_lb_type_modify(
2809 struct nb_cb_modify_args
*args
)
2815 lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_lb_type_destroy(
2816 struct nb_cb_destroy_args
*args
)
2818 return lib_route_map_entry_set_destroy(args
);
2823 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:extcommunity-lb/bandwidth
2826 lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_bandwidth_modify(
2827 struct nb_cb_modify_args
*args
)
2833 lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_bandwidth_destroy(
2834 struct nb_cb_destroy_args
*args
)
2836 return lib_route_map_entry_set_destroy(args
);
2841 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:extcommunity-lb/two-octet-as-specific
2844 lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_two_octet_as_specific_modify(
2845 struct nb_cb_modify_args
*args
)
2851 lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_two_octet_as_specific_destroy(
2852 struct nb_cb_destroy_args
*args
)
2854 return lib_route_map_entry_set_destroy(args
);
2859 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:extcommunity-none
2861 int lib_route_map_entry_set_action_rmap_set_action_extcommunity_none_modify(
2862 struct nb_cb_modify_args
*args
)
2864 struct routemap_hook_context
*rhc
;
2868 switch (args
->event
) {
2869 case NB_EV_VALIDATE
:
2874 /* Add configuration. */
2875 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
2876 none
= yang_dnode_get_bool(args
->dnode
, NULL
);
2878 /* Set destroy information. */
2879 rhc
->rhc_shook
= generic_set_delete
;
2880 rhc
->rhc_rule
= "extcommunity";
2881 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
2884 rv
= generic_set_add(rhc
->rhc_rmi
, "extcommunity",
2885 "none", args
->errmsg
,
2887 if (rv
!= CMD_SUCCESS
) {
2888 rhc
->rhc_shook
= NULL
;
2889 return NB_ERR_INCONSISTENCY
;
2894 return NB_ERR_INCONSISTENCY
;
2900 int lib_route_map_entry_set_action_rmap_set_action_extcommunity_none_destroy(
2901 struct nb_cb_destroy_args
*args
)
2903 switch (args
->event
) {
2904 case NB_EV_VALIDATE
:
2909 return lib_route_map_entry_set_destroy(args
);
2917 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:evpn-gateway-ip-ipv4
2919 int lib_route_map_entry_set_action_rmap_set_action_evpn_gateway_ip_ipv4_modify(
2920 struct nb_cb_modify_args
*args
)
2922 struct routemap_hook_context
*rhc
;
2926 switch (args
->event
) {
2927 case NB_EV_VALIDATE
:
2932 /* Add configuration. */
2933 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
2934 type
= yang_dnode_get_string(args
->dnode
, NULL
);
2936 /* Set destroy information. */
2937 rhc
->rhc_shook
= generic_set_delete
;
2938 rhc
->rhc_rule
= "evpn gateway-ip ipv4";
2939 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
2941 rv
= generic_set_add(rhc
->rhc_rmi
, "evpn gateway-ip ipv4", type
,
2942 args
->errmsg
, args
->errmsg_len
);
2943 if (rv
!= CMD_SUCCESS
) {
2944 rhc
->rhc_shook
= NULL
;
2945 return NB_ERR_INCONSISTENCY
;
2952 int lib_route_map_entry_set_action_rmap_set_action_evpn_gateway_ip_ipv4_destroy(
2953 struct nb_cb_destroy_args
*args
)
2955 switch (args
->event
) {
2956 case NB_EV_VALIDATE
:
2961 return lib_route_map_entry_set_destroy(args
);
2969 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:evpn-gateway-ip-ipv6
2971 int lib_route_map_entry_set_action_rmap_set_action_evpn_gateway_ip_ipv6_modify(
2972 struct nb_cb_modify_args
*args
)
2974 struct routemap_hook_context
*rhc
;
2978 switch (args
->event
) {
2979 case NB_EV_VALIDATE
:
2984 /* Add configuration. */
2985 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
2986 type
= yang_dnode_get_string(args
->dnode
, NULL
);
2988 /* Set destroy information. */
2989 rhc
->rhc_shook
= generic_set_delete
;
2990 rhc
->rhc_rule
= "evpn gateway-ip ipv6";
2991 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
2993 rv
= generic_set_add(rhc
->rhc_rmi
, "evpn gateway-ip ipv6", type
,
2994 args
->errmsg
, args
->errmsg_len
);
2995 if (rv
!= CMD_SUCCESS
) {
2996 rhc
->rhc_shook
= NULL
;
2997 return NB_ERR_INCONSISTENCY
;
3004 int lib_route_map_entry_set_action_rmap_set_action_evpn_gateway_ip_ipv6_destroy(
3005 struct nb_cb_destroy_args
*args
)
3007 switch (args
->event
) {
3008 case NB_EV_VALIDATE
:
3013 return lib_route_map_entry_set_destroy(args
);
3021 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/l3vpn-nexthop-encapsulation
3023 int lib_route_map_entry_set_action_rmap_set_action_l3vpn_nexthop_encapsulation_modify(
3024 struct nb_cb_modify_args
*args
)
3026 struct routemap_hook_context
*rhc
;
3030 switch (args
->event
) {
3031 case NB_EV_VALIDATE
:
3036 /* Add configuration. */
3037 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
3038 type
= yang_dnode_get_string(args
->dnode
, NULL
);
3040 /* Set destroy information. */
3041 rhc
->rhc_shook
= generic_set_delete
;
3042 rhc
->rhc_rule
= "l3vpn next-hop encapsulation";
3043 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
3045 rv
= generic_set_add(rhc
->rhc_rmi
,
3046 "l3vpn next-hop encapsulation", type
,
3047 args
->errmsg
, args
->errmsg_len
);
3048 if (rv
!= CMD_SUCCESS
) {
3049 rhc
->rhc_shook
= NULL
;
3050 return NB_ERR_INCONSISTENCY
;
3057 int lib_route_map_entry_set_action_rmap_set_action_l3vpn_nexthop_encapsulation_destroy(
3058 struct nb_cb_destroy_args
*args
)
3060 switch (args
->event
) {
3061 case NB_EV_VALIDATE
:
3066 return lib_route_map_entry_set_destroy(args
);