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
);
384 * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:probability
387 lib_route_map_entry_match_condition_rmap_match_condition_probability_modify(
388 struct nb_cb_modify_args
*args
)
390 struct routemap_hook_context
*rhc
;
391 const char *probability
;
392 enum rmap_compile_rets ret
;
394 switch (args
->event
) {
400 /* Add configuration. */
401 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
402 probability
= yang_dnode_get_string(args
->dnode
, NULL
);
404 /* Set destroy information. */
405 rhc
->rhc_mhook
= bgp_route_match_delete
;
406 rhc
->rhc_rule
= "probability";
407 rhc
->rhc_event
= RMAP_EVENT_MATCH_DELETED
;
409 ret
= bgp_route_match_add(rhc
->rhc_rmi
, "probability",
410 probability
, 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
;
423 lib_route_map_entry_match_condition_rmap_match_condition_probability_destroy(
424 struct nb_cb_destroy_args
*args
)
426 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:source-vrf
441 lib_route_map_entry_match_condition_rmap_match_condition_source_vrf_modify(
442 struct nb_cb_modify_args
*args
)
444 struct routemap_hook_context
*rhc
;
446 enum rmap_compile_rets ret
;
448 switch (args
->event
) {
454 /* Add configuration. */
455 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
456 vrf
= yang_dnode_get_string(args
->dnode
, NULL
);
458 /* Set destroy information. */
459 rhc
->rhc_mhook
= bgp_route_match_delete
;
460 rhc
->rhc_rule
= "source-vrf";
461 rhc
->rhc_event
= RMAP_EVENT_MATCH_DELETED
;
463 ret
= bgp_route_match_add(rhc
->rhc_rmi
, "source-vrf", vrf
,
464 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_source_vrf_destroy(
478 struct nb_cb_destroy_args
*args
)
480 switch (args
->event
) {
486 return lib_route_map_entry_match_destroy(args
);
493 * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:peer-ipv4-address
496 lib_route_map_entry_match_condition_rmap_match_condition_peer_ipv4_address_modify(
497 struct nb_cb_modify_args
*args
)
499 struct routemap_hook_context
*rhc
;
501 enum rmap_compile_rets ret
;
503 switch (args
->event
) {
509 /* Add configuration. */
510 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
511 peer
= yang_dnode_get_string(args
->dnode
, NULL
);
513 /* Set destroy information. */
514 rhc
->rhc_mhook
= bgp_route_match_delete
;
515 rhc
->rhc_rule
= "peer";
516 rhc
->rhc_event
= RMAP_EVENT_MATCH_DELETED
;
518 ret
= bgp_route_match_add(rhc
->rhc_rmi
, "peer", peer
,
519 RMAP_EVENT_MATCH_ADDED
,
520 args
->errmsg
, args
->errmsg_len
);
522 if (ret
!= RMAP_COMPILE_SUCCESS
) {
523 rhc
->rhc_mhook
= NULL
;
524 return NB_ERR_INCONSISTENCY
;
532 lib_route_map_entry_match_condition_rmap_match_condition_peer_ipv4_address_destroy(
533 struct nb_cb_destroy_args
*args
)
535 switch (args
->event
) {
541 return lib_route_map_entry_match_destroy(args
);
548 * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:peer-interface
551 lib_route_map_entry_match_condition_rmap_match_condition_peer_interface_modify(
552 struct nb_cb_modify_args
*args
)
554 struct routemap_hook_context
*rhc
;
556 enum rmap_compile_rets ret
;
558 switch (args
->event
) {
564 /* Add configuration. */
565 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
566 peer
= yang_dnode_get_string(args
->dnode
, NULL
);
568 /* Set destroy information. */
569 rhc
->rhc_mhook
= bgp_route_match_delete
;
570 rhc
->rhc_rule
= "peer";
571 rhc
->rhc_event
= RMAP_EVENT_MATCH_DELETED
;
573 ret
= bgp_route_match_add(rhc
->rhc_rmi
, "peer", peer
,
574 RMAP_EVENT_MATCH_ADDED
,
575 args
->errmsg
, args
->errmsg_len
);
577 if (ret
!= RMAP_COMPILE_SUCCESS
) {
578 rhc
->rhc_mhook
= NULL
;
579 return NB_ERR_INCONSISTENCY
;
587 lib_route_map_entry_match_condition_rmap_match_condition_peer_interface_destroy(
588 struct nb_cb_destroy_args
*args
)
590 switch (args
->event
) {
596 return lib_route_map_entry_match_destroy(args
);
603 * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:peer-ipv6-address
606 lib_route_map_entry_match_condition_rmap_match_condition_peer_ipv6_address_modify(
607 struct nb_cb_modify_args
*args
)
609 struct routemap_hook_context
*rhc
;
611 enum rmap_compile_rets ret
;
613 switch (args
->event
) {
619 /* Add configuration. */
620 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
621 peer
= yang_dnode_get_string(args
->dnode
, NULL
);
623 /* Set destroy information. */
624 rhc
->rhc_mhook
= bgp_route_match_delete
;
625 rhc
->rhc_rule
= "peer";
626 rhc
->rhc_event
= RMAP_EVENT_MATCH_DELETED
;
628 ret
= bgp_route_match_add(rhc
->rhc_rmi
, "peer", peer
,
629 RMAP_EVENT_MATCH_ADDED
,
630 args
->errmsg
, args
->errmsg_len
);
632 if (ret
!= RMAP_COMPILE_SUCCESS
) {
633 rhc
->rhc_mhook
= NULL
;
634 return NB_ERR_INCONSISTENCY
;
642 lib_route_map_entry_match_condition_rmap_match_condition_peer_ipv6_address_destroy(
643 struct nb_cb_destroy_args
*args
)
645 switch (args
->event
) {
651 return lib_route_map_entry_match_destroy(args
);
658 * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:peer-local
661 lib_route_map_entry_match_condition_rmap_match_condition_peer_local_modify(
662 struct nb_cb_modify_args
*args
)
664 struct routemap_hook_context
*rhc
;
666 enum rmap_compile_rets ret
;
668 switch (args
->event
) {
674 /* Add configuration. */
675 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
676 value
= yang_dnode_get_bool(args
->dnode
, NULL
);
678 /* Set destroy information. */
679 rhc
->rhc_mhook
= bgp_route_match_delete
;
680 rhc
->rhc_rule
= "peer";
681 rhc
->rhc_event
= RMAP_EVENT_MATCH_DELETED
;
684 ret
= bgp_route_match_add(rhc
->rhc_rmi
, "peer",
686 RMAP_EVENT_MATCH_ADDED
,
687 args
->errmsg
, args
->errmsg_len
);
689 if (ret
!= RMAP_COMPILE_SUCCESS
) {
690 rhc
->rhc_mhook
= NULL
;
691 return NB_ERR_INCONSISTENCY
;
700 lib_route_map_entry_match_condition_rmap_match_condition_peer_local_destroy(
701 struct nb_cb_destroy_args
*args
)
703 switch (args
->event
) {
709 return lib_route_map_entry_match_destroy(args
);
716 * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:list-name
719 lib_route_map_entry_match_condition_rmap_match_condition_list_name_modify(
720 struct nb_cb_modify_args
*args
)
722 struct routemap_hook_context
*rhc
;
723 const char *list_name
;
724 enum rmap_compile_rets ret
= RMAP_COMPILE_SUCCESS
;
725 const char *condition
;
727 switch (args
->event
) {
733 /* Add configuration. */
734 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
735 list_name
= yang_dnode_get_string(args
->dnode
, NULL
);
736 condition
= yang_dnode_get_string(args
->dnode
,
737 "../../frr-route-map:condition");
739 if (IS_MATCH_AS_LIST(condition
)) {
740 /* Set destroy information. */
741 rhc
->rhc_mhook
= bgp_route_match_delete
;
742 rhc
->rhc_rule
= "as-path";
743 rhc
->rhc_event
= RMAP_EVENT_ASLIST_DELETED
;
745 ret
= bgp_route_match_add(rhc
->rhc_rmi
, "as-path",
746 list_name
, RMAP_EVENT_ASLIST_ADDED
,
747 args
->errmsg
, args
->errmsg_len
);
748 } else if (IS_MATCH_MAC_LIST(condition
)) {
749 /* Set destroy information. */
750 rhc
->rhc_mhook
= bgp_route_match_delete
;
751 rhc
->rhc_rule
= "mac address";
752 rhc
->rhc_event
= RMAP_EVENT_FILTER_DELETED
;
754 ret
= bgp_route_match_add(rhc
->rhc_rmi
,
757 RMAP_EVENT_FILTER_ADDED
,
758 args
->errmsg
, args
->errmsg_len
);
759 } else if (IS_MATCH_ROUTE_SRC(condition
)) {
760 /* Set destroy information. */
761 rhc
->rhc_mhook
= bgp_route_match_delete
;
762 rhc
->rhc_rule
= "ip route-source";
763 rhc
->rhc_event
= RMAP_EVENT_FILTER_DELETED
;
765 ret
= bgp_route_match_add(rhc
->rhc_rmi
,
767 list_name
, RMAP_EVENT_FILTER_ADDED
,
768 args
->errmsg
, args
->errmsg_len
);
769 } else if (IS_MATCH_ROUTE_SRC_PL(condition
)) {
770 /* Set destroy information. */
771 rhc
->rhc_mhook
= bgp_route_match_delete
;
772 rhc
->rhc_rule
= "ip route-source prefix-list";
773 rhc
->rhc_event
= RMAP_EVENT_PLIST_DELETED
;
775 ret
= bgp_route_match_add(rhc
->rhc_rmi
,
776 "ip route-source prefix-list",
777 list_name
, RMAP_EVENT_PLIST_ADDED
,
778 args
->errmsg
, args
->errmsg_len
);
781 if (ret
!= RMAP_COMPILE_SUCCESS
) {
782 rhc
->rhc_mhook
= NULL
;
783 return NB_ERR_INCONSISTENCY
;
791 lib_route_map_entry_match_condition_rmap_match_condition_list_name_destroy(
792 struct nb_cb_destroy_args
*args
)
794 switch (args
->event
) {
800 return lib_route_map_entry_match_destroy(args
);
807 * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:evpn-default-route
810 lib_route_map_entry_match_condition_rmap_match_condition_evpn_default_route_create(
811 struct nb_cb_create_args
*args
)
813 struct routemap_hook_context
*rhc
;
814 enum rmap_compile_rets ret
;
816 switch (args
->event
) {
822 /* Add configuration. */
823 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
825 /* Set destroy information. */
826 rhc
->rhc_mhook
= bgp_route_match_delete
;
827 rhc
->rhc_rule
= "evpn default-route";
828 rhc
->rhc_event
= RMAP_EVENT_MATCH_DELETED
;
830 ret
= bgp_route_match_add(rhc
->rhc_rmi
, "evpn default-route",
831 NULL
, RMAP_EVENT_MATCH_ADDED
,
832 args
->errmsg
, args
->errmsg_len
);
834 if (ret
!= RMAP_COMPILE_SUCCESS
) {
835 rhc
->rhc_mhook
= NULL
;
836 return NB_ERR_INCONSISTENCY
;
844 lib_route_map_entry_match_condition_rmap_match_condition_evpn_default_route_destroy(
845 struct nb_cb_destroy_args
*args
)
847 switch (args
->event
) {
853 return lib_route_map_entry_match_destroy(args
);
860 * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:evpn-vni
863 lib_route_map_entry_match_condition_rmap_match_condition_evpn_vni_modify(
864 struct nb_cb_modify_args
*args
)
866 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);
878 vni
= yang_dnode_get_string(args
->dnode
, NULL
);
880 /* Set destroy information. */
881 rhc
->rhc_mhook
= bgp_route_match_delete
;
882 rhc
->rhc_rule
= "evpn vni";
883 rhc
->rhc_event
= RMAP_EVENT_MATCH_DELETED
;
885 ret
= bgp_route_match_add(rhc
->rhc_rmi
, "evpn vni", vni
,
886 RMAP_EVENT_MATCH_ADDED
,
887 args
->errmsg
, args
->errmsg_len
);
889 if (ret
!= RMAP_COMPILE_SUCCESS
) {
890 rhc
->rhc_mhook
= NULL
;
891 return NB_ERR_INCONSISTENCY
;
899 lib_route_map_entry_match_condition_rmap_match_condition_evpn_vni_destroy(
900 struct nb_cb_destroy_args
*args
)
902 switch (args
->event
) {
908 return lib_route_map_entry_match_destroy(args
);
915 * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:evpn-route-type
918 lib_route_map_entry_match_condition_rmap_match_condition_evpn_route_type_modify(
919 struct nb_cb_modify_args
*args
)
921 struct routemap_hook_context
*rhc
;
923 enum rmap_compile_rets ret
;
925 switch (args
->event
) {
931 /* Add configuration. */
932 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
933 type
= yang_dnode_get_string(args
->dnode
, NULL
);
935 /* Set destroy information. */
936 rhc
->rhc_mhook
= bgp_route_match_delete
;
937 rhc
->rhc_rule
= "evpn route-type";
938 rhc
->rhc_event
= RMAP_EVENT_MATCH_DELETED
;
940 ret
= bgp_route_match_add(rhc
->rhc_rmi
, "evpn route-type",
942 RMAP_EVENT_MATCH_ADDED
,
943 args
->errmsg
, args
->errmsg_len
);
945 if (ret
!= RMAP_COMPILE_SUCCESS
) {
946 rhc
->rhc_mhook
= NULL
;
947 return NB_ERR_INCONSISTENCY
;
955 lib_route_map_entry_match_condition_rmap_match_condition_evpn_route_type_destroy(
956 struct nb_cb_destroy_args
*args
)
958 switch (args
->event
) {
964 return lib_route_map_entry_match_destroy(args
);
971 * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:route-distinguisher
974 lib_route_map_entry_match_condition_rmap_match_condition_route_distinguisher_modify(
975 struct nb_cb_modify_args
*args
)
977 struct routemap_hook_context
*rhc
;
979 enum rmap_compile_rets ret
;
981 switch (args
->event
) {
987 /* Add configuration. */
988 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
989 rd
= yang_dnode_get_string(args
->dnode
, NULL
);
991 /* Set destroy information. */
992 rhc
->rhc_mhook
= bgp_route_match_delete
;
993 rhc
->rhc_rule
= "evpn rd";
994 rhc
->rhc_event
= RMAP_EVENT_MATCH_DELETED
;
996 ret
= bgp_route_match_add(rhc
->rhc_rmi
, "evpn rd", rd
,
997 RMAP_EVENT_MATCH_ADDED
,
998 args
->errmsg
, args
->errmsg_len
);
1000 if (ret
!= RMAP_COMPILE_SUCCESS
) {
1001 rhc
->rhc_mhook
= NULL
;
1002 return NB_ERR_INCONSISTENCY
;
1010 lib_route_map_entry_match_condition_rmap_match_condition_route_distinguisher_destroy(
1011 struct nb_cb_destroy_args
*args
)
1013 switch (args
->event
) {
1014 case NB_EV_VALIDATE
:
1019 return lib_route_map_entry_match_destroy(args
);
1026 * XPath = /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:comm-list
1029 lib_route_map_entry_match_condition_rmap_match_condition_comm_list_finish(
1030 struct nb_cb_apply_finish_args
*args
)
1032 struct routemap_hook_context
*rhc
;
1034 bool exact_match
= false;
1036 const char *condition
;
1037 route_map_event_t event
;
1040 /* Add configuration. */
1041 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
1042 value
= yang_dnode_get_string(args
->dnode
, "./comm-list-name");
1044 if (yang_dnode_exists(args
->dnode
, "./comm-list-name-exact-match"))
1045 exact_match
= yang_dnode_get_bool(
1046 args
->dnode
, "./comm-list-name-exact-match");
1049 argstr
= XMALLOC(MTYPE_ROUTE_MAP_COMPILED
,
1050 strlen(value
) + strlen("exact-match") + 2);
1052 snprintf(argstr
, (strlen(value
) + strlen("exact-match") + 2),
1053 "%s exact-match", value
);
1055 argstr
= (char *)value
;
1057 /* Set destroy information. */
1058 rhc
->rhc_mhook
= bgp_route_match_delete
;
1060 condition
= yang_dnode_get_string(args
->dnode
,
1061 "../../frr-route-map:condition");
1062 if (IS_MATCH_COMMUNITY(condition
)) {
1063 rhc
->rhc_rule
= "community";
1064 event
= RMAP_EVENT_CLIST_ADDED
;
1065 rhc
->rhc_event
= RMAP_EVENT_CLIST_DELETED
;
1066 } else if (IS_MATCH_LCOMMUNITY(condition
)) {
1067 rhc
->rhc_rule
= "large-community";
1068 event
= RMAP_EVENT_LLIST_ADDED
;
1069 rhc
->rhc_event
= RMAP_EVENT_LLIST_DELETED
;
1071 rhc
->rhc_rule
= "extcommunity";
1072 event
= RMAP_EVENT_ECLIST_ADDED
;
1073 rhc
->rhc_event
= RMAP_EVENT_ECLIST_DELETED
;
1076 ret
= bgp_route_match_add(rhc
->rhc_rmi
, rhc
->rhc_rule
, argstr
, event
,
1077 args
->errmsg
, args
->errmsg_len
);
1079 * At this point if this is not a successful operation
1080 * bgpd is about to crash. Let's just cut to the
1083 assert(ret
== RMAP_COMPILE_SUCCESS
);
1085 if (argstr
!= value
)
1086 XFREE(MTYPE_ROUTE_MAP_COMPILED
, argstr
);
1091 * /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:comm-list/comm-list-name
1094 lib_route_map_entry_match_condition_rmap_match_condition_comm_list_comm_list_name_modify(
1095 struct nb_cb_modify_args
*args
)
1097 switch (args
->event
) {
1098 case NB_EV_VALIDATE
:
1109 lib_route_map_entry_match_condition_rmap_match_condition_comm_list_comm_list_name_destroy(
1110 struct nb_cb_destroy_args
*args
)
1112 switch (args
->event
) {
1113 case NB_EV_VALIDATE
:
1118 return lib_route_map_entry_match_destroy(args
);
1126 * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:comm-list/comm-list-name-exact-match
1129 lib_route_map_entry_match_condition_rmap_match_condition_comm_list_comm_list_name_exact_match_modify(
1130 struct nb_cb_modify_args
*args
)
1132 switch (args
->event
) {
1133 case NB_EV_VALIDATE
:
1144 lib_route_map_entry_match_condition_rmap_match_condition_comm_list_comm_list_name_exact_match_destroy(
1145 struct nb_cb_destroy_args
*args
)
1147 switch (args
->event
) {
1148 case NB_EV_VALIDATE
:
1153 return lib_route_map_entry_match_destroy(args
);
1160 * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:ipv4-address
1163 lib_route_map_entry_match_condition_rmap_match_condition_ipv4_address_modify(
1164 struct nb_cb_modify_args
*args
)
1166 struct routemap_hook_context
*rhc
;
1168 enum rmap_compile_rets ret
;
1170 switch (args
->event
) {
1171 case NB_EV_VALIDATE
:
1176 /* Add configuration. */
1177 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
1178 peer
= yang_dnode_get_string(args
->dnode
, NULL
);
1180 /* Set destroy information. */
1181 rhc
->rhc_mhook
= bgp_route_match_delete
;
1182 rhc
->rhc_rule
= "ip next-hop address";
1183 rhc
->rhc_event
= RMAP_EVENT_MATCH_DELETED
;
1185 ret
= bgp_route_match_add(rhc
->rhc_rmi
, rhc
->rhc_rule
,
1186 peer
, RMAP_EVENT_MATCH_ADDED
,
1187 args
->errmsg
, args
->errmsg_len
);
1189 if (ret
!= RMAP_COMPILE_SUCCESS
) {
1190 rhc
->rhc_mhook
= NULL
;
1191 return NB_ERR_INCONSISTENCY
;
1199 lib_route_map_entry_match_condition_rmap_match_condition_ipv4_address_destroy(
1200 struct nb_cb_destroy_args
*args
)
1202 switch (args
->event
) {
1203 case NB_EV_VALIDATE
:
1208 return lib_route_map_entry_match_destroy(args
);
1215 * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:ipv6-address
1218 lib_route_map_entry_match_condition_rmap_match_condition_ipv6_address_modify(
1219 struct nb_cb_modify_args
*args
)
1221 struct routemap_hook_context
*rhc
;
1223 enum rmap_compile_rets ret
;
1225 switch (args
->event
) {
1226 case NB_EV_VALIDATE
:
1231 /* Add configuration. */
1232 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
1233 peer
= yang_dnode_get_string(args
->dnode
, NULL
);
1235 /* Set destroy information. */
1236 rhc
->rhc_mhook
= bgp_route_match_delete
;
1237 rhc
->rhc_rule
= "ipv6 next-hop";
1238 rhc
->rhc_event
= RMAP_EVENT_MATCH_DELETED
;
1240 ret
= bgp_route_match_add(rhc
->rhc_rmi
, rhc
->rhc_rule
,
1241 peer
, RMAP_EVENT_MATCH_ADDED
,
1242 args
->errmsg
, args
->errmsg_len
);
1244 if (ret
!= RMAP_COMPILE_SUCCESS
) {
1245 rhc
->rhc_mhook
= NULL
;
1246 return NB_ERR_INCONSISTENCY
;
1254 lib_route_map_entry_match_condition_rmap_match_condition_ipv6_address_destroy(
1255 struct nb_cb_destroy_args
*args
)
1257 switch (args
->event
) {
1258 case NB_EV_VALIDATE
:
1263 return lib_route_map_entry_match_destroy(args
);
1271 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:distance
1273 int lib_route_map_entry_set_action_rmap_set_action_distance_modify(
1274 struct nb_cb_modify_args
*args
)
1276 struct routemap_hook_context
*rhc
;
1280 switch (args
->event
) {
1281 case NB_EV_VALIDATE
:
1286 /* Add configuration. */
1287 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
1288 type
= yang_dnode_get_string(args
->dnode
, NULL
);
1290 /* Set destroy information. */
1291 rhc
->rhc_shook
= generic_set_delete
;
1292 rhc
->rhc_rule
= "distance";
1293 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
1295 rv
= generic_set_add(rhc
->rhc_rmi
, "distance", type
,
1296 args
->errmsg
, args
->errmsg_len
);
1297 if (rv
!= CMD_SUCCESS
) {
1298 rhc
->rhc_shook
= NULL
;
1299 return NB_ERR_INCONSISTENCY
;
1306 int lib_route_map_entry_set_action_rmap_set_action_distance_destroy(
1307 struct nb_cb_destroy_args
*args
)
1309 switch (args
->event
) {
1310 case NB_EV_VALIDATE
:
1315 return lib_route_map_entry_match_destroy(args
);
1323 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:extcommunity-rt
1326 lib_route_map_entry_set_action_rmap_set_action_extcommunity_rt_modify(
1327 struct nb_cb_modify_args
*args
)
1329 struct routemap_hook_context
*rhc
;
1333 switch (args
->event
) {
1334 case NB_EV_VALIDATE
:
1339 /* Add configuration. */
1340 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
1341 type
= yang_dnode_get_string(args
->dnode
, NULL
);
1343 /* Set destroy information. */
1344 rhc
->rhc_shook
= generic_set_delete
;
1345 rhc
->rhc_rule
= "extcommunity rt";
1346 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
1348 rv
= generic_set_add(rhc
->rhc_rmi
, "extcommunity rt", type
,
1349 args
->errmsg
, args
->errmsg_len
);
1350 if (rv
!= CMD_SUCCESS
) {
1351 rhc
->rhc_shook
= NULL
;
1352 return NB_ERR_INCONSISTENCY
;
1360 lib_route_map_entry_set_action_rmap_set_action_extcommunity_rt_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-soo
1380 lib_route_map_entry_set_action_rmap_set_action_extcommunity_soo_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 soo";
1400 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
1402 rv
= generic_set_add(rhc
->rhc_rmi
, "extcommunity soo",
1404 args
->errmsg
, args
->errmsg_len
);
1405 if (rv
!= CMD_SUCCESS
) {
1406 rhc
->rhc_shook
= NULL
;
1407 return NB_ERR_INCONSISTENCY
;
1415 lib_route_map_entry_set_action_rmap_set_action_extcommunity_soo_destroy(
1416 struct nb_cb_destroy_args
*args
)
1418 switch (args
->event
) {
1419 case NB_EV_VALIDATE
:
1424 return lib_route_map_entry_match_destroy(args
);
1432 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:ipv4-address
1434 int lib_route_map_entry_set_action_rmap_set_action_ipv4_address_modify(
1435 struct nb_cb_modify_args
*args
)
1437 struct routemap_hook_context
*rhc
;
1439 int rv
= CMD_SUCCESS
;
1441 switch (args
->event
) {
1442 case NB_EV_VALIDATE
:
1447 /* Add configuration. */
1448 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
1449 addr
= yang_dnode_get_string(args
->dnode
, NULL
);
1451 rhc
->rhc_shook
= generic_set_delete
;
1452 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
1453 rhc
->rhc_rule
= "ipv4 vpn next-hop";
1455 rv
= generic_set_add(rhc
->rhc_rmi
, rhc
->rhc_rule
, addr
,
1456 args
->errmsg
, args
->errmsg_len
);
1458 if (rv
!= CMD_SUCCESS
) {
1459 rhc
->rhc_shook
= NULL
;
1460 return NB_ERR_INCONSISTENCY
;
1467 int lib_route_map_entry_set_action_rmap_set_action_ipv4_address_destroy(
1468 struct nb_cb_destroy_args
*args
)
1470 switch (args
->event
) {
1471 case NB_EV_VALIDATE
:
1476 return lib_route_map_entry_set_destroy(args
);
1484 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:ipv4-nexthop
1486 int lib_route_map_entry_set_action_rmap_set_action_ipv4_nexthop_modify(
1487 struct nb_cb_modify_args
*args
)
1489 struct routemap_hook_context
*rhc
;
1493 switch (args
->event
) {
1494 case NB_EV_VALIDATE
:
1499 /* Add configuration. */
1500 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
1501 type
= yang_dnode_get_string(args
->dnode
, NULL
);
1503 /* Set destroy information. */
1504 rhc
->rhc_shook
= generic_set_delete
;
1505 rhc
->rhc_rule
= "ip next-hop";
1506 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
1508 rv
= generic_set_add(rhc
->rhc_rmi
, rhc
->rhc_rule
, type
,
1509 args
->errmsg
, args
->errmsg_len
);
1511 if (rv
!= CMD_SUCCESS
) {
1512 rhc
->rhc_shook
= NULL
;
1513 return NB_ERR_INCONSISTENCY
;
1520 int lib_route_map_entry_set_action_rmap_set_action_ipv4_nexthop_destroy(
1521 struct nb_cb_destroy_args
*args
)
1523 switch (args
->event
) {
1524 case NB_EV_VALIDATE
:
1529 return lib_route_map_entry_set_destroy(args
);
1537 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:ipv6-address
1539 int lib_route_map_entry_set_action_rmap_set_action_ipv6_address_modify(
1540 struct nb_cb_modify_args
*args
)
1542 struct routemap_hook_context
*rhc
;
1544 int rv
= CMD_SUCCESS
;
1545 const char *action
= NULL
;
1546 struct in6_addr i6a
;
1548 action
= yang_dnode_get_string(args
->dnode
,
1549 "../../frr-route-map:action");
1550 switch (args
->event
) {
1551 case NB_EV_VALIDATE
:
1552 if (action
&& IS_SET_IPV6_NH_GLOBAL(action
)) {
1553 yang_dnode_get_ipv6(&i6a
, args
->dnode
, NULL
);
1554 if (IN6_IS_ADDR_UNSPECIFIED(&i6a
)
1555 || IN6_IS_ADDR_LOOPBACK(&i6a
)
1556 || IN6_IS_ADDR_MULTICAST(&i6a
)
1557 || IN6_IS_ADDR_LINKLOCAL(&i6a
))
1558 return NB_ERR_VALIDATION
;
1568 /* Add configuration. */
1569 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
1570 addr
= yang_dnode_get_string(args
->dnode
, NULL
);
1572 rhc
->rhc_shook
= generic_set_delete
;
1573 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
1575 if (IS_SET_IPV6_NH_GLOBAL(action
))
1576 /* Set destroy information. */
1577 rhc
->rhc_rule
= "ipv6 next-hop global";
1579 rhc
->rhc_rule
= "ipv6 vpn next-hop";
1581 rv
= generic_set_add(rhc
->rhc_rmi
, rhc
->rhc_rule
, addr
,
1582 args
->errmsg
, args
->errmsg_len
);
1584 if (rv
!= CMD_SUCCESS
) {
1585 rhc
->rhc_shook
= NULL
;
1586 return NB_ERR_INCONSISTENCY
;
1592 int lib_route_map_entry_set_action_rmap_set_action_ipv6_address_destroy(
1593 struct nb_cb_destroy_args
*args
)
1595 switch (args
->event
) {
1596 case NB_EV_VALIDATE
:
1601 return lib_route_map_entry_set_destroy(args
);
1609 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:preference
1611 int lib_route_map_entry_set_action_rmap_set_action_preference_modify(
1612 struct nb_cb_modify_args
*args
)
1614 struct routemap_hook_context
*rhc
;
1615 int rv
= CMD_SUCCESS
;
1616 const char *action
= NULL
;
1619 switch (args
->event
) {
1620 case NB_EV_VALIDATE
:
1625 /* Add configuration. */
1626 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
1627 value
= yang_dnode_get_bool(args
->dnode
, NULL
);
1629 rhc
->rhc_shook
= generic_set_delete
;
1630 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
1632 action
= yang_dnode_get_string(args
->dnode
,
1633 "../../frr-route-map:action");
1636 if (IS_SET_IPV6_PEER_ADDR(action
))
1637 /* Set destroy information. */
1638 rhc
->rhc_rule
= "ipv6 next-hop peer-address";
1640 rhc
->rhc_rule
= "ipv6 next-hop prefer-global";
1642 rv
= generic_set_add(rhc
->rhc_rmi
, rhc
->rhc_rule
,
1644 args
->errmsg
, args
->errmsg_len
);
1647 if (rv
!= CMD_SUCCESS
) {
1648 rhc
->rhc_shook
= NULL
;
1649 return NB_ERR_INCONSISTENCY
;
1656 int lib_route_map_entry_set_action_rmap_set_action_preference_destroy(
1657 struct nb_cb_destroy_args
*args
)
1659 switch (args
->event
) {
1660 case NB_EV_VALIDATE
:
1665 return lib_route_map_entry_set_destroy(args
);
1673 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:label-index
1675 int lib_route_map_entry_set_action_rmap_set_action_label_index_modify(
1676 struct nb_cb_modify_args
*args
)
1678 struct routemap_hook_context
*rhc
;
1682 switch (args
->event
) {
1683 case NB_EV_VALIDATE
:
1688 /* Add configuration. */
1689 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
1690 type
= yang_dnode_get_string(args
->dnode
, NULL
);
1692 /* Set destroy information. */
1693 rhc
->rhc_shook
= generic_set_delete
;
1694 rhc
->rhc_rule
= "label-index";
1695 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
1697 rv
= generic_set_add(rhc
->rhc_rmi
, "label-index", type
,
1698 args
->errmsg
, args
->errmsg_len
);
1699 if (rv
!= CMD_SUCCESS
) {
1700 rhc
->rhc_shook
= NULL
;
1701 return NB_ERR_INCONSISTENCY
;
1708 int lib_route_map_entry_set_action_rmap_set_action_label_index_destroy(
1709 struct nb_cb_destroy_args
*args
)
1711 switch (args
->event
) {
1712 case NB_EV_VALIDATE
:
1717 return lib_route_map_entry_set_destroy(args
);
1725 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:local-pref
1727 int lib_route_map_entry_set_action_rmap_set_action_local_pref_modify(
1728 struct nb_cb_modify_args
*args
)
1730 struct routemap_hook_context
*rhc
;
1734 switch (args
->event
) {
1735 case NB_EV_VALIDATE
:
1740 /* Add configuration. */
1741 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
1742 type
= yang_dnode_get_string(args
->dnode
, NULL
);
1744 /* Set destroy information. */
1745 rhc
->rhc_shook
= generic_set_delete
;
1746 rhc
->rhc_rule
= "local-preference";
1747 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
1749 rv
= generic_set_add(rhc
->rhc_rmi
, "local-preference",
1751 args
->errmsg
, args
->errmsg_len
);
1752 if (rv
!= CMD_SUCCESS
) {
1753 rhc
->rhc_shook
= NULL
;
1754 return NB_ERR_INCONSISTENCY
;
1761 int lib_route_map_entry_set_action_rmap_set_action_local_pref_destroy(
1762 struct nb_cb_destroy_args
*args
)
1764 switch (args
->event
) {
1765 case NB_EV_VALIDATE
:
1770 return lib_route_map_entry_set_destroy(args
);
1778 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:weight
1780 int lib_route_map_entry_set_action_rmap_set_action_weight_modify(
1781 struct nb_cb_modify_args
*args
)
1783 struct routemap_hook_context
*rhc
;
1787 switch (args
->event
) {
1788 case NB_EV_VALIDATE
:
1793 /* Add configuration. */
1794 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
1795 type
= yang_dnode_get_string(args
->dnode
, NULL
);
1797 /* Set destroy information. */
1798 rhc
->rhc_shook
= generic_set_delete
;
1799 rhc
->rhc_rule
= "weight";
1800 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
1802 rv
= generic_set_add(rhc
->rhc_rmi
, "weight", type
,
1803 args
->errmsg
, args
->errmsg_len
);
1804 if (rv
!= CMD_SUCCESS
) {
1805 rhc
->rhc_shook
= NULL
;
1806 return NB_ERR_INCONSISTENCY
;
1813 int lib_route_map_entry_set_action_rmap_set_action_weight_destroy(
1814 struct nb_cb_destroy_args
*args
)
1816 switch (args
->event
) {
1817 case NB_EV_VALIDATE
:
1822 return lib_route_map_entry_set_destroy(args
);
1830 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:origin
1832 int lib_route_map_entry_set_action_rmap_set_action_origin_modify(
1833 struct nb_cb_modify_args
*args
)
1835 struct routemap_hook_context
*rhc
;
1839 switch (args
->event
) {
1840 case NB_EV_VALIDATE
:
1845 /* Add configuration. */
1846 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
1847 type
= yang_dnode_get_string(args
->dnode
, NULL
);
1849 /* Set destroy information. */
1850 rhc
->rhc_shook
= generic_set_delete
;
1851 rhc
->rhc_rule
= "origin";
1852 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
1854 rv
= generic_set_add(rhc
->rhc_rmi
, "origin", type
,
1855 args
->errmsg
, args
->errmsg_len
);
1856 if (rv
!= CMD_SUCCESS
) {
1857 rhc
->rhc_shook
= NULL
;
1858 return NB_ERR_INCONSISTENCY
;
1865 int lib_route_map_entry_set_action_rmap_set_action_origin_destroy(
1866 struct nb_cb_destroy_args
*args
)
1868 switch (args
->event
) {
1869 case NB_EV_VALIDATE
:
1874 return lib_route_map_entry_set_destroy(args
);
1883 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:originator-id
1885 int lib_route_map_entry_set_action_rmap_set_action_originator_id_modify(
1886 struct nb_cb_modify_args
*args
)
1888 struct routemap_hook_context
*rhc
;
1892 switch (args
->event
) {
1893 case NB_EV_VALIDATE
:
1898 /* Add configuration. */
1899 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
1900 type
= yang_dnode_get_string(args
->dnode
, NULL
);
1902 /* Set destroy information. */
1903 rhc
->rhc_shook
= generic_set_delete
;
1904 rhc
->rhc_rule
= "originator-id";
1905 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
1907 rv
= generic_set_add(rhc
->rhc_rmi
, "originator-id", type
,
1908 args
->errmsg
, args
->errmsg_len
);
1909 if (rv
!= CMD_SUCCESS
) {
1910 rhc
->rhc_shook
= NULL
;
1911 return NB_ERR_INCONSISTENCY
;
1918 int lib_route_map_entry_set_action_rmap_set_action_originator_id_destroy(
1919 struct nb_cb_destroy_args
*args
)
1921 switch (args
->event
) {
1922 case NB_EV_VALIDATE
:
1927 return lib_route_map_entry_set_destroy(args
);
1935 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:table
1937 int lib_route_map_entry_set_action_rmap_set_action_table_modify(
1938 struct nb_cb_modify_args
*args
)
1940 struct routemap_hook_context
*rhc
;
1944 switch (args
->event
) {
1945 case NB_EV_VALIDATE
:
1950 /* Add configuration. */
1951 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
1952 type
= yang_dnode_get_string(args
->dnode
, NULL
);
1954 /* Set destroy information. */
1955 rhc
->rhc_shook
= generic_set_delete
;
1956 rhc
->rhc_rule
= "table";
1957 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
1959 rv
= generic_set_add(rhc
->rhc_rmi
, "table", type
,
1960 args
->errmsg
, args
->errmsg_len
);
1961 if (rv
!= CMD_SUCCESS
) {
1962 rhc
->rhc_shook
= NULL
;
1963 return NB_ERR_INCONSISTENCY
;
1970 int lib_route_map_entry_set_action_rmap_set_action_table_destroy(
1971 struct nb_cb_destroy_args
*args
)
1973 switch (args
->event
) {
1974 case NB_EV_VALIDATE
:
1979 return lib_route_map_entry_set_destroy(args
);
1987 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:atomic-aggregate
1990 lib_route_map_entry_set_action_rmap_set_action_atomic_aggregate_create(
1991 struct nb_cb_create_args
*args
)
1993 struct routemap_hook_context
*rhc
;
1996 switch (args
->event
) {
1997 case NB_EV_VALIDATE
:
2002 /* Add configuration. */
2003 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
2005 /* Set destroy information. */
2006 rhc
->rhc_shook
= generic_set_delete
;
2007 rhc
->rhc_rule
= "atomic-aggregate";
2008 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
2010 rv
= generic_set_add(rhc
->rhc_rmi
, rhc
->rhc_rule
, NULL
,
2011 args
->errmsg
, args
->errmsg_len
);
2012 if (rv
!= CMD_SUCCESS
) {
2013 rhc
->rhc_shook
= NULL
;
2014 return NB_ERR_INCONSISTENCY
;
2022 lib_route_map_entry_set_action_rmap_set_action_atomic_aggregate_destroy(
2023 struct nb_cb_destroy_args
*args
)
2025 switch (args
->event
) {
2026 case NB_EV_VALIDATE
:
2031 return lib_route_map_entry_set_destroy(args
);
2039 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:prepend-as-path
2042 lib_route_map_entry_set_action_rmap_set_action_prepend_as_path_modify(
2043 struct nb_cb_modify_args
*args
)
2045 struct routemap_hook_context
*rhc
;
2049 switch (args
->event
) {
2050 case NB_EV_VALIDATE
:
2055 /* Add configuration. */
2056 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
2057 type
= yang_dnode_get_string(args
->dnode
, NULL
);
2059 /* Set destroy information. */
2060 rhc
->rhc_shook
= generic_set_delete
;
2061 rhc
->rhc_rule
= "as-path prepend";
2062 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
2064 rv
= generic_set_add(rhc
->rhc_rmi
, "as-path prepend",
2066 args
->errmsg
, args
->errmsg_len
);
2067 if (rv
!= CMD_SUCCESS
) {
2068 rhc
->rhc_shook
= NULL
;
2069 return NB_ERR_INCONSISTENCY
;
2077 lib_route_map_entry_set_action_rmap_set_action_prepend_as_path_destroy(
2078 struct nb_cb_destroy_args
*args
)
2080 switch (args
->event
) {
2081 case NB_EV_VALIDATE
:
2086 return lib_route_map_entry_set_destroy(args
);
2094 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:last-as
2096 int lib_route_map_entry_set_action_rmap_set_action_last_as_modify(
2097 struct nb_cb_modify_args
*args
)
2099 struct routemap_hook_context
*rhc
;
2104 switch (args
->event
) {
2105 case NB_EV_VALIDATE
:
2110 /* Add configuration. */
2111 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
2112 value
= yang_dnode_get_string(args
->dnode
, NULL
);
2114 /* Set destroy information. */
2115 rhc
->rhc_shook
= generic_set_delete
;
2116 rhc
->rhc_rule
= "as-path prepend";
2117 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
2119 argstr
= XMALLOC(MTYPE_ROUTE_MAP_COMPILED
,
2120 strlen(value
) + strlen("last-as") + 2);
2122 snprintf(argstr
, (strlen(value
) + strlen("last-as") + 2),
2123 "last-as %s", value
);
2125 rv
= generic_set_add(rhc
->rhc_rmi
, "as-path prepend",
2127 args
->errmsg
, args
->errmsg_len
);
2128 if (rv
!= CMD_SUCCESS
) {
2129 rhc
->rhc_shook
= NULL
;
2130 XFREE(MTYPE_ROUTE_MAP_COMPILED
, argstr
);
2131 return NB_ERR_INCONSISTENCY
;
2134 XFREE(MTYPE_ROUTE_MAP_COMPILED
, argstr
);
2140 int lib_route_map_entry_set_action_rmap_set_action_last_as_destroy(
2141 struct nb_cb_destroy_args
*args
)
2143 switch (args
->event
) {
2144 case NB_EV_VALIDATE
:
2149 return lib_route_map_entry_set_destroy(args
);
2157 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:exclude-as-path
2160 lib_route_map_entry_set_action_rmap_set_action_exclude_as_path_modify(
2161 struct nb_cb_modify_args
*args
)
2163 struct routemap_hook_context
*rhc
;
2167 switch (args
->event
) {
2168 case NB_EV_VALIDATE
:
2173 /* Add configuration. */
2174 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
2175 type
= yang_dnode_get_string(args
->dnode
, NULL
);
2177 /* Set destroy information. */
2178 rhc
->rhc_shook
= generic_set_delete
;
2179 rhc
->rhc_rule
= "as-path exclude";
2180 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
2182 rv
= generic_set_add(rhc
->rhc_rmi
, "as-path exclude",
2184 args
->errmsg
, args
->errmsg_len
);
2185 if (rv
!= CMD_SUCCESS
) {
2186 rhc
->rhc_shook
= NULL
;
2187 return NB_ERR_INCONSISTENCY
;
2195 lib_route_map_entry_set_action_rmap_set_action_exclude_as_path_destroy(
2196 struct nb_cb_destroy_args
*args
)
2198 switch (args
->event
) {
2199 case NB_EV_VALIDATE
:
2204 return lib_route_map_entry_set_destroy(args
);
2212 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:community-none
2214 int lib_route_map_entry_set_action_rmap_set_action_community_none_modify(
2215 struct nb_cb_modify_args
*args
)
2217 struct routemap_hook_context
*rhc
;
2221 switch (args
->event
) {
2222 case NB_EV_VALIDATE
:
2227 /* Add configuration. */
2228 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
2229 none
= yang_dnode_get_bool(args
->dnode
, NULL
);
2231 /* Set destroy information. */
2232 rhc
->rhc_shook
= generic_set_delete
;
2233 rhc
->rhc_rule
= "community";
2234 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
2237 rv
= generic_set_add(rhc
->rhc_rmi
, "community",
2239 args
->errmsg
, args
->errmsg_len
);
2240 if (rv
!= CMD_SUCCESS
) {
2241 rhc
->rhc_shook
= NULL
;
2242 return NB_ERR_INCONSISTENCY
;
2247 return NB_ERR_INCONSISTENCY
;
2254 lib_route_map_entry_set_action_rmap_set_action_community_none_destroy(
2255 struct nb_cb_destroy_args
*args
)
2257 switch (args
->event
) {
2258 case NB_EV_VALIDATE
:
2263 return lib_route_map_entry_set_destroy(args
);
2271 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:community-string
2274 lib_route_map_entry_set_action_rmap_set_action_community_string_modify(
2275 struct nb_cb_modify_args
*args
)
2277 struct routemap_hook_context
*rhc
;
2281 switch (args
->event
) {
2282 case NB_EV_VALIDATE
:
2287 /* Add configuration. */
2288 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
2289 type
= yang_dnode_get_string(args
->dnode
, NULL
);
2291 /* Set destroy information. */
2292 rhc
->rhc_shook
= generic_set_delete
;
2293 rhc
->rhc_rule
= "community";
2294 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
2296 rv
= generic_set_add(rhc
->rhc_rmi
, "community", type
,
2297 args
->errmsg
, args
->errmsg_len
);
2298 if (rv
!= CMD_SUCCESS
) {
2299 rhc
->rhc_shook
= NULL
;
2300 return NB_ERR_INCONSISTENCY
;
2308 lib_route_map_entry_set_action_rmap_set_action_community_string_destroy(
2309 struct nb_cb_destroy_args
*args
)
2311 switch (args
->event
) {
2312 case NB_EV_VALIDATE
:
2317 return lib_route_map_entry_set_destroy(args
);
2325 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:large-community-none
2328 lib_route_map_entry_set_action_rmap_set_action_large_community_none_modify(
2329 struct nb_cb_modify_args
*args
)
2331 struct routemap_hook_context
*rhc
;
2335 switch (args
->event
) {
2336 case NB_EV_VALIDATE
:
2341 /* Add configuration. */
2342 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
2343 none
= yang_dnode_get_bool(args
->dnode
, NULL
);
2345 /* Set destroy information. */
2346 rhc
->rhc_shook
= generic_set_delete
;
2347 rhc
->rhc_rule
= "large-community";
2348 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
2351 rv
= generic_set_add(rhc
->rhc_rmi
,
2354 args
->errmsg
, args
->errmsg_len
);
2355 if (rv
!= CMD_SUCCESS
) {
2356 rhc
->rhc_shook
= NULL
;
2357 return NB_ERR_INCONSISTENCY
;
2362 return NB_ERR_INCONSISTENCY
;
2369 lib_route_map_entry_set_action_rmap_set_action_large_community_none_destroy(
2370 struct nb_cb_destroy_args
*args
)
2372 switch (args
->event
) {
2373 case NB_EV_VALIDATE
:
2378 return lib_route_map_entry_set_destroy(args
);
2386 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:large-community-string
2389 lib_route_map_entry_set_action_rmap_set_action_large_community_string_modify(
2390 struct nb_cb_modify_args
*args
)
2392 struct routemap_hook_context
*rhc
;
2396 switch (args
->event
) {
2397 case NB_EV_VALIDATE
:
2402 /* Add configuration. */
2403 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
2404 type
= yang_dnode_get_string(args
->dnode
, NULL
);
2406 /* Set destroy information. */
2407 rhc
->rhc_shook
= generic_set_delete
;
2408 rhc
->rhc_rule
= "large-community";
2409 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
2411 rv
= generic_set_add(rhc
->rhc_rmi
, "large-community",
2413 args
->errmsg
, args
->errmsg_len
);
2414 if (rv
!= CMD_SUCCESS
) {
2415 rhc
->rhc_shook
= NULL
;
2416 return NB_ERR_INCONSISTENCY
;
2424 lib_route_map_entry_set_action_rmap_set_action_large_community_string_destroy(
2425 struct nb_cb_destroy_args
*args
)
2427 switch (args
->event
) {
2428 case NB_EV_VALIDATE
:
2433 return lib_route_map_entry_set_destroy(args
);
2441 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:aggregator
2443 void lib_route_map_entry_set_action_rmap_set_action_aggregator_finish(
2444 struct nb_cb_apply_finish_args
*args
)
2446 struct routemap_hook_context
*rhc
;
2452 /* Add configuration. */
2453 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
2454 asn
= yang_dnode_get_string(args
->dnode
, "./aggregator-asn");
2455 addr
= yang_dnode_get_string(args
->dnode
, "./aggregator-address");
2457 argstr
= XMALLOC(MTYPE_ROUTE_MAP_COMPILED
,
2458 strlen(asn
) + strlen(addr
) + 2);
2460 snprintf(argstr
, (strlen(asn
) + strlen(addr
) + 2), "%s %s", asn
, addr
);
2462 /* Set destroy information. */
2463 rhc
->rhc_shook
= generic_set_delete
;
2464 rhc
->rhc_rule
= "aggregator as";
2465 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
2467 ret
= generic_set_add(rhc
->rhc_rmi
, rhc
->rhc_rule
, argstr
, args
->errmsg
,
2470 * At this point if this is not a successful operation
2471 * bgpd is about to crash. Let's just cut to the
2474 assert(ret
== CMD_SUCCESS
);
2476 XFREE(MTYPE_ROUTE_MAP_COMPILED
, argstr
);
2480 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:aggregator/aggregator-asn
2483 lib_route_map_entry_set_action_rmap_set_action_aggregator_aggregator_asn_modify(
2484 struct nb_cb_modify_args
*args
)
2486 switch (args
->event
) {
2487 case NB_EV_VALIDATE
:
2498 lib_route_map_entry_set_action_rmap_set_action_aggregator_aggregator_asn_destroy(
2499 struct nb_cb_destroy_args
*args
)
2501 switch (args
->event
) {
2502 case NB_EV_VALIDATE
:
2507 return lib_route_map_entry_set_destroy(args
);
2515 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:aggregator/aggregator-address
2518 lib_route_map_entry_set_action_rmap_set_action_aggregator_aggregator_address_modify(
2519 struct nb_cb_modify_args
*args
)
2521 switch (args
->event
) {
2522 case NB_EV_VALIDATE
:
2533 lib_route_map_entry_set_action_rmap_set_action_aggregator_aggregator_address_destroy(
2534 struct nb_cb_destroy_args
*args
)
2536 switch (args
->event
) {
2537 case NB_EV_VALIDATE
:
2542 return lib_route_map_entry_set_destroy(args
);
2550 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:comm-list-name
2552 int lib_route_map_entry_set_action_rmap_set_action_comm_list_name_modify(
2553 struct nb_cb_modify_args
*args
)
2555 struct routemap_hook_context
*rhc
;
2558 int rv
= CMD_SUCCESS
;
2560 switch (args
->event
) {
2561 case NB_EV_VALIDATE
:
2566 /* Add configuration. */
2567 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
2568 value
= yang_dnode_get_string(args
->dnode
, NULL
);
2570 /* Set destroy information. */
2571 rhc
->rhc_shook
= generic_set_delete
;
2573 action
= yang_dnode_get_string(args
->dnode
,
2574 "../../frr-route-map:action");
2575 if (IS_SET_COMM_LIST_DEL(action
))
2576 rhc
->rhc_rule
= "comm-list";
2578 rhc
->rhc_rule
= "large-comm-list";
2580 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
2582 rv
= generic_set_add(rhc
->rhc_rmi
, rhc
->rhc_rule
, value
,
2583 args
->errmsg
, args
->errmsg_len
);
2585 if (rv
!= CMD_SUCCESS
) {
2586 rhc
->rhc_shook
= NULL
;
2587 return NB_ERR_INCONSISTENCY
;
2595 lib_route_map_entry_set_action_rmap_set_action_comm_list_name_destroy(
2596 struct nb_cb_destroy_args
*args
)
2598 switch (args
->event
) {
2599 case NB_EV_VALIDATE
:
2604 return lib_route_map_entry_set_destroy(args
);
2612 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:extcommunity-lb
2615 lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_finish(
2616 struct nb_cb_apply_finish_args
*args
)
2618 struct routemap_hook_context
*rhc
;
2619 enum ecommunity_lb_type lb_type
;
2620 char str
[VTY_BUFSIZ
];
2624 /* Add configuration. */
2625 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
2626 lb_type
= yang_dnode_get_enum(args
->dnode
, "./lb-type");
2628 /* Set destroy information. */
2629 rhc
->rhc_shook
= generic_set_delete
;
2630 rhc
->rhc_rule
= "extcommunity bandwidth";
2631 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
2634 case EXPLICIT_BANDWIDTH
:
2635 bandwidth
= yang_dnode_get_uint16(args
->dnode
, "./bandwidth");
2636 snprintf(str
, sizeof(str
), "%d", bandwidth
);
2638 case CUMULATIVE_BANDWIDTH
:
2639 snprintf(str
, sizeof(str
), "%s", "cumulative");
2641 case COMPUTED_BANDWIDTH
:
2642 snprintf(str
, sizeof(str
), "%s", "num-multipaths");
2645 if (yang_dnode_get_bool(args
->dnode
, "./two-octet-as-specific"))
2646 strlcat(str
, " non-transitive", sizeof(str
));
2648 ret
= generic_set_add(rhc
->rhc_rmi
, "extcommunity bandwidth", str
,
2649 args
->errmsg
, args
->errmsg_len
);
2651 * At this point if this is not a successful operation
2652 * bgpd is about to crash. Let's just cut to the
2655 assert(ret
== CMD_SUCCESS
);
2660 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:extcommunity-lb/lb-type
2663 lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_lb_type_modify(
2664 struct nb_cb_modify_args
*args
)
2670 lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_lb_type_destroy(
2671 struct nb_cb_destroy_args
*args
)
2673 return lib_route_map_entry_set_destroy(args
);
2678 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:extcommunity-lb/bandwidth
2681 lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_bandwidth_modify(
2682 struct nb_cb_modify_args
*args
)
2688 lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_bandwidth_destroy(
2689 struct nb_cb_destroy_args
*args
)
2691 return lib_route_map_entry_set_destroy(args
);
2696 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:extcommunity-lb/two-octet-as-specific
2699 lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_two_octet_as_specific_modify(
2700 struct nb_cb_modify_args
*args
)
2706 lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_two_octet_as_specific_destroy(
2707 struct nb_cb_destroy_args
*args
)
2709 return lib_route_map_entry_set_destroy(args
);
2714 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:extcommunity-none
2716 int lib_route_map_entry_set_action_rmap_set_action_extcommunity_none_modify(
2717 struct nb_cb_modify_args
*args
)
2719 struct routemap_hook_context
*rhc
;
2723 switch (args
->event
) {
2724 case NB_EV_VALIDATE
:
2729 /* Add configuration. */
2730 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
2731 none
= yang_dnode_get_bool(args
->dnode
, NULL
);
2733 /* Set destroy information. */
2734 rhc
->rhc_shook
= generic_set_delete
;
2735 rhc
->rhc_rule
= "extcommunity";
2736 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
2739 rv
= generic_set_add(rhc
->rhc_rmi
, "extcommunity",
2740 "none", args
->errmsg
,
2742 if (rv
!= CMD_SUCCESS
) {
2743 rhc
->rhc_shook
= NULL
;
2744 return NB_ERR_INCONSISTENCY
;
2749 return NB_ERR_INCONSISTENCY
;
2755 int lib_route_map_entry_set_action_rmap_set_action_extcommunity_none_destroy(
2756 struct nb_cb_destroy_args
*args
)
2758 switch (args
->event
) {
2759 case NB_EV_VALIDATE
:
2764 return lib_route_map_entry_set_destroy(args
);
2772 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:evpn-gateway-ip-ipv4
2774 int lib_route_map_entry_set_action_rmap_set_action_evpn_gateway_ip_ipv4_modify(
2775 struct nb_cb_modify_args
*args
)
2777 struct routemap_hook_context
*rhc
;
2781 switch (args
->event
) {
2782 case NB_EV_VALIDATE
:
2787 /* Add configuration. */
2788 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
2789 type
= yang_dnode_get_string(args
->dnode
, NULL
);
2791 /* Set destroy information. */
2792 rhc
->rhc_shook
= generic_set_delete
;
2793 rhc
->rhc_rule
= "evpn gateway-ip ipv4";
2794 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
2796 rv
= generic_set_add(rhc
->rhc_rmi
, "evpn gateway-ip ipv4", type
,
2797 args
->errmsg
, args
->errmsg_len
);
2798 if (rv
!= CMD_SUCCESS
) {
2799 rhc
->rhc_shook
= NULL
;
2800 return NB_ERR_INCONSISTENCY
;
2807 int lib_route_map_entry_set_action_rmap_set_action_evpn_gateway_ip_ipv4_destroy(
2808 struct nb_cb_destroy_args
*args
)
2810 switch (args
->event
) {
2811 case NB_EV_VALIDATE
:
2816 return lib_route_map_entry_set_destroy(args
);
2824 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:evpn-gateway-ip-ipv6
2826 int lib_route_map_entry_set_action_rmap_set_action_evpn_gateway_ip_ipv6_modify(
2827 struct nb_cb_modify_args
*args
)
2829 struct routemap_hook_context
*rhc
;
2833 switch (args
->event
) {
2834 case NB_EV_VALIDATE
:
2839 /* Add configuration. */
2840 rhc
= nb_running_get_entry(args
->dnode
, NULL
, true);
2841 type
= yang_dnode_get_string(args
->dnode
, NULL
);
2843 /* Set destroy information. */
2844 rhc
->rhc_shook
= generic_set_delete
;
2845 rhc
->rhc_rule
= "evpn gateway-ip ipv6";
2846 rhc
->rhc_event
= RMAP_EVENT_SET_DELETED
;
2848 rv
= generic_set_add(rhc
->rhc_rmi
, "evpn gateway-ip ipv6", type
,
2849 args
->errmsg
, args
->errmsg_len
);
2850 if (rv
!= CMD_SUCCESS
) {
2851 rhc
->rhc_shook
= NULL
;
2852 return NB_ERR_INCONSISTENCY
;
2859 int lib_route_map_entry_set_action_rmap_set_action_evpn_gateway_ip_ipv6_destroy(
2860 struct nb_cb_destroy_args
*args
)
2862 switch (args
->event
) {
2863 case NB_EV_VALIDATE
:
2868 return lib_route_map_entry_set_destroy(args
);