1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (C) 2019 Cumulus Networks, Inc.
9 #include "lib/admin_group.h"
10 #include "lib/affinitymap.h"
12 #include "lib/northbound.h"
13 #include "lib/printfrr.h"
15 #include "lib/command.h"
16 #include "lib/routemap.h"
17 #include "zebra/zebra_nb.h"
18 #include "zebra/rib.h"
20 #include "zebra/interface.h"
21 #include "zebra/connected.h"
22 #include "zebra/zebra_router.h"
23 #include "zebra/debug.h"
24 #include "zebra/zebra_vxlan_private.h"
25 #include "zebra/zebra_vxlan.h"
28 * XPath: /frr-zebra:zebra/mcast-rpf-lookup
30 int zebra_mcast_rpf_lookup_modify(struct nb_cb_modify_args
*args
)
32 switch (args
->event
) {
37 /* TODO: implement me. */
45 * XPath: /frr-zebra:zebra/ip-forwarding
47 int zebra_ip_forwarding_modify(struct nb_cb_modify_args
*args
)
49 switch (args
->event
) {
54 /* TODO: implement me. */
61 int zebra_ip_forwarding_destroy(struct nb_cb_destroy_args
*args
)
63 switch (args
->event
) {
68 /* TODO: implement me. */
76 * XPath: /frr-zebra:zebra/ipv6-forwarding
78 int zebra_ipv6_forwarding_modify(struct nb_cb_modify_args
*args
)
80 switch (args
->event
) {
85 /* TODO: implement me. */
92 int zebra_ipv6_forwarding_destroy(struct nb_cb_destroy_args
*args
)
94 switch (args
->event
) {
99 /* TODO: implement me. */
107 * XPath: /frr-zebra:zebra/workqueue-hold-timer
109 int zebra_workqueue_hold_timer_modify(struct nb_cb_modify_args
*args
)
111 switch (args
->event
) {
116 /* TODO: implement me. */
124 * XPath: /frr-zebra:zebra/zapi-packets
126 int zebra_zapi_packets_modify(struct nb_cb_modify_args
*args
)
128 switch (args
->event
) {
133 /* TODO: implement me. */
141 * XPath: /frr-zebra:zebra/import-kernel-table/table-id
143 int zebra_import_kernel_table_table_id_modify(struct nb_cb_modify_args
*args
)
145 switch (args
->event
) {
150 /* TODO: implement me. */
157 int zebra_import_kernel_table_table_id_destroy(struct nb_cb_destroy_args
*args
)
159 switch (args
->event
) {
164 /* TODO: implement me. */
172 * XPath: /frr-zebra:zebra/import-kernel-table/distance
174 int zebra_import_kernel_table_distance_modify(struct nb_cb_modify_args
*args
)
176 switch (args
->event
) {
181 /* TODO: implement me. */
189 * XPath: /frr-zebra:zebra/import-kernel-table/route-map
191 int zebra_import_kernel_table_route_map_modify(struct nb_cb_modify_args
*args
)
193 switch (args
->event
) {
198 /* TODO: implement me. */
205 int zebra_import_kernel_table_route_map_destroy(struct nb_cb_destroy_args
*args
)
207 switch (args
->event
) {
212 /* TODO: implement me. */
220 * XPath: /frr-zebra:zebra/allow-external-route-update
222 int zebra_allow_external_route_update_create(struct nb_cb_create_args
*args
)
224 switch (args
->event
) {
229 /* TODO: implement me. */
236 int zebra_allow_external_route_update_destroy(struct nb_cb_destroy_args
*args
)
238 switch (args
->event
) {
243 /* TODO: implement me. */
251 * XPath: /frr-zebra:zebra/dplane-queue-limit
253 int zebra_dplane_queue_limit_modify(struct nb_cb_modify_args
*args
)
255 switch (args
->event
) {
260 /* TODO: implement me. */
268 * XPath: /frr-zebra:zebra/debugs/debug-events
270 int zebra_debugs_debug_events_modify(struct nb_cb_modify_args
*args
)
272 switch (args
->event
) {
277 /* TODO: implement me. */
284 int zebra_debugs_debug_events_destroy(struct nb_cb_destroy_args
*args
)
286 switch (args
->event
) {
291 /* TODO: implement me. */
299 * XPath: /frr-zebra:zebra/debugs/debug-zapi-send
301 int zebra_debugs_debug_zapi_send_modify(struct nb_cb_modify_args
*args
)
303 switch (args
->event
) {
308 /* TODO: implement me. */
315 int zebra_debugs_debug_zapi_send_destroy(struct nb_cb_destroy_args
*args
)
317 switch (args
->event
) {
322 /* TODO: implement me. */
330 * XPath: /frr-zebra:zebra/debugs/debug-zapi-recv
332 int zebra_debugs_debug_zapi_recv_modify(struct nb_cb_modify_args
*args
)
334 switch (args
->event
) {
339 /* TODO: implement me. */
346 int zebra_debugs_debug_zapi_recv_destroy(struct nb_cb_destroy_args
*args
)
348 switch (args
->event
) {
353 /* TODO: implement me. */
361 * XPath: /frr-zebra:zebra/debugs/debug-zapi-detail
363 int zebra_debugs_debug_zapi_detail_modify(struct nb_cb_modify_args
*args
)
365 switch (args
->event
) {
370 /* TODO: implement me. */
377 int zebra_debugs_debug_zapi_detail_destroy(struct nb_cb_destroy_args
*args
)
379 switch (args
->event
) {
384 /* TODO: implement me. */
392 * XPath: /frr-zebra:zebra/debugs/debug-kernel
394 int zebra_debugs_debug_kernel_modify(struct nb_cb_modify_args
*args
)
396 switch (args
->event
) {
401 /* TODO: implement me. */
408 int zebra_debugs_debug_kernel_destroy(struct nb_cb_destroy_args
*args
)
410 switch (args
->event
) {
415 /* TODO: implement me. */
423 * XPath: /frr-zebra:zebra/debugs/debug-kernel-msg-send
425 int zebra_debugs_debug_kernel_msg_send_modify(struct nb_cb_modify_args
*args
)
427 switch (args
->event
) {
432 /* TODO: implement me. */
439 int zebra_debugs_debug_kernel_msg_send_destroy(struct nb_cb_destroy_args
*args
)
441 switch (args
->event
) {
446 /* TODO: implement me. */
454 * XPath: /frr-zebra:zebra/debugs/debug-kernel-msg-recv
456 int zebra_debugs_debug_kernel_msg_recv_modify(struct nb_cb_modify_args
*args
)
458 switch (args
->event
) {
463 /* TODO: implement me. */
470 int zebra_debugs_debug_kernel_msg_recv_destroy(struct nb_cb_destroy_args
*args
)
472 switch (args
->event
) {
477 /* TODO: implement me. */
485 * XPath: /frr-zebra:zebra/debugs/debug-rib
487 int zebra_debugs_debug_rib_modify(struct nb_cb_modify_args
*args
)
489 switch (args
->event
) {
494 /* TODO: implement me. */
501 int zebra_debugs_debug_rib_destroy(struct nb_cb_destroy_args
*args
)
503 switch (args
->event
) {
508 /* TODO: implement me. */
516 * XPath: /frr-zebra:zebra/debugs/debug-rib-detail
518 int zebra_debugs_debug_rib_detail_modify(struct nb_cb_modify_args
*args
)
520 switch (args
->event
) {
525 /* TODO: implement me. */
532 int zebra_debugs_debug_rib_detail_destroy(struct nb_cb_destroy_args
*args
)
534 switch (args
->event
) {
539 /* TODO: implement me. */
547 * XPath: /frr-zebra:zebra/debugs/debug-fpm
549 int zebra_debugs_debug_fpm_modify(struct nb_cb_modify_args
*args
)
551 switch (args
->event
) {
556 /* TODO: implement me. */
563 int zebra_debugs_debug_fpm_destroy(struct nb_cb_destroy_args
*args
)
565 switch (args
->event
) {
570 /* TODO: implement me. */
578 * XPath: /frr-zebra:zebra/debugs/debug-nht
580 int zebra_debugs_debug_nht_modify(struct nb_cb_modify_args
*args
)
582 switch (args
->event
) {
587 /* TODO: implement me. */
594 int zebra_debugs_debug_nht_destroy(struct nb_cb_destroy_args
*args
)
596 switch (args
->event
) {
601 /* TODO: implement me. */
609 * XPath: /frr-zebra:zebra/debugs/debug-nht-detail
611 int zebra_debugs_debug_nht_detail_modify(struct nb_cb_modify_args
*args
)
613 switch (args
->event
) {
618 /* TODO: implement me. */
625 int zebra_debugs_debug_nht_detail_destroy(struct nb_cb_destroy_args
*args
)
627 switch (args
->event
) {
632 /* TODO: implement me. */
640 * XPath: /frr-zebra:zebra/debugs/debug-mpls
642 int zebra_debugs_debug_mpls_modify(struct nb_cb_modify_args
*args
)
644 switch (args
->event
) {
649 /* TODO: implement me. */
656 int zebra_debugs_debug_mpls_destroy(struct nb_cb_destroy_args
*args
)
658 switch (args
->event
) {
663 /* TODO: implement me. */
671 * XPath: /frr-zebra:zebra/debugs/debug-vxlan
673 int zebra_debugs_debug_vxlan_modify(struct nb_cb_modify_args
*args
)
675 switch (args
->event
) {
680 /* TODO: implement me. */
687 int zebra_debugs_debug_vxlan_destroy(struct nb_cb_destroy_args
*args
)
689 switch (args
->event
) {
694 /* TODO: implement me. */
702 * XPath: /frr-zebra:zebra/debugs/debug-pw
704 int zebra_debugs_debug_pw_modify(struct nb_cb_modify_args
*args
)
706 switch (args
->event
) {
711 /* TODO: implement me. */
718 int zebra_debugs_debug_pw_destroy(struct nb_cb_destroy_args
*args
)
720 switch (args
->event
) {
725 /* TODO: implement me. */
733 * XPath: /frr-zebra:zebra/debugs/debug-dplane
735 int zebra_debugs_debug_dplane_modify(struct nb_cb_modify_args
*args
)
737 switch (args
->event
) {
742 /* TODO: implement me. */
749 int zebra_debugs_debug_dplane_destroy(struct nb_cb_destroy_args
*args
)
751 switch (args
->event
) {
756 /* TODO: implement me. */
764 * XPath: /frr-zebra:zebra/debugs/debug-dplane-detail
766 int zebra_debugs_debug_dplane_detail_modify(struct nb_cb_modify_args
*args
)
768 switch (args
->event
) {
773 /* TODO: implement me. */
780 int zebra_debugs_debug_dplane_detail_destroy(struct nb_cb_destroy_args
*args
)
782 switch (args
->event
) {
787 /* TODO: implement me. */
795 * XPath: /frr-zebra:zebra/debugs/debug-mlag
797 int zebra_debugs_debug_mlag_modify(struct nb_cb_modify_args
*args
)
799 switch (args
->event
) {
804 /* TODO: implement me. */
811 int zebra_debugs_debug_mlag_destroy(struct nb_cb_destroy_args
*args
)
813 switch (args
->event
) {
818 /* TODO: implement me. */
826 * XPath: /frr-interface:lib/interface/frr-zebra:zebra/ip-addrs
828 int lib_interface_zebra_ip_addrs_create(struct nb_cb_create_args
*args
)
830 struct interface
*ifp
;
831 struct prefix prefix
;
833 // addr_family = yang_dnode_get_enum(dnode, "./address-family");
834 yang_dnode_get_prefix(&prefix
, args
->dnode
, "./ip-prefix");
837 switch (args
->event
) {
839 if (prefix
.family
== AF_INET
840 && ipv4_martian(&prefix
.u
.prefix4
)) {
841 snprintfrr(args
->errmsg
, args
->errmsg_len
,
842 "invalid address %pFX", &prefix
);
843 return NB_ERR_VALIDATION
;
844 } else if (prefix
.family
== AF_INET6
845 && ipv6_martian(&prefix
.u
.prefix6
)) {
846 snprintfrr(args
->errmsg
, args
->errmsg_len
,
847 "invalid address %pFX", &prefix
);
848 return NB_ERR_VALIDATION
;
855 ifp
= nb_running_get_entry(args
->dnode
, NULL
, true);
856 if (prefix
.family
== AF_INET
)
857 if_ip_address_install(ifp
, &prefix
, NULL
, NULL
);
858 else if (prefix
.family
== AF_INET6
)
859 if_ipv6_address_install(ifp
, &prefix
, NULL
);
867 int lib_interface_zebra_ip_addrs_destroy(struct nb_cb_destroy_args
*args
)
869 struct interface
*ifp
;
870 struct prefix prefix
;
871 struct connected
*ifc
;
873 yang_dnode_get_prefix(&prefix
, args
->dnode
, "./ip-prefix");
876 switch (args
->event
) {
878 ifp
= nb_running_get_entry(args
->dnode
, NULL
, false);
882 if (prefix
.family
== AF_INET
) {
883 /* Check current interface address. */
884 ifc
= connected_check_ptp(ifp
, &prefix
, NULL
);
886 snprintf(args
->errmsg
, args
->errmsg_len
,
887 "interface %s Can't find address\n",
889 return NB_ERR_VALIDATION
;
891 } else if (prefix
.family
== AF_INET6
) {
892 /* Check current interface address. */
893 ifc
= connected_check(ifp
, &prefix
);
895 snprintf(args
->errmsg
, args
->errmsg_len
,
896 "interface can't find address %s",
898 return NB_ERR_VALIDATION
;
901 return NB_ERR_VALIDATION
;
903 /* This is not configured address. */
904 if (!CHECK_FLAG(ifc
->conf
, ZEBRA_IFC_CONFIGURED
)) {
905 snprintf(args
->errmsg
, args
->errmsg_len
,
906 "interface %s not configured", ifp
->name
);
907 return NB_ERR_VALIDATION
;
910 /* This is not real address or interface is not active. */
911 if (!CHECK_FLAG(ifc
->conf
, ZEBRA_IFC_QUEUED
)
912 || !CHECK_FLAG(ifp
->status
, ZEBRA_INTERFACE_ACTIVE
)) {
913 listnode_delete(ifp
->connected
, ifc
);
914 connected_free(&ifc
);
915 return NB_ERR_VALIDATION
;
922 ifp
= nb_running_get_entry(args
->dnode
, NULL
, true);
923 if_ip_address_uinstall(ifp
, &prefix
);
931 * XPath: /frr-interface:lib/interface/frr-zebra:zebra/ip-addrs/label
933 int lib_interface_zebra_ip_addrs_label_modify(struct nb_cb_modify_args
*args
)
935 switch (args
->event
) {
940 /* TODO: implement me. */
947 int lib_interface_zebra_ip_addrs_label_destroy(struct nb_cb_destroy_args
*args
)
949 switch (args
->event
) {
954 /* TODO: implement me. */
962 * XPath: /frr-interface:lib/interface/frr-zebra:zebra/ip-addrs/ip4-peer
964 int lib_interface_zebra_ip_addrs_ip4_peer_modify(struct nb_cb_modify_args
*args
)
966 switch (args
->event
) {
971 /* TODO: implement me. */
978 int lib_interface_zebra_ip_addrs_ip4_peer_destroy(
979 struct nb_cb_destroy_args
*args
)
981 switch (args
->event
) {
986 /* TODO: implement me. */
994 * XPath: /frr-interface:lib/interface/frr-zebra:zebra/multicast
996 int lib_interface_zebra_multicast_modify(struct nb_cb_modify_args
*args
)
998 if (args
->event
!= NB_EV_APPLY
)
1001 struct interface
*ifp
;
1003 ifp
= nb_running_get_entry(args
->dnode
, NULL
, true);
1005 if_multicast_set(ifp
);
1010 int lib_interface_zebra_multicast_destroy(struct nb_cb_destroy_args
*args
)
1012 if (args
->event
!= NB_EV_APPLY
)
1015 struct interface
*ifp
;
1017 ifp
= nb_running_get_entry(args
->dnode
, NULL
, true);
1019 if_multicast_unset(ifp
);
1025 * XPath: /frr-interface:lib/interface/frr-zebra:zebra/link-detect
1027 int lib_interface_zebra_link_detect_modify(struct nb_cb_modify_args
*args
)
1029 if (args
->event
!= NB_EV_APPLY
)
1032 struct interface
*ifp
;
1035 ifp
= nb_running_get_entry(args
->dnode
, NULL
, true);
1036 link_detect
= yang_dnode_get_bool(args
->dnode
, "./link-detect");
1038 if_linkdetect(ifp
, link_detect
);
1043 int lib_interface_zebra_link_detect_destroy(struct nb_cb_destroy_args
*args
)
1045 if (args
->event
!= NB_EV_APPLY
)
1048 struct interface
*ifp
;
1051 ifp
= nb_running_get_entry(args
->dnode
, NULL
, true);
1052 link_detect
= yang_dnode_get_bool(args
->dnode
, "./link-detect");
1054 if_linkdetect(ifp
, link_detect
);
1060 * XPath: /frr-interface:lib/interface/frr-zebra:zebra/shutdown
1062 int lib_interface_zebra_shutdown_modify(struct nb_cb_modify_args
*args
)
1064 if (args
->event
!= NB_EV_APPLY
)
1067 struct interface
*ifp
;
1069 ifp
= nb_running_get_entry(args
->dnode
, NULL
, true);
1076 int lib_interface_zebra_shutdown_destroy(struct nb_cb_destroy_args
*args
)
1078 if (args
->event
!= NB_EV_APPLY
)
1081 struct interface
*ifp
;
1083 ifp
= nb_running_get_entry(args
->dnode
, NULL
, true);
1085 if_no_shutdown(ifp
);
1091 * XPath: /frr-interface:lib/interface/frr-zebra:zebra/bandwidth
1093 int lib_interface_zebra_bandwidth_modify(struct nb_cb_modify_args
*args
)
1095 if (args
->event
!= NB_EV_APPLY
)
1098 struct interface
*ifp
;
1101 ifp
= nb_running_get_entry(args
->dnode
, NULL
, true);
1102 bandwidth
= yang_dnode_get_uint32(args
->dnode
, "./bandwidth");
1104 ifp
->bandwidth
= bandwidth
;
1106 /* force protocols to recalculate routes due to cost change */
1107 if (if_is_operative(ifp
))
1108 zebra_interface_up_update(ifp
);
1113 int lib_interface_zebra_bandwidth_destroy(struct nb_cb_destroy_args
*args
)
1115 if (args
->event
!= NB_EV_APPLY
)
1118 struct interface
*ifp
;
1120 ifp
= nb_running_get_entry(args
->dnode
, NULL
, true);
1124 /* force protocols to recalculate routes due to cost change */
1125 if (if_is_operative(ifp
))
1126 zebra_interface_up_update(ifp
);
1133 * /frr-interface:lib/interface/frr-zebra:zebra/link-params/legacy-admin-group
1135 int lib_interface_zebra_legacy_admin_group_modify(
1136 struct nb_cb_modify_args
*args
)
1138 struct interface
*ifp
;
1139 struct if_link_params
*iflp
;
1140 uint32_t admin_group_value
;
1142 ifp
= nb_running_get_entry(args
->dnode
, NULL
, true);
1143 admin_group_value
= yang_dnode_get_uint32(args
->dnode
, ".");
1146 return NB_ERR_RESOURCE
;
1148 iflp
= if_link_params_get(ifp
);
1150 switch (args
->event
) {
1151 case NB_EV_VALIDATE
:
1157 iflp
= if_link_params_enable(ifp
);
1159 iflp
->admin_grp
= admin_group_value
;
1160 SET_PARAM(iflp
, LP_ADM_GRP
);
1162 admin_group_clear(&iflp
->ext_admin_grp
);
1163 UNSET_PARAM(iflp
, LP_EXTEND_ADM_GRP
);
1165 if (if_is_operative(ifp
))
1166 zebra_interface_parameters_update(ifp
);
1172 int lib_interface_zebra_legacy_admin_group_destroy(
1173 struct nb_cb_destroy_args
*args
)
1175 struct interface
*ifp
;
1176 struct if_link_params
*iflp
;
1178 ifp
= nb_running_get_entry(args
->dnode
, NULL
, true);
1181 return NB_ERR_RESOURCE
;
1183 iflp
= if_link_params_get(ifp
);
1185 switch (args
->event
) {
1186 case NB_EV_VALIDATE
:
1192 iflp
= if_link_params_enable(ifp
);
1194 iflp
->admin_grp
= 0;
1195 UNSET_PARAM(iflp
, LP_ADM_GRP
);
1197 if (if_is_operative(ifp
))
1198 zebra_interface_parameters_update(ifp
);
1206 * /frr-interface:lib/interface/frr-zebra:zebra/link-params/affinities/affinity
1208 int lib_interface_zebra_affinity_create(struct nb_cb_create_args
*args
)
1210 struct interface
*ifp
;
1211 const char *affname
;
1212 struct if_link_params
*iflp
;
1213 struct affinity_map
*affmap
;
1214 enum affinity_mode affinity_mode
;
1217 ifp
= nb_running_get_entry(args
->dnode
, NULL
, true);
1218 affname
= yang_dnode_get_string(args
->dnode
, ".");
1219 affinity_mode
= yang_dnode_get_enum(args
->dnode
, "../../affinity-mode");
1222 return NB_ERR_RESOURCE
;
1224 affmap
= affinity_map_get(affname
);
1225 iflp
= if_link_params_get(ifp
);
1227 switch (args
->event
) {
1228 case NB_EV_VALIDATE
:
1230 snprintf(args
->errmsg
, args
->errmsg_len
,
1231 "affinity-map %s not found.", affname
);
1232 return NB_ERR_VALIDATION
;
1234 if (affinity_mode
== AFFINITY_MODE_STANDARD
&&
1235 affmap
->bit_position
> 31) {
1237 args
->errmsg
, args
->errmsg_len
,
1238 "affinity %s bit-position %d is not compatible with affinity-mode standard (bit-position > 31).",
1239 affname
, affmap
->bit_position
);
1240 return NB_ERR_VALIDATION
;
1248 iflp
= if_link_params_enable(ifp
);
1250 if (affmap
->bit_position
< 32 &&
1251 (affinity_mode
== AFFINITY_MODE_STANDARD
||
1252 affinity_mode
== AFFINITY_MODE_BOTH
)) {
1253 iflp
->admin_grp
|= 1 << affmap
->bit_position
;
1254 SET_PARAM(iflp
, LP_ADM_GRP
);
1256 if (affinity_mode
== AFFINITY_MODE_EXTENDED
||
1257 affinity_mode
== AFFINITY_MODE_BOTH
) {
1258 admin_group_set(&iflp
->ext_admin_grp
,
1259 affmap
->bit_position
);
1260 SET_PARAM(iflp
, LP_EXTEND_ADM_GRP
);
1263 if (if_is_operative(ifp
))
1264 zebra_interface_parameters_update(ifp
);
1270 int lib_interface_zebra_affinity_destroy(struct nb_cb_destroy_args
*args
)
1272 struct interface
*ifp
;
1273 const char *affname
;
1274 struct if_link_params
*iflp
;
1275 struct affinity_map
*affmap
;
1276 enum affinity_mode affinity_mode
;
1278 ifp
= nb_running_get_entry(args
->dnode
, NULL
, true);
1279 affname
= yang_dnode_get_string(args
->dnode
, ".");
1280 affinity_mode
= yang_dnode_get_enum(args
->dnode
, "../../affinity-mode");
1283 return NB_ERR_RESOURCE
;
1285 affmap
= affinity_map_get(affname
);
1286 iflp
= if_link_params_get(ifp
);
1288 switch (args
->event
) {
1289 case NB_EV_VALIDATE
:
1291 snprintf(args
->errmsg
, args
->errmsg_len
,
1292 "affinity-map %s not found.", affname
);
1293 return NB_ERR_VALIDATION
;
1302 if (affmap
->bit_position
< 32 &&
1303 (affinity_mode
== AFFINITY_MODE_STANDARD
||
1304 affinity_mode
== AFFINITY_MODE_BOTH
)) {
1305 iflp
->admin_grp
&= ~(1 << affmap
->bit_position
);
1306 if (iflp
->admin_grp
== 0)
1307 UNSET_PARAM(iflp
, LP_ADM_GRP
);
1309 if (affinity_mode
== AFFINITY_MODE_EXTENDED
||
1310 affinity_mode
== AFFINITY_MODE_BOTH
) {
1311 admin_group_unset(&iflp
->ext_admin_grp
,
1312 affmap
->bit_position
);
1313 if (admin_group_zero(&iflp
->ext_admin_grp
))
1314 UNSET_PARAM(iflp
, LP_EXTEND_ADM_GRP
);
1317 if (if_is_operative(ifp
))
1318 zebra_interface_parameters_update(ifp
);
1326 * /frr-interface:lib/interface/frr-zebra:zebra/link-params/affinity-mode
1328 int lib_interface_zebra_affinity_mode_modify(struct nb_cb_modify_args
*args
)
1330 struct interface
*ifp
;
1331 struct if_link_params
*iflp
;
1332 enum affinity_mode affinity_mode
;
1335 ifp
= nb_running_get_entry(args
->dnode
, NULL
, true);
1336 affinity_mode
= yang_dnode_get_enum(args
->dnode
, ".");
1339 return NB_ERR_RESOURCE
;
1341 iflp
= if_link_params_get(ifp
);
1343 switch (args
->event
) {
1344 case NB_EV_VALIDATE
:
1345 if (affinity_mode
== AFFINITY_MODE_STANDARD
&&
1346 admin_group_nb_words(&iflp
->ext_admin_grp
) > 1) {
1348 args
->errmsg
, args
->errmsg_len
,
1349 "affinity-mode standard cannot be set when a bit-position > 31 is set.");
1350 return NB_ERR_VALIDATION
;
1358 iflp
= if_link_params_enable(ifp
);
1359 if (affinity_mode
== AFFINITY_MODE_STANDARD
) {
1360 if (!IS_PARAM_SET(iflp
, LP_ADM_GRP
) &&
1361 IS_PARAM_SET(iflp
, LP_EXTEND_ADM_GRP
)) {
1362 iflp
->admin_grp
= admin_group_get_offset(
1363 &iflp
->ext_admin_grp
, 0);
1364 SET_PARAM(iflp
, LP_ADM_GRP
);
1366 admin_group_clear(&iflp
->ext_admin_grp
);
1367 UNSET_PARAM(iflp
, LP_EXTEND_ADM_GRP
);
1369 if (affinity_mode
== AFFINITY_MODE_EXTENDED
) {
1370 if (!IS_PARAM_SET(iflp
, LP_EXTEND_ADM_GRP
) &&
1371 IS_PARAM_SET(iflp
, LP_ADM_GRP
)) {
1372 admin_group_bulk_set(&iflp
->ext_admin_grp
,
1373 iflp
->admin_grp
, 0);
1374 SET_PARAM(iflp
, LP_EXTEND_ADM_GRP
);
1376 iflp
->admin_grp
= 0;
1377 UNSET_PARAM(iflp
, LP_ADM_GRP
);
1379 if (affinity_mode
== AFFINITY_MODE_BOTH
) {
1380 if (!IS_PARAM_SET(iflp
, LP_EXTEND_ADM_GRP
) &&
1381 IS_PARAM_SET(iflp
, LP_ADM_GRP
)) {
1382 admin_group_bulk_set(&iflp
->ext_admin_grp
,
1383 iflp
->admin_grp
, 0);
1384 SET_PARAM(iflp
, LP_EXTEND_ADM_GRP
);
1385 } else if (!IS_PARAM_SET(iflp
, LP_ADM_GRP
) &&
1386 IS_PARAM_SET(iflp
, LP_EXTEND_ADM_GRP
)) {
1387 iflp
->admin_grp
= admin_group_get_offset(
1388 &iflp
->ext_admin_grp
, 0);
1389 SET_PARAM(iflp
, LP_ADM_GRP
);
1393 if (if_is_operative(ifp
))
1394 zebra_interface_parameters_update(ifp
);
1401 * XPath: /frr-vrf:lib/vrf/frr-zebra:zebra/l3vni-id
1403 int lib_vrf_zebra_l3vni_id_modify(struct nb_cb_modify_args
*args
)
1406 struct zebra_vrf
*zvrf
;
1408 struct zebra_l3vni
*zl3vni
= NULL
;
1409 char err
[ERR_STR_SZ
];
1410 bool pfx_only
= false;
1411 const struct lyd_node
*pn_dnode
;
1412 const char *vrfname
;
1414 switch (args
->event
) {
1418 case NB_EV_VALIDATE
:
1419 vni
= yang_dnode_get_uint32(args
->dnode
, NULL
);
1420 /* Get vrf info from parent node, reject configuration
1421 * if zebra vrf already mapped to different vni id.
1423 pn_dnode
= yang_dnode_get_parent(args
->dnode
, "vrf");
1424 vrfname
= yang_dnode_get_string(pn_dnode
, "./name");
1425 zvrf
= zebra_vrf_lookup_by_name(vrfname
);
1427 snprintf(args
->errmsg
, args
->errmsg_len
,
1428 "zebra vrf info not found for vrf:%s.",
1430 return NB_ERR_VALIDATION
;
1432 if (zvrf
->l3vni
&& zvrf
->l3vni
!= vni
) {
1434 args
->errmsg
, args
->errmsg_len
,
1435 "vni %u cannot be configured as vni %u is already configured under the vrf",
1437 return NB_ERR_VALIDATION
;
1440 /* Check if this VNI is already present in the system */
1441 zl3vni
= zl3vni_lookup(vni
);
1443 snprintf(args
->errmsg
, args
->errmsg_len
,
1444 "VNI %u is already configured as L3-VNI", vni
);
1445 return NB_ERR_VALIDATION
;
1451 vrf
= nb_running_get_entry(args
->dnode
, NULL
, true);
1452 zvrf
= zebra_vrf_lookup_by_name(vrf
->name
);
1453 vni
= yang_dnode_get_uint32(args
->dnode
, NULL
);
1454 /* Note: This covers lib_vrf_zebra_prefix_only_modify() config
1455 * along with l3vni config
1457 pfx_only
= yang_dnode_get_bool(args
->dnode
, "../prefix-only");
1459 if (zebra_vxlan_process_vrf_vni_cmd(zvrf
, vni
, err
, ERR_STR_SZ
,
1460 pfx_only
? 1 : 0, 1)
1462 if (IS_ZEBRA_DEBUG_VXLAN
)
1464 args
->errmsg
, args
->errmsg_len
,
1465 "vrf vni %u mapping failed with error: %s",
1476 int lib_vrf_zebra_l3vni_id_destroy(struct nb_cb_destroy_args
*args
)
1479 struct zebra_vrf
*zvrf
;
1481 char err
[ERR_STR_SZ
];
1484 switch (args
->event
) {
1487 case NB_EV_VALIDATE
:
1490 vrf
= nb_running_get_entry(args
->dnode
, NULL
, true);
1491 zvrf
= zebra_vrf_lookup_by_name(vrf
->name
);
1492 vni
= yang_dnode_get_uint32(args
->dnode
, NULL
);
1494 if (!zl3vni_lookup(vni
))
1497 if (zvrf
->l3vni
!= vni
) {
1498 snprintf(args
->errmsg
, args
->errmsg_len
,
1499 "vrf %s has different vni %u mapped",
1500 vrf
->name
, zvrf
->l3vni
);
1504 if (is_l3vni_for_prefix_routes_only(zvrf
->l3vni
))
1507 if (zebra_vxlan_process_vrf_vni_cmd(zvrf
, vni
, err
, ERR_STR_SZ
,
1510 if (IS_ZEBRA_DEBUG_VXLAN
)
1512 "vrf vni %u unmapping failed with error: %s",
1524 * XPath: /frr-vrf:lib/vrf/frr-zebra:zebra/prefix-only
1526 int lib_vrf_zebra_prefix_only_modify(struct nb_cb_modify_args
*args
)
1528 switch (args
->event
) {
1529 case NB_EV_VALIDATE
:
1533 /* TODO: implement me. */