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
;
38 const struct lyd_node
*vrf_dnode
;
43 switch (args
->event
) {
45 vrf_dnode
= yang_dnode_get_parent(args
->dnode
,
46 "control-plane-protocol");
47 vrf
= yang_dnode_get_string(vrf_dnode
, "./vrf");
48 table_id
= yang_dnode_get_uint32(args
->dnode
, "./table-id");
51 * TableId is not applicable for VRF. Consider the case of
52 * l3mdev, there is one uint32_t space to work with.
53 * A l3mdev device points at a specific table that it
54 * relates to and a set of interfaces it belongs to.
56 if (table_id
&& (strcmp(vrf
, vrf_get_default_name()) != 0)
57 && !vrf_is_backend_netns()) {
59 args
->errmsg
, args
->errmsg_len
,
60 "%% table param only available when running on netns-based vrfs");
61 return NB_ERR_VALIDATION
;
68 rn
= nb_running_get_entry(args
->dnode
, NULL
, true);
69 distance
= yang_dnode_get_uint8(args
->dnode
, "./distance");
70 table_id
= yang_dnode_get_uint32(args
->dnode
, "./table-id");
71 pn
= static_add_path(rn
, table_id
, distance
);
72 nb_running_set_entry(args
->dnode
, pn
);
78 static void static_path_list_destroy(struct nb_cb_destroy_args
*args
,
79 const struct lyd_node
*rn_dnode
,
80 struct stable_info
*info
)
82 struct route_node
*rn
;
83 struct static_path
*pn
;
85 pn
= nb_running_unset_entry(args
->dnode
);
86 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
87 static_del_path(rn
, pn
, info
->safi
, info
->svrf
);
90 static void static_path_list_tag_modify(struct nb_cb_modify_args
*args
,
91 const struct lyd_node
*rn_dnode
,
92 struct stable_info
*info
)
94 struct static_path
*pn
;
95 struct route_node
*rn
;
98 tag
= yang_dnode_get_uint32(args
->dnode
, NULL
);
99 pn
= nb_running_get_entry(args
->dnode
, NULL
, true);
101 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
103 static_install_path(rn
, pn
, info
->safi
, info
->svrf
);
106 static bool static_nexthop_create(struct nb_cb_create_args
*args
,
107 const struct lyd_node
*rn_dnode
,
108 struct stable_info
*info
)
110 struct route_node
*rn
;
111 struct static_path
*pn
;
112 struct ipaddr ipaddr
;
113 struct static_nexthop
*nh
;
118 switch (args
->event
) {
120 ifname
= yang_dnode_get_string(args
->dnode
, "./interface");
121 if (ifname
!= NULL
) {
122 if (strcasecmp(ifname
, "Null0") == 0
123 || strcasecmp(ifname
, "reject") == 0
124 || strcasecmp(ifname
, "blackhole") == 0) {
125 snprintf(args
->errmsg
, args
->errmsg_len
,
126 "%s: Nexthop interface name can not be from reserved keywords(Null0, reject, blackhole)",
128 return NB_ERR_VALIDATION
;
136 yang_dnode_get_ip(&ipaddr
, args
->dnode
, "./gateway");
137 nh_type
= yang_dnode_get_enum(args
->dnode
, "./nh-type");
138 ifname
= yang_dnode_get_string(args
->dnode
, "./interface");
139 nh_vrf
= yang_dnode_get_string(args
->dnode
, "./vrf");
140 pn
= nb_running_get_entry(args
->dnode
, NULL
, true);
141 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
143 if (!static_add_nexthop_validate(nh_vrf
, nh_type
, &ipaddr
))
145 EC_LIB_NB_CB_CONFIG_VALIDATE
,
146 "Warning!! Local connected address is configured as Gateway IP((%s))",
147 yang_dnode_get_string(args
->dnode
,
149 nh
= static_add_nexthop(rn
, pn
, info
->safi
, info
->svrf
, nh_type
,
150 &ipaddr
, ifname
, nh_vrf
, 0);
151 nb_running_set_entry(args
->dnode
, nh
);
158 static bool static_nexthop_destroy(struct nb_cb_destroy_args
*args
,
159 const struct lyd_node
*rn_dnode
,
160 struct stable_info
*info
)
162 struct route_node
*rn
;
163 struct static_path
*pn
;
164 const struct lyd_node
*pn_dnode
;
165 struct static_nexthop
*nh
;
168 nh
= nb_running_unset_entry(args
->dnode
);
169 pn_dnode
= yang_dnode_get_parent(args
->dnode
, "path-list");
170 pn
= nb_running_get_entry(pn_dnode
, NULL
, true);
171 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
173 ret
= static_delete_nexthop(rn
, pn
, info
->safi
, info
->svrf
, nh
);
175 char buf
[SRCDEST2STR_BUFFER
];
177 flog_warn(EC_LIB_NB_CB_CONFIG_APPLY
,
178 "%s : nh [%d:%s:%s:%s] nexthop destroy failed",
179 srcdest_rnode2str(rn
, buf
, sizeof(buf
)),
180 yang_dnode_get_enum(args
->dnode
, "./nh-type"),
181 yang_dnode_get_string(args
->dnode
, "./interface"),
182 yang_dnode_get_string(args
->dnode
, "./gateway"),
183 yang_dnode_get_string(args
->dnode
, "./vrf"));
190 static int nexthop_mpls_label_stack_entry_create(struct nb_cb_create_args
*args
)
192 struct static_nexthop
*nh
;
196 switch (args
->event
) {
200 args
->errmsg
, args
->errmsg_len
,
201 "%% MPLS not turned on in kernel ignoring static route");
202 return NB_ERR_VALIDATION
;
209 nh
= nb_running_get_entry(args
->dnode
, NULL
, true);
210 pos
= yang_get_list_pos(args
->dnode
);
212 flog_warn(EC_LIB_NB_CB_CONFIG_APPLY
,
213 "libyang returns invalid label position");
216 /* Mapping to array = list-index -1 */
218 nh
->snh_label
.label
[index
] = 0;
219 nh
->snh_label
.num_labels
++;
227 nexthop_mpls_label_stack_entry_destroy(struct nb_cb_destroy_args
*args
)
229 struct static_nexthop
*nh
;
233 switch (args
->event
) {
239 nh
= nb_running_get_entry(args
->dnode
, NULL
, true);
240 pos
= yang_get_list_pos(args
->dnode
);
242 flog_warn(EC_LIB_NB_CB_CONFIG_APPLY
,
243 "libyang returns invalid label position");
247 nh
->snh_label
.label
[index
] = 0;
248 nh
->snh_label
.num_labels
--;
255 static int static_nexthop_mpls_label_modify(struct nb_cb_modify_args
*args
)
257 struct static_nexthop
*nh
;
261 nh
= nb_running_get_entry(args
->dnode
, NULL
, true);
262 pos
= yang_get_list_pos(args
->dnode
->parent
);
264 flog_warn(EC_LIB_NB_CB_CONFIG_APPLY
,
265 "libyang returns invalid label position");
268 /* Mapping to array = list-index -1 */
270 nh
->snh_label
.label
[index
] = yang_dnode_get_uint32(args
->dnode
, NULL
);
275 static int static_nexthop_onlink_modify(struct nb_cb_modify_args
*args
)
277 struct static_nexthop
*nh
;
278 static_types nh_type
;
280 switch (args
->event
) {
282 nh_type
= yang_dnode_get_enum(args
->dnode
, "../nh-type");
283 if ((nh_type
!= STATIC_IPV4_GATEWAY_IFNAME
)
284 && (nh_type
!= STATIC_IPV6_GATEWAY_IFNAME
)) {
286 args
->errmsg
, args
->errmsg_len
,
287 "nexthop type is not the ipv4 or ipv6 interface type");
288 return NB_ERR_VALIDATION
;
295 nh
= nb_running_get_entry(args
->dnode
, NULL
, true);
296 nh
->onlink
= yang_dnode_get_bool(args
->dnode
, NULL
);
303 static int static_nexthop_color_modify(struct nb_cb_modify_args
*args
)
305 struct static_nexthop
*nh
;
307 nh
= nb_running_get_entry(args
->dnode
, NULL
, true);
308 nh
->color
= yang_dnode_get_uint32(args
->dnode
, NULL
);
313 static int static_nexthop_color_destroy(struct nb_cb_destroy_args
*args
)
315 struct static_nexthop
*nh
;
317 nh
= nb_running_unset_entry(args
->dnode
);
323 static int static_nexthop_bh_type_modify(struct nb_cb_modify_args
*args
)
325 struct static_nexthop
*nh
;
326 static_types nh_type
;
328 switch (args
->event
) {
330 nh_type
= yang_dnode_get_enum(args
->dnode
, "../nh-type");
331 if (nh_type
!= STATIC_BLACKHOLE
) {
332 snprintf(args
->errmsg
, args
->errmsg_len
,
333 "nexthop type is not the blackhole type");
334 return NB_ERR_VALIDATION
;
341 nh
= nb_running_get_entry(args
->dnode
, NULL
, true);
342 nh
->bh_type
= yang_dnode_get_enum(args
->dnode
, NULL
);
350 void routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_apply_finish(
351 struct nb_cb_apply_finish_args
*args
)
353 struct static_nexthop
*nh
;
354 struct static_path
*pn
;
355 struct route_node
*rn
;
356 const struct lyd_node
*pn_dnode
;
357 const struct lyd_node
*rn_dnode
;
360 struct stable_info
*info
;
363 nh_type
= yang_dnode_get_enum(args
->dnode
, "./nh-type");
364 ifname
= yang_dnode_get_string(args
->dnode
, "./interface");
365 nh_vrf
= yang_dnode_get_string(args
->dnode
, "./vrf");
367 nh
= nb_running_get_entry(args
->dnode
, NULL
, true);
369 pn_dnode
= yang_dnode_get_parent(args
->dnode
, "path-list");
370 pn
= nb_running_get_entry(pn_dnode
, NULL
, true);
372 rn_dnode
= yang_dnode_get_parent(pn_dnode
, "route-list");
373 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
374 info
= route_table_get_info(rn
->table
);
376 static_install_nexthop(rn
, pn
, nh
, info
->safi
, info
->svrf
, ifname
,
381 void routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_apply_finish(
382 struct nb_cb_apply_finish_args
*args
)
384 struct static_nexthop
*nh
;
385 struct static_path
*pn
;
386 struct route_node
*rn
;
387 struct route_node
*src_rn
;
388 const struct lyd_node
*pn_dnode
;
389 const struct lyd_node
*rn_dnode
;
390 const struct lyd_node
*src_dnode
;
393 struct stable_info
*info
;
396 nh_type
= yang_dnode_get_enum(args
->dnode
, "./nh-type");
397 ifname
= yang_dnode_get_string(args
->dnode
, "./interface");
398 nh_vrf
= yang_dnode_get_string(args
->dnode
, "./vrf");
400 nh
= nb_running_get_entry(args
->dnode
, NULL
, true);
402 pn_dnode
= yang_dnode_get_parent(args
->dnode
, "path-list");
403 pn
= nb_running_get_entry(pn_dnode
, NULL
, true);
405 src_dnode
= yang_dnode_get_parent(pn_dnode
, "src-list");
406 src_rn
= nb_running_get_entry(src_dnode
, NULL
, true);
408 rn_dnode
= yang_dnode_get_parent(src_dnode
, "route-list");
409 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
410 info
= route_table_get_info(rn
->table
);
412 static_install_nexthop(src_rn
, pn
, nh
, info
->safi
, info
->svrf
, ifname
,
415 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_pre_validate(
416 struct nb_cb_pre_validate_args
*args
)
418 const struct lyd_node
*mls_dnode
;
421 mls_dnode
= yang_dnode_get(args
->dnode
, "./mpls-label-stack");
422 count
= yang_get_list_elements_count(yang_dnode_get_child(mls_dnode
));
424 if (count
> MPLS_MAX_LABELS
) {
425 snprintf(args
->errmsg
, args
->errmsg_len
,
426 "Too many labels, Enter %d or fewer",
428 return NB_ERR_VALIDATION
;
433 int routing_control_plane_protocols_name_validate(
434 struct nb_cb_create_args
*args
)
438 name
= yang_dnode_get_string(args
->dnode
, "./name");
439 if (!strmatch(name
, "staticd")) {
440 snprintf(args
->errmsg
, args
->errmsg_len
,
441 "static routing supports only one instance with name staticd");
442 return NB_ERR_VALIDATION
;
448 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list
450 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_create(
451 struct nb_cb_create_args
*args
)
454 struct static_vrf
*s_vrf
;
455 struct route_node
*rn
;
456 const struct lyd_node
*vrf_dnode
;
457 struct prefix prefix
;
458 const char *afi_safi
;
463 switch (args
->event
) {
465 yang_dnode_get_prefix(&prefix
, args
->dnode
, "./prefix");
466 afi_safi
= yang_dnode_get_string(args
->dnode
, "./afi-safi");
467 yang_afi_safi_identity2value(afi_safi
, &afi
, &safi
);
468 prefix_afi
= family2afi(prefix
.family
);
469 if (afi
!= prefix_afi
) {
471 EC_LIB_NB_CB_CONFIG_VALIDATE
,
472 "route node %s creation failed",
473 yang_dnode_get_string(args
->dnode
, "./prefix"));
474 return NB_ERR_VALIDATION
;
481 vrf_dnode
= yang_dnode_get_parent(args
->dnode
,
482 "control-plane-protocol");
483 vrf
= nb_running_get_entry(vrf_dnode
, NULL
, true);
486 yang_dnode_get_prefix(&prefix
, args
->dnode
, "./prefix");
487 afi_safi
= yang_dnode_get_string(args
->dnode
, "./afi-safi");
488 yang_afi_safi_identity2value(afi_safi
, &afi
, &safi
);
490 rn
= static_add_route(afi
, safi
, &prefix
, NULL
, s_vrf
);
493 EC_LIB_NB_CB_CONFIG_APPLY
,
494 "route node %s creation failed",
495 yang_dnode_get_string(args
->dnode
, "./prefix"));
498 if (vrf
->vrf_id
== VRF_UNKNOWN
)
500 args
->errmsg
, args
->errmsg_len
,
501 "Static Route to %s not installed currently because dependent config not fully available",
502 yang_dnode_get_string(args
->dnode
, "./prefix"));
503 nb_running_set_entry(args
->dnode
, rn
);
509 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_destroy(
510 struct nb_cb_destroy_args
*args
)
512 struct route_node
*rn
;
513 struct stable_info
*info
;
515 switch (args
->event
) {
521 rn
= nb_running_unset_entry(args
->dnode
);
522 info
= route_table_get_info(rn
->table
);
523 static_del_route(rn
, info
->safi
, info
->svrf
);
531 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list
533 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_create(
534 struct nb_cb_create_args
*args
)
536 return static_path_list_create(args
);
539 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_destroy(
540 struct nb_cb_destroy_args
*args
)
542 const struct lyd_node
*rn_dnode
;
543 struct route_node
*rn
;
544 struct stable_info
*info
;
546 switch (args
->event
) {
552 rn_dnode
= yang_dnode_get_parent(args
->dnode
, "route-list");
553 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
554 info
= route_table_get_info(rn
->table
);
555 static_path_list_destroy(args
, rn_dnode
, info
);
563 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/tag
565 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_tag_modify(
566 struct nb_cb_modify_args
*args
)
568 struct stable_info
*info
;
569 struct route_node
*rn
;
570 const struct lyd_node
*rn_dnode
;
572 switch (args
->event
) {
578 rn_dnode
= yang_dnode_get_parent(args
->dnode
, "route-list");
579 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
580 info
= route_table_get_info(rn
->table
);
581 static_path_list_tag_modify(args
, rn_dnode
, info
);
590 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop
592 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_create(
593 struct nb_cb_create_args
*args
)
595 struct route_node
*rn
;
596 const struct lyd_node
*rn_dnode
;
597 struct stable_info
*info
;
599 switch (args
->event
) {
601 rn_dnode
= yang_dnode_get_parent(args
->dnode
, "route-list");
602 if (static_nexthop_create(args
, rn_dnode
, NULL
) != NB_OK
)
603 return NB_ERR_VALIDATION
;
609 rn_dnode
= yang_dnode_get_parent(args
->dnode
, "route-list");
610 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
611 info
= route_table_get_info(rn
->table
);
613 if (static_nexthop_create(args
, rn_dnode
, info
) != NB_OK
)
614 return NB_ERR_INCONSISTENCY
;
620 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_destroy(
621 struct nb_cb_destroy_args
*args
)
623 struct route_node
*rn
;
624 const struct lyd_node
*rn_dnode
;
625 struct stable_info
*info
;
627 switch (args
->event
) {
633 rn_dnode
= yang_dnode_get_parent(args
->dnode
, "route-list");
634 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
635 info
= route_table_get_info(rn
->table
);
637 if (static_nexthop_destroy(args
, rn_dnode
, info
) != NB_OK
)
646 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/bh-type
648 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_bh_type_modify(
649 struct nb_cb_modify_args
*args
)
651 return static_nexthop_bh_type_modify(args
);
654 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_bh_type_destroy(
655 struct nb_cb_destroy_args
*args
)
657 /* blackhole type has a boolean type with default value,
658 * so no need to do any operations in destroy callback
660 switch (args
->event
) {
672 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/onlink
674 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_onlink_modify(
675 struct nb_cb_modify_args
*args
)
677 return static_nexthop_onlink_modify(args
);
682 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/srte-color
684 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_color_modify(
685 struct nb_cb_modify_args
*args
)
687 switch (args
->event
) {
693 if (static_nexthop_color_modify(args
) != NB_OK
)
701 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_color_destroy(
702 struct nb_cb_destroy_args
*args
)
704 switch (args
->event
) {
710 if (static_nexthop_color_destroy(args
) != NB_OK
)
719 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/mpls-label-stack/entry
721 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_create(
722 struct nb_cb_create_args
*args
)
724 return nexthop_mpls_label_stack_entry_create(args
);
727 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_destroy(
728 struct nb_cb_destroy_args
*args
)
730 return nexthop_mpls_label_stack_entry_destroy(args
);
735 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/mpls-label-stack/entry/label
737 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_label_modify(
738 struct nb_cb_modify_args
*args
)
740 switch (args
->event
) {
746 if (static_nexthop_mpls_label_modify(args
) != NB_OK
)
753 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_label_destroy(
754 struct nb_cb_destroy_args
*args
)
757 * No operation is required in this call back.
758 * nexthop_mpls_label_stack_entry_destroy() will take care
759 * to reset the label vaue.
761 switch (args
->event
) {
773 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/mpls-label-stack/entry/ttl
775 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_ttl_modify(
776 struct nb_cb_modify_args
*args
)
778 switch (args
->event
) {
789 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_ttl_destroy(
790 struct nb_cb_destroy_args
*args
)
792 switch (args
->event
) {
805 * /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
807 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_traffic_class_modify(
808 struct nb_cb_modify_args
*args
)
810 switch (args
->event
) {
821 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_traffic_class_destroy(
822 struct nb_cb_destroy_args
*args
)
824 switch (args
->event
) {
837 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list
839 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_create(
840 struct nb_cb_create_args
*args
)
842 struct static_vrf
*s_vrf
;
843 struct route_node
*rn
;
844 struct route_node
*src_rn
;
845 struct prefix_ipv6 src_prefix
= {};
846 struct stable_info
*info
;
848 safi_t safi
= SAFI_UNICAST
;
850 switch (args
->event
) {
856 rn
= nb_running_get_entry(args
->dnode
, NULL
, true);
857 info
= route_table_get_info(rn
->table
);
859 yang_dnode_get_ipv6p(&src_prefix
, args
->dnode
, "./src-prefix");
860 afi
= family2afi(src_prefix
.family
);
862 static_add_route(afi
, safi
, &rn
->p
, &src_prefix
, s_vrf
);
864 flog_warn(EC_LIB_NB_CB_CONFIG_APPLY
,
865 "src rn %s creation failed",
866 yang_dnode_get_string(args
->dnode
,
870 nb_running_set_entry(args
->dnode
, src_rn
);
876 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_destroy(
877 struct nb_cb_destroy_args
*args
)
879 struct route_node
*src_rn
;
880 struct route_node
*rn
;
881 struct stable_info
*info
;
882 const struct lyd_node
*rn_dnode
;
884 switch (args
->event
) {
890 src_rn
= nb_running_unset_entry(args
->dnode
);
891 rn_dnode
= yang_dnode_get_parent(args
->dnode
, "route-list");
892 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
893 info
= route_table_get_info(rn
->table
);
894 static_del_route(src_rn
, info
->safi
, info
->svrf
);
903 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list
905 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_create(
906 struct nb_cb_create_args
*args
)
908 return static_path_list_create(args
);
911 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_destroy(
912 struct nb_cb_destroy_args
*args
)
914 struct route_node
*rn
;
915 const struct lyd_node
*rn_dnode
;
916 const struct lyd_node
*srn_dnode
;
917 struct stable_info
*info
;
919 switch (args
->event
) {
925 srn_dnode
= yang_dnode_get_parent(args
->dnode
, "src-list");
926 rn_dnode
= yang_dnode_get_parent(srn_dnode
, "route-list");
927 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
928 info
= route_table_get_info(rn
->table
);
929 static_path_list_destroy(args
, srn_dnode
, info
);
937 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/tag
939 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_tag_modify(
940 struct nb_cb_modify_args
*args
)
942 struct stable_info
*info
;
943 struct route_node
*rn
;
944 const struct lyd_node
*srn_dnode
;
945 const struct lyd_node
*rn_dnode
;
947 switch (args
->event
) {
953 srn_dnode
= yang_dnode_get_parent(args
->dnode
, "src-list");
954 rn_dnode
= yang_dnode_get_parent(srn_dnode
, "route-list");
955 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
956 info
= route_table_get_info(rn
->table
);
957 static_path_list_tag_modify(args
, srn_dnode
, info
);
965 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/frr-nexthops/nexthop
967 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_create(
968 struct nb_cb_create_args
*args
)
970 struct route_node
*rn
;
971 const struct lyd_node
*rn_dnode
;
972 const struct lyd_node
*src_dnode
;
973 struct stable_info
*info
;
975 switch (args
->event
) {
977 rn_dnode
= yang_dnode_get_parent(args
->dnode
, "route-list");
978 if (static_nexthop_create(args
, rn_dnode
, NULL
) != NB_OK
)
979 return NB_ERR_VALIDATION
;
985 src_dnode
= yang_dnode_get_parent(args
->dnode
, "src-list");
986 rn_dnode
= yang_dnode_get_parent(src_dnode
, "route-list");
987 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
988 info
= route_table_get_info(rn
->table
);
990 if (static_nexthop_create(args
, src_dnode
, info
) != NB_OK
)
991 return NB_ERR_VALIDATION
;
998 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_destroy(
999 struct nb_cb_destroy_args
*args
)
1001 struct route_node
*rn
;
1002 const struct lyd_node
*rn_dnode
;
1003 const struct lyd_node
*src_dnode
;
1004 struct stable_info
*info
;
1006 switch (args
->event
) {
1007 case NB_EV_VALIDATE
:
1012 src_dnode
= yang_dnode_get_parent(args
->dnode
, "src-list");
1013 rn_dnode
= yang_dnode_get_parent(src_dnode
, "route-list");
1014 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
1015 info
= route_table_get_info(rn
->table
);
1017 if (static_nexthop_destroy(args
, rn_dnode
, info
) != NB_OK
)
1026 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/frr-nexthops/nexthop/bh-type
1028 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_bh_type_modify(
1029 struct nb_cb_modify_args
*args
)
1031 return static_nexthop_bh_type_modify(args
);
1034 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_bh_type_destroy(
1035 struct nb_cb_destroy_args
*args
)
1037 /* blackhole type has a boolean type with default value,
1038 * so no need to do any operations in destroy callback
1040 switch (args
->event
) {
1041 case NB_EV_VALIDATE
:
1053 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/frr-nexthops/nexthop/onlink
1055 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_onlink_modify(
1056 struct nb_cb_modify_args
*args
)
1058 return static_nexthop_onlink_modify(args
);
1063 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/frr-nexthops/nexthop/srte-color
1065 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_color_modify(
1066 struct nb_cb_modify_args
*args
)
1068 switch (args
->event
) {
1069 case NB_EV_VALIDATE
:
1074 if (static_nexthop_color_modify(args
) != NB_OK
)
1083 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_color_destroy(
1084 struct nb_cb_destroy_args
*args
)
1086 switch (args
->event
) {
1087 case NB_EV_VALIDATE
:
1092 if (static_nexthop_color_destroy(args
) != NB_OK
)
1101 * /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
1103 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_create(
1104 struct nb_cb_create_args
*args
)
1106 return nexthop_mpls_label_stack_entry_create(args
);
1109 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_destroy(
1110 struct nb_cb_destroy_args
*args
)
1112 return nexthop_mpls_label_stack_entry_destroy(args
);
1117 * /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
1119 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_label_modify(
1120 struct nb_cb_modify_args
*args
)
1122 switch (args
->event
) {
1123 case NB_EV_VALIDATE
:
1128 if (static_nexthop_mpls_label_modify(args
) != NB_OK
)
1135 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_label_destroy(
1136 struct nb_cb_destroy_args
*args
)
1139 * No operation is required in this call back.
1140 * nexthop_mpls_label_stack_entry_destroy() will take care
1141 * to reset the label vaue.
1143 switch (args
->event
) {
1144 case NB_EV_VALIDATE
:
1155 * /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
1157 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_ttl_modify(
1158 struct nb_cb_modify_args
*args
)
1160 switch (args
->event
) {
1161 case NB_EV_VALIDATE
:
1171 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_ttl_destroy(
1172 struct nb_cb_destroy_args
*args
)
1174 switch (args
->event
) {
1175 case NB_EV_VALIDATE
:
1187 * /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
1189 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(
1190 struct nb_cb_modify_args
*args
)
1192 switch (args
->event
) {
1193 case NB_EV_VALIDATE
:
1203 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(
1204 struct nb_cb_destroy_args
*args
)
1206 switch (args
->event
) {
1207 case NB_EV_VALIDATE
: