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
) {
227 args
->errmsg
, args
->errmsg_len
,
228 "%% MPLS not turned on in kernel ignoring static route");
229 return NB_ERR_VALIDATION
;
236 nh
= nb_running_get_entry(args
->dnode
, NULL
, true);
237 pos
= yang_get_list_pos(args
->dnode
);
239 flog_warn(EC_LIB_NB_CB_CONFIG_APPLY
,
240 "libyang returns invalid label position");
243 /* Mapping to array = list-index -1 */
245 nh
->snh_label
.label
[index
] = 0;
246 nh
->snh_label
.num_labels
++;
254 nexthop_mpls_label_stack_entry_destroy(struct nb_cb_destroy_args
*args
)
256 struct static_nexthop
*nh
;
260 switch (args
->event
) {
266 nh
= nb_running_get_entry(args
->dnode
, NULL
, true);
267 pos
= yang_get_list_pos(args
->dnode
);
269 flog_warn(EC_LIB_NB_CB_CONFIG_APPLY
,
270 "libyang returns invalid label position");
274 nh
->snh_label
.label
[index
] = 0;
275 nh
->snh_label
.num_labels
--;
282 static int static_nexthop_mpls_label_modify(struct nb_cb_modify_args
*args
)
284 struct static_nexthop
*nh
;
288 nh
= nb_running_get_entry(args
->dnode
, NULL
, true);
289 pos
= yang_get_list_pos(args
->dnode
->parent
);
291 flog_warn(EC_LIB_NB_CB_CONFIG_APPLY
,
292 "libyang returns invalid label position");
295 /* Mapping to array = list-index -1 */
297 nh
->snh_label
.label
[index
] = yang_dnode_get_uint32(args
->dnode
, NULL
);
302 static int static_nexthop_onlink_modify(struct nb_cb_modify_args
*args
)
304 struct static_nexthop
*nh
;
306 nh
= nb_running_get_entry(args
->dnode
, NULL
, true);
307 nh
->onlink
= yang_dnode_get_bool(args
->dnode
, NULL
);
312 static int static_nexthop_color_modify(struct nb_cb_modify_args
*args
)
314 struct static_nexthop
*nh
;
316 nh
= nb_running_get_entry(args
->dnode
, NULL
, true);
317 nh
->color
= yang_dnode_get_uint32(args
->dnode
, NULL
);
322 static int static_nexthop_color_destroy(struct nb_cb_destroy_args
*args
)
324 struct static_nexthop
*nh
;
326 nh
= nb_running_unset_entry(args
->dnode
);
332 static int static_nexthop_bh_type_modify(struct nb_cb_modify_args
*args
)
334 struct static_nexthop
*nh
;
336 nh
= nb_running_get_entry(args
->dnode
, NULL
, true);
337 nh
->bh_type
= yang_dnode_get_enum(args
->dnode
, NULL
);
343 void routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_apply_finish(
344 struct nb_cb_apply_finish_args
*args
)
346 struct static_nexthop
*nh
;
347 struct static_path
*pn
;
348 struct route_node
*rn
;
349 const struct lyd_node
*pn_dnode
;
350 const struct lyd_node
*rn_dnode
;
353 struct stable_info
*info
;
356 nh_type
= yang_dnode_get_enum(args
->dnode
, "./nh-type");
357 ifname
= yang_dnode_get_string(args
->dnode
, "./interface");
358 nh_vrf
= yang_dnode_get_string(args
->dnode
, "./vrf");
360 nh
= nb_running_get_entry(args
->dnode
, NULL
, true);
362 pn_dnode
= yang_dnode_get_parent(args
->dnode
, "path-list");
363 pn
= nb_running_get_entry(pn_dnode
, NULL
, true);
365 rn_dnode
= yang_dnode_get_parent(pn_dnode
, "route-list");
366 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
367 info
= route_table_get_info(rn
->table
);
369 static_install_nexthop(rn
, pn
, nh
, info
->safi
, info
->svrf
, ifname
,
374 void routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_apply_finish(
375 struct nb_cb_apply_finish_args
*args
)
377 struct static_nexthop
*nh
;
378 struct static_path
*pn
;
379 struct route_node
*rn
;
380 struct route_node
*src_rn
;
381 const struct lyd_node
*pn_dnode
;
382 const struct lyd_node
*rn_dnode
;
383 const struct lyd_node
*src_dnode
;
386 struct stable_info
*info
;
389 nh_type
= yang_dnode_get_enum(args
->dnode
, "./nh-type");
390 ifname
= yang_dnode_get_string(args
->dnode
, "./interface");
391 nh_vrf
= yang_dnode_get_string(args
->dnode
, "./vrf");
393 nh
= nb_running_get_entry(args
->dnode
, NULL
, true);
395 pn_dnode
= yang_dnode_get_parent(args
->dnode
, "path-list");
396 pn
= nb_running_get_entry(pn_dnode
, NULL
, true);
398 src_dnode
= yang_dnode_get_parent(pn_dnode
, "src-list");
399 src_rn
= nb_running_get_entry(src_dnode
, NULL
, true);
401 rn_dnode
= yang_dnode_get_parent(src_dnode
, "route-list");
402 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
403 info
= route_table_get_info(rn
->table
);
405 static_install_nexthop(src_rn
, pn
, nh
, info
->safi
, info
->svrf
, ifname
,
408 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_pre_validate(
409 struct nb_cb_pre_validate_args
*args
)
411 const struct lyd_node
*mls_dnode
;
414 mls_dnode
= yang_dnode_get(args
->dnode
, "./mpls-label-stack");
415 count
= yang_get_list_elements_count(yang_dnode_get_child(mls_dnode
));
417 if (count
> MPLS_MAX_LABELS
) {
418 snprintf(args
->errmsg
, args
->errmsg_len
,
419 "Too many labels, Enter %d or fewer",
421 return NB_ERR_VALIDATION
;
426 int routing_control_plane_protocols_name_validate(
427 struct nb_cb_create_args
*args
)
431 name
= yang_dnode_get_string(args
->dnode
, "./name");
432 if (!strmatch(name
, "staticd")) {
433 snprintf(args
->errmsg
, args
->errmsg_len
,
434 "static routing supports only one instance with name staticd");
435 return NB_ERR_VALIDATION
;
441 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list
443 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_create(
444 struct nb_cb_create_args
*args
)
447 struct static_vrf
*s_vrf
;
448 struct route_node
*rn
;
449 const struct lyd_node
*vrf_dnode
;
450 struct prefix prefix
;
451 const char *afi_safi
;
456 switch (args
->event
) {
458 yang_dnode_get_prefix(&prefix
, args
->dnode
, "./prefix");
459 afi_safi
= yang_dnode_get_string(args
->dnode
, "./afi-safi");
460 yang_afi_safi_identity2value(afi_safi
, &afi
, &safi
);
461 prefix_afi
= family2afi(prefix
.family
);
462 if (afi
!= prefix_afi
) {
464 EC_LIB_NB_CB_CONFIG_VALIDATE
,
465 "route node %s creation failed",
466 yang_dnode_get_string(args
->dnode
, "./prefix"));
467 return NB_ERR_VALIDATION
;
474 vrf_dnode
= yang_dnode_get_parent(args
->dnode
,
475 "control-plane-protocol");
476 vrf
= nb_running_get_entry(vrf_dnode
, NULL
, true);
479 yang_dnode_get_prefix(&prefix
, args
->dnode
, "./prefix");
480 afi_safi
= yang_dnode_get_string(args
->dnode
, "./afi-safi");
481 yang_afi_safi_identity2value(afi_safi
, &afi
, &safi
);
483 rn
= static_add_route(afi
, safi
, &prefix
, NULL
, s_vrf
);
486 EC_LIB_NB_CB_CONFIG_APPLY
,
487 "route node %s creation failed",
488 yang_dnode_get_string(args
->dnode
, "./prefix"));
491 if (vrf
->vrf_id
== VRF_UNKNOWN
)
493 args
->errmsg
, args
->errmsg_len
,
494 "Static Route to %s not installed currently because dependent config not fully available",
495 yang_dnode_get_string(args
->dnode
, "./prefix"));
496 nb_running_set_entry(args
->dnode
, rn
);
502 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_destroy(
503 struct nb_cb_destroy_args
*args
)
505 struct route_node
*rn
;
506 struct stable_info
*info
;
508 switch (args
->event
) {
514 rn
= nb_running_unset_entry(args
->dnode
);
515 info
= route_table_get_info(rn
->table
);
516 static_del_route(rn
, info
->safi
, info
->svrf
);
524 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list
526 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_create(
527 struct nb_cb_create_args
*args
)
529 return static_path_list_create(args
);
532 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_destroy(
533 struct nb_cb_destroy_args
*args
)
535 const struct lyd_node
*rn_dnode
;
536 struct route_node
*rn
;
537 struct stable_info
*info
;
539 switch (args
->event
) {
545 rn_dnode
= yang_dnode_get_parent(args
->dnode
, "route-list");
546 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
547 info
= route_table_get_info(rn
->table
);
548 static_path_list_destroy(args
, rn_dnode
, info
);
556 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/tag
558 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_tag_modify(
559 struct nb_cb_modify_args
*args
)
561 struct stable_info
*info
;
562 struct route_node
*rn
;
563 const struct lyd_node
*rn_dnode
;
565 switch (args
->event
) {
571 rn_dnode
= yang_dnode_get_parent(args
->dnode
, "route-list");
572 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
573 info
= route_table_get_info(rn
->table
);
574 static_path_list_tag_modify(args
, rn_dnode
, info
);
583 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/table-id
585 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_table_id_modify(
586 struct nb_cb_modify_args
*args
)
588 struct route_node
*rn
;
589 const struct lyd_node
*rn_dnode
;
590 struct stable_info
*info
;
592 switch (args
->event
) {
594 if (static_path_list_tableid_modify(args
, NULL
, NULL
) != NB_OK
)
595 return NB_ERR_VALIDATION
;
601 rn_dnode
= yang_dnode_get_parent(args
->dnode
, "route-list");
602 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
603 info
= route_table_get_info(rn
->table
);
605 if (static_path_list_tableid_modify(args
, rn_dnode
, info
)
607 return NB_ERR_VALIDATION
;
615 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop
617 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_create(
618 struct nb_cb_create_args
*args
)
620 struct route_node
*rn
;
621 const struct lyd_node
*rn_dnode
;
622 struct stable_info
*info
;
624 switch (args
->event
) {
626 rn_dnode
= yang_dnode_get_parent(args
->dnode
, "route-list");
627 if (static_nexthop_create(args
, rn_dnode
, NULL
) != NB_OK
)
628 return NB_ERR_VALIDATION
;
634 rn_dnode
= yang_dnode_get_parent(args
->dnode
, "route-list");
635 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
636 info
= route_table_get_info(rn
->table
);
638 if (static_nexthop_create(args
, rn_dnode
, info
) != NB_OK
)
639 return NB_ERR_VALIDATION
;
645 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_destroy(
646 struct nb_cb_destroy_args
*args
)
648 struct route_node
*rn
;
649 const struct lyd_node
*rn_dnode
;
650 struct stable_info
*info
;
652 switch (args
->event
) {
658 rn_dnode
= yang_dnode_get_parent(args
->dnode
, "route-list");
659 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
660 info
= route_table_get_info(rn
->table
);
662 if (static_nexthop_destroy(args
, rn_dnode
, info
) != NB_OK
)
671 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/bh-type
673 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_bh_type_modify(
674 struct nb_cb_modify_args
*args
)
676 switch (args
->event
) {
682 if (static_nexthop_bh_type_modify(args
) != NB_OK
)
689 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_bh_type_destroy(
690 struct nb_cb_destroy_args
*args
)
692 /* blackhole type has a boolean type with default value,
693 * so no need to do any operations in destroy callback
695 switch (args
->event
) {
707 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/onlink
709 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_onlink_modify(
710 struct nb_cb_modify_args
*args
)
712 switch (args
->event
) {
718 if (static_nexthop_onlink_modify(args
) != NB_OK
)
725 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_onlink_destroy(
726 struct nb_cb_destroy_args
*args
)
728 /* onlink has a boolean type with default value,
729 * so no need to do any operations in destroy callback
731 switch (args
->event
) {
743 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/srte-color
745 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_color_modify(
746 struct nb_cb_modify_args
*args
)
748 switch (args
->event
) {
754 if (static_nexthop_color_modify(args
) != NB_OK
)
762 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_color_destroy(
763 struct nb_cb_destroy_args
*args
)
765 switch (args
->event
) {
771 if (static_nexthop_color_destroy(args
) != NB_OK
)
780 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/mpls-label-stack/entry
782 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_create(
783 struct nb_cb_create_args
*args
)
785 return nexthop_mpls_label_stack_entry_create(args
);
788 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_destroy(
789 struct nb_cb_destroy_args
*args
)
791 return nexthop_mpls_label_stack_entry_destroy(args
);
796 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/mpls-label-stack/entry/label
798 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_label_modify(
799 struct nb_cb_modify_args
*args
)
801 switch (args
->event
) {
807 if (static_nexthop_mpls_label_modify(args
) != NB_OK
)
814 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_label_destroy(
815 struct nb_cb_destroy_args
*args
)
818 * No operation is required in this call back.
819 * nexthop_mpls_label_stack_entry_destroy() will take care
820 * to reset the label vaue.
822 switch (args
->event
) {
834 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/mpls-label-stack/entry/ttl
836 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_ttl_modify(
837 struct nb_cb_modify_args
*args
)
839 switch (args
->event
) {
850 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_ttl_destroy(
851 struct nb_cb_destroy_args
*args
)
853 switch (args
->event
) {
866 * /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
868 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_traffic_class_modify(
869 struct nb_cb_modify_args
*args
)
871 switch (args
->event
) {
882 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_traffic_class_destroy(
883 struct nb_cb_destroy_args
*args
)
885 switch (args
->event
) {
898 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list
900 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_create(
901 struct nb_cb_create_args
*args
)
903 struct static_vrf
*s_vrf
;
904 struct route_node
*rn
;
905 struct route_node
*src_rn
;
906 struct prefix_ipv6 src_prefix
= {};
907 struct stable_info
*info
;
909 safi_t safi
= SAFI_UNICAST
;
911 switch (args
->event
) {
917 rn
= nb_running_get_entry(args
->dnode
, NULL
, true);
918 info
= route_table_get_info(rn
->table
);
920 yang_dnode_get_ipv6p(&src_prefix
, args
->dnode
, "./src-prefix");
921 afi
= family2afi(src_prefix
.family
);
923 static_add_route(afi
, safi
, &rn
->p
, &src_prefix
, s_vrf
);
925 flog_warn(EC_LIB_NB_CB_CONFIG_APPLY
,
926 "src rn %s creation failed",
927 yang_dnode_get_string(args
->dnode
,
931 nb_running_set_entry(args
->dnode
, src_rn
);
937 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_destroy(
938 struct nb_cb_destroy_args
*args
)
940 struct route_node
*src_rn
;
941 struct route_node
*rn
;
942 struct stable_info
*info
;
943 const struct lyd_node
*rn_dnode
;
945 switch (args
->event
) {
951 src_rn
= nb_running_unset_entry(args
->dnode
);
952 rn_dnode
= yang_dnode_get_parent(args
->dnode
, "route-list");
953 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
954 info
= route_table_get_info(rn
->table
);
955 static_del_route(src_rn
, info
->safi
, info
->svrf
);
964 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list
966 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_create(
967 struct nb_cb_create_args
*args
)
969 return static_path_list_create(args
);
972 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_destroy(
973 struct nb_cb_destroy_args
*args
)
975 struct route_node
*rn
;
976 const struct lyd_node
*rn_dnode
;
977 const struct lyd_node
*srn_dnode
;
978 struct stable_info
*info
;
980 switch (args
->event
) {
986 srn_dnode
= yang_dnode_get_parent(args
->dnode
, "src-list");
987 rn_dnode
= yang_dnode_get_parent(srn_dnode
, "route-list");
988 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
989 info
= route_table_get_info(rn
->table
);
990 static_path_list_destroy(args
, srn_dnode
, info
);
998 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/tag
1000 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_tag_modify(
1001 struct nb_cb_modify_args
*args
)
1003 struct stable_info
*info
;
1004 struct route_node
*rn
;
1005 const struct lyd_node
*srn_dnode
;
1006 const struct lyd_node
*rn_dnode
;
1008 switch (args
->event
) {
1009 case NB_EV_VALIDATE
:
1014 srn_dnode
= yang_dnode_get_parent(args
->dnode
, "src-list");
1015 rn_dnode
= yang_dnode_get_parent(srn_dnode
, "route-list");
1016 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
1017 info
= route_table_get_info(rn
->table
);
1018 static_path_list_tag_modify(args
, srn_dnode
, info
);
1026 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/table-id
1028 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_table_id_modify(
1029 struct nb_cb_modify_args
*args
)
1031 struct route_node
*rn
;
1032 const struct lyd_node
*rn_dnode
;
1033 const struct lyd_node
*src_dnode
;
1034 struct stable_info
*info
;
1036 switch (args
->event
) {
1037 case NB_EV_VALIDATE
:
1038 if (static_path_list_tableid_modify(args
, NULL
, NULL
) != NB_OK
)
1039 return NB_ERR_VALIDATION
;
1045 src_dnode
= yang_dnode_get_parent(args
->dnode
, "src-list");
1046 rn_dnode
= yang_dnode_get_parent(src_dnode
, "route-list");
1047 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
1048 info
= route_table_get_info(rn
->table
);
1050 if (static_path_list_tableid_modify(args
, src_dnode
, info
)
1052 return NB_ERR_VALIDATION
;
1061 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/frr-nexthops/nexthop
1063 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_create(
1064 struct nb_cb_create_args
*args
)
1066 struct route_node
*rn
;
1067 const struct lyd_node
*rn_dnode
;
1068 const struct lyd_node
*src_dnode
;
1069 struct stable_info
*info
;
1071 switch (args
->event
) {
1072 case NB_EV_VALIDATE
:
1073 rn_dnode
= yang_dnode_get_parent(args
->dnode
, "route-list");
1074 if (static_nexthop_create(args
, rn_dnode
, NULL
) != NB_OK
)
1075 return NB_ERR_VALIDATION
;
1081 src_dnode
= yang_dnode_get_parent(args
->dnode
, "src-list");
1082 rn_dnode
= yang_dnode_get_parent(src_dnode
, "route-list");
1083 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
1084 info
= route_table_get_info(rn
->table
);
1086 if (static_nexthop_create(args
, src_dnode
, info
) != NB_OK
)
1087 return NB_ERR_VALIDATION
;
1094 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_destroy(
1095 struct nb_cb_destroy_args
*args
)
1097 struct route_node
*rn
;
1098 const struct lyd_node
*rn_dnode
;
1099 const struct lyd_node
*src_dnode
;
1100 struct stable_info
*info
;
1102 switch (args
->event
) {
1103 case NB_EV_VALIDATE
:
1108 src_dnode
= yang_dnode_get_parent(args
->dnode
, "src-list");
1109 rn_dnode
= yang_dnode_get_parent(src_dnode
, "route-list");
1110 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
1111 info
= route_table_get_info(rn
->table
);
1113 if (static_nexthop_destroy(args
, rn_dnode
, info
) != NB_OK
)
1122 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/frr-nexthops/nexthop/bh-type
1124 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_bh_type_modify(
1125 struct nb_cb_modify_args
*args
)
1127 switch (args
->event
) {
1128 case NB_EV_VALIDATE
:
1133 if (static_nexthop_bh_type_modify(args
) != NB_OK
)
1140 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_bh_type_destroy(
1141 struct nb_cb_destroy_args
*args
)
1143 /* blackhole type has a boolean type with default value,
1144 * so no need to do any operations in destroy callback
1146 switch (args
->event
) {
1147 case NB_EV_VALIDATE
:
1159 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/frr-nexthops/nexthop/onlink
1161 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_onlink_modify(
1162 struct nb_cb_modify_args
*args
)
1164 switch (args
->event
) {
1165 case NB_EV_VALIDATE
:
1170 if (static_nexthop_onlink_modify(args
) != NB_OK
)
1179 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_onlink_destroy(
1180 struct nb_cb_destroy_args
*args
)
1182 /* onlink has a boolean type with default value,
1183 * so no need to do any operations in destroy callback
1185 switch (args
->event
) {
1186 case NB_EV_VALIDATE
:
1197 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/frr-nexthops/nexthop/srte-color
1199 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_color_modify(
1200 struct nb_cb_modify_args
*args
)
1202 switch (args
->event
) {
1203 case NB_EV_VALIDATE
:
1208 if (static_nexthop_color_modify(args
) != NB_OK
)
1217 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_color_destroy(
1218 struct nb_cb_destroy_args
*args
)
1220 switch (args
->event
) {
1221 case NB_EV_VALIDATE
:
1226 if (static_nexthop_color_destroy(args
) != NB_OK
)
1235 * /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
1237 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_create(
1238 struct nb_cb_create_args
*args
)
1240 return nexthop_mpls_label_stack_entry_create(args
);
1243 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_destroy(
1244 struct nb_cb_destroy_args
*args
)
1246 return nexthop_mpls_label_stack_entry_destroy(args
);
1251 * /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
1253 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_label_modify(
1254 struct nb_cb_modify_args
*args
)
1256 switch (args
->event
) {
1257 case NB_EV_VALIDATE
:
1262 if (static_nexthop_mpls_label_modify(args
) != NB_OK
)
1269 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_label_destroy(
1270 struct nb_cb_destroy_args
*args
)
1273 * No operation is required in this call back.
1274 * nexthop_mpls_label_stack_entry_destroy() will take care
1275 * to reset the label vaue.
1277 switch (args
->event
) {
1278 case NB_EV_VALIDATE
:
1289 * /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
1291 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_ttl_modify(
1292 struct nb_cb_modify_args
*args
)
1294 switch (args
->event
) {
1295 case NB_EV_VALIDATE
:
1305 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_ttl_destroy(
1306 struct nb_cb_destroy_args
*args
)
1308 switch (args
->event
) {
1309 case NB_EV_VALIDATE
:
1321 * /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
1323 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(
1324 struct nb_cb_modify_args
*args
)
1326 switch (args
->event
) {
1327 case NB_EV_VALIDATE
:
1337 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(
1338 struct nb_cb_destroy_args
*args
)
1340 switch (args
->event
) {
1341 case NB_EV_VALIDATE
: