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:source-protocol
374 int lib_route_map_entry_match_condition_rmap_match_condition_source_protocol_modify(
375 struct nb_cb_modify_args
*args
)
377 struct routemap_hook_context
*rhc
;
378 enum rmap_compile_rets ret
;
381 switch (args
->event
) {
387 /* Add configuration. */
388 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
389 proto
= yang_dnode_get_string(args
->dnode
, NULL
);
391 /* Set destroy information. */
392 rhc
->rhc_mhook
= bgp_route_match_delete
;
393 rhc
->rhc_rule
= "source-protocol";
394 rhc
->rhc_event
= RMAP_EVENT_MATCH_DELETED
;
396 ret
= bgp_route_match_add(rhc
->rhc_rmi
, "source-protocol",
397 proto
, 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_source_protocol_destroy(
410 struct nb_cb_destroy_args
*args
)
412 switch (args
->event
) {
418 return lib_route_map_entry_match_destroy(args
);
426 * /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:rpki-extcommunity
428 int lib_route_map_entry_match_condition_rmap_match_condition_rpki_extcommunity_modify(
429 struct nb_cb_modify_args
*args
)
431 struct routemap_hook_context
*rhc
;
433 enum rmap_compile_rets ret
;
435 switch (args
->event
) {
441 /* Add configuration. */
442 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
443 rpki
= yang_dnode_get_string(args
->dnode
, NULL
);
445 /* Set destroy information. */
446 rhc
->rhc_mhook
= bgp_route_match_delete
;
447 rhc
->rhc_rule
= "rpki-extcommunity";
448 rhc
->rhc_event
= RMAP_EVENT_MATCH_DELETED
;
450 ret
= bgp_route_match_add(rhc
->rhc_rmi
, "rpki-extcommunity",
451 rpki
, 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
;
463 int lib_route_map_entry_match_condition_rmap_match_condition_rpki_extcommunity_destroy(
464 struct nb_cb_destroy_args
*args
)
466 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:probability
482 lib_route_map_entry_match_condition_rmap_match_condition_probability_modify(
483 struct nb_cb_modify_args
*args
)
485 struct routemap_hook_context
*rhc
;
486 const char *probability
;
487 enum rmap_compile_rets ret
;
489 switch (args
->event
) {
495 /* Add configuration. */
496 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
497 probability
= yang_dnode_get_string(args
->dnode
, NULL
);
499 /* Set destroy information. */
500 rhc
->rhc_mhook
= bgp_route_match_delete
;
501 rhc
->rhc_rule
= "probability";
502 rhc
->rhc_event
= RMAP_EVENT_MATCH_DELETED
;
504 ret
= bgp_route_match_add(rhc
->rhc_rmi
, "probability",
505 probability
, 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_probability_destroy(
519 struct nb_cb_destroy_args
*args
)
521 switch (args
->event
) {
526 return lib_route_map_entry_match_destroy(args
);
533 * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:source-vrf
536 lib_route_map_entry_match_condition_rmap_match_condition_source_vrf_modify(
537 struct nb_cb_modify_args
*args
)
539 struct routemap_hook_context
*rhc
;
541 enum rmap_compile_rets ret
;
543 switch (args
->event
) {
549 /* Add configuration. */
550 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
551 vrf
= yang_dnode_get_string(args
->dnode
, NULL
);
553 /* Set destroy information. */
554 rhc
->rhc_mhook
= bgp_route_match_delete
;
555 rhc
->rhc_rule
= "source-vrf";
556 rhc
->rhc_event
= RMAP_EVENT_MATCH_DELETED
;
558 ret
= bgp_route_match_add(rhc
->rhc_rmi
, "source-vrf", vrf
,
559 RMAP_EVENT_MATCH_ADDED
,
560 args
->errmsg
, args
->errmsg_len
);
562 if (ret
!= RMAP_COMPILE_SUCCESS
) {
563 rhc
->rhc_mhook
= NULL
;
564 return NB_ERR_INCONSISTENCY
;
572 lib_route_map_entry_match_condition_rmap_match_condition_source_vrf_destroy(
573 struct nb_cb_destroy_args
*args
)
575 switch (args
->event
) {
581 return lib_route_map_entry_match_destroy(args
);
588 * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:peer-ipv4-address
591 lib_route_map_entry_match_condition_rmap_match_condition_peer_ipv4_address_modify(
592 struct nb_cb_modify_args
*args
)
594 struct routemap_hook_context
*rhc
;
596 enum rmap_compile_rets ret
;
598 switch (args
->event
) {
604 /* Add configuration. */
605 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
606 peer
= yang_dnode_get_string(args
->dnode
, NULL
);
608 /* Set destroy information. */
609 rhc
->rhc_mhook
= bgp_route_match_delete
;
610 rhc
->rhc_rule
= "peer";
611 rhc
->rhc_event
= RMAP_EVENT_MATCH_DELETED
;
613 ret
= bgp_route_match_add(rhc
->rhc_rmi
, "peer", peer
,
614 RMAP_EVENT_MATCH_ADDED
,
615 args
->errmsg
, args
->errmsg_len
);
617 if (ret
!= RMAP_COMPILE_SUCCESS
) {
618 rhc
->rhc_mhook
= NULL
;
619 return NB_ERR_INCONSISTENCY
;
627 lib_route_map_entry_match_condition_rmap_match_condition_peer_ipv4_address_destroy(
628 struct nb_cb_destroy_args
*args
)
630 switch (args
->event
) {
636 return lib_route_map_entry_match_destroy(args
);
643 * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:peer-interface
646 lib_route_map_entry_match_condition_rmap_match_condition_peer_interface_modify(
647 struct nb_cb_modify_args
*args
)
649 struct routemap_hook_context
*rhc
;
651 enum rmap_compile_rets ret
;
653 switch (args
->event
) {
659 /* Add configuration. */
660 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
661 peer
= yang_dnode_get_string(args
->dnode
, NULL
);
663 /* Set destroy information. */
664 rhc
->rhc_mhook
= bgp_route_match_delete
;
665 rhc
->rhc_rule
= "peer";
666 rhc
->rhc_event
= RMAP_EVENT_MATCH_DELETED
;
668 ret
= bgp_route_match_add(rhc
->rhc_rmi
, "peer", peer
,
669 RMAP_EVENT_MATCH_ADDED
,
670 args
->errmsg
, args
->errmsg_len
);
672 if (ret
!= RMAP_COMPILE_SUCCESS
) {
673 rhc
->rhc_mhook
= NULL
;
674 return NB_ERR_INCONSISTENCY
;
682 lib_route_map_entry_match_condition_rmap_match_condition_peer_interface_destroy(
683 struct nb_cb_destroy_args
*args
)
685 switch (args
->event
) {
691 return lib_route_map_entry_match_destroy(args
);
698 * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:peer-ipv6-address
701 lib_route_map_entry_match_condition_rmap_match_condition_peer_ipv6_address_modify(
702 struct nb_cb_modify_args
*args
)
704 struct routemap_hook_context
*rhc
;
706 enum rmap_compile_rets ret
;
708 switch (args
->event
) {
714 /* Add configuration. */
715 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
716 peer
= yang_dnode_get_string(args
->dnode
, NULL
);
718 /* Set destroy information. */
719 rhc
->rhc_mhook
= bgp_route_match_delete
;
720 rhc
->rhc_rule
= "peer";
721 rhc
->rhc_event
= RMAP_EVENT_MATCH_DELETED
;
723 ret
= bgp_route_match_add(rhc
->rhc_rmi
, "peer", peer
,
724 RMAP_EVENT_MATCH_ADDED
,
725 args
->errmsg
, args
->errmsg_len
);
727 if (ret
!= RMAP_COMPILE_SUCCESS
) {
728 rhc
->rhc_mhook
= NULL
;
729 return NB_ERR_INCONSISTENCY
;
737 lib_route_map_entry_match_condition_rmap_match_condition_peer_ipv6_address_destroy(
738 struct nb_cb_destroy_args
*args
)
740 switch (args
->event
) {
746 return lib_route_map_entry_match_destroy(args
);
753 * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:peer-local
756 lib_route_map_entry_match_condition_rmap_match_condition_peer_local_modify(
757 struct nb_cb_modify_args
*args
)
759 struct routemap_hook_context
*rhc
;
761 enum rmap_compile_rets ret
;
763 switch (args
->event
) {
769 /* Add configuration. */
770 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
771 value
= yang_dnode_get_bool(args
->dnode
, NULL
);
773 /* Set destroy information. */
774 rhc
->rhc_mhook
= bgp_route_match_delete
;
775 rhc
->rhc_rule
= "peer";
776 rhc
->rhc_event
= RMAP_EVENT_MATCH_DELETED
;
779 ret
= bgp_route_match_add(rhc
->rhc_rmi
, "peer",
781 RMAP_EVENT_MATCH_ADDED
,
782 args
->errmsg
, args
->errmsg_len
);
784 if (ret
!= RMAP_COMPILE_SUCCESS
) {
785 rhc
->rhc_mhook
= NULL
;
786 return NB_ERR_INCONSISTENCY
;
795 lib_route_map_entry_match_condition_rmap_match_condition_peer_local_destroy(
796 struct nb_cb_destroy_args
*args
)
798 switch (args
->event
) {
804 return lib_route_map_entry_match_destroy(args
);
811 * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:list-name
814 lib_route_map_entry_match_condition_rmap_match_condition_list_name_modify(
815 struct nb_cb_modify_args
*args
)
817 struct routemap_hook_context
*rhc
;
818 const char *list_name
;
819 enum rmap_compile_rets ret
= RMAP_COMPILE_SUCCESS
;
820 const char *condition
;
822 switch (args
->event
) {
828 /* Add configuration. */
829 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
830 list_name
= yang_dnode_get_string(args
->dnode
, NULL
);
831 condition
= yang_dnode_get_string(args
->dnode
,
832 "../../frr-route-map:condition");
834 if (IS_MATCH_AS_LIST(condition
)) {
835 /* Set destroy information. */
836 rhc
->rhc_mhook
= bgp_route_match_delete
;
837 rhc
->rhc_rule
= "as-path";
838 rhc
->rhc_event
= RMAP_EVENT_ASLIST_DELETED
;
840 ret
= bgp_route_match_add(rhc
->rhc_rmi
, "as-path",
841 list_name
, RMAP_EVENT_ASLIST_ADDED
,
842 args
->errmsg
, args
->errmsg_len
);
843 } else if (IS_MATCH_MAC_LIST(condition
)) {
844 /* Set destroy information. */
845 rhc
->rhc_mhook
= bgp_route_match_delete
;
846 rhc
->rhc_rule
= "mac address";
847 rhc
->rhc_event
= RMAP_EVENT_FILTER_DELETED
;
849 ret
= bgp_route_match_add(rhc
->rhc_rmi
,
852 RMAP_EVENT_FILTER_ADDED
,
853 args
->errmsg
, args
->errmsg_len
);
854 } else if (IS_MATCH_ROUTE_SRC(condition
)) {
855 /* Set destroy information. */
856 rhc
->rhc_mhook
= bgp_route_match_delete
;
857 rhc
->rhc_rule
= "ip route-source";
858 rhc
->rhc_event
= RMAP_EVENT_FILTER_DELETED
;
860 ret
= bgp_route_match_add(rhc
->rhc_rmi
,
862 list_name
, RMAP_EVENT_FILTER_ADDED
,
863 args
->errmsg
, args
->errmsg_len
);
864 } else if (IS_MATCH_ROUTE_SRC_PL(condition
)) {
865 /* Set destroy information. */
866 rhc
->rhc_mhook
= bgp_route_match_delete
;
867 rhc
->rhc_rule
= "ip route-source prefix-list";
868 rhc
->rhc_event
= RMAP_EVENT_PLIST_DELETED
;
870 ret
= bgp_route_match_add(rhc
->rhc_rmi
,
871 "ip route-source prefix-list",
872 list_name
, RMAP_EVENT_PLIST_ADDED
,
873 args
->errmsg
, args
->errmsg_len
);
876 if (ret
!= RMAP_COMPILE_SUCCESS
) {
877 rhc
->rhc_mhook
= NULL
;
878 return NB_ERR_INCONSISTENCY
;
886 lib_route_map_entry_match_condition_rmap_match_condition_list_name_destroy(
887 struct nb_cb_destroy_args
*args
)
889 switch (args
->event
) {
895 return lib_route_map_entry_match_destroy(args
);
902 * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:evpn-default-route
905 lib_route_map_entry_match_condition_rmap_match_condition_evpn_default_route_create(
906 struct nb_cb_create_args
*args
)
908 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);
920 /* Set destroy information. */
921 rhc
->rhc_mhook
= bgp_route_match_delete
;
922 rhc
->rhc_rule
= "evpn default-route";
923 rhc
->rhc_event
= RMAP_EVENT_MATCH_DELETED
;
925 ret
= bgp_route_match_add(rhc
->rhc_rmi
, "evpn default-route",
926 NULL
, RMAP_EVENT_MATCH_ADDED
,
927 args
->errmsg
, args
->errmsg_len
);
929 if (ret
!= RMAP_COMPILE_SUCCESS
) {
930 rhc
->rhc_mhook
= NULL
;
931 return NB_ERR_INCONSISTENCY
;
939 lib_route_map_entry_match_condition_rmap_match_condition_evpn_default_route_destroy(
940 struct nb_cb_destroy_args
*args
)
942 switch (args
->event
) {
948 return lib_route_map_entry_match_destroy(args
);
955 * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:evpn-vni
958 lib_route_map_entry_match_condition_rmap_match_condition_evpn_vni_modify(
959 struct nb_cb_modify_args
*args
)
961 struct routemap_hook_context
*rhc
;
963 enum rmap_compile_rets ret
;
965 switch (args
->event
) {
971 /* Add configuration. */
972 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
973 vni
= yang_dnode_get_string(args
->dnode
, NULL
);
975 /* Set destroy information. */
976 rhc
->rhc_mhook
= bgp_route_match_delete
;
977 rhc
->rhc_rule
= "evpn vni";
978 rhc
->rhc_event
= RMAP_EVENT_MATCH_DELETED
;
980 ret
= bgp_route_match_add(rhc
->rhc_rmi
, "evpn vni", vni
,
981 RMAP_EVENT_MATCH_ADDED
,
982 args
->errmsg
, args
->errmsg_len
);
984 if (ret
!= RMAP_COMPILE_SUCCESS
) {
985 rhc
->rhc_mhook
= NULL
;
986 return NB_ERR_INCONSISTENCY
;
994 lib_route_map_entry_match_condition_rmap_match_condition_evpn_vni_destroy(
995 struct nb_cb_destroy_args
*args
)
997 switch (args
->event
) {
1003 return lib_route_map_entry_match_destroy(args
);
1010 * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:evpn-route-type
1013 lib_route_map_entry_match_condition_rmap_match_condition_evpn_route_type_modify(
1014 struct nb_cb_modify_args
*args
)
1016 struct routemap_hook_context
*rhc
;
1018 enum rmap_compile_rets ret
;
1020 switch (args
->event
) {
1021 case NB_EV_VALIDATE
:
1026 /* Add configuration. */
1027 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
1028 type
= yang_dnode_get_string(args
->dnode
, NULL
);
1030 /* Set destroy information. */
1031 rhc
->rhc_mhook
= bgp_route_match_delete
;
1032 rhc
->rhc_rule
= "evpn route-type";
1033 rhc
->rhc_event
= RMAP_EVENT_MATCH_DELETED
;
1035 ret
= bgp_route_match_add(rhc
->rhc_rmi
, "evpn route-type",
1037 RMAP_EVENT_MATCH_ADDED
,
1038 args
->errmsg
, args
->errmsg_len
);
1040 if (ret
!= RMAP_COMPILE_SUCCESS
) {
1041 rhc
->rhc_mhook
= NULL
;
1042 return NB_ERR_INCONSISTENCY
;
1050 lib_route_map_entry_match_condition_rmap_match_condition_evpn_route_type_destroy(
1051 struct nb_cb_destroy_args
*args
)
1053 switch (args
->event
) {
1054 case NB_EV_VALIDATE
:
1059 return lib_route_map_entry_match_destroy(args
);
1066 * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:route-distinguisher
1069 lib_route_map_entry_match_condition_rmap_match_condition_route_distinguisher_modify(
1070 struct nb_cb_modify_args
*args
)
1072 struct routemap_hook_context
*rhc
;
1074 enum rmap_compile_rets ret
;
1076 switch (args
->event
) {
1077 case NB_EV_VALIDATE
:
1082 /* Add configuration. */
1083 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
1084 rd
= yang_dnode_get_string(args
->dnode
, NULL
);
1086 /* Set destroy information. */
1087 rhc
->rhc_mhook
= bgp_route_match_delete
;
1088 rhc
->rhc_rule
= "evpn rd";
1089 rhc
->rhc_event
= RMAP_EVENT_MATCH_DELETED
;
1091 ret
= bgp_route_match_add(rhc
->rhc_rmi
, "evpn rd", rd
,
1092 RMAP_EVENT_MATCH_ADDED
,
1093 args
->errmsg
, args
->errmsg_len
);
1095 if (ret
!= RMAP_COMPILE_SUCCESS
) {
1096 rhc
->rhc_mhook
= NULL
;
1097 return NB_ERR_INCONSISTENCY
;
1105 lib_route_map_entry_match_condition_rmap_match_condition_route_distinguisher_destroy(
1106 struct nb_cb_destroy_args
*args
)
1108 switch (args
->event
) {
1109 case NB_EV_VALIDATE
:
1114 return lib_route_map_entry_match_destroy(args
);
1121 * XPath = /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:comm-list
1124 lib_route_map_entry_match_condition_rmap_match_condition_comm_list_finish(
1125 struct nb_cb_apply_finish_args
*args
)
1127 struct routemap_hook_context
*rhc
;
1129 bool exact_match
= false;
1131 const char *condition
;
1132 route_map_event_t event
;
1135 /* Add configuration. */
1136 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
1137 value
= yang_dnode_get_string(args
->dnode
, "./comm-list-name");
1139 if (yang_dnode_exists(args
->dnode
, "./comm-list-name-exact-match"))
1140 exact_match
= yang_dnode_get_bool(
1141 args
->dnode
, "./comm-list-name-exact-match");
1144 argstr
= XMALLOC(MTYPE_ROUTE_MAP_COMPILED
,
1145 strlen(value
) + strlen("exact-match") + 2);
1147 snprintf(argstr
, (strlen(value
) + strlen("exact-match") + 2),
1148 "%s exact-match", value
);
1150 argstr
= (char *)value
;
1152 /* Set destroy information. */
1153 rhc
->rhc_mhook
= bgp_route_match_delete
;
1155 condition
= yang_dnode_get_string(args
->dnode
,
1156 "../../frr-route-map:condition");
1157 if (IS_MATCH_COMMUNITY(condition
)) {
1158 rhc
->rhc_rule
= "community";
1159 event
= RMAP_EVENT_CLIST_ADDED
;
1160 rhc
->rhc_event
= RMAP_EVENT_CLIST_DELETED
;
1161 } else if (IS_MATCH_LCOMMUNITY(condition
)) {
1162 rhc
->rhc_rule
= "large-community";
1163 event
= RMAP_EVENT_LLIST_ADDED
;
1164 rhc
->rhc_event
= RMAP_EVENT_LLIST_DELETED
;
1166 rhc
->rhc_rule
= "extcommunity";
1167 event
= RMAP_EVENT_ECLIST_ADDED
;
1168 rhc
->rhc_event
= RMAP_EVENT_ECLIST_DELETED
;
1171 ret
= bgp_route_match_add(rhc
->rhc_rmi
, rhc
->rhc_rule
, argstr
, event
,
1172 args
->errmsg
, args
->errmsg_len
);
1174 * At this point if this is not a successful operation
1175 * bgpd is about to crash. Let's just cut to the
1178 assert(ret
== RMAP_COMPILE_SUCCESS
);
1180 if (argstr
!= value
)
1181 XFREE(MTYPE_ROUTE_MAP_COMPILED
, argstr
);
1186 * /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:comm-list/comm-list-name
1189 lib_route_map_entry_match_condition_rmap_match_condition_comm_list_comm_list_name_modify(
1190 struct nb_cb_modify_args
*args
)
1192 switch (args
->event
) {
1193 case NB_EV_VALIDATE
:
1204 lib_route_map_entry_match_condition_rmap_match_condition_comm_list_comm_list_name_destroy(
1205 struct nb_cb_destroy_args
*args
)
1207 switch (args
->event
) {
1208 case NB_EV_VALIDATE
:
1213 return lib_route_map_entry_match_destroy(args
);
1221 * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:comm-list/comm-list-name-exact-match
1224 lib_route_map_entry_match_condition_rmap_match_condition_comm_list_comm_list_name_exact_match_modify(
1225 struct nb_cb_modify_args
*args
)
1227 switch (args
->event
) {
1228 case NB_EV_VALIDATE
:
1239 lib_route_map_entry_match_condition_rmap_match_condition_comm_list_comm_list_name_exact_match_destroy(
1240 struct nb_cb_destroy_args
*args
)
1242 switch (args
->event
) {
1243 case NB_EV_VALIDATE
:
1248 return lib_route_map_entry_match_destroy(args
);
1255 * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:ipv4-address
1258 lib_route_map_entry_match_condition_rmap_match_condition_ipv4_address_modify(
1259 struct nb_cb_modify_args
*args
)
1261 struct routemap_hook_context
*rhc
;
1263 enum rmap_compile_rets ret
;
1265 switch (args
->event
) {
1266 case NB_EV_VALIDATE
:
1271 /* Add configuration. */
1272 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
1273 peer
= yang_dnode_get_string(args
->dnode
, NULL
);
1275 /* Set destroy information. */
1276 rhc
->rhc_mhook
= bgp_route_match_delete
;
1277 rhc
->rhc_rule
= "ip next-hop address";
1278 rhc
->rhc_event
= RMAP_EVENT_MATCH_DELETED
;
1280 ret
= bgp_route_match_add(rhc
->rhc_rmi
, rhc
->rhc_rule
,
1281 peer
, RMAP_EVENT_MATCH_ADDED
,
1282 args
->errmsg
, args
->errmsg_len
);
1284 if (ret
!= RMAP_COMPILE_SUCCESS
) {
1285 rhc
->rhc_mhook
= NULL
;
1286 return NB_ERR_INCONSISTENCY
;
1294 lib_route_map_entry_match_condition_rmap_match_condition_ipv4_address_destroy(
1295 struct nb_cb_destroy_args
*args
)
1297 switch (args
->event
) {
1298 case NB_EV_VALIDATE
:
1303 return lib_route_map_entry_match_destroy(args
);
1310 * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:ipv6-address
1313 lib_route_map_entry_match_condition_rmap_match_condition_ipv6_address_modify(
1314 struct nb_cb_modify_args
*args
)
1316 struct routemap_hook_context
*rhc
;
1318 enum rmap_compile_rets ret
;
1320 switch (args
->event
) {
1321 case NB_EV_VALIDATE
:
1326 /* Add configuration. */
1327 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
1328 peer
= yang_dnode_get_string(args
->dnode
, NULL
);
1330 /* Set destroy information. */
1331 rhc
->rhc_mhook
= bgp_route_match_delete
;
1332 rhc
->rhc_rule
= "ipv6 next-hop address";
1333 rhc
->rhc_event
= RMAP_EVENT_MATCH_DELETED
;
1335 ret
= bgp_route_match_add(rhc
->rhc_rmi
, rhc
->rhc_rule
,
1336 peer
, RMAP_EVENT_MATCH_ADDED
,
1337 args
->errmsg
, args
->errmsg_len
);
1339 if (ret
!= RMAP_COMPILE_SUCCESS
) {
1340 rhc
->rhc_mhook
= NULL
;
1341 return NB_ERR_INCONSISTENCY
;
1349 lib_route_map_entry_match_condition_rmap_match_condition_ipv6_address_destroy(
1350 struct nb_cb_destroy_args
*args
)
1352 switch (args
->event
) {
1353 case NB_EV_VALIDATE
:
1358 return lib_route_map_entry_match_destroy(args
);
1366 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:distance
1368 int lib_route_map_entry_set_action_rmap_set_action_distance_modify(
1369 struct nb_cb_modify_args
*args
)
1371 struct routemap_hook_context
*rhc
;
1375 switch (args
->event
) {
1376 case NB_EV_VALIDATE
:
1381 /* Add configuration. */
1382 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
1383 type
= yang_dnode_get_string(args
->dnode
, NULL
);
1385 /* Set destroy information. */
1386 rhc
->rhc_shook
= generic_set_delete
;
1387 rhc
->rhc_rule
= "distance";
1388 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
1390 rv
= generic_set_add(rhc
->rhc_rmi
, "distance", type
,
1391 args
->errmsg
, args
->errmsg_len
);
1392 if (rv
!= CMD_SUCCESS
) {
1393 rhc
->rhc_shook
= NULL
;
1394 return NB_ERR_INCONSISTENCY
;
1401 int lib_route_map_entry_set_action_rmap_set_action_distance_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-rt
1421 lib_route_map_entry_set_action_rmap_set_action_extcommunity_rt_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 rt";
1441 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
1443 rv
= generic_set_add(rhc
->rhc_rmi
, "extcommunity rt", type
,
1444 args
->errmsg
, args
->errmsg_len
);
1445 if (rv
!= CMD_SUCCESS
) {
1446 rhc
->rhc_shook
= NULL
;
1447 return NB_ERR_INCONSISTENCY
;
1455 lib_route_map_entry_set_action_rmap_set_action_extcommunity_rt_destroy(
1456 struct nb_cb_destroy_args
*args
)
1458 switch (args
->event
) {
1459 case NB_EV_VALIDATE
:
1464 return lib_route_map_entry_match_destroy(args
);
1472 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:extcommunity-nt
1474 int lib_route_map_entry_set_action_rmap_set_action_extcommunity_nt_modify(
1475 struct nb_cb_modify_args
*args
)
1477 struct routemap_hook_context
*rhc
;
1481 switch (args
->event
) {
1482 case NB_EV_VALIDATE
:
1487 /* Add configuration. */
1488 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
1489 str
= yang_dnode_get_string(args
->dnode
, NULL
);
1491 /* Set destroy information. */
1492 rhc
->rhc_shook
= generic_set_delete
;
1493 rhc
->rhc_rule
= "extcommunity nt";
1494 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
1496 rv
= generic_set_add(rhc
->rhc_rmi
, "extcommunity nt", str
,
1497 args
->errmsg
, args
->errmsg_len
);
1498 if (rv
!= CMD_SUCCESS
) {
1499 rhc
->rhc_shook
= NULL
;
1500 return NB_ERR_INCONSISTENCY
;
1507 int lib_route_map_entry_set_action_rmap_set_action_extcommunity_nt_destroy(
1508 struct nb_cb_destroy_args
*args
)
1510 switch (args
->event
) {
1511 case NB_EV_VALIDATE
:
1516 return lib_route_map_entry_match_destroy(args
);
1524 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:extcommunity-soo
1527 lib_route_map_entry_set_action_rmap_set_action_extcommunity_soo_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
= "extcommunity soo";
1547 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
1549 rv
= generic_set_add(rhc
->rhc_rmi
, "extcommunity soo",
1551 args
->errmsg
, args
->errmsg_len
);
1552 if (rv
!= CMD_SUCCESS
) {
1553 rhc
->rhc_shook
= NULL
;
1554 return NB_ERR_INCONSISTENCY
;
1562 lib_route_map_entry_set_action_rmap_set_action_extcommunity_soo_destroy(
1563 struct nb_cb_destroy_args
*args
)
1565 switch (args
->event
) {
1566 case NB_EV_VALIDATE
:
1571 return lib_route_map_entry_match_destroy(args
);
1579 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:ipv4-address
1581 int lib_route_map_entry_set_action_rmap_set_action_ipv4_address_modify(
1582 struct nb_cb_modify_args
*args
)
1584 struct routemap_hook_context
*rhc
;
1586 int rv
= CMD_SUCCESS
;
1588 switch (args
->event
) {
1589 case NB_EV_VALIDATE
:
1594 /* Add configuration. */
1595 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
1596 addr
= yang_dnode_get_string(args
->dnode
, NULL
);
1598 rhc
->rhc_shook
= generic_set_delete
;
1599 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
1600 rhc
->rhc_rule
= "ipv4 vpn next-hop";
1602 rv
= generic_set_add(rhc
->rhc_rmi
, rhc
->rhc_rule
, addr
,
1603 args
->errmsg
, args
->errmsg_len
);
1605 if (rv
!= CMD_SUCCESS
) {
1606 rhc
->rhc_shook
= NULL
;
1607 return NB_ERR_INCONSISTENCY
;
1614 int lib_route_map_entry_set_action_rmap_set_action_ipv4_address_destroy(
1615 struct nb_cb_destroy_args
*args
)
1617 switch (args
->event
) {
1618 case NB_EV_VALIDATE
:
1623 return lib_route_map_entry_set_destroy(args
);
1631 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:ipv4-nexthop
1633 int lib_route_map_entry_set_action_rmap_set_action_ipv4_nexthop_modify(
1634 struct nb_cb_modify_args
*args
)
1636 struct routemap_hook_context
*rhc
;
1640 switch (args
->event
) {
1641 case NB_EV_VALIDATE
:
1646 /* Add configuration. */
1647 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
1648 type
= yang_dnode_get_string(args
->dnode
, NULL
);
1650 /* Set destroy information. */
1651 rhc
->rhc_shook
= generic_set_delete
;
1652 rhc
->rhc_rule
= "ip next-hop";
1653 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
1655 rv
= generic_set_add(rhc
->rhc_rmi
, rhc
->rhc_rule
, type
,
1656 args
->errmsg
, args
->errmsg_len
);
1658 if (rv
!= CMD_SUCCESS
) {
1659 rhc
->rhc_shook
= NULL
;
1660 return NB_ERR_INCONSISTENCY
;
1667 int lib_route_map_entry_set_action_rmap_set_action_ipv4_nexthop_destroy(
1668 struct nb_cb_destroy_args
*args
)
1670 switch (args
->event
) {
1671 case NB_EV_VALIDATE
:
1676 return lib_route_map_entry_set_destroy(args
);
1684 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:ipv6-address
1686 int lib_route_map_entry_set_action_rmap_set_action_ipv6_address_modify(
1687 struct nb_cb_modify_args
*args
)
1689 struct routemap_hook_context
*rhc
;
1691 int rv
= CMD_SUCCESS
;
1692 const char *action
= NULL
;
1693 struct in6_addr i6a
;
1695 action
= yang_dnode_get_string(args
->dnode
,
1696 "../../frr-route-map:action");
1697 switch (args
->event
) {
1698 case NB_EV_VALIDATE
:
1699 if (action
&& IS_SET_IPV6_NH_GLOBAL(action
)) {
1700 yang_dnode_get_ipv6(&i6a
, args
->dnode
, NULL
);
1701 if (IN6_IS_ADDR_UNSPECIFIED(&i6a
)
1702 || IN6_IS_ADDR_LOOPBACK(&i6a
)
1703 || IN6_IS_ADDR_MULTICAST(&i6a
)
1704 || IN6_IS_ADDR_LINKLOCAL(&i6a
))
1705 return NB_ERR_VALIDATION
;
1715 /* Add configuration. */
1716 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
1717 addr
= yang_dnode_get_string(args
->dnode
, NULL
);
1719 rhc
->rhc_shook
= generic_set_delete
;
1720 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
1722 if (IS_SET_IPV6_NH_GLOBAL(action
))
1723 /* Set destroy information. */
1724 rhc
->rhc_rule
= "ipv6 next-hop global";
1726 rhc
->rhc_rule
= "ipv6 vpn next-hop";
1728 rv
= generic_set_add(rhc
->rhc_rmi
, rhc
->rhc_rule
, addr
,
1729 args
->errmsg
, args
->errmsg_len
);
1731 if (rv
!= CMD_SUCCESS
) {
1732 rhc
->rhc_shook
= NULL
;
1733 return NB_ERR_INCONSISTENCY
;
1739 int lib_route_map_entry_set_action_rmap_set_action_ipv6_address_destroy(
1740 struct nb_cb_destroy_args
*args
)
1742 switch (args
->event
) {
1743 case NB_EV_VALIDATE
:
1748 return lib_route_map_entry_set_destroy(args
);
1756 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:preference
1758 int lib_route_map_entry_set_action_rmap_set_action_preference_modify(
1759 struct nb_cb_modify_args
*args
)
1761 struct routemap_hook_context
*rhc
;
1762 int rv
= CMD_SUCCESS
;
1763 const char *action
= NULL
;
1766 switch (args
->event
) {
1767 case NB_EV_VALIDATE
:
1772 /* Add configuration. */
1773 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
1774 value
= yang_dnode_get_bool(args
->dnode
, NULL
);
1776 rhc
->rhc_shook
= generic_set_delete
;
1777 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
1779 action
= yang_dnode_get_string(args
->dnode
,
1780 "../../frr-route-map:action");
1783 if (IS_SET_IPV6_PEER_ADDR(action
))
1784 /* Set destroy information. */
1785 rhc
->rhc_rule
= "ipv6 next-hop peer-address";
1787 rhc
->rhc_rule
= "ipv6 next-hop prefer-global";
1789 rv
= generic_set_add(rhc
->rhc_rmi
, rhc
->rhc_rule
,
1791 args
->errmsg
, args
->errmsg_len
);
1794 if (rv
!= CMD_SUCCESS
) {
1795 rhc
->rhc_shook
= NULL
;
1796 return NB_ERR_INCONSISTENCY
;
1803 int lib_route_map_entry_set_action_rmap_set_action_preference_destroy(
1804 struct nb_cb_destroy_args
*args
)
1806 switch (args
->event
) {
1807 case NB_EV_VALIDATE
:
1812 return lib_route_map_entry_set_destroy(args
);
1820 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:label-index
1822 int lib_route_map_entry_set_action_rmap_set_action_label_index_modify(
1823 struct nb_cb_modify_args
*args
)
1825 struct routemap_hook_context
*rhc
;
1829 switch (args
->event
) {
1830 case NB_EV_VALIDATE
:
1835 /* Add configuration. */
1836 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
1837 type
= yang_dnode_get_string(args
->dnode
, NULL
);
1839 /* Set destroy information. */
1840 rhc
->rhc_shook
= generic_set_delete
;
1841 rhc
->rhc_rule
= "label-index";
1842 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
1844 rv
= generic_set_add(rhc
->rhc_rmi
, "label-index", type
,
1845 args
->errmsg
, args
->errmsg_len
);
1846 if (rv
!= CMD_SUCCESS
) {
1847 rhc
->rhc_shook
= NULL
;
1848 return NB_ERR_INCONSISTENCY
;
1855 int lib_route_map_entry_set_action_rmap_set_action_label_index_destroy(
1856 struct nb_cb_destroy_args
*args
)
1858 switch (args
->event
) {
1859 case NB_EV_VALIDATE
:
1864 return lib_route_map_entry_set_destroy(args
);
1872 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:local-pref
1874 int lib_route_map_entry_set_action_rmap_set_action_local_pref_modify(
1875 struct nb_cb_modify_args
*args
)
1877 struct routemap_hook_context
*rhc
;
1881 switch (args
->event
) {
1882 case NB_EV_VALIDATE
:
1887 /* Add configuration. */
1888 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
1889 type
= yang_dnode_get_string(args
->dnode
, NULL
);
1891 /* Set destroy information. */
1892 rhc
->rhc_shook
= generic_set_delete
;
1893 rhc
->rhc_rule
= "local-preference";
1894 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
1896 rv
= generic_set_add(rhc
->rhc_rmi
, "local-preference",
1898 args
->errmsg
, args
->errmsg_len
);
1899 if (rv
!= CMD_SUCCESS
) {
1900 rhc
->rhc_shook
= NULL
;
1901 return NB_ERR_INCONSISTENCY
;
1908 int lib_route_map_entry_set_action_rmap_set_action_local_pref_destroy(
1909 struct nb_cb_destroy_args
*args
)
1911 switch (args
->event
) {
1912 case NB_EV_VALIDATE
:
1917 return lib_route_map_entry_set_destroy(args
);
1925 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:weight
1927 int lib_route_map_entry_set_action_rmap_set_action_weight_modify(
1928 struct nb_cb_modify_args
*args
)
1930 struct routemap_hook_context
*rhc
;
1934 switch (args
->event
) {
1935 case NB_EV_VALIDATE
:
1940 /* Add configuration. */
1941 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
1942 type
= yang_dnode_get_string(args
->dnode
, NULL
);
1944 /* Set destroy information. */
1945 rhc
->rhc_shook
= generic_set_delete
;
1946 rhc
->rhc_rule
= "weight";
1947 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
1949 rv
= generic_set_add(rhc
->rhc_rmi
, "weight", type
,
1950 args
->errmsg
, args
->errmsg_len
);
1951 if (rv
!= CMD_SUCCESS
) {
1952 rhc
->rhc_shook
= NULL
;
1953 return NB_ERR_INCONSISTENCY
;
1960 int lib_route_map_entry_set_action_rmap_set_action_weight_destroy(
1961 struct nb_cb_destroy_args
*args
)
1963 switch (args
->event
) {
1964 case NB_EV_VALIDATE
:
1969 return lib_route_map_entry_set_destroy(args
);
1977 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:origin
1979 int lib_route_map_entry_set_action_rmap_set_action_origin_modify(
1980 struct nb_cb_modify_args
*args
)
1982 struct routemap_hook_context
*rhc
;
1986 switch (args
->event
) {
1987 case NB_EV_VALIDATE
:
1992 /* Add configuration. */
1993 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
1994 type
= yang_dnode_get_string(args
->dnode
, NULL
);
1996 /* Set destroy information. */
1997 rhc
->rhc_shook
= generic_set_delete
;
1998 rhc
->rhc_rule
= "origin";
1999 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
2001 rv
= generic_set_add(rhc
->rhc_rmi
, "origin", type
,
2002 args
->errmsg
, args
->errmsg_len
);
2003 if (rv
!= CMD_SUCCESS
) {
2004 rhc
->rhc_shook
= NULL
;
2005 return NB_ERR_INCONSISTENCY
;
2012 int lib_route_map_entry_set_action_rmap_set_action_origin_destroy(
2013 struct nb_cb_destroy_args
*args
)
2015 switch (args
->event
) {
2016 case NB_EV_VALIDATE
:
2021 return lib_route_map_entry_set_destroy(args
);
2030 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:originator-id
2032 int lib_route_map_entry_set_action_rmap_set_action_originator_id_modify(
2033 struct nb_cb_modify_args
*args
)
2035 struct routemap_hook_context
*rhc
;
2039 switch (args
->event
) {
2040 case NB_EV_VALIDATE
:
2045 /* Add configuration. */
2046 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
2047 type
= yang_dnode_get_string(args
->dnode
, NULL
);
2049 /* Set destroy information. */
2050 rhc
->rhc_shook
= generic_set_delete
;
2051 rhc
->rhc_rule
= "originator-id";
2052 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
2054 rv
= generic_set_add(rhc
->rhc_rmi
, "originator-id", type
,
2055 args
->errmsg
, args
->errmsg_len
);
2056 if (rv
!= CMD_SUCCESS
) {
2057 rhc
->rhc_shook
= NULL
;
2058 return NB_ERR_INCONSISTENCY
;
2065 int lib_route_map_entry_set_action_rmap_set_action_originator_id_destroy(
2066 struct nb_cb_destroy_args
*args
)
2068 switch (args
->event
) {
2069 case NB_EV_VALIDATE
:
2074 return lib_route_map_entry_set_destroy(args
);
2082 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:table
2084 int lib_route_map_entry_set_action_rmap_set_action_table_modify(
2085 struct nb_cb_modify_args
*args
)
2087 struct routemap_hook_context
*rhc
;
2091 switch (args
->event
) {
2092 case NB_EV_VALIDATE
:
2097 /* Add configuration. */
2098 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
2099 type
= yang_dnode_get_string(args
->dnode
, NULL
);
2101 /* Set destroy information. */
2102 rhc
->rhc_shook
= generic_set_delete
;
2103 rhc
->rhc_rule
= "table";
2104 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
2106 rv
= generic_set_add(rhc
->rhc_rmi
, "table", type
,
2107 args
->errmsg
, args
->errmsg_len
);
2108 if (rv
!= CMD_SUCCESS
) {
2109 rhc
->rhc_shook
= NULL
;
2110 return NB_ERR_INCONSISTENCY
;
2117 int lib_route_map_entry_set_action_rmap_set_action_table_destroy(
2118 struct nb_cb_destroy_args
*args
)
2120 switch (args
->event
) {
2121 case NB_EV_VALIDATE
:
2126 return lib_route_map_entry_set_destroy(args
);
2134 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:atomic-aggregate
2137 lib_route_map_entry_set_action_rmap_set_action_atomic_aggregate_create(
2138 struct nb_cb_create_args
*args
)
2140 struct routemap_hook_context
*rhc
;
2143 switch (args
->event
) {
2144 case NB_EV_VALIDATE
:
2149 /* Add configuration. */
2150 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
2152 /* Set destroy information. */
2153 rhc
->rhc_shook
= generic_set_delete
;
2154 rhc
->rhc_rule
= "atomic-aggregate";
2155 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
2157 rv
= generic_set_add(rhc
->rhc_rmi
, rhc
->rhc_rule
, NULL
,
2158 args
->errmsg
, args
->errmsg_len
);
2159 if (rv
!= CMD_SUCCESS
) {
2160 rhc
->rhc_shook
= NULL
;
2161 return NB_ERR_INCONSISTENCY
;
2169 lib_route_map_entry_set_action_rmap_set_action_atomic_aggregate_destroy(
2170 struct nb_cb_destroy_args
*args
)
2172 switch (args
->event
) {
2173 case NB_EV_VALIDATE
:
2178 return lib_route_map_entry_set_destroy(args
);
2186 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:aigp-metric
2188 int lib_route_map_entry_set_action_rmap_set_action_aigp_metric_modify(
2189 struct nb_cb_modify_args
*args
)
2191 struct routemap_hook_context
*rhc
;
2195 switch (args
->event
) {
2196 case NB_EV_VALIDATE
:
2201 /* Add configuration. */
2202 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
2203 aigp
= yang_dnode_get_string(args
->dnode
, NULL
);
2205 /* Set destroy information. */
2206 rhc
->rhc_shook
= generic_set_delete
;
2207 rhc
->rhc_rule
= "aigp-metric";
2208 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
2210 rv
= generic_set_add(rhc
->rhc_rmi
, rhc
->rhc_rule
, aigp
,
2211 args
->errmsg
, args
->errmsg_len
);
2212 if (rv
!= CMD_SUCCESS
) {
2213 rhc
->rhc_shook
= NULL
;
2214 return NB_ERR_INCONSISTENCY
;
2221 int lib_route_map_entry_set_action_rmap_set_action_aigp_metric_destroy(
2222 struct nb_cb_destroy_args
*args
)
2224 switch (args
->event
) {
2225 case NB_EV_VALIDATE
:
2230 return lib_route_map_entry_set_destroy(args
);
2238 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:prepend-as-path
2241 lib_route_map_entry_set_action_rmap_set_action_prepend_as_path_modify(
2242 struct nb_cb_modify_args
*args
)
2244 struct routemap_hook_context
*rhc
;
2248 switch (args
->event
) {
2249 case NB_EV_VALIDATE
:
2254 /* Add configuration. */
2255 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
2256 type
= yang_dnode_get_string(args
->dnode
, NULL
);
2258 /* Set destroy information. */
2259 rhc
->rhc_shook
= generic_set_delete
;
2260 rhc
->rhc_rule
= "as-path prepend";
2261 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
2263 rv
= generic_set_add(rhc
->rhc_rmi
, "as-path prepend",
2265 args
->errmsg
, args
->errmsg_len
);
2266 if (rv
!= CMD_SUCCESS
) {
2267 rhc
->rhc_shook
= NULL
;
2268 return NB_ERR_INCONSISTENCY
;
2276 lib_route_map_entry_set_action_rmap_set_action_prepend_as_path_destroy(
2277 struct nb_cb_destroy_args
*args
)
2279 switch (args
->event
) {
2280 case NB_EV_VALIDATE
:
2285 return lib_route_map_entry_set_destroy(args
);
2293 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:last-as
2295 int lib_route_map_entry_set_action_rmap_set_action_last_as_modify(
2296 struct nb_cb_modify_args
*args
)
2298 struct routemap_hook_context
*rhc
;
2303 switch (args
->event
) {
2304 case NB_EV_VALIDATE
:
2309 /* Add configuration. */
2310 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
2311 value
= yang_dnode_get_string(args
->dnode
, NULL
);
2313 /* Set destroy information. */
2314 rhc
->rhc_shook
= generic_set_delete
;
2315 rhc
->rhc_rule
= "as-path prepend";
2316 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
2318 argstr
= XMALLOC(MTYPE_ROUTE_MAP_COMPILED
,
2319 strlen(value
) + strlen("last-as") + 2);
2321 snprintf(argstr
, (strlen(value
) + strlen("last-as") + 2),
2322 "last-as %s", value
);
2324 rv
= generic_set_add(rhc
->rhc_rmi
, "as-path prepend",
2326 args
->errmsg
, args
->errmsg_len
);
2327 if (rv
!= CMD_SUCCESS
) {
2328 rhc
->rhc_shook
= NULL
;
2329 XFREE(MTYPE_ROUTE_MAP_COMPILED
, argstr
);
2330 return NB_ERR_INCONSISTENCY
;
2333 XFREE(MTYPE_ROUTE_MAP_COMPILED
, argstr
);
2339 int lib_route_map_entry_set_action_rmap_set_action_last_as_destroy(
2340 struct nb_cb_destroy_args
*args
)
2342 switch (args
->event
) {
2343 case NB_EV_VALIDATE
:
2348 return lib_route_map_entry_set_destroy(args
);
2356 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:exclude-as-path
2359 lib_route_map_entry_set_action_rmap_set_action_exclude_as_path_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 type
= yang_dnode_get_string(args
->dnode
, NULL
);
2376 /* Set destroy information. */
2377 rhc
->rhc_shook
= generic_set_delete
;
2378 rhc
->rhc_rule
= "as-path exclude";
2379 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
2381 rv
= generic_set_add(rhc
->rhc_rmi
, "as-path exclude",
2383 args
->errmsg
, args
->errmsg_len
);
2384 if (rv
!= CMD_SUCCESS
) {
2385 rhc
->rhc_shook
= NULL
;
2386 return NB_ERR_INCONSISTENCY
;
2394 lib_route_map_entry_set_action_rmap_set_action_exclude_as_path_destroy(
2395 struct nb_cb_destroy_args
*args
)
2397 switch (args
->event
) {
2398 case NB_EV_VALIDATE
:
2403 return lib_route_map_entry_set_destroy(args
);
2411 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:replace-as-path
2413 int lib_route_map_entry_set_action_rmap_set_action_replace_as_path_modify(
2414 struct nb_cb_modify_args
*args
)
2416 struct routemap_hook_context
*rhc
;
2420 switch (args
->event
) {
2421 case NB_EV_VALIDATE
:
2426 /* Add configuration. */
2427 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
2428 type
= yang_dnode_get_string(args
->dnode
, NULL
);
2430 /* Set destroy information. */
2431 rhc
->rhc_shook
= generic_set_delete
;
2432 rhc
->rhc_rule
= "as-path replace";
2433 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
2435 rv
= generic_set_add(rhc
->rhc_rmi
, "as-path replace", type
,
2436 args
->errmsg
, args
->errmsg_len
);
2437 if (rv
!= CMD_SUCCESS
) {
2438 rhc
->rhc_shook
= NULL
;
2439 return NB_ERR_INCONSISTENCY
;
2446 int lib_route_map_entry_set_action_rmap_set_action_replace_as_path_destroy(
2447 struct nb_cb_destroy_args
*args
)
2449 switch (args
->event
) {
2450 case NB_EV_VALIDATE
:
2455 return lib_route_map_entry_set_destroy(args
);
2463 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:community-none
2465 int lib_route_map_entry_set_action_rmap_set_action_community_none_modify(
2466 struct nb_cb_modify_args
*args
)
2468 struct routemap_hook_context
*rhc
;
2472 switch (args
->event
) {
2473 case NB_EV_VALIDATE
:
2478 /* Add configuration. */
2479 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
2480 none
= yang_dnode_get_bool(args
->dnode
, NULL
);
2482 /* Set destroy information. */
2483 rhc
->rhc_shook
= generic_set_delete
;
2484 rhc
->rhc_rule
= "community";
2485 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
2488 rv
= generic_set_add(rhc
->rhc_rmi
, "community",
2490 args
->errmsg
, args
->errmsg_len
);
2491 if (rv
!= CMD_SUCCESS
) {
2492 rhc
->rhc_shook
= NULL
;
2493 return NB_ERR_INCONSISTENCY
;
2498 return NB_ERR_INCONSISTENCY
;
2505 lib_route_map_entry_set_action_rmap_set_action_community_none_destroy(
2506 struct nb_cb_destroy_args
*args
)
2508 switch (args
->event
) {
2509 case NB_EV_VALIDATE
:
2514 return lib_route_map_entry_set_destroy(args
);
2522 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:community-string
2525 lib_route_map_entry_set_action_rmap_set_action_community_string_modify(
2526 struct nb_cb_modify_args
*args
)
2528 struct routemap_hook_context
*rhc
;
2532 switch (args
->event
) {
2533 case NB_EV_VALIDATE
:
2538 /* Add configuration. */
2539 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
2540 type
= yang_dnode_get_string(args
->dnode
, NULL
);
2542 /* Set destroy information. */
2543 rhc
->rhc_shook
= generic_set_delete
;
2544 rhc
->rhc_rule
= "community";
2545 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
2547 rv
= generic_set_add(rhc
->rhc_rmi
, "community", type
,
2548 args
->errmsg
, args
->errmsg_len
);
2549 if (rv
!= CMD_SUCCESS
) {
2550 rhc
->rhc_shook
= NULL
;
2551 return NB_ERR_INCONSISTENCY
;
2559 lib_route_map_entry_set_action_rmap_set_action_community_string_destroy(
2560 struct nb_cb_destroy_args
*args
)
2562 switch (args
->event
) {
2563 case NB_EV_VALIDATE
:
2568 return lib_route_map_entry_set_destroy(args
);
2576 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:large-community-none
2579 lib_route_map_entry_set_action_rmap_set_action_large_community_none_modify(
2580 struct nb_cb_modify_args
*args
)
2582 struct routemap_hook_context
*rhc
;
2586 switch (args
->event
) {
2587 case NB_EV_VALIDATE
:
2592 /* Add configuration. */
2593 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
2594 none
= yang_dnode_get_bool(args
->dnode
, NULL
);
2596 /* Set destroy information. */
2597 rhc
->rhc_shook
= generic_set_delete
;
2598 rhc
->rhc_rule
= "large-community";
2599 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
2602 rv
= generic_set_add(rhc
->rhc_rmi
,
2605 args
->errmsg
, args
->errmsg_len
);
2606 if (rv
!= CMD_SUCCESS
) {
2607 rhc
->rhc_shook
= NULL
;
2608 return NB_ERR_INCONSISTENCY
;
2613 return NB_ERR_INCONSISTENCY
;
2620 lib_route_map_entry_set_action_rmap_set_action_large_community_none_destroy(
2621 struct nb_cb_destroy_args
*args
)
2623 switch (args
->event
) {
2624 case NB_EV_VALIDATE
:
2629 return lib_route_map_entry_set_destroy(args
);
2637 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:large-community-string
2640 lib_route_map_entry_set_action_rmap_set_action_large_community_string_modify(
2641 struct nb_cb_modify_args
*args
)
2643 struct routemap_hook_context
*rhc
;
2647 switch (args
->event
) {
2648 case NB_EV_VALIDATE
:
2653 /* Add configuration. */
2654 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
2655 type
= yang_dnode_get_string(args
->dnode
, NULL
);
2657 /* Set destroy information. */
2658 rhc
->rhc_shook
= generic_set_delete
;
2659 rhc
->rhc_rule
= "large-community";
2660 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
2662 rv
= generic_set_add(rhc
->rhc_rmi
, "large-community",
2664 args
->errmsg
, args
->errmsg_len
);
2665 if (rv
!= CMD_SUCCESS
) {
2666 rhc
->rhc_shook
= NULL
;
2667 return NB_ERR_INCONSISTENCY
;
2675 lib_route_map_entry_set_action_rmap_set_action_large_community_string_destroy(
2676 struct nb_cb_destroy_args
*args
)
2678 switch (args
->event
) {
2679 case NB_EV_VALIDATE
:
2684 return lib_route_map_entry_set_destroy(args
);
2692 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:aggregator
2694 void lib_route_map_entry_set_action_rmap_set_action_aggregator_finish(
2695 struct nb_cb_apply_finish_args
*args
)
2697 struct routemap_hook_context
*rhc
;
2703 /* Add configuration. */
2704 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
2705 asn
= yang_dnode_get_string(args
->dnode
, "./aggregator-asn");
2706 addr
= yang_dnode_get_string(args
->dnode
, "./aggregator-address");
2708 argstr
= XMALLOC(MTYPE_ROUTE_MAP_COMPILED
,
2709 strlen(asn
) + strlen(addr
) + 2);
2711 snprintf(argstr
, (strlen(asn
) + strlen(addr
) + 2), "%s %s", asn
, addr
);
2713 /* Set destroy information. */
2714 rhc
->rhc_shook
= generic_set_delete
;
2715 rhc
->rhc_rule
= "aggregator as";
2716 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
2718 ret
= generic_set_add(rhc
->rhc_rmi
, rhc
->rhc_rule
, argstr
, args
->errmsg
,
2721 * At this point if this is not a successful operation
2722 * bgpd is about to crash. Let's just cut to the
2725 assert(ret
== CMD_SUCCESS
);
2727 XFREE(MTYPE_ROUTE_MAP_COMPILED
, argstr
);
2731 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:aggregator/aggregator-asn
2734 lib_route_map_entry_set_action_rmap_set_action_aggregator_aggregator_asn_modify(
2735 struct nb_cb_modify_args
*args
)
2738 enum match_type match
;
2740 switch (args
->event
) {
2741 case NB_EV_VALIDATE
:
2742 asn
= yang_dnode_get_string(args
->dnode
, NULL
);
2744 return NB_ERR_VALIDATION
;
2745 match
= asn_str2asn_match(asn
);
2746 if (match
== exact_match
)
2748 return NB_ERR_VALIDATION
;
2759 lib_route_map_entry_set_action_rmap_set_action_aggregator_aggregator_asn_destroy(
2760 struct nb_cb_destroy_args
*args
)
2762 switch (args
->event
) {
2763 case NB_EV_VALIDATE
:
2768 return lib_route_map_entry_set_destroy(args
);
2776 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:aggregator/aggregator-address
2779 lib_route_map_entry_set_action_rmap_set_action_aggregator_aggregator_address_modify(
2780 struct nb_cb_modify_args
*args
)
2782 switch (args
->event
) {
2783 case NB_EV_VALIDATE
:
2794 lib_route_map_entry_set_action_rmap_set_action_aggregator_aggregator_address_destroy(
2795 struct nb_cb_destroy_args
*args
)
2797 switch (args
->event
) {
2798 case NB_EV_VALIDATE
:
2803 return lib_route_map_entry_set_destroy(args
);
2811 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:comm-list-name
2813 int lib_route_map_entry_set_action_rmap_set_action_comm_list_name_modify(
2814 struct nb_cb_modify_args
*args
)
2816 struct routemap_hook_context
*rhc
;
2819 int rv
= CMD_SUCCESS
;
2821 switch (args
->event
) {
2822 case NB_EV_VALIDATE
:
2827 /* Add configuration. */
2828 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
2829 value
= yang_dnode_get_string(args
->dnode
, NULL
);
2831 /* Set destroy information. */
2832 rhc
->rhc_shook
= generic_set_delete
;
2834 action
= yang_dnode_get_string(args
->dnode
,
2835 "../../frr-route-map:action");
2836 if (IS_SET_COMM_LIST_DEL(action
))
2837 rhc
->rhc_rule
= "comm-list";
2839 rhc
->rhc_rule
= "large-comm-list";
2841 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
2843 rv
= generic_set_add(rhc
->rhc_rmi
, rhc
->rhc_rule
, value
,
2844 args
->errmsg
, args
->errmsg_len
);
2846 if (rv
!= CMD_SUCCESS
) {
2847 rhc
->rhc_shook
= NULL
;
2848 return NB_ERR_INCONSISTENCY
;
2856 lib_route_map_entry_set_action_rmap_set_action_comm_list_name_destroy(
2857 struct nb_cb_destroy_args
*args
)
2859 switch (args
->event
) {
2860 case NB_EV_VALIDATE
:
2865 return lib_route_map_entry_set_destroy(args
);
2873 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:extcommunity-lb
2876 lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_finish(
2877 struct nb_cb_apply_finish_args
*args
)
2879 struct routemap_hook_context
*rhc
;
2880 enum ecommunity_lb_type lb_type
;
2881 char str
[VTY_BUFSIZ
];
2885 /* Add configuration. */
2886 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
2887 lb_type
= yang_dnode_get_enum(args
->dnode
, "./lb-type");
2889 /* Set destroy information. */
2890 rhc
->rhc_shook
= generic_set_delete
;
2891 rhc
->rhc_rule
= "extcommunity bandwidth";
2892 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
2895 case EXPLICIT_BANDWIDTH
:
2896 bandwidth
= yang_dnode_get_uint16(args
->dnode
, "./bandwidth");
2897 snprintf(str
, sizeof(str
), "%d", bandwidth
);
2899 case CUMULATIVE_BANDWIDTH
:
2900 snprintf(str
, sizeof(str
), "%s", "cumulative");
2902 case COMPUTED_BANDWIDTH
:
2903 snprintf(str
, sizeof(str
), "%s", "num-multipaths");
2906 if (yang_dnode_get_bool(args
->dnode
, "./two-octet-as-specific"))
2907 strlcat(str
, " non-transitive", sizeof(str
));
2909 ret
= generic_set_add(rhc
->rhc_rmi
, "extcommunity bandwidth", str
,
2910 args
->errmsg
, args
->errmsg_len
);
2912 * At this point if this is not a successful operation
2913 * bgpd is about to crash. Let's just cut to the
2916 assert(ret
== CMD_SUCCESS
);
2921 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:extcommunity-lb/lb-type
2924 lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_lb_type_modify(
2925 struct nb_cb_modify_args
*args
)
2931 lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_lb_type_destroy(
2932 struct nb_cb_destroy_args
*args
)
2934 return lib_route_map_entry_set_destroy(args
);
2939 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:extcommunity-lb/bandwidth
2942 lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_bandwidth_modify(
2943 struct nb_cb_modify_args
*args
)
2949 lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_bandwidth_destroy(
2950 struct nb_cb_destroy_args
*args
)
2952 return lib_route_map_entry_set_destroy(args
);
2957 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:extcommunity-lb/two-octet-as-specific
2960 lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_two_octet_as_specific_modify(
2961 struct nb_cb_modify_args
*args
)
2967 lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_two_octet_as_specific_destroy(
2968 struct nb_cb_destroy_args
*args
)
2970 return lib_route_map_entry_set_destroy(args
);
2975 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:extcommunity-none
2977 int lib_route_map_entry_set_action_rmap_set_action_extcommunity_none_modify(
2978 struct nb_cb_modify_args
*args
)
2980 struct routemap_hook_context
*rhc
;
2984 switch (args
->event
) {
2985 case NB_EV_VALIDATE
:
2990 /* Add configuration. */
2991 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
2992 none
= yang_dnode_get_bool(args
->dnode
, NULL
);
2994 /* Set destroy information. */
2995 rhc
->rhc_shook
= generic_set_delete
;
2996 rhc
->rhc_rule
= "extcommunity";
2997 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
3000 rv
= generic_set_add(rhc
->rhc_rmi
, "extcommunity",
3001 "none", args
->errmsg
,
3003 if (rv
!= CMD_SUCCESS
) {
3004 rhc
->rhc_shook
= NULL
;
3005 return NB_ERR_INCONSISTENCY
;
3010 return NB_ERR_INCONSISTENCY
;
3016 int lib_route_map_entry_set_action_rmap_set_action_extcommunity_none_destroy(
3017 struct nb_cb_destroy_args
*args
)
3019 switch (args
->event
) {
3020 case NB_EV_VALIDATE
:
3025 return lib_route_map_entry_set_destroy(args
);
3033 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:evpn-gateway-ip-ipv4
3035 int lib_route_map_entry_set_action_rmap_set_action_evpn_gateway_ip_ipv4_modify(
3036 struct nb_cb_modify_args
*args
)
3038 struct routemap_hook_context
*rhc
;
3042 switch (args
->event
) {
3043 case NB_EV_VALIDATE
:
3048 /* Add configuration. */
3049 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
3050 type
= yang_dnode_get_string(args
->dnode
, NULL
);
3052 /* Set destroy information. */
3053 rhc
->rhc_shook
= generic_set_delete
;
3054 rhc
->rhc_rule
= "evpn gateway-ip ipv4";
3055 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
3057 rv
= generic_set_add(rhc
->rhc_rmi
, "evpn gateway-ip ipv4", type
,
3058 args
->errmsg
, args
->errmsg_len
);
3059 if (rv
!= CMD_SUCCESS
) {
3060 rhc
->rhc_shook
= NULL
;
3061 return NB_ERR_INCONSISTENCY
;
3068 int lib_route_map_entry_set_action_rmap_set_action_evpn_gateway_ip_ipv4_destroy(
3069 struct nb_cb_destroy_args
*args
)
3071 switch (args
->event
) {
3072 case NB_EV_VALIDATE
:
3077 return lib_route_map_entry_set_destroy(args
);
3085 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:evpn-gateway-ip-ipv6
3087 int lib_route_map_entry_set_action_rmap_set_action_evpn_gateway_ip_ipv6_modify(
3088 struct nb_cb_modify_args
*args
)
3090 struct routemap_hook_context
*rhc
;
3094 switch (args
->event
) {
3095 case NB_EV_VALIDATE
:
3100 /* Add configuration. */
3101 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
3102 type
= yang_dnode_get_string(args
->dnode
, NULL
);
3104 /* Set destroy information. */
3105 rhc
->rhc_shook
= generic_set_delete
;
3106 rhc
->rhc_rule
= "evpn gateway-ip ipv6";
3107 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
3109 rv
= generic_set_add(rhc
->rhc_rmi
, "evpn gateway-ip ipv6", type
,
3110 args
->errmsg
, args
->errmsg_len
);
3111 if (rv
!= CMD_SUCCESS
) {
3112 rhc
->rhc_shook
= NULL
;
3113 return NB_ERR_INCONSISTENCY
;
3120 int lib_route_map_entry_set_action_rmap_set_action_evpn_gateway_ip_ipv6_destroy(
3121 struct nb_cb_destroy_args
*args
)
3123 switch (args
->event
) {
3124 case NB_EV_VALIDATE
:
3129 return lib_route_map_entry_set_destroy(args
);
3137 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/l3vpn-nexthop-encapsulation
3139 int lib_route_map_entry_set_action_rmap_set_action_l3vpn_nexthop_encapsulation_modify(
3140 struct nb_cb_modify_args
*args
)
3142 struct routemap_hook_context
*rhc
;
3146 switch (args
->event
) {
3147 case NB_EV_VALIDATE
:
3152 /* Add configuration. */
3153 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
3154 type
= yang_dnode_get_string(args
->dnode
, NULL
);
3156 /* Set destroy information. */
3157 rhc
->rhc_shook
= generic_set_delete
;
3158 rhc
->rhc_rule
= "l3vpn next-hop encapsulation";
3159 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
3161 rv
= generic_set_add(rhc
->rhc_rmi
,
3162 "l3vpn next-hop encapsulation", type
,
3163 args
->errmsg
, args
->errmsg_len
);
3164 if (rv
!= CMD_SUCCESS
) {
3165 rhc
->rhc_shook
= NULL
;
3166 return NB_ERR_INCONSISTENCY
;
3173 int lib_route_map_entry_set_action_rmap_set_action_l3vpn_nexthop_encapsulation_destroy(
3174 struct nb_cb_destroy_args
*args
)
3176 switch (args
->event
) {
3177 case NB_EV_VALIDATE
:
3182 return lib_route_map_entry_set_destroy(args
);