2 * Copyright (C) 2020 Vmware
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the Free
7 * Software Foundation; either version 2 of the License, or (at your option)
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * You should have received a copy of the GNU General Public License along
16 * with this program; see the file COPYING; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #include "lib/command.h"
24 #include "lib/northbound.h"
25 #include "lib/routemap.h"
26 #include "bgpd/bgpd.h"
27 #include "bgpd/bgp_routemap_nb.h"
29 /* Add bgp route map rule. */
30 static int bgp_route_match_add(struct route_map_index
*index
,
31 const char *command
, const char *arg
,
32 route_map_event_t type
,
33 char *errmsg
, size_t errmsg_len
)
35 int retval
= CMD_SUCCESS
;
36 enum rmap_compile_rets ret
;
38 ret
= route_map_add_match(index
, command
, arg
, type
);
40 case RMAP_RULE_MISSING
:
41 snprintf(errmsg
, errmsg_len
, "%% BGP Can't find rule.");
42 retval
= CMD_WARNING_CONFIG_FAILED
;
44 case RMAP_COMPILE_ERROR
:
45 snprintf(errmsg
, errmsg_len
, "%% BGP Argument is malformed.");
46 retval
= CMD_WARNING_CONFIG_FAILED
;
48 case RMAP_COMPILE_SUCCESS
:
50 * Intentionally doing nothing here.
58 /* Delete bgp route map rule. */
59 static int bgp_route_match_delete(struct route_map_index
*index
,
60 const char *command
, const char *arg
,
61 route_map_event_t type
,
62 char *errmsg
, size_t errmsg_len
)
64 enum rmap_compile_rets ret
;
65 int retval
= CMD_SUCCESS
;
66 char *dep_name
= NULL
;
68 char *rmap_name
= NULL
;
70 if (type
!= RMAP_EVENT_MATCH_DELETED
) {
71 /* ignore the mundane, the types without any dependency */
73 tmpstr
= route_map_get_match_arg(index
, command
);
76 XSTRDUP(MTYPE_ROUTE_MAP_RULE
, tmpstr
);
78 dep_name
= XSTRDUP(MTYPE_ROUTE_MAP_RULE
, arg
);
80 rmap_name
= XSTRDUP(MTYPE_ROUTE_MAP_NAME
, index
->map
->name
);
83 ret
= route_map_delete_match(index
, command
, dep_name
, type
);
85 case RMAP_RULE_MISSING
:
86 snprintf(errmsg
, errmsg_len
, "%% BGP Can't find rule.");
87 retval
= CMD_WARNING_CONFIG_FAILED
;
89 case RMAP_COMPILE_ERROR
:
90 snprintf(errmsg
, errmsg_len
,
91 "%% BGP Argument is malformed.");
92 retval
= CMD_WARNING_CONFIG_FAILED
;
94 case RMAP_COMPILE_SUCCESS
:
101 XFREE(MTYPE_ROUTE_MAP_RULE
, dep_name
);
102 XFREE(MTYPE_ROUTE_MAP_NAME
, rmap_name
);
108 * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:local-preference
111 lib_route_map_entry_match_condition_rmap_match_condition_local_preference_modify(
112 struct nb_cb_modify_args
*args
)
114 struct routemap_hook_context
*rhc
;
115 const char *local_pref
;
116 enum rmap_compile_rets ret
;
118 switch (args
->event
) {
124 /* Add configuration. */
125 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
126 local_pref
= yang_dnode_get_string(args
->dnode
, NULL
);
128 /* Set destroy information. */
129 rhc
->rhc_mhook
= bgp_route_match_delete
;
130 rhc
->rhc_rule
= "local-preference";
131 rhc
->rhc_event
= RMAP_EVENT_MATCH_DELETED
;
133 ret
= bgp_route_match_add(rhc
->rhc_rmi
, "local-preference",
134 local_pref
, RMAP_EVENT_MATCH_ADDED
,
135 args
->errmsg
, args
->errmsg_len
);
137 if (ret
!= RMAP_COMPILE_SUCCESS
) {
138 rhc
->rhc_mhook
= NULL
;
139 return NB_ERR_INCONSISTENCY
;
147 lib_route_map_entry_match_condition_rmap_match_condition_local_preference_destroy(
148 struct nb_cb_destroy_args
*args
)
150 switch (args
->event
) {
156 return lib_route_map_entry_match_destroy(args
);
164 * /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:alias
166 int lib_route_map_entry_match_condition_rmap_match_condition_alias_modify(
167 struct nb_cb_modify_args
*args
)
169 struct routemap_hook_context
*rhc
;
171 enum rmap_compile_rets ret
;
173 switch (args
->event
) {
179 /* Add configuration. */
180 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
181 alias
= yang_dnode_get_string(args
->dnode
, NULL
);
183 /* Set destroy information. */
184 rhc
->rhc_mhook
= bgp_route_match_delete
;
185 rhc
->rhc_rule
= "alias";
186 rhc
->rhc_event
= RMAP_EVENT_MATCH_DELETED
;
188 ret
= bgp_route_match_add(rhc
->rhc_rmi
, "alias", alias
,
189 RMAP_EVENT_MATCH_ADDED
, args
->errmsg
,
192 if (ret
!= RMAP_COMPILE_SUCCESS
) {
193 rhc
->rhc_mhook
= NULL
;
194 return NB_ERR_VALIDATION
;
203 int lib_route_map_entry_match_condition_rmap_match_condition_alias_destroy(
204 struct nb_cb_destroy_args
*args
)
206 switch (args
->event
) {
212 return lib_route_map_entry_match_destroy(args
);
219 * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:script
222 lib_route_map_entry_match_condition_rmap_match_condition_script_modify(
223 struct nb_cb_modify_args
*args
)
225 struct routemap_hook_context
*rhc
;
227 enum rmap_compile_rets ret
;
229 switch (args
->event
) {
235 /* Add configuration. */
236 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
237 script
= yang_dnode_get_string(args
->dnode
, NULL
);
239 /* Set destroy information. */
240 rhc
->rhc_mhook
= bgp_route_match_delete
;
241 rhc
->rhc_rule
= "script";
242 rhc
->rhc_event
= RMAP_EVENT_MATCH_DELETED
;
244 ret
= bgp_route_match_add(rhc
->rhc_rmi
, "script",
245 script
, RMAP_EVENT_MATCH_ADDED
,
246 args
->errmsg
, args
->errmsg_len
);
248 if (ret
!= RMAP_COMPILE_SUCCESS
) {
249 rhc
->rhc_mhook
= NULL
;
250 return NB_ERR_INCONSISTENCY
;
258 lib_route_map_entry_match_condition_rmap_match_condition_script_destroy(
259 struct nb_cb_destroy_args
*args
)
261 switch (args
->event
) {
267 return lib_route_map_entry_match_destroy(args
);
274 * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:origin
277 lib_route_map_entry_match_condition_rmap_match_condition_origin_modify(
278 struct nb_cb_modify_args
*args
)
280 struct routemap_hook_context
*rhc
;
282 enum rmap_compile_rets ret
;
284 switch (args
->event
) {
290 /* Add configuration. */
291 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
292 origin
= yang_dnode_get_string(args
->dnode
, NULL
);
294 /* Set destroy information. */
295 rhc
->rhc_mhook
= bgp_route_match_delete
;
296 rhc
->rhc_rule
= "origin";
297 rhc
->rhc_event
= RMAP_EVENT_MATCH_DELETED
;
299 ret
= bgp_route_match_add(rhc
->rhc_rmi
, "origin", origin
,
300 RMAP_EVENT_MATCH_ADDED
,
301 args
->errmsg
, args
->errmsg_len
);
303 if (ret
!= RMAP_COMPILE_SUCCESS
) {
304 rhc
->rhc_mhook
= NULL
;
305 return NB_ERR_INCONSISTENCY
;
313 lib_route_map_entry_match_condition_rmap_match_condition_origin_destroy(
314 struct nb_cb_destroy_args
*args
)
316 switch (args
->event
) {
322 return lib_route_map_entry_match_destroy(args
);
329 * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:rpki
332 lib_route_map_entry_match_condition_rmap_match_condition_rpki_modify(
333 struct nb_cb_modify_args
*args
)
335 struct routemap_hook_context
*rhc
;
337 enum rmap_compile_rets ret
;
339 switch (args
->event
) {
345 /* Add configuration. */
346 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
347 rpki
= yang_dnode_get_string(args
->dnode
, NULL
);
349 /* Set destroy information. */
350 rhc
->rhc_mhook
= bgp_route_match_delete
;
351 rhc
->rhc_rule
= "rpki";
352 rhc
->rhc_event
= RMAP_EVENT_MATCH_DELETED
;
354 ret
= bgp_route_match_add(rhc
->rhc_rmi
, "rpki", rpki
,
355 RMAP_EVENT_MATCH_ADDED
,
356 args
->errmsg
, args
->errmsg_len
);
358 if (ret
!= RMAP_COMPILE_SUCCESS
) {
359 rhc
->rhc_mhook
= NULL
;
360 return NB_ERR_INCONSISTENCY
;
368 lib_route_map_entry_match_condition_rmap_match_condition_rpki_destroy(
369 struct nb_cb_destroy_args
*args
)
371 switch (args
->event
) {
377 return lib_route_map_entry_match_destroy(args
);
385 * /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:rpki-extcommunity
387 int lib_route_map_entry_match_condition_rmap_match_condition_rpki_extcommunity_modify(
388 struct nb_cb_modify_args
*args
)
390 struct routemap_hook_context
*rhc
;
392 enum rmap_compile_rets ret
;
394 switch (args
->event
) {
400 /* Add configuration. */
401 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
402 rpki
= yang_dnode_get_string(args
->dnode
, NULL
);
404 /* Set destroy information. */
405 rhc
->rhc_mhook
= bgp_route_match_delete
;
406 rhc
->rhc_rule
= "rpki-extcommunity";
407 rhc
->rhc_event
= RMAP_EVENT_MATCH_DELETED
;
409 ret
= bgp_route_match_add(rhc
->rhc_rmi
, "rpki-extcommunity",
410 rpki
, RMAP_EVENT_MATCH_ADDED
,
411 args
->errmsg
, args
->errmsg_len
);
413 if (ret
!= RMAP_COMPILE_SUCCESS
) {
414 rhc
->rhc_mhook
= NULL
;
415 return NB_ERR_INCONSISTENCY
;
422 int lib_route_map_entry_match_condition_rmap_match_condition_rpki_extcommunity_destroy(
423 struct nb_cb_destroy_args
*args
)
425 switch (args
->event
) {
431 return lib_route_map_entry_match_destroy(args
);
438 * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:probability
441 lib_route_map_entry_match_condition_rmap_match_condition_probability_modify(
442 struct nb_cb_modify_args
*args
)
444 struct routemap_hook_context
*rhc
;
445 const char *probability
;
446 enum rmap_compile_rets ret
;
448 switch (args
->event
) {
454 /* Add configuration. */
455 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
456 probability
= yang_dnode_get_string(args
->dnode
, NULL
);
458 /* Set destroy information. */
459 rhc
->rhc_mhook
= bgp_route_match_delete
;
460 rhc
->rhc_rule
= "probability";
461 rhc
->rhc_event
= RMAP_EVENT_MATCH_DELETED
;
463 ret
= bgp_route_match_add(rhc
->rhc_rmi
, "probability",
464 probability
, RMAP_EVENT_MATCH_ADDED
,
465 args
->errmsg
, args
->errmsg_len
);
467 if (ret
!= RMAP_COMPILE_SUCCESS
) {
468 rhc
->rhc_mhook
= NULL
;
469 return NB_ERR_INCONSISTENCY
;
477 lib_route_map_entry_match_condition_rmap_match_condition_probability_destroy(
478 struct nb_cb_destroy_args
*args
)
480 switch (args
->event
) {
485 return lib_route_map_entry_match_destroy(args
);
492 * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:source-vrf
495 lib_route_map_entry_match_condition_rmap_match_condition_source_vrf_modify(
496 struct nb_cb_modify_args
*args
)
498 struct routemap_hook_context
*rhc
;
500 enum rmap_compile_rets ret
;
502 switch (args
->event
) {
508 /* Add configuration. */
509 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
510 vrf
= yang_dnode_get_string(args
->dnode
, NULL
);
512 /* Set destroy information. */
513 rhc
->rhc_mhook
= bgp_route_match_delete
;
514 rhc
->rhc_rule
= "source-vrf";
515 rhc
->rhc_event
= RMAP_EVENT_MATCH_DELETED
;
517 ret
= bgp_route_match_add(rhc
->rhc_rmi
, "source-vrf", vrf
,
518 RMAP_EVENT_MATCH_ADDED
,
519 args
->errmsg
, args
->errmsg_len
);
521 if (ret
!= RMAP_COMPILE_SUCCESS
) {
522 rhc
->rhc_mhook
= NULL
;
523 return NB_ERR_INCONSISTENCY
;
531 lib_route_map_entry_match_condition_rmap_match_condition_source_vrf_destroy(
532 struct nb_cb_destroy_args
*args
)
534 switch (args
->event
) {
540 return lib_route_map_entry_match_destroy(args
);
547 * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:peer-ipv4-address
550 lib_route_map_entry_match_condition_rmap_match_condition_peer_ipv4_address_modify(
551 struct nb_cb_modify_args
*args
)
553 struct routemap_hook_context
*rhc
;
555 enum rmap_compile_rets ret
;
557 switch (args
->event
) {
563 /* Add configuration. */
564 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
565 peer
= yang_dnode_get_string(args
->dnode
, NULL
);
567 /* Set destroy information. */
568 rhc
->rhc_mhook
= bgp_route_match_delete
;
569 rhc
->rhc_rule
= "peer";
570 rhc
->rhc_event
= RMAP_EVENT_MATCH_DELETED
;
572 ret
= bgp_route_match_add(rhc
->rhc_rmi
, "peer", peer
,
573 RMAP_EVENT_MATCH_ADDED
,
574 args
->errmsg
, args
->errmsg_len
);
576 if (ret
!= RMAP_COMPILE_SUCCESS
) {
577 rhc
->rhc_mhook
= NULL
;
578 return NB_ERR_INCONSISTENCY
;
586 lib_route_map_entry_match_condition_rmap_match_condition_peer_ipv4_address_destroy(
587 struct nb_cb_destroy_args
*args
)
589 switch (args
->event
) {
595 return lib_route_map_entry_match_destroy(args
);
602 * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:peer-interface
605 lib_route_map_entry_match_condition_rmap_match_condition_peer_interface_modify(
606 struct nb_cb_modify_args
*args
)
608 struct routemap_hook_context
*rhc
;
610 enum rmap_compile_rets ret
;
612 switch (args
->event
) {
618 /* Add configuration. */
619 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
620 peer
= yang_dnode_get_string(args
->dnode
, NULL
);
622 /* Set destroy information. */
623 rhc
->rhc_mhook
= bgp_route_match_delete
;
624 rhc
->rhc_rule
= "peer";
625 rhc
->rhc_event
= RMAP_EVENT_MATCH_DELETED
;
627 ret
= bgp_route_match_add(rhc
->rhc_rmi
, "peer", peer
,
628 RMAP_EVENT_MATCH_ADDED
,
629 args
->errmsg
, args
->errmsg_len
);
631 if (ret
!= RMAP_COMPILE_SUCCESS
) {
632 rhc
->rhc_mhook
= NULL
;
633 return NB_ERR_INCONSISTENCY
;
641 lib_route_map_entry_match_condition_rmap_match_condition_peer_interface_destroy(
642 struct nb_cb_destroy_args
*args
)
644 switch (args
->event
) {
650 return lib_route_map_entry_match_destroy(args
);
657 * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:peer-ipv6-address
660 lib_route_map_entry_match_condition_rmap_match_condition_peer_ipv6_address_modify(
661 struct nb_cb_modify_args
*args
)
663 struct routemap_hook_context
*rhc
;
665 enum rmap_compile_rets ret
;
667 switch (args
->event
) {
673 /* Add configuration. */
674 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
675 peer
= yang_dnode_get_string(args
->dnode
, NULL
);
677 /* Set destroy information. */
678 rhc
->rhc_mhook
= bgp_route_match_delete
;
679 rhc
->rhc_rule
= "peer";
680 rhc
->rhc_event
= RMAP_EVENT_MATCH_DELETED
;
682 ret
= bgp_route_match_add(rhc
->rhc_rmi
, "peer", peer
,
683 RMAP_EVENT_MATCH_ADDED
,
684 args
->errmsg
, args
->errmsg_len
);
686 if (ret
!= RMAP_COMPILE_SUCCESS
) {
687 rhc
->rhc_mhook
= NULL
;
688 return NB_ERR_INCONSISTENCY
;
696 lib_route_map_entry_match_condition_rmap_match_condition_peer_ipv6_address_destroy(
697 struct nb_cb_destroy_args
*args
)
699 switch (args
->event
) {
705 return lib_route_map_entry_match_destroy(args
);
712 * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:peer-local
715 lib_route_map_entry_match_condition_rmap_match_condition_peer_local_modify(
716 struct nb_cb_modify_args
*args
)
718 struct routemap_hook_context
*rhc
;
720 enum rmap_compile_rets ret
;
722 switch (args
->event
) {
728 /* Add configuration. */
729 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
730 value
= yang_dnode_get_bool(args
->dnode
, NULL
);
732 /* Set destroy information. */
733 rhc
->rhc_mhook
= bgp_route_match_delete
;
734 rhc
->rhc_rule
= "peer";
735 rhc
->rhc_event
= RMAP_EVENT_MATCH_DELETED
;
738 ret
= bgp_route_match_add(rhc
->rhc_rmi
, "peer",
740 RMAP_EVENT_MATCH_ADDED
,
741 args
->errmsg
, args
->errmsg_len
);
743 if (ret
!= RMAP_COMPILE_SUCCESS
) {
744 rhc
->rhc_mhook
= NULL
;
745 return NB_ERR_INCONSISTENCY
;
754 lib_route_map_entry_match_condition_rmap_match_condition_peer_local_destroy(
755 struct nb_cb_destroy_args
*args
)
757 switch (args
->event
) {
763 return lib_route_map_entry_match_destroy(args
);
770 * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:list-name
773 lib_route_map_entry_match_condition_rmap_match_condition_list_name_modify(
774 struct nb_cb_modify_args
*args
)
776 struct routemap_hook_context
*rhc
;
777 const char *list_name
;
778 enum rmap_compile_rets ret
= RMAP_COMPILE_SUCCESS
;
779 const char *condition
;
781 switch (args
->event
) {
787 /* Add configuration. */
788 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
789 list_name
= yang_dnode_get_string(args
->dnode
, NULL
);
790 condition
= yang_dnode_get_string(args
->dnode
,
791 "../../frr-route-map:condition");
793 if (IS_MATCH_AS_LIST(condition
)) {
794 /* Set destroy information. */
795 rhc
->rhc_mhook
= bgp_route_match_delete
;
796 rhc
->rhc_rule
= "as-path";
797 rhc
->rhc_event
= RMAP_EVENT_ASLIST_DELETED
;
799 ret
= bgp_route_match_add(rhc
->rhc_rmi
, "as-path",
800 list_name
, RMAP_EVENT_ASLIST_ADDED
,
801 args
->errmsg
, args
->errmsg_len
);
802 } else if (IS_MATCH_MAC_LIST(condition
)) {
803 /* Set destroy information. */
804 rhc
->rhc_mhook
= bgp_route_match_delete
;
805 rhc
->rhc_rule
= "mac address";
806 rhc
->rhc_event
= RMAP_EVENT_FILTER_DELETED
;
808 ret
= bgp_route_match_add(rhc
->rhc_rmi
,
811 RMAP_EVENT_FILTER_ADDED
,
812 args
->errmsg
, args
->errmsg_len
);
813 } else if (IS_MATCH_ROUTE_SRC(condition
)) {
814 /* Set destroy information. */
815 rhc
->rhc_mhook
= bgp_route_match_delete
;
816 rhc
->rhc_rule
= "ip route-source";
817 rhc
->rhc_event
= RMAP_EVENT_FILTER_DELETED
;
819 ret
= bgp_route_match_add(rhc
->rhc_rmi
,
821 list_name
, RMAP_EVENT_FILTER_ADDED
,
822 args
->errmsg
, args
->errmsg_len
);
823 } else if (IS_MATCH_ROUTE_SRC_PL(condition
)) {
824 /* Set destroy information. */
825 rhc
->rhc_mhook
= bgp_route_match_delete
;
826 rhc
->rhc_rule
= "ip route-source prefix-list";
827 rhc
->rhc_event
= RMAP_EVENT_PLIST_DELETED
;
829 ret
= bgp_route_match_add(rhc
->rhc_rmi
,
830 "ip route-source prefix-list",
831 list_name
, RMAP_EVENT_PLIST_ADDED
,
832 args
->errmsg
, args
->errmsg_len
);
835 if (ret
!= RMAP_COMPILE_SUCCESS
) {
836 rhc
->rhc_mhook
= NULL
;
837 return NB_ERR_INCONSISTENCY
;
845 lib_route_map_entry_match_condition_rmap_match_condition_list_name_destroy(
846 struct nb_cb_destroy_args
*args
)
848 switch (args
->event
) {
854 return lib_route_map_entry_match_destroy(args
);
861 * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:evpn-default-route
864 lib_route_map_entry_match_condition_rmap_match_condition_evpn_default_route_create(
865 struct nb_cb_create_args
*args
)
867 struct routemap_hook_context
*rhc
;
868 enum rmap_compile_rets ret
;
870 switch (args
->event
) {
876 /* Add configuration. */
877 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
879 /* Set destroy information. */
880 rhc
->rhc_mhook
= bgp_route_match_delete
;
881 rhc
->rhc_rule
= "evpn default-route";
882 rhc
->rhc_event
= RMAP_EVENT_MATCH_DELETED
;
884 ret
= bgp_route_match_add(rhc
->rhc_rmi
, "evpn default-route",
885 NULL
, RMAP_EVENT_MATCH_ADDED
,
886 args
->errmsg
, args
->errmsg_len
);
888 if (ret
!= RMAP_COMPILE_SUCCESS
) {
889 rhc
->rhc_mhook
= NULL
;
890 return NB_ERR_INCONSISTENCY
;
898 lib_route_map_entry_match_condition_rmap_match_condition_evpn_default_route_destroy(
899 struct nb_cb_destroy_args
*args
)
901 switch (args
->event
) {
907 return lib_route_map_entry_match_destroy(args
);
914 * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:evpn-vni
917 lib_route_map_entry_match_condition_rmap_match_condition_evpn_vni_modify(
918 struct nb_cb_modify_args
*args
)
920 struct routemap_hook_context
*rhc
;
922 enum rmap_compile_rets ret
;
924 switch (args
->event
) {
930 /* Add configuration. */
931 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
932 vni
= yang_dnode_get_string(args
->dnode
, NULL
);
934 /* Set destroy information. */
935 rhc
->rhc_mhook
= bgp_route_match_delete
;
936 rhc
->rhc_rule
= "evpn vni";
937 rhc
->rhc_event
= RMAP_EVENT_MATCH_DELETED
;
939 ret
= bgp_route_match_add(rhc
->rhc_rmi
, "evpn vni", vni
,
940 RMAP_EVENT_MATCH_ADDED
,
941 args
->errmsg
, args
->errmsg_len
);
943 if (ret
!= RMAP_COMPILE_SUCCESS
) {
944 rhc
->rhc_mhook
= NULL
;
945 return NB_ERR_INCONSISTENCY
;
953 lib_route_map_entry_match_condition_rmap_match_condition_evpn_vni_destroy(
954 struct nb_cb_destroy_args
*args
)
956 switch (args
->event
) {
962 return lib_route_map_entry_match_destroy(args
);
969 * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:evpn-route-type
972 lib_route_map_entry_match_condition_rmap_match_condition_evpn_route_type_modify(
973 struct nb_cb_modify_args
*args
)
975 struct routemap_hook_context
*rhc
;
977 enum rmap_compile_rets ret
;
979 switch (args
->event
) {
985 /* Add configuration. */
986 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
987 type
= yang_dnode_get_string(args
->dnode
, NULL
);
989 /* Set destroy information. */
990 rhc
->rhc_mhook
= bgp_route_match_delete
;
991 rhc
->rhc_rule
= "evpn route-type";
992 rhc
->rhc_event
= RMAP_EVENT_MATCH_DELETED
;
994 ret
= bgp_route_match_add(rhc
->rhc_rmi
, "evpn route-type",
996 RMAP_EVENT_MATCH_ADDED
,
997 args
->errmsg
, args
->errmsg_len
);
999 if (ret
!= RMAP_COMPILE_SUCCESS
) {
1000 rhc
->rhc_mhook
= NULL
;
1001 return NB_ERR_INCONSISTENCY
;
1009 lib_route_map_entry_match_condition_rmap_match_condition_evpn_route_type_destroy(
1010 struct nb_cb_destroy_args
*args
)
1012 switch (args
->event
) {
1013 case NB_EV_VALIDATE
:
1018 return lib_route_map_entry_match_destroy(args
);
1025 * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:route-distinguisher
1028 lib_route_map_entry_match_condition_rmap_match_condition_route_distinguisher_modify(
1029 struct nb_cb_modify_args
*args
)
1031 struct routemap_hook_context
*rhc
;
1033 enum rmap_compile_rets ret
;
1035 switch (args
->event
) {
1036 case NB_EV_VALIDATE
:
1041 /* Add configuration. */
1042 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
1043 rd
= yang_dnode_get_string(args
->dnode
, NULL
);
1045 /* Set destroy information. */
1046 rhc
->rhc_mhook
= bgp_route_match_delete
;
1047 rhc
->rhc_rule
= "evpn rd";
1048 rhc
->rhc_event
= RMAP_EVENT_MATCH_DELETED
;
1050 ret
= bgp_route_match_add(rhc
->rhc_rmi
, "evpn rd", rd
,
1051 RMAP_EVENT_MATCH_ADDED
,
1052 args
->errmsg
, args
->errmsg_len
);
1054 if (ret
!= RMAP_COMPILE_SUCCESS
) {
1055 rhc
->rhc_mhook
= NULL
;
1056 return NB_ERR_INCONSISTENCY
;
1064 lib_route_map_entry_match_condition_rmap_match_condition_route_distinguisher_destroy(
1065 struct nb_cb_destroy_args
*args
)
1067 switch (args
->event
) {
1068 case NB_EV_VALIDATE
:
1073 return lib_route_map_entry_match_destroy(args
);
1080 * XPath = /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:comm-list
1083 lib_route_map_entry_match_condition_rmap_match_condition_comm_list_finish(
1084 struct nb_cb_apply_finish_args
*args
)
1086 struct routemap_hook_context
*rhc
;
1088 bool exact_match
= false;
1090 const char *condition
;
1091 route_map_event_t event
;
1094 /* Add configuration. */
1095 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
1096 value
= yang_dnode_get_string(args
->dnode
, "./comm-list-name");
1098 if (yang_dnode_exists(args
->dnode
, "./comm-list-name-exact-match"))
1099 exact_match
= yang_dnode_get_bool(
1100 args
->dnode
, "./comm-list-name-exact-match");
1103 argstr
= XMALLOC(MTYPE_ROUTE_MAP_COMPILED
,
1104 strlen(value
) + strlen("exact-match") + 2);
1106 snprintf(argstr
, (strlen(value
) + strlen("exact-match") + 2),
1107 "%s exact-match", value
);
1109 argstr
= (char *)value
;
1111 /* Set destroy information. */
1112 rhc
->rhc_mhook
= bgp_route_match_delete
;
1114 condition
= yang_dnode_get_string(args
->dnode
,
1115 "../../frr-route-map:condition");
1116 if (IS_MATCH_COMMUNITY(condition
)) {
1117 rhc
->rhc_rule
= "community";
1118 event
= RMAP_EVENT_CLIST_ADDED
;
1119 rhc
->rhc_event
= RMAP_EVENT_CLIST_DELETED
;
1120 } else if (IS_MATCH_LCOMMUNITY(condition
)) {
1121 rhc
->rhc_rule
= "large-community";
1122 event
= RMAP_EVENT_LLIST_ADDED
;
1123 rhc
->rhc_event
= RMAP_EVENT_LLIST_DELETED
;
1125 rhc
->rhc_rule
= "extcommunity";
1126 event
= RMAP_EVENT_ECLIST_ADDED
;
1127 rhc
->rhc_event
= RMAP_EVENT_ECLIST_DELETED
;
1130 ret
= bgp_route_match_add(rhc
->rhc_rmi
, rhc
->rhc_rule
, argstr
, event
,
1131 args
->errmsg
, args
->errmsg_len
);
1133 * At this point if this is not a successful operation
1134 * bgpd is about to crash. Let's just cut to the
1137 assert(ret
== RMAP_COMPILE_SUCCESS
);
1139 if (argstr
!= value
)
1140 XFREE(MTYPE_ROUTE_MAP_COMPILED
, argstr
);
1145 * /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:comm-list/comm-list-name
1148 lib_route_map_entry_match_condition_rmap_match_condition_comm_list_comm_list_name_modify(
1149 struct nb_cb_modify_args
*args
)
1151 switch (args
->event
) {
1152 case NB_EV_VALIDATE
:
1163 lib_route_map_entry_match_condition_rmap_match_condition_comm_list_comm_list_name_destroy(
1164 struct nb_cb_destroy_args
*args
)
1166 switch (args
->event
) {
1167 case NB_EV_VALIDATE
:
1172 return lib_route_map_entry_match_destroy(args
);
1180 * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:comm-list/comm-list-name-exact-match
1183 lib_route_map_entry_match_condition_rmap_match_condition_comm_list_comm_list_name_exact_match_modify(
1184 struct nb_cb_modify_args
*args
)
1186 switch (args
->event
) {
1187 case NB_EV_VALIDATE
:
1198 lib_route_map_entry_match_condition_rmap_match_condition_comm_list_comm_list_name_exact_match_destroy(
1199 struct nb_cb_destroy_args
*args
)
1201 switch (args
->event
) {
1202 case NB_EV_VALIDATE
:
1207 return lib_route_map_entry_match_destroy(args
);
1214 * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:ipv4-address
1217 lib_route_map_entry_match_condition_rmap_match_condition_ipv4_address_modify(
1218 struct nb_cb_modify_args
*args
)
1220 struct routemap_hook_context
*rhc
;
1222 enum rmap_compile_rets ret
;
1224 switch (args
->event
) {
1225 case NB_EV_VALIDATE
:
1230 /* Add configuration. */
1231 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
1232 peer
= yang_dnode_get_string(args
->dnode
, NULL
);
1234 /* Set destroy information. */
1235 rhc
->rhc_mhook
= bgp_route_match_delete
;
1236 rhc
->rhc_rule
= "ip next-hop address";
1237 rhc
->rhc_event
= RMAP_EVENT_MATCH_DELETED
;
1239 ret
= bgp_route_match_add(rhc
->rhc_rmi
, rhc
->rhc_rule
,
1240 peer
, RMAP_EVENT_MATCH_ADDED
,
1241 args
->errmsg
, args
->errmsg_len
);
1243 if (ret
!= RMAP_COMPILE_SUCCESS
) {
1244 rhc
->rhc_mhook
= NULL
;
1245 return NB_ERR_INCONSISTENCY
;
1253 lib_route_map_entry_match_condition_rmap_match_condition_ipv4_address_destroy(
1254 struct nb_cb_destroy_args
*args
)
1256 switch (args
->event
) {
1257 case NB_EV_VALIDATE
:
1262 return lib_route_map_entry_match_destroy(args
);
1269 * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:ipv6-address
1272 lib_route_map_entry_match_condition_rmap_match_condition_ipv6_address_modify(
1273 struct nb_cb_modify_args
*args
)
1275 struct routemap_hook_context
*rhc
;
1277 enum rmap_compile_rets ret
;
1279 switch (args
->event
) {
1280 case NB_EV_VALIDATE
:
1285 /* Add configuration. */
1286 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
1287 peer
= yang_dnode_get_string(args
->dnode
, NULL
);
1289 /* Set destroy information. */
1290 rhc
->rhc_mhook
= bgp_route_match_delete
;
1291 rhc
->rhc_rule
= "ipv6 next-hop address";
1292 rhc
->rhc_event
= RMAP_EVENT_MATCH_DELETED
;
1294 ret
= bgp_route_match_add(rhc
->rhc_rmi
, rhc
->rhc_rule
,
1295 peer
, RMAP_EVENT_MATCH_ADDED
,
1296 args
->errmsg
, args
->errmsg_len
);
1298 if (ret
!= RMAP_COMPILE_SUCCESS
) {
1299 rhc
->rhc_mhook
= NULL
;
1300 return NB_ERR_INCONSISTENCY
;
1308 lib_route_map_entry_match_condition_rmap_match_condition_ipv6_address_destroy(
1309 struct nb_cb_destroy_args
*args
)
1311 switch (args
->event
) {
1312 case NB_EV_VALIDATE
:
1317 return lib_route_map_entry_match_destroy(args
);
1325 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:distance
1327 int lib_route_map_entry_set_action_rmap_set_action_distance_modify(
1328 struct nb_cb_modify_args
*args
)
1330 struct routemap_hook_context
*rhc
;
1334 switch (args
->event
) {
1335 case NB_EV_VALIDATE
:
1340 /* Add configuration. */
1341 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
1342 type
= yang_dnode_get_string(args
->dnode
, NULL
);
1344 /* Set destroy information. */
1345 rhc
->rhc_shook
= generic_set_delete
;
1346 rhc
->rhc_rule
= "distance";
1347 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
1349 rv
= generic_set_add(rhc
->rhc_rmi
, "distance", type
,
1350 args
->errmsg
, args
->errmsg_len
);
1351 if (rv
!= CMD_SUCCESS
) {
1352 rhc
->rhc_shook
= NULL
;
1353 return NB_ERR_INCONSISTENCY
;
1360 int lib_route_map_entry_set_action_rmap_set_action_distance_destroy(
1361 struct nb_cb_destroy_args
*args
)
1363 switch (args
->event
) {
1364 case NB_EV_VALIDATE
:
1369 return lib_route_map_entry_match_destroy(args
);
1377 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:extcommunity-rt
1380 lib_route_map_entry_set_action_rmap_set_action_extcommunity_rt_modify(
1381 struct nb_cb_modify_args
*args
)
1383 struct routemap_hook_context
*rhc
;
1387 switch (args
->event
) {
1388 case NB_EV_VALIDATE
:
1393 /* Add configuration. */
1394 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
1395 type
= yang_dnode_get_string(args
->dnode
, NULL
);
1397 /* Set destroy information. */
1398 rhc
->rhc_shook
= generic_set_delete
;
1399 rhc
->rhc_rule
= "extcommunity rt";
1400 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
1402 rv
= generic_set_add(rhc
->rhc_rmi
, "extcommunity rt", type
,
1403 args
->errmsg
, args
->errmsg_len
);
1404 if (rv
!= CMD_SUCCESS
) {
1405 rhc
->rhc_shook
= NULL
;
1406 return NB_ERR_INCONSISTENCY
;
1414 lib_route_map_entry_set_action_rmap_set_action_extcommunity_rt_destroy(
1415 struct nb_cb_destroy_args
*args
)
1417 switch (args
->event
) {
1418 case NB_EV_VALIDATE
:
1423 return lib_route_map_entry_match_destroy(args
);
1431 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:extcommunity-soo
1434 lib_route_map_entry_set_action_rmap_set_action_extcommunity_soo_modify(
1435 struct nb_cb_modify_args
*args
)
1437 struct routemap_hook_context
*rhc
;
1441 switch (args
->event
) {
1442 case NB_EV_VALIDATE
:
1447 /* Add configuration. */
1448 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
1449 type
= yang_dnode_get_string(args
->dnode
, NULL
);
1451 /* Set destroy information. */
1452 rhc
->rhc_shook
= generic_set_delete
;
1453 rhc
->rhc_rule
= "extcommunity soo";
1454 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
1456 rv
= generic_set_add(rhc
->rhc_rmi
, "extcommunity soo",
1458 args
->errmsg
, args
->errmsg_len
);
1459 if (rv
!= CMD_SUCCESS
) {
1460 rhc
->rhc_shook
= NULL
;
1461 return NB_ERR_INCONSISTENCY
;
1469 lib_route_map_entry_set_action_rmap_set_action_extcommunity_soo_destroy(
1470 struct nb_cb_destroy_args
*args
)
1472 switch (args
->event
) {
1473 case NB_EV_VALIDATE
:
1478 return lib_route_map_entry_match_destroy(args
);
1486 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:ipv4-address
1488 int lib_route_map_entry_set_action_rmap_set_action_ipv4_address_modify(
1489 struct nb_cb_modify_args
*args
)
1491 struct routemap_hook_context
*rhc
;
1493 int rv
= CMD_SUCCESS
;
1495 switch (args
->event
) {
1496 case NB_EV_VALIDATE
:
1501 /* Add configuration. */
1502 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
1503 addr
= yang_dnode_get_string(args
->dnode
, NULL
);
1505 rhc
->rhc_shook
= generic_set_delete
;
1506 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
1507 rhc
->rhc_rule
= "ipv4 vpn next-hop";
1509 rv
= generic_set_add(rhc
->rhc_rmi
, rhc
->rhc_rule
, addr
,
1510 args
->errmsg
, args
->errmsg_len
);
1512 if (rv
!= CMD_SUCCESS
) {
1513 rhc
->rhc_shook
= NULL
;
1514 return NB_ERR_INCONSISTENCY
;
1521 int lib_route_map_entry_set_action_rmap_set_action_ipv4_address_destroy(
1522 struct nb_cb_destroy_args
*args
)
1524 switch (args
->event
) {
1525 case NB_EV_VALIDATE
:
1530 return lib_route_map_entry_set_destroy(args
);
1538 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:ipv4-nexthop
1540 int lib_route_map_entry_set_action_rmap_set_action_ipv4_nexthop_modify(
1541 struct nb_cb_modify_args
*args
)
1543 struct routemap_hook_context
*rhc
;
1547 switch (args
->event
) {
1548 case NB_EV_VALIDATE
:
1553 /* Add configuration. */
1554 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
1555 type
= yang_dnode_get_string(args
->dnode
, NULL
);
1557 /* Set destroy information. */
1558 rhc
->rhc_shook
= generic_set_delete
;
1559 rhc
->rhc_rule
= "ip next-hop";
1560 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
1562 rv
= generic_set_add(rhc
->rhc_rmi
, rhc
->rhc_rule
, type
,
1563 args
->errmsg
, args
->errmsg_len
);
1565 if (rv
!= CMD_SUCCESS
) {
1566 rhc
->rhc_shook
= NULL
;
1567 return NB_ERR_INCONSISTENCY
;
1574 int lib_route_map_entry_set_action_rmap_set_action_ipv4_nexthop_destroy(
1575 struct nb_cb_destroy_args
*args
)
1577 switch (args
->event
) {
1578 case NB_EV_VALIDATE
:
1583 return lib_route_map_entry_set_destroy(args
);
1591 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:ipv6-address
1593 int lib_route_map_entry_set_action_rmap_set_action_ipv6_address_modify(
1594 struct nb_cb_modify_args
*args
)
1596 struct routemap_hook_context
*rhc
;
1598 int rv
= CMD_SUCCESS
;
1599 const char *action
= NULL
;
1600 struct in6_addr i6a
;
1602 action
= yang_dnode_get_string(args
->dnode
,
1603 "../../frr-route-map:action");
1604 switch (args
->event
) {
1605 case NB_EV_VALIDATE
:
1606 if (action
&& IS_SET_IPV6_NH_GLOBAL(action
)) {
1607 yang_dnode_get_ipv6(&i6a
, args
->dnode
, NULL
);
1608 if (IN6_IS_ADDR_UNSPECIFIED(&i6a
)
1609 || IN6_IS_ADDR_LOOPBACK(&i6a
)
1610 || IN6_IS_ADDR_MULTICAST(&i6a
)
1611 || IN6_IS_ADDR_LINKLOCAL(&i6a
))
1612 return NB_ERR_VALIDATION
;
1622 /* Add configuration. */
1623 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
1624 addr
= yang_dnode_get_string(args
->dnode
, NULL
);
1626 rhc
->rhc_shook
= generic_set_delete
;
1627 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
1629 if (IS_SET_IPV6_NH_GLOBAL(action
))
1630 /* Set destroy information. */
1631 rhc
->rhc_rule
= "ipv6 next-hop global";
1633 rhc
->rhc_rule
= "ipv6 vpn next-hop";
1635 rv
= generic_set_add(rhc
->rhc_rmi
, rhc
->rhc_rule
, addr
,
1636 args
->errmsg
, args
->errmsg_len
);
1638 if (rv
!= CMD_SUCCESS
) {
1639 rhc
->rhc_shook
= NULL
;
1640 return NB_ERR_INCONSISTENCY
;
1646 int lib_route_map_entry_set_action_rmap_set_action_ipv6_address_destroy(
1647 struct nb_cb_destroy_args
*args
)
1649 switch (args
->event
) {
1650 case NB_EV_VALIDATE
:
1655 return lib_route_map_entry_set_destroy(args
);
1663 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:preference
1665 int lib_route_map_entry_set_action_rmap_set_action_preference_modify(
1666 struct nb_cb_modify_args
*args
)
1668 struct routemap_hook_context
*rhc
;
1669 int rv
= CMD_SUCCESS
;
1670 const char *action
= NULL
;
1673 switch (args
->event
) {
1674 case NB_EV_VALIDATE
:
1679 /* Add configuration. */
1680 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
1681 value
= yang_dnode_get_bool(args
->dnode
, NULL
);
1683 rhc
->rhc_shook
= generic_set_delete
;
1684 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
1686 action
= yang_dnode_get_string(args
->dnode
,
1687 "../../frr-route-map:action");
1690 if (IS_SET_IPV6_PEER_ADDR(action
))
1691 /* Set destroy information. */
1692 rhc
->rhc_rule
= "ipv6 next-hop peer-address";
1694 rhc
->rhc_rule
= "ipv6 next-hop prefer-global";
1696 rv
= generic_set_add(rhc
->rhc_rmi
, rhc
->rhc_rule
,
1698 args
->errmsg
, args
->errmsg_len
);
1701 if (rv
!= CMD_SUCCESS
) {
1702 rhc
->rhc_shook
= NULL
;
1703 return NB_ERR_INCONSISTENCY
;
1710 int lib_route_map_entry_set_action_rmap_set_action_preference_destroy(
1711 struct nb_cb_destroy_args
*args
)
1713 switch (args
->event
) {
1714 case NB_EV_VALIDATE
:
1719 return lib_route_map_entry_set_destroy(args
);
1727 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:label-index
1729 int lib_route_map_entry_set_action_rmap_set_action_label_index_modify(
1730 struct nb_cb_modify_args
*args
)
1732 struct routemap_hook_context
*rhc
;
1736 switch (args
->event
) {
1737 case NB_EV_VALIDATE
:
1742 /* Add configuration. */
1743 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
1744 type
= yang_dnode_get_string(args
->dnode
, NULL
);
1746 /* Set destroy information. */
1747 rhc
->rhc_shook
= generic_set_delete
;
1748 rhc
->rhc_rule
= "label-index";
1749 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
1751 rv
= generic_set_add(rhc
->rhc_rmi
, "label-index", type
,
1752 args
->errmsg
, args
->errmsg_len
);
1753 if (rv
!= CMD_SUCCESS
) {
1754 rhc
->rhc_shook
= NULL
;
1755 return NB_ERR_INCONSISTENCY
;
1762 int lib_route_map_entry_set_action_rmap_set_action_label_index_destroy(
1763 struct nb_cb_destroy_args
*args
)
1765 switch (args
->event
) {
1766 case NB_EV_VALIDATE
:
1771 return lib_route_map_entry_set_destroy(args
);
1779 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:local-pref
1781 int lib_route_map_entry_set_action_rmap_set_action_local_pref_modify(
1782 struct nb_cb_modify_args
*args
)
1784 struct routemap_hook_context
*rhc
;
1788 switch (args
->event
) {
1789 case NB_EV_VALIDATE
:
1794 /* Add configuration. */
1795 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
1796 type
= yang_dnode_get_string(args
->dnode
, NULL
);
1798 /* Set destroy information. */
1799 rhc
->rhc_shook
= generic_set_delete
;
1800 rhc
->rhc_rule
= "local-preference";
1801 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
1803 rv
= generic_set_add(rhc
->rhc_rmi
, "local-preference",
1805 args
->errmsg
, args
->errmsg_len
);
1806 if (rv
!= CMD_SUCCESS
) {
1807 rhc
->rhc_shook
= NULL
;
1808 return NB_ERR_INCONSISTENCY
;
1815 int lib_route_map_entry_set_action_rmap_set_action_local_pref_destroy(
1816 struct nb_cb_destroy_args
*args
)
1818 switch (args
->event
) {
1819 case NB_EV_VALIDATE
:
1824 return lib_route_map_entry_set_destroy(args
);
1832 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:weight
1834 int lib_route_map_entry_set_action_rmap_set_action_weight_modify(
1835 struct nb_cb_modify_args
*args
)
1837 struct routemap_hook_context
*rhc
;
1841 switch (args
->event
) {
1842 case NB_EV_VALIDATE
:
1847 /* Add configuration. */
1848 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
1849 type
= yang_dnode_get_string(args
->dnode
, NULL
);
1851 /* Set destroy information. */
1852 rhc
->rhc_shook
= generic_set_delete
;
1853 rhc
->rhc_rule
= "weight";
1854 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
1856 rv
= generic_set_add(rhc
->rhc_rmi
, "weight", type
,
1857 args
->errmsg
, args
->errmsg_len
);
1858 if (rv
!= CMD_SUCCESS
) {
1859 rhc
->rhc_shook
= NULL
;
1860 return NB_ERR_INCONSISTENCY
;
1867 int lib_route_map_entry_set_action_rmap_set_action_weight_destroy(
1868 struct nb_cb_destroy_args
*args
)
1870 switch (args
->event
) {
1871 case NB_EV_VALIDATE
:
1876 return lib_route_map_entry_set_destroy(args
);
1884 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:origin
1886 int lib_route_map_entry_set_action_rmap_set_action_origin_modify(
1887 struct nb_cb_modify_args
*args
)
1889 struct routemap_hook_context
*rhc
;
1893 switch (args
->event
) {
1894 case NB_EV_VALIDATE
:
1899 /* Add configuration. */
1900 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
1901 type
= yang_dnode_get_string(args
->dnode
, NULL
);
1903 /* Set destroy information. */
1904 rhc
->rhc_shook
= generic_set_delete
;
1905 rhc
->rhc_rule
= "origin";
1906 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
1908 rv
= generic_set_add(rhc
->rhc_rmi
, "origin", type
,
1909 args
->errmsg
, args
->errmsg_len
);
1910 if (rv
!= CMD_SUCCESS
) {
1911 rhc
->rhc_shook
= NULL
;
1912 return NB_ERR_INCONSISTENCY
;
1919 int lib_route_map_entry_set_action_rmap_set_action_origin_destroy(
1920 struct nb_cb_destroy_args
*args
)
1922 switch (args
->event
) {
1923 case NB_EV_VALIDATE
:
1928 return lib_route_map_entry_set_destroy(args
);
1937 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:originator-id
1939 int lib_route_map_entry_set_action_rmap_set_action_originator_id_modify(
1940 struct nb_cb_modify_args
*args
)
1942 struct routemap_hook_context
*rhc
;
1946 switch (args
->event
) {
1947 case NB_EV_VALIDATE
:
1952 /* Add configuration. */
1953 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
1954 type
= yang_dnode_get_string(args
->dnode
, NULL
);
1956 /* Set destroy information. */
1957 rhc
->rhc_shook
= generic_set_delete
;
1958 rhc
->rhc_rule
= "originator-id";
1959 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
1961 rv
= generic_set_add(rhc
->rhc_rmi
, "originator-id", type
,
1962 args
->errmsg
, args
->errmsg_len
);
1963 if (rv
!= CMD_SUCCESS
) {
1964 rhc
->rhc_shook
= NULL
;
1965 return NB_ERR_INCONSISTENCY
;
1972 int lib_route_map_entry_set_action_rmap_set_action_originator_id_destroy(
1973 struct nb_cb_destroy_args
*args
)
1975 switch (args
->event
) {
1976 case NB_EV_VALIDATE
:
1981 return lib_route_map_entry_set_destroy(args
);
1989 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:table
1991 int lib_route_map_entry_set_action_rmap_set_action_table_modify(
1992 struct nb_cb_modify_args
*args
)
1994 struct routemap_hook_context
*rhc
;
1998 switch (args
->event
) {
1999 case NB_EV_VALIDATE
:
2004 /* Add configuration. */
2005 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
2006 type
= yang_dnode_get_string(args
->dnode
, NULL
);
2008 /* Set destroy information. */
2009 rhc
->rhc_shook
= generic_set_delete
;
2010 rhc
->rhc_rule
= "table";
2011 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
2013 rv
= generic_set_add(rhc
->rhc_rmi
, "table", type
,
2014 args
->errmsg
, args
->errmsg_len
);
2015 if (rv
!= CMD_SUCCESS
) {
2016 rhc
->rhc_shook
= NULL
;
2017 return NB_ERR_INCONSISTENCY
;
2024 int lib_route_map_entry_set_action_rmap_set_action_table_destroy(
2025 struct nb_cb_destroy_args
*args
)
2027 switch (args
->event
) {
2028 case NB_EV_VALIDATE
:
2033 return lib_route_map_entry_set_destroy(args
);
2041 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:atomic-aggregate
2044 lib_route_map_entry_set_action_rmap_set_action_atomic_aggregate_create(
2045 struct nb_cb_create_args
*args
)
2047 struct routemap_hook_context
*rhc
;
2050 switch (args
->event
) {
2051 case NB_EV_VALIDATE
:
2056 /* Add configuration. */
2057 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
2059 /* Set destroy information. */
2060 rhc
->rhc_shook
= generic_set_delete
;
2061 rhc
->rhc_rule
= "atomic-aggregate";
2062 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
2064 rv
= generic_set_add(rhc
->rhc_rmi
, rhc
->rhc_rule
, NULL
,
2065 args
->errmsg
, args
->errmsg_len
);
2066 if (rv
!= CMD_SUCCESS
) {
2067 rhc
->rhc_shook
= NULL
;
2068 return NB_ERR_INCONSISTENCY
;
2076 lib_route_map_entry_set_action_rmap_set_action_atomic_aggregate_destroy(
2077 struct nb_cb_destroy_args
*args
)
2079 switch (args
->event
) {
2080 case NB_EV_VALIDATE
:
2085 return lib_route_map_entry_set_destroy(args
);
2093 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:aigp-metric
2095 int lib_route_map_entry_set_action_rmap_set_action_aigp_metric_modify(
2096 struct nb_cb_modify_args
*args
)
2098 struct routemap_hook_context
*rhc
;
2102 switch (args
->event
) {
2103 case NB_EV_VALIDATE
:
2108 /* Add configuration. */
2109 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
2110 aigp
= yang_dnode_get_string(args
->dnode
, NULL
);
2112 /* Set destroy information. */
2113 rhc
->rhc_shook
= generic_set_delete
;
2114 rhc
->rhc_rule
= "aigp-metric";
2115 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
2117 rv
= generic_set_add(rhc
->rhc_rmi
, rhc
->rhc_rule
, aigp
,
2118 args
->errmsg
, args
->errmsg_len
);
2119 if (rv
!= CMD_SUCCESS
) {
2120 rhc
->rhc_shook
= NULL
;
2121 return NB_ERR_INCONSISTENCY
;
2128 int lib_route_map_entry_set_action_rmap_set_action_aigp_metric_destroy(
2129 struct nb_cb_destroy_args
*args
)
2131 switch (args
->event
) {
2132 case NB_EV_VALIDATE
:
2137 return lib_route_map_entry_set_destroy(args
);
2145 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:prepend-as-path
2148 lib_route_map_entry_set_action_rmap_set_action_prepend_as_path_modify(
2149 struct nb_cb_modify_args
*args
)
2151 struct routemap_hook_context
*rhc
;
2155 switch (args
->event
) {
2156 case NB_EV_VALIDATE
:
2161 /* Add configuration. */
2162 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
2163 type
= yang_dnode_get_string(args
->dnode
, NULL
);
2165 /* Set destroy information. */
2166 rhc
->rhc_shook
= generic_set_delete
;
2167 rhc
->rhc_rule
= "as-path prepend";
2168 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
2170 rv
= generic_set_add(rhc
->rhc_rmi
, "as-path prepend",
2172 args
->errmsg
, args
->errmsg_len
);
2173 if (rv
!= CMD_SUCCESS
) {
2174 rhc
->rhc_shook
= NULL
;
2175 return NB_ERR_INCONSISTENCY
;
2183 lib_route_map_entry_set_action_rmap_set_action_prepend_as_path_destroy(
2184 struct nb_cb_destroy_args
*args
)
2186 switch (args
->event
) {
2187 case NB_EV_VALIDATE
:
2192 return lib_route_map_entry_set_destroy(args
);
2200 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:last-as
2202 int lib_route_map_entry_set_action_rmap_set_action_last_as_modify(
2203 struct nb_cb_modify_args
*args
)
2205 struct routemap_hook_context
*rhc
;
2210 switch (args
->event
) {
2211 case NB_EV_VALIDATE
:
2216 /* Add configuration. */
2217 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
2218 value
= yang_dnode_get_string(args
->dnode
, NULL
);
2220 /* Set destroy information. */
2221 rhc
->rhc_shook
= generic_set_delete
;
2222 rhc
->rhc_rule
= "as-path prepend";
2223 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
2225 argstr
= XMALLOC(MTYPE_ROUTE_MAP_COMPILED
,
2226 strlen(value
) + strlen("last-as") + 2);
2228 snprintf(argstr
, (strlen(value
) + strlen("last-as") + 2),
2229 "last-as %s", value
);
2231 rv
= generic_set_add(rhc
->rhc_rmi
, "as-path prepend",
2233 args
->errmsg
, args
->errmsg_len
);
2234 if (rv
!= CMD_SUCCESS
) {
2235 rhc
->rhc_shook
= NULL
;
2236 XFREE(MTYPE_ROUTE_MAP_COMPILED
, argstr
);
2237 return NB_ERR_INCONSISTENCY
;
2240 XFREE(MTYPE_ROUTE_MAP_COMPILED
, argstr
);
2246 int lib_route_map_entry_set_action_rmap_set_action_last_as_destroy(
2247 struct nb_cb_destroy_args
*args
)
2249 switch (args
->event
) {
2250 case NB_EV_VALIDATE
:
2255 return lib_route_map_entry_set_destroy(args
);
2263 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:exclude-as-path
2266 lib_route_map_entry_set_action_rmap_set_action_exclude_as_path_modify(
2267 struct nb_cb_modify_args
*args
)
2269 struct routemap_hook_context
*rhc
;
2273 switch (args
->event
) {
2274 case NB_EV_VALIDATE
:
2279 /* Add configuration. */
2280 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
2281 type
= yang_dnode_get_string(args
->dnode
, NULL
);
2283 /* Set destroy information. */
2284 rhc
->rhc_shook
= generic_set_delete
;
2285 rhc
->rhc_rule
= "as-path exclude";
2286 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
2288 rv
= generic_set_add(rhc
->rhc_rmi
, "as-path exclude",
2290 args
->errmsg
, args
->errmsg_len
);
2291 if (rv
!= CMD_SUCCESS
) {
2292 rhc
->rhc_shook
= NULL
;
2293 return NB_ERR_INCONSISTENCY
;
2301 lib_route_map_entry_set_action_rmap_set_action_exclude_as_path_destroy(
2302 struct nb_cb_destroy_args
*args
)
2304 switch (args
->event
) {
2305 case NB_EV_VALIDATE
:
2310 return lib_route_map_entry_set_destroy(args
);
2318 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:replace-as-path
2320 int lib_route_map_entry_set_action_rmap_set_action_replace_as_path_modify(
2321 struct nb_cb_modify_args
*args
)
2323 struct routemap_hook_context
*rhc
;
2327 switch (args
->event
) {
2328 case NB_EV_VALIDATE
:
2333 /* Add configuration. */
2334 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
2335 type
= yang_dnode_get_string(args
->dnode
, NULL
);
2337 /* Set destroy information. */
2338 rhc
->rhc_shook
= generic_set_delete
;
2339 rhc
->rhc_rule
= "as-path replace";
2340 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
2342 rv
= generic_set_add(rhc
->rhc_rmi
, "as-path replace", type
,
2343 args
->errmsg
, args
->errmsg_len
);
2344 if (rv
!= CMD_SUCCESS
) {
2345 rhc
->rhc_shook
= NULL
;
2346 return NB_ERR_INCONSISTENCY
;
2353 int lib_route_map_entry_set_action_rmap_set_action_replace_as_path_destroy(
2354 struct nb_cb_destroy_args
*args
)
2356 switch (args
->event
) {
2357 case NB_EV_VALIDATE
:
2362 return lib_route_map_entry_set_destroy(args
);
2370 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:community-none
2372 int lib_route_map_entry_set_action_rmap_set_action_community_none_modify(
2373 struct nb_cb_modify_args
*args
)
2375 struct routemap_hook_context
*rhc
;
2379 switch (args
->event
) {
2380 case NB_EV_VALIDATE
:
2385 /* Add configuration. */
2386 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
2387 none
= yang_dnode_get_bool(args
->dnode
, NULL
);
2389 /* Set destroy information. */
2390 rhc
->rhc_shook
= generic_set_delete
;
2391 rhc
->rhc_rule
= "community";
2392 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
2395 rv
= generic_set_add(rhc
->rhc_rmi
, "community",
2397 args
->errmsg
, args
->errmsg_len
);
2398 if (rv
!= CMD_SUCCESS
) {
2399 rhc
->rhc_shook
= NULL
;
2400 return NB_ERR_INCONSISTENCY
;
2405 return NB_ERR_INCONSISTENCY
;
2412 lib_route_map_entry_set_action_rmap_set_action_community_none_destroy(
2413 struct nb_cb_destroy_args
*args
)
2415 switch (args
->event
) {
2416 case NB_EV_VALIDATE
:
2421 return lib_route_map_entry_set_destroy(args
);
2429 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:community-string
2432 lib_route_map_entry_set_action_rmap_set_action_community_string_modify(
2433 struct nb_cb_modify_args
*args
)
2435 struct routemap_hook_context
*rhc
;
2439 switch (args
->event
) {
2440 case NB_EV_VALIDATE
:
2445 /* Add configuration. */
2446 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
2447 type
= yang_dnode_get_string(args
->dnode
, NULL
);
2449 /* Set destroy information. */
2450 rhc
->rhc_shook
= generic_set_delete
;
2451 rhc
->rhc_rule
= "community";
2452 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
2454 rv
= generic_set_add(rhc
->rhc_rmi
, "community", type
,
2455 args
->errmsg
, args
->errmsg_len
);
2456 if (rv
!= CMD_SUCCESS
) {
2457 rhc
->rhc_shook
= NULL
;
2458 return NB_ERR_INCONSISTENCY
;
2466 lib_route_map_entry_set_action_rmap_set_action_community_string_destroy(
2467 struct nb_cb_destroy_args
*args
)
2469 switch (args
->event
) {
2470 case NB_EV_VALIDATE
:
2475 return lib_route_map_entry_set_destroy(args
);
2483 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:large-community-none
2486 lib_route_map_entry_set_action_rmap_set_action_large_community_none_modify(
2487 struct nb_cb_modify_args
*args
)
2489 struct routemap_hook_context
*rhc
;
2493 switch (args
->event
) {
2494 case NB_EV_VALIDATE
:
2499 /* Add configuration. */
2500 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
2501 none
= yang_dnode_get_bool(args
->dnode
, NULL
);
2503 /* Set destroy information. */
2504 rhc
->rhc_shook
= generic_set_delete
;
2505 rhc
->rhc_rule
= "large-community";
2506 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
2509 rv
= generic_set_add(rhc
->rhc_rmi
,
2512 args
->errmsg
, args
->errmsg_len
);
2513 if (rv
!= CMD_SUCCESS
) {
2514 rhc
->rhc_shook
= NULL
;
2515 return NB_ERR_INCONSISTENCY
;
2520 return NB_ERR_INCONSISTENCY
;
2527 lib_route_map_entry_set_action_rmap_set_action_large_community_none_destroy(
2528 struct nb_cb_destroy_args
*args
)
2530 switch (args
->event
) {
2531 case NB_EV_VALIDATE
:
2536 return lib_route_map_entry_set_destroy(args
);
2544 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:large-community-string
2547 lib_route_map_entry_set_action_rmap_set_action_large_community_string_modify(
2548 struct nb_cb_modify_args
*args
)
2550 struct routemap_hook_context
*rhc
;
2554 switch (args
->event
) {
2555 case NB_EV_VALIDATE
:
2560 /* Add configuration. */
2561 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
2562 type
= yang_dnode_get_string(args
->dnode
, NULL
);
2564 /* Set destroy information. */
2565 rhc
->rhc_shook
= generic_set_delete
;
2566 rhc
->rhc_rule
= "large-community";
2567 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
2569 rv
= generic_set_add(rhc
->rhc_rmi
, "large-community",
2571 args
->errmsg
, args
->errmsg_len
);
2572 if (rv
!= CMD_SUCCESS
) {
2573 rhc
->rhc_shook
= NULL
;
2574 return NB_ERR_INCONSISTENCY
;
2582 lib_route_map_entry_set_action_rmap_set_action_large_community_string_destroy(
2583 struct nb_cb_destroy_args
*args
)
2585 switch (args
->event
) {
2586 case NB_EV_VALIDATE
:
2591 return lib_route_map_entry_set_destroy(args
);
2599 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:aggregator
2601 void lib_route_map_entry_set_action_rmap_set_action_aggregator_finish(
2602 struct nb_cb_apply_finish_args
*args
)
2604 struct routemap_hook_context
*rhc
;
2610 /* Add configuration. */
2611 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
2612 asn
= yang_dnode_get_string(args
->dnode
, "./aggregator-asn");
2613 addr
= yang_dnode_get_string(args
->dnode
, "./aggregator-address");
2615 argstr
= XMALLOC(MTYPE_ROUTE_MAP_COMPILED
,
2616 strlen(asn
) + strlen(addr
) + 2);
2618 snprintf(argstr
, (strlen(asn
) + strlen(addr
) + 2), "%s %s", asn
, addr
);
2620 /* Set destroy information. */
2621 rhc
->rhc_shook
= generic_set_delete
;
2622 rhc
->rhc_rule
= "aggregator as";
2623 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
2625 ret
= generic_set_add(rhc
->rhc_rmi
, rhc
->rhc_rule
, argstr
, args
->errmsg
,
2628 * At this point if this is not a successful operation
2629 * bgpd is about to crash. Let's just cut to the
2632 assert(ret
== CMD_SUCCESS
);
2634 XFREE(MTYPE_ROUTE_MAP_COMPILED
, argstr
);
2638 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:aggregator/aggregator-asn
2641 lib_route_map_entry_set_action_rmap_set_action_aggregator_aggregator_asn_modify(
2642 struct nb_cb_modify_args
*args
)
2644 switch (args
->event
) {
2645 case NB_EV_VALIDATE
:
2656 lib_route_map_entry_set_action_rmap_set_action_aggregator_aggregator_asn_destroy(
2657 struct nb_cb_destroy_args
*args
)
2659 switch (args
->event
) {
2660 case NB_EV_VALIDATE
:
2665 return lib_route_map_entry_set_destroy(args
);
2673 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:aggregator/aggregator-address
2676 lib_route_map_entry_set_action_rmap_set_action_aggregator_aggregator_address_modify(
2677 struct nb_cb_modify_args
*args
)
2679 switch (args
->event
) {
2680 case NB_EV_VALIDATE
:
2691 lib_route_map_entry_set_action_rmap_set_action_aggregator_aggregator_address_destroy(
2692 struct nb_cb_destroy_args
*args
)
2694 switch (args
->event
) {
2695 case NB_EV_VALIDATE
:
2700 return lib_route_map_entry_set_destroy(args
);
2708 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:comm-list-name
2710 int lib_route_map_entry_set_action_rmap_set_action_comm_list_name_modify(
2711 struct nb_cb_modify_args
*args
)
2713 struct routemap_hook_context
*rhc
;
2716 int rv
= CMD_SUCCESS
;
2718 switch (args
->event
) {
2719 case NB_EV_VALIDATE
:
2724 /* Add configuration. */
2725 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
2726 value
= yang_dnode_get_string(args
->dnode
, NULL
);
2728 /* Set destroy information. */
2729 rhc
->rhc_shook
= generic_set_delete
;
2731 action
= yang_dnode_get_string(args
->dnode
,
2732 "../../frr-route-map:action");
2733 if (IS_SET_COMM_LIST_DEL(action
))
2734 rhc
->rhc_rule
= "comm-list";
2736 rhc
->rhc_rule
= "large-comm-list";
2738 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
2740 rv
= generic_set_add(rhc
->rhc_rmi
, rhc
->rhc_rule
, value
,
2741 args
->errmsg
, args
->errmsg_len
);
2743 if (rv
!= CMD_SUCCESS
) {
2744 rhc
->rhc_shook
= NULL
;
2745 return NB_ERR_INCONSISTENCY
;
2753 lib_route_map_entry_set_action_rmap_set_action_comm_list_name_destroy(
2754 struct nb_cb_destroy_args
*args
)
2756 switch (args
->event
) {
2757 case NB_EV_VALIDATE
:
2762 return lib_route_map_entry_set_destroy(args
);
2770 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:extcommunity-lb
2773 lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_finish(
2774 struct nb_cb_apply_finish_args
*args
)
2776 struct routemap_hook_context
*rhc
;
2777 enum ecommunity_lb_type lb_type
;
2778 char str
[VTY_BUFSIZ
];
2782 /* Add configuration. */
2783 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
2784 lb_type
= yang_dnode_get_enum(args
->dnode
, "./lb-type");
2786 /* Set destroy information. */
2787 rhc
->rhc_shook
= generic_set_delete
;
2788 rhc
->rhc_rule
= "extcommunity bandwidth";
2789 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
2792 case EXPLICIT_BANDWIDTH
:
2793 bandwidth
= yang_dnode_get_uint16(args
->dnode
, "./bandwidth");
2794 snprintf(str
, sizeof(str
), "%d", bandwidth
);
2796 case CUMULATIVE_BANDWIDTH
:
2797 snprintf(str
, sizeof(str
), "%s", "cumulative");
2799 case COMPUTED_BANDWIDTH
:
2800 snprintf(str
, sizeof(str
), "%s", "num-multipaths");
2803 if (yang_dnode_get_bool(args
->dnode
, "./two-octet-as-specific"))
2804 strlcat(str
, " non-transitive", sizeof(str
));
2806 ret
= generic_set_add(rhc
->rhc_rmi
, "extcommunity bandwidth", str
,
2807 args
->errmsg
, args
->errmsg_len
);
2809 * At this point if this is not a successful operation
2810 * bgpd is about to crash. Let's just cut to the
2813 assert(ret
== CMD_SUCCESS
);
2818 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:extcommunity-lb/lb-type
2821 lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_lb_type_modify(
2822 struct nb_cb_modify_args
*args
)
2828 lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_lb_type_destroy(
2829 struct nb_cb_destroy_args
*args
)
2831 return lib_route_map_entry_set_destroy(args
);
2836 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:extcommunity-lb/bandwidth
2839 lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_bandwidth_modify(
2840 struct nb_cb_modify_args
*args
)
2846 lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_bandwidth_destroy(
2847 struct nb_cb_destroy_args
*args
)
2849 return lib_route_map_entry_set_destroy(args
);
2854 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:extcommunity-lb/two-octet-as-specific
2857 lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_two_octet_as_specific_modify(
2858 struct nb_cb_modify_args
*args
)
2864 lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_two_octet_as_specific_destroy(
2865 struct nb_cb_destroy_args
*args
)
2867 return lib_route_map_entry_set_destroy(args
);
2872 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:extcommunity-none
2874 int lib_route_map_entry_set_action_rmap_set_action_extcommunity_none_modify(
2875 struct nb_cb_modify_args
*args
)
2877 struct routemap_hook_context
*rhc
;
2881 switch (args
->event
) {
2882 case NB_EV_VALIDATE
:
2887 /* Add configuration. */
2888 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
2889 none
= yang_dnode_get_bool(args
->dnode
, NULL
);
2891 /* Set destroy information. */
2892 rhc
->rhc_shook
= generic_set_delete
;
2893 rhc
->rhc_rule
= "extcommunity";
2894 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
2897 rv
= generic_set_add(rhc
->rhc_rmi
, "extcommunity",
2898 "none", args
->errmsg
,
2900 if (rv
!= CMD_SUCCESS
) {
2901 rhc
->rhc_shook
= NULL
;
2902 return NB_ERR_INCONSISTENCY
;
2907 return NB_ERR_INCONSISTENCY
;
2913 int lib_route_map_entry_set_action_rmap_set_action_extcommunity_none_destroy(
2914 struct nb_cb_destroy_args
*args
)
2916 switch (args
->event
) {
2917 case NB_EV_VALIDATE
:
2922 return lib_route_map_entry_set_destroy(args
);
2930 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:evpn-gateway-ip-ipv4
2932 int lib_route_map_entry_set_action_rmap_set_action_evpn_gateway_ip_ipv4_modify(
2933 struct nb_cb_modify_args
*args
)
2935 struct routemap_hook_context
*rhc
;
2939 switch (args
->event
) {
2940 case NB_EV_VALIDATE
:
2945 /* Add configuration. */
2946 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
2947 type
= yang_dnode_get_string(args
->dnode
, NULL
);
2949 /* Set destroy information. */
2950 rhc
->rhc_shook
= generic_set_delete
;
2951 rhc
->rhc_rule
= "evpn gateway-ip ipv4";
2952 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
2954 rv
= generic_set_add(rhc
->rhc_rmi
, "evpn gateway-ip ipv4", type
,
2955 args
->errmsg
, args
->errmsg_len
);
2956 if (rv
!= CMD_SUCCESS
) {
2957 rhc
->rhc_shook
= NULL
;
2958 return NB_ERR_INCONSISTENCY
;
2965 int lib_route_map_entry_set_action_rmap_set_action_evpn_gateway_ip_ipv4_destroy(
2966 struct nb_cb_destroy_args
*args
)
2968 switch (args
->event
) {
2969 case NB_EV_VALIDATE
:
2974 return lib_route_map_entry_set_destroy(args
);
2982 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:evpn-gateway-ip-ipv6
2984 int lib_route_map_entry_set_action_rmap_set_action_evpn_gateway_ip_ipv6_modify(
2985 struct nb_cb_modify_args
*args
)
2987 struct routemap_hook_context
*rhc
;
2991 switch (args
->event
) {
2992 case NB_EV_VALIDATE
:
2997 /* Add configuration. */
2998 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
2999 type
= yang_dnode_get_string(args
->dnode
, NULL
);
3001 /* Set destroy information. */
3002 rhc
->rhc_shook
= generic_set_delete
;
3003 rhc
->rhc_rule
= "evpn gateway-ip ipv6";
3004 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
3006 rv
= generic_set_add(rhc
->rhc_rmi
, "evpn gateway-ip ipv6", type
,
3007 args
->errmsg
, args
->errmsg_len
);
3008 if (rv
!= CMD_SUCCESS
) {
3009 rhc
->rhc_shook
= NULL
;
3010 return NB_ERR_INCONSISTENCY
;
3017 int lib_route_map_entry_set_action_rmap_set_action_evpn_gateway_ip_ipv6_destroy(
3018 struct nb_cb_destroy_args
*args
)
3020 switch (args
->event
) {
3021 case NB_EV_VALIDATE
:
3026 return lib_route_map_entry_set_destroy(args
);
3034 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/l3vpn-nexthop-encapsulation
3036 int lib_route_map_entry_set_action_rmap_set_action_l3vpn_nexthop_encapsulation_modify(
3037 struct nb_cb_modify_args
*args
)
3039 struct routemap_hook_context
*rhc
;
3043 switch (args
->event
) {
3044 case NB_EV_VALIDATE
:
3049 /* Add configuration. */
3050 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
3051 type
= yang_dnode_get_string(args
->dnode
, NULL
);
3053 /* Set destroy information. */
3054 rhc
->rhc_shook
= generic_set_delete
;
3055 rhc
->rhc_rule
= "l3vpn next-hop encapsulation";
3056 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
3058 rv
= generic_set_add(rhc
->rhc_rmi
,
3059 "l3vpn next-hop encapsulation", type
,
3060 args
->errmsg
, args
->errmsg_len
);
3061 if (rv
!= CMD_SUCCESS
) {
3062 rhc
->rhc_shook
= NULL
;
3063 return NB_ERR_INCONSISTENCY
;
3070 int lib_route_map_entry_set_action_rmap_set_action_l3vpn_nexthop_encapsulation_destroy(
3071 struct nb_cb_destroy_args
*args
)
3073 switch (args
->event
) {
3074 case NB_EV_VALIDATE
:
3079 return lib_route_map_entry_set_destroy(args
);