2 * Copyright (C) 2018 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
19 #include "northbound.h"
22 #include "lib_errors.h"
27 #include "srcdest_table.h"
29 #include "static_vrf.h"
30 #include "static_routes.h"
31 #include "static_nb.h"
34 static int static_path_list_create(struct nb_cb_create_args
*args
)
36 struct route_node
*rn
;
37 struct static_path
*pn
;
40 switch (args
->event
) {
46 rn
= nb_running_get_entry(args
->dnode
, NULL
, true);
47 distance
= yang_dnode_get_uint8(args
->dnode
, "./distance");
48 pn
= static_add_path(rn
, distance
);
49 nb_running_set_entry(args
->dnode
, pn
);
55 static void static_path_list_destroy(struct nb_cb_destroy_args
*args
,
56 const struct lyd_node
*rn_dnode
,
57 struct stable_info
*info
)
59 struct route_node
*rn
;
60 struct static_path
*pn
;
62 pn
= nb_running_unset_entry(args
->dnode
);
63 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
64 static_del_path(rn
, pn
, info
->safi
, info
->svrf
);
67 static void static_path_list_tag_modify(struct nb_cb_modify_args
*args
,
68 const struct lyd_node
*rn_dnode
,
69 struct stable_info
*info
)
71 struct static_path
*pn
;
72 struct route_node
*rn
;
75 tag
= yang_dnode_get_uint32(args
->dnode
, NULL
);
76 pn
= nb_running_get_entry(args
->dnode
, NULL
, true);
78 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
80 static_install_path(rn
, pn
, info
->safi
, info
->svrf
);
83 static int static_path_list_tableid_modify(struct nb_cb_modify_args
*args
,
84 const struct lyd_node
*rn_dnode
,
85 struct stable_info
*info
)
87 struct static_path
*pn
;
88 struct route_node
*rn
;
90 const struct lyd_node
*vrf_dnode
;
93 switch (args
->event
) {
95 vrf_dnode
= yang_dnode_get_parent(args
->dnode
,
96 "control-plane-protocol");
97 vrf
= yang_dnode_get_string(vrf_dnode
, "./vrf");
98 table_id
= yang_dnode_get_uint32(args
->dnode
, NULL
);
99 if (table_id
&& (strcmp(vrf
, vrf_get_default_name()) != 0)
100 && !vrf_is_backend_netns()) {
101 snprintf(args
->errmsg
, args
->errmsg_len
,
102 "%% table param only available when running on netns-based vrfs");
103 return NB_ERR_VALIDATION
;
110 table_id
= yang_dnode_get_uint32(args
->dnode
, NULL
);
111 pn
= nb_running_get_entry(args
->dnode
, NULL
, true);
112 pn
->table_id
= table_id
;
113 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
114 static_install_path(rn
, pn
, info
->safi
, info
->svrf
);
121 static bool static_nexthop_create(struct nb_cb_create_args
*args
,
122 const struct lyd_node
*rn_dnode
,
123 struct stable_info
*info
)
125 struct route_node
*rn
;
126 struct static_path
*pn
;
127 struct ipaddr ipaddr
;
128 struct static_nexthop
*nh
;
133 switch (args
->event
) {
135 ifname
= yang_dnode_get_string(args
->dnode
, "./interface");
136 if (ifname
!= NULL
) {
137 if (strcasecmp(ifname
, "Null0") == 0
138 || strcasecmp(ifname
, "reject") == 0
139 || strcasecmp(ifname
, "blackhole") == 0) {
140 snprintf(args
->errmsg
, args
->errmsg_len
,
141 "%s: Nexthop interface name can not be from reserved keywords(Null0, reject, blackhole)",
143 return NB_ERR_VALIDATION
;
151 yang_dnode_get_ip(&ipaddr
, args
->dnode
, "./gateway");
152 nh_type
= yang_dnode_get_enum(args
->dnode
, "./nh-type");
153 ifname
= yang_dnode_get_string(args
->dnode
, "./interface");
154 nh_vrf
= yang_dnode_get_string(args
->dnode
, "./vrf");
155 pn
= nb_running_get_entry(args
->dnode
, NULL
, true);
156 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
158 if (!static_add_nexthop_validate(info
->svrf
, nh_type
, &ipaddr
))
160 EC_LIB_NB_CB_CONFIG_VALIDATE
,
161 "Warning!! Local connected address is configured as Gateway IP((%s))",
162 yang_dnode_get_string(args
->dnode
,
164 nh
= static_add_nexthop(rn
, pn
, info
->safi
, info
->svrf
, nh_type
,
165 &ipaddr
, ifname
, nh_vrf
, 0);
167 char buf
[SRCDEST2STR_BUFFER
];
170 EC_LIB_NB_CB_CONFIG_APPLY
,
171 "%s : nh [%d:%s:%s:%s] nexthop creation failed",
172 srcdest_rnode2str(rn
, buf
, sizeof(buf
)),
174 yang_dnode_get_string(args
->dnode
, "./gateway"),
178 nb_running_set_entry(args
->dnode
, nh
);
185 static bool static_nexthop_destroy(struct nb_cb_destroy_args
*args
,
186 const struct lyd_node
*rn_dnode
,
187 struct stable_info
*info
)
189 struct route_node
*rn
;
190 struct static_path
*pn
;
191 const struct lyd_node
*pn_dnode
;
192 struct static_nexthop
*nh
;
195 nh
= nb_running_unset_entry(args
->dnode
);
196 pn_dnode
= yang_dnode_get_parent(args
->dnode
, "path-list");
197 pn
= nb_running_get_entry(pn_dnode
, NULL
, true);
198 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
200 ret
= static_delete_nexthop(rn
, pn
, info
->safi
, info
->svrf
, nh
);
202 char buf
[SRCDEST2STR_BUFFER
];
204 flog_warn(EC_LIB_NB_CB_CONFIG_APPLY
,
205 "%s : nh [%d:%s:%s:%s] nexthop destroy failed",
206 srcdest_rnode2str(rn
, buf
, sizeof(buf
)),
207 yang_dnode_get_enum(args
->dnode
, "./nh-type"),
208 yang_dnode_get_string(args
->dnode
, "./interface"),
209 yang_dnode_get_string(args
->dnode
, "./gateway"),
210 yang_dnode_get_string(args
->dnode
, "./vrf"));
217 static int nexthop_mpls_label_stack_entry_create(struct nb_cb_create_args
*args
)
219 struct static_nexthop
*nh
;
223 switch (args
->event
) {
229 nh
= nb_running_get_entry(args
->dnode
, NULL
, true);
230 pos
= yang_get_list_pos(args
->dnode
);
232 flog_warn(EC_LIB_NB_CB_CONFIG_APPLY
,
233 "libyang returns invalid label position");
236 /* Mapping to array = list-index -1 */
238 nh
->snh_label
.label
[index
] = 0;
239 nh
->snh_label
.num_labels
++;
247 nexthop_mpls_label_stack_entry_destroy(struct nb_cb_destroy_args
*args
)
249 struct static_nexthop
*nh
;
253 switch (args
->event
) {
259 nh
= nb_running_get_entry(args
->dnode
, NULL
, true);
260 pos
= yang_get_list_pos(args
->dnode
);
262 flog_warn(EC_LIB_NB_CB_CONFIG_APPLY
,
263 "libyang returns invalid label position");
267 nh
->snh_label
.label
[index
] = 0;
268 nh
->snh_label
.num_labels
--;
275 static int static_nexthop_mpls_label_modify(struct nb_cb_modify_args
*args
)
277 struct static_nexthop
*nh
;
281 nh
= nb_running_get_entry(args
->dnode
, NULL
, true);
282 pos
= yang_get_list_pos(args
->dnode
->parent
);
284 flog_warn(EC_LIB_NB_CB_CONFIG_APPLY
,
285 "libyang returns invalid label position");
288 /* Mapping to array = list-index -1 */
290 nh
->snh_label
.label
[index
] = yang_dnode_get_uint32(args
->dnode
, NULL
);
295 static int static_nexthop_onlink_modify(struct nb_cb_modify_args
*args
)
297 struct static_nexthop
*nh
;
299 nh
= nb_running_get_entry(args
->dnode
, NULL
, true);
300 nh
->onlink
= yang_dnode_get_bool(args
->dnode
, NULL
);
305 static int static_nexthop_color_modify(struct nb_cb_modify_args
*args
)
307 struct static_nexthop
*nh
;
309 nh
= nb_running_get_entry(args
->dnode
, NULL
, true);
310 nh
->color
= yang_dnode_get_uint32(args
->dnode
, NULL
);
315 static int static_nexthop_color_destroy(struct nb_cb_destroy_args
*args
)
317 struct static_nexthop
*nh
;
319 nh
= nb_running_unset_entry(args
->dnode
);
325 static int static_nexthop_bh_type_modify(struct nb_cb_modify_args
*args
)
327 struct static_nexthop
*nh
;
329 nh
= nb_running_get_entry(args
->dnode
, NULL
, true);
330 nh
->bh_type
= yang_dnode_get_enum(args
->dnode
, NULL
);
336 void routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_apply_finish(
337 struct nb_cb_apply_finish_args
*args
)
339 struct static_nexthop
*nh
;
340 struct static_path
*pn
;
341 struct route_node
*rn
;
342 const struct lyd_node
*pn_dnode
;
343 const struct lyd_node
*rn_dnode
;
346 struct stable_info
*info
;
349 nh_type
= yang_dnode_get_enum(args
->dnode
, "./nh-type");
350 ifname
= yang_dnode_get_string(args
->dnode
, "./interface");
351 nh_vrf
= yang_dnode_get_string(args
->dnode
, "./vrf");
353 nh
= nb_running_get_entry(args
->dnode
, NULL
, true);
355 pn_dnode
= yang_dnode_get_parent(args
->dnode
, "path-list");
356 pn
= nb_running_get_entry(pn_dnode
, NULL
, true);
358 rn_dnode
= yang_dnode_get_parent(pn_dnode
, "route-list");
359 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
360 info
= route_table_get_info(rn
->table
);
362 static_install_nexthop(rn
, pn
, nh
, info
->safi
, info
->svrf
, ifname
,
367 void routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_apply_finish(
368 struct nb_cb_apply_finish_args
*args
)
370 struct static_nexthop
*nh
;
371 struct static_path
*pn
;
372 struct route_node
*rn
;
373 struct route_node
*src_rn
;
374 const struct lyd_node
*pn_dnode
;
375 const struct lyd_node
*rn_dnode
;
376 const struct lyd_node
*src_dnode
;
379 struct stable_info
*info
;
382 nh_type
= yang_dnode_get_enum(args
->dnode
, "./nh-type");
383 ifname
= yang_dnode_get_string(args
->dnode
, "./interface");
384 nh_vrf
= yang_dnode_get_string(args
->dnode
, "./vrf");
386 nh
= nb_running_get_entry(args
->dnode
, NULL
, true);
388 pn_dnode
= yang_dnode_get_parent(args
->dnode
, "path-list");
389 pn
= nb_running_get_entry(pn_dnode
, NULL
, true);
391 src_dnode
= yang_dnode_get_parent(pn_dnode
, "src-list");
392 src_rn
= nb_running_get_entry(src_dnode
, NULL
, true);
394 rn_dnode
= yang_dnode_get_parent(src_dnode
, "route-list");
395 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
396 info
= route_table_get_info(rn
->table
);
398 static_install_nexthop(src_rn
, pn
, nh
, info
->safi
, info
->svrf
, ifname
,
401 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_pre_validate(
402 struct nb_cb_pre_validate_args
*args
)
404 const struct lyd_node
*mls_dnode
;
407 mls_dnode
= yang_dnode_get(args
->dnode
, "./mpls-label-stack");
408 count
= yang_get_list_elements_count(yang_dnode_get_child(mls_dnode
));
410 if (count
> MPLS_MAX_LABELS
) {
411 snprintf(args
->errmsg
, args
->errmsg_len
,
412 "Too many labels, Enter %d or fewer",
414 return NB_ERR_VALIDATION
;
419 int routing_control_plane_protocols_name_validate(
420 struct nb_cb_create_args
*args
)
424 name
= yang_dnode_get_string(args
->dnode
, "./name");
425 if (!strmatch(name
, "staticd")) {
426 snprintf(args
->errmsg
, args
->errmsg_len
,
427 "static routing supports only one instance with name staticd");
428 return NB_ERR_VALIDATION
;
434 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list
436 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_create(
437 struct nb_cb_create_args
*args
)
440 struct static_vrf
*s_vrf
;
441 struct route_node
*rn
;
442 const struct lyd_node
*vrf_dnode
;
443 struct prefix prefix
;
444 const char *afi_safi
;
449 switch (args
->event
) {
451 yang_dnode_get_prefix(&prefix
, args
->dnode
, "./prefix");
452 afi_safi
= yang_dnode_get_string(args
->dnode
, "./afi-safi");
453 yang_afi_safi_identity2value(afi_safi
, &afi
, &safi
);
454 prefix_afi
= family2afi(prefix
.family
);
455 if (afi
!= prefix_afi
) {
457 EC_LIB_NB_CB_CONFIG_VALIDATE
,
458 "route node %s creation failed",
459 yang_dnode_get_string(args
->dnode
, "./prefix"));
460 return NB_ERR_VALIDATION
;
467 vrf_dnode
= yang_dnode_get_parent(args
->dnode
,
468 "control-plane-protocol");
469 vrf
= nb_running_get_entry(vrf_dnode
, NULL
, true);
472 yang_dnode_get_prefix(&prefix
, args
->dnode
, "./prefix");
473 afi_safi
= yang_dnode_get_string(args
->dnode
, "./afi-safi");
474 yang_afi_safi_identity2value(afi_safi
, &afi
, &safi
);
476 rn
= static_add_route(afi
, safi
, &prefix
, NULL
, s_vrf
);
479 EC_LIB_NB_CB_CONFIG_APPLY
,
480 "route node %s creation failed",
481 yang_dnode_get_string(args
->dnode
, "./prefix"));
484 nb_running_set_entry(args
->dnode
, rn
);
490 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_destroy(
491 struct nb_cb_destroy_args
*args
)
493 struct route_node
*rn
;
494 struct stable_info
*info
;
496 switch (args
->event
) {
502 rn
= nb_running_unset_entry(args
->dnode
);
503 info
= route_table_get_info(rn
->table
);
504 static_del_route(rn
, info
->safi
, info
->svrf
);
512 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list
514 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_create(
515 struct nb_cb_create_args
*args
)
517 return static_path_list_create(args
);
520 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_destroy(
521 struct nb_cb_destroy_args
*args
)
523 const struct lyd_node
*rn_dnode
;
524 struct route_node
*rn
;
525 struct stable_info
*info
;
527 switch (args
->event
) {
533 rn_dnode
= yang_dnode_get_parent(args
->dnode
, "route-list");
534 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
535 info
= route_table_get_info(rn
->table
);
536 static_path_list_destroy(args
, rn_dnode
, info
);
544 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/tag
546 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_tag_modify(
547 struct nb_cb_modify_args
*args
)
549 struct stable_info
*info
;
550 struct route_node
*rn
;
551 const struct lyd_node
*rn_dnode
;
553 switch (args
->event
) {
559 rn_dnode
= yang_dnode_get_parent(args
->dnode
, "route-list");
560 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
561 info
= route_table_get_info(rn
->table
);
562 static_path_list_tag_modify(args
, rn_dnode
, info
);
571 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/table-id
573 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_table_id_modify(
574 struct nb_cb_modify_args
*args
)
576 struct route_node
*rn
;
577 const struct lyd_node
*rn_dnode
;
578 struct stable_info
*info
;
580 switch (args
->event
) {
582 if (static_path_list_tableid_modify(args
, NULL
, NULL
) != NB_OK
)
583 return NB_ERR_VALIDATION
;
589 rn_dnode
= yang_dnode_get_parent(args
->dnode
, "route-list");
590 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
591 info
= route_table_get_info(rn
->table
);
593 if (static_path_list_tableid_modify(args
, rn_dnode
, info
)
595 return NB_ERR_VALIDATION
;
603 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop
605 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_create(
606 struct nb_cb_create_args
*args
)
608 struct route_node
*rn
;
609 const struct lyd_node
*rn_dnode
;
610 struct stable_info
*info
;
612 switch (args
->event
) {
614 rn_dnode
= yang_dnode_get_parent(args
->dnode
, "route-list");
615 if (static_nexthop_create(args
, rn_dnode
, NULL
) != NB_OK
)
616 return NB_ERR_VALIDATION
;
622 rn_dnode
= yang_dnode_get_parent(args
->dnode
, "route-list");
623 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
624 info
= route_table_get_info(rn
->table
);
626 if (static_nexthop_create(args
, rn_dnode
, info
) != NB_OK
)
627 return NB_ERR_VALIDATION
;
633 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_destroy(
634 struct nb_cb_destroy_args
*args
)
636 struct route_node
*rn
;
637 const struct lyd_node
*rn_dnode
;
638 struct stable_info
*info
;
640 switch (args
->event
) {
646 rn_dnode
= yang_dnode_get_parent(args
->dnode
, "route-list");
647 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
648 info
= route_table_get_info(rn
->table
);
650 if (static_nexthop_destroy(args
, rn_dnode
, info
) != NB_OK
)
659 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/bh-type
661 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_bh_type_modify(
662 struct nb_cb_modify_args
*args
)
664 switch (args
->event
) {
670 if (static_nexthop_bh_type_modify(args
) != NB_OK
)
677 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_bh_type_destroy(
678 struct nb_cb_destroy_args
*args
)
680 /* blackhole type has a boolean type with default value,
681 * so no need to do any operations in destroy callback
683 switch (args
->event
) {
695 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/onlink
697 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_onlink_modify(
698 struct nb_cb_modify_args
*args
)
700 switch (args
->event
) {
706 if (static_nexthop_onlink_modify(args
) != NB_OK
)
713 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_onlink_destroy(
714 struct nb_cb_destroy_args
*args
)
716 /* onlink has a boolean type with default value,
717 * so no need to do any operations in destroy callback
719 switch (args
->event
) {
731 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/srte-color
733 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_color_modify(
734 struct nb_cb_modify_args
*args
)
736 switch (args
->event
) {
742 if (static_nexthop_color_modify(args
) != NB_OK
)
750 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_color_destroy(
751 struct nb_cb_destroy_args
*args
)
753 switch (args
->event
) {
759 if (static_nexthop_color_destroy(args
) != NB_OK
)
768 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/mpls-label-stack/entry
770 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_create(
771 struct nb_cb_create_args
*args
)
773 return nexthop_mpls_label_stack_entry_create(args
);
776 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_destroy(
777 struct nb_cb_destroy_args
*args
)
779 return nexthop_mpls_label_stack_entry_destroy(args
);
784 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/mpls-label-stack/entry/label
786 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_label_modify(
787 struct nb_cb_modify_args
*args
)
789 switch (args
->event
) {
795 if (static_nexthop_mpls_label_modify(args
) != NB_OK
)
802 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_label_destroy(
803 struct nb_cb_destroy_args
*args
)
806 * No operation is required in this call back.
807 * nexthop_mpls_label_stack_entry_destroy() will take care
808 * to reset the label vaue.
810 switch (args
->event
) {
822 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/mpls-label-stack/entry/ttl
824 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_ttl_modify(
825 struct nb_cb_modify_args
*args
)
827 switch (args
->event
) {
838 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_ttl_destroy(
839 struct nb_cb_destroy_args
*args
)
841 switch (args
->event
) {
854 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/mpls-label-stack/entry/traffic-class
856 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_traffic_class_modify(
857 struct nb_cb_modify_args
*args
)
859 switch (args
->event
) {
870 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_traffic_class_destroy(
871 struct nb_cb_destroy_args
*args
)
873 switch (args
->event
) {
886 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list
888 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_create(
889 struct nb_cb_create_args
*args
)
891 struct static_vrf
*s_vrf
;
892 struct route_node
*rn
;
893 struct route_node
*src_rn
;
894 struct prefix_ipv6 src_prefix
= {};
895 struct stable_info
*info
;
897 safi_t safi
= SAFI_UNICAST
;
899 switch (args
->event
) {
905 rn
= nb_running_get_entry(args
->dnode
, NULL
, true);
906 info
= route_table_get_info(rn
->table
);
908 yang_dnode_get_ipv6p(&src_prefix
, args
->dnode
, "./src-prefix");
909 afi
= family2afi(src_prefix
.family
);
911 static_add_route(afi
, safi
, &rn
->p
, &src_prefix
, s_vrf
);
913 flog_warn(EC_LIB_NB_CB_CONFIG_APPLY
,
914 "src rn %s creation failed",
915 yang_dnode_get_string(args
->dnode
,
919 nb_running_set_entry(args
->dnode
, src_rn
);
925 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_destroy(
926 struct nb_cb_destroy_args
*args
)
928 struct route_node
*src_rn
;
929 struct route_node
*rn
;
930 struct stable_info
*info
;
931 const struct lyd_node
*rn_dnode
;
933 switch (args
->event
) {
939 src_rn
= nb_running_unset_entry(args
->dnode
);
940 rn_dnode
= yang_dnode_get_parent(args
->dnode
, "route-list");
941 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
942 info
= route_table_get_info(rn
->table
);
943 static_del_route(src_rn
, info
->safi
, info
->svrf
);
952 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list
954 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_create(
955 struct nb_cb_create_args
*args
)
957 return static_path_list_create(args
);
960 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_destroy(
961 struct nb_cb_destroy_args
*args
)
963 struct route_node
*rn
;
964 const struct lyd_node
*rn_dnode
;
965 const struct lyd_node
*srn_dnode
;
966 struct stable_info
*info
;
968 switch (args
->event
) {
974 srn_dnode
= yang_dnode_get_parent(args
->dnode
, "src-list");
975 rn_dnode
= yang_dnode_get_parent(srn_dnode
, "route-list");
976 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
977 info
= route_table_get_info(rn
->table
);
978 static_path_list_destroy(args
, srn_dnode
, info
);
986 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/tag
988 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_tag_modify(
989 struct nb_cb_modify_args
*args
)
991 struct stable_info
*info
;
992 struct route_node
*rn
;
993 const struct lyd_node
*srn_dnode
;
994 const struct lyd_node
*rn_dnode
;
996 switch (args
->event
) {
1002 srn_dnode
= yang_dnode_get_parent(args
->dnode
, "src-list");
1003 rn_dnode
= yang_dnode_get_parent(srn_dnode
, "route-list");
1004 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
1005 info
= route_table_get_info(rn
->table
);
1006 static_path_list_tag_modify(args
, srn_dnode
, info
);
1014 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/table-id
1016 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_table_id_modify(
1017 struct nb_cb_modify_args
*args
)
1019 struct route_node
*rn
;
1020 const struct lyd_node
*rn_dnode
;
1021 const struct lyd_node
*src_dnode
;
1022 struct stable_info
*info
;
1024 switch (args
->event
) {
1025 case NB_EV_VALIDATE
:
1026 if (static_path_list_tableid_modify(args
, NULL
, NULL
) != NB_OK
)
1027 return NB_ERR_VALIDATION
;
1033 src_dnode
= yang_dnode_get_parent(args
->dnode
, "src-list");
1034 rn_dnode
= yang_dnode_get_parent(src_dnode
, "route-list");
1035 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
1036 info
= route_table_get_info(rn
->table
);
1038 if (static_path_list_tableid_modify(args
, src_dnode
, info
)
1040 return NB_ERR_VALIDATION
;
1049 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/frr-nexthops/nexthop
1051 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_create(
1052 struct nb_cb_create_args
*args
)
1054 struct route_node
*rn
;
1055 const struct lyd_node
*rn_dnode
;
1056 const struct lyd_node
*src_dnode
;
1057 struct stable_info
*info
;
1059 switch (args
->event
) {
1060 case NB_EV_VALIDATE
:
1061 rn_dnode
= yang_dnode_get_parent(args
->dnode
, "route-list");
1062 if (static_nexthop_create(args
, rn_dnode
, NULL
) != NB_OK
)
1063 return NB_ERR_VALIDATION
;
1069 src_dnode
= yang_dnode_get_parent(args
->dnode
, "src-list");
1070 rn_dnode
= yang_dnode_get_parent(src_dnode
, "route-list");
1071 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
1072 info
= route_table_get_info(rn
->table
);
1074 if (static_nexthop_create(args
, src_dnode
, info
) != NB_OK
)
1075 return NB_ERR_VALIDATION
;
1082 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_destroy(
1083 struct nb_cb_destroy_args
*args
)
1085 struct route_node
*rn
;
1086 const struct lyd_node
*rn_dnode
;
1087 const struct lyd_node
*src_dnode
;
1088 struct stable_info
*info
;
1090 switch (args
->event
) {
1091 case NB_EV_VALIDATE
:
1096 src_dnode
= yang_dnode_get_parent(args
->dnode
, "src-list");
1097 rn_dnode
= yang_dnode_get_parent(src_dnode
, "route-list");
1098 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
1099 info
= route_table_get_info(rn
->table
);
1101 if (static_nexthop_destroy(args
, rn_dnode
, info
) != NB_OK
)
1110 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/frr-nexthops/nexthop/bh-type
1112 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_bh_type_modify(
1113 struct nb_cb_modify_args
*args
)
1115 switch (args
->event
) {
1116 case NB_EV_VALIDATE
:
1121 if (static_nexthop_bh_type_modify(args
) != NB_OK
)
1128 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_bh_type_destroy(
1129 struct nb_cb_destroy_args
*args
)
1131 /* blackhole type has a boolean type with default value,
1132 * so no need to do any operations in destroy callback
1134 switch (args
->event
) {
1135 case NB_EV_VALIDATE
:
1147 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/frr-nexthops/nexthop/onlink
1149 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_onlink_modify(
1150 struct nb_cb_modify_args
*args
)
1152 switch (args
->event
) {
1153 case NB_EV_VALIDATE
:
1158 if (static_nexthop_onlink_modify(args
) != NB_OK
)
1167 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_onlink_destroy(
1168 struct nb_cb_destroy_args
*args
)
1170 /* onlink has a boolean type with default value,
1171 * so no need to do any operations in destroy callback
1173 switch (args
->event
) {
1174 case NB_EV_VALIDATE
:
1185 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/frr-nexthops/nexthop/srte-color
1187 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_color_modify(
1188 struct nb_cb_modify_args
*args
)
1190 switch (args
->event
) {
1191 case NB_EV_VALIDATE
:
1196 if (static_nexthop_color_modify(args
) != NB_OK
)
1205 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_color_destroy(
1206 struct nb_cb_destroy_args
*args
)
1208 switch (args
->event
) {
1209 case NB_EV_VALIDATE
:
1214 if (static_nexthop_color_destroy(args
) != NB_OK
)
1223 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/frr-nexthops/nexthop/mpls-label-stack/entry
1225 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_create(
1226 struct nb_cb_create_args
*args
)
1228 return nexthop_mpls_label_stack_entry_create(args
);
1231 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_destroy(
1232 struct nb_cb_destroy_args
*args
)
1234 return nexthop_mpls_label_stack_entry_destroy(args
);
1239 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/frr-nexthops/nexthop/mpls-label-stack/entry/label
1241 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_label_modify(
1242 struct nb_cb_modify_args
*args
)
1244 switch (args
->event
) {
1245 case NB_EV_VALIDATE
:
1250 if (static_nexthop_mpls_label_modify(args
) != NB_OK
)
1257 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_label_destroy(
1258 struct nb_cb_destroy_args
*args
)
1261 * No operation is required in this call back.
1262 * nexthop_mpls_label_stack_entry_destroy() will take care
1263 * to reset the label vaue.
1265 switch (args
->event
) {
1266 case NB_EV_VALIDATE
:
1277 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/frr-nexthops/nexthop/mpls-label-stack/entry/ttl
1279 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_ttl_modify(
1280 struct nb_cb_modify_args
*args
)
1282 switch (args
->event
) {
1283 case NB_EV_VALIDATE
:
1293 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_ttl_destroy(
1294 struct nb_cb_destroy_args
*args
)
1296 switch (args
->event
) {
1297 case NB_EV_VALIDATE
:
1309 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/frr-nexthops/nexthop/mpls-label-stack/entry/traffic-class
1311 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_traffic_class_modify(
1312 struct nb_cb_modify_args
*args
)
1314 switch (args
->event
) {
1315 case NB_EV_VALIDATE
:
1325 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_traffic_class_destroy(
1326 struct nb_cb_destroy_args
*args
)
1328 switch (args
->event
) {
1329 case NB_EV_VALIDATE
: