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
21 #include "northbound.h"
24 #include "lib_errors.h"
29 #include "srcdest_table.h"
31 #include "static_vrf.h"
32 #include "static_routes.h"
33 #include "static_nb.h"
36 static int static_path_list_create(struct nb_cb_create_args
*args
)
38 struct route_node
*rn
;
39 struct static_path
*pn
;
40 const struct lyd_node
*vrf_dnode
;
45 switch (args
->event
) {
47 vrf_dnode
= yang_dnode_get_parent(args
->dnode
,
48 "control-plane-protocol");
49 vrf
= yang_dnode_get_string(vrf_dnode
, "./vrf");
50 table_id
= yang_dnode_get_uint32(args
->dnode
, "./table-id");
53 * TableId is not applicable for VRF. Consider the case of
54 * l3mdev, there is one uint32_t space to work with.
55 * A l3mdev device points at a specific table that it
56 * relates to and a set of interfaces it belongs to.
58 if (table_id
&& (strcmp(vrf
, vrf_get_default_name()) != 0)
59 && !vrf_is_backend_netns()) {
61 args
->errmsg
, args
->errmsg_len
,
62 "%% table param only available when running on netns-based vrfs");
63 return NB_ERR_VALIDATION
;
70 rn
= nb_running_get_entry(args
->dnode
, NULL
, true);
71 distance
= yang_dnode_get_uint8(args
->dnode
, "./distance");
72 table_id
= yang_dnode_get_uint32(args
->dnode
, "./table-id");
73 pn
= static_add_path(rn
, table_id
, distance
);
74 nb_running_set_entry(args
->dnode
, pn
);
80 static void static_path_list_destroy(struct nb_cb_destroy_args
*args
,
81 const struct lyd_node
*rn_dnode
,
82 struct stable_info
*info
)
84 struct route_node
*rn
;
85 struct static_path
*pn
;
87 pn
= nb_running_unset_entry(args
->dnode
);
88 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
89 static_del_path(rn
, pn
, info
->safi
, info
->svrf
);
92 static void static_path_list_tag_modify(struct nb_cb_modify_args
*args
,
93 const struct lyd_node
*rn_dnode
,
94 struct stable_info
*info
)
96 struct static_path
*pn
;
97 struct route_node
*rn
;
100 tag
= yang_dnode_get_uint32(args
->dnode
, NULL
);
101 pn
= nb_running_get_entry(args
->dnode
, NULL
, true);
103 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
105 static_install_path(rn
, pn
, info
->safi
, info
->svrf
);
108 struct nexthop_iter
{
113 static int nexthop_iter_cb(const struct lyd_node
*dnode
, void *arg
)
115 struct nexthop_iter
*iter
= arg
;
118 nh_type
= yang_dnode_get_enum(dnode
, "./nh-type");
120 if (nh_type
== STATIC_BLACKHOLE
)
121 iter
->blackhole
= true;
125 return YANG_ITER_CONTINUE
;
128 static bool static_nexthop_create(struct nb_cb_create_args
*args
,
129 const struct lyd_node
*rn_dnode
,
130 struct stable_info
*info
)
132 const struct lyd_node
*pn_dnode
;
133 struct nexthop_iter iter
;
134 struct route_node
*rn
;
135 struct static_path
*pn
;
136 struct ipaddr ipaddr
;
137 struct static_nexthop
*nh
;
142 switch (args
->event
) {
144 ifname
= yang_dnode_get_string(args
->dnode
, "./interface");
145 if (ifname
!= NULL
) {
146 if (strcasecmp(ifname
, "Null0") == 0
147 || strcasecmp(ifname
, "reject") == 0
148 || strcasecmp(ifname
, "blackhole") == 0) {
149 snprintf(args
->errmsg
, args
->errmsg_len
,
150 "%s: Nexthop interface name can not be from reserved keywords(Null0, reject, blackhole)",
152 return NB_ERR_VALIDATION
;
157 iter
.blackhole
= false;
159 pn_dnode
= yang_dnode_get_parent(args
->dnode
, "path-list");
160 yang_dnode_iterate(nexthop_iter_cb
, &iter
, pn_dnode
,
161 "./frr-nexthops/nexthop");
163 if (iter
.blackhole
&& iter
.count
> 1) {
165 args
->errmsg
, args
->errmsg_len
,
166 "Route can not have blackhole and non-blackhole nexthops simultaneously");
167 return NB_ERR_VALIDATION
;
174 yang_dnode_get_ip(&ipaddr
, args
->dnode
, "./gateway");
175 nh_type
= yang_dnode_get_enum(args
->dnode
, "./nh-type");
176 ifname
= yang_dnode_get_string(args
->dnode
, "./interface");
177 nh_vrf
= yang_dnode_get_string(args
->dnode
, "./vrf");
178 pn
= nb_running_get_entry(args
->dnode
, NULL
, true);
179 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
181 if (!static_add_nexthop_validate(nh_vrf
, nh_type
, &ipaddr
))
183 EC_LIB_NB_CB_CONFIG_VALIDATE
,
184 "Warning!! Local connected address is configured as Gateway IP((%s))",
185 yang_dnode_get_string(args
->dnode
,
187 nh
= static_add_nexthop(rn
, pn
, info
->safi
, info
->svrf
, nh_type
,
188 &ipaddr
, ifname
, nh_vrf
, 0);
189 nb_running_set_entry(args
->dnode
, nh
);
196 static bool static_nexthop_destroy(struct nb_cb_destroy_args
*args
,
197 const struct lyd_node
*rn_dnode
,
198 struct stable_info
*info
)
200 struct route_node
*rn
;
201 struct static_path
*pn
;
202 const struct lyd_node
*pn_dnode
;
203 struct static_nexthop
*nh
;
206 nh
= nb_running_unset_entry(args
->dnode
);
207 pn_dnode
= yang_dnode_get_parent(args
->dnode
, "path-list");
208 pn
= nb_running_get_entry(pn_dnode
, NULL
, true);
209 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
211 ret
= static_delete_nexthop(rn
, pn
, info
->safi
, info
->svrf
, nh
);
213 char buf
[SRCDEST2STR_BUFFER
];
215 flog_warn(EC_LIB_NB_CB_CONFIG_APPLY
,
216 "%s : nh [%d:%s:%s:%s] nexthop destroy failed",
217 srcdest_rnode2str(rn
, buf
, sizeof(buf
)),
218 yang_dnode_get_enum(args
->dnode
, "./nh-type"),
219 yang_dnode_get_string(args
->dnode
, "./interface"),
220 yang_dnode_get_string(args
->dnode
, "./gateway"),
221 yang_dnode_get_string(args
->dnode
, "./vrf"));
228 static int nexthop_mpls_label_stack_entry_create(struct nb_cb_create_args
*args
)
230 struct static_nexthop
*nh
;
234 switch (args
->event
) {
238 args
->errmsg
, args
->errmsg_len
,
239 "%% MPLS not turned on in kernel ignoring static route");
240 return NB_ERR_VALIDATION
;
247 nh
= nb_running_get_entry(args
->dnode
, NULL
, true);
248 pos
= yang_get_list_pos(args
->dnode
);
250 flog_warn(EC_LIB_NB_CB_CONFIG_APPLY
,
251 "libyang returns invalid label position");
254 /* Mapping to array = list-index -1 */
256 nh
->snh_label
.label
[index
] = 0;
257 nh
->snh_label
.num_labels
++;
265 nexthop_mpls_label_stack_entry_destroy(struct nb_cb_destroy_args
*args
)
267 struct static_nexthop
*nh
;
271 switch (args
->event
) {
277 nh
= nb_running_get_entry(args
->dnode
, NULL
, true);
278 pos
= yang_get_list_pos(args
->dnode
);
280 flog_warn(EC_LIB_NB_CB_CONFIG_APPLY
,
281 "libyang returns invalid label position");
285 nh
->snh_label
.label
[index
] = 0;
286 nh
->snh_label
.num_labels
--;
293 static int static_nexthop_mpls_label_modify(struct nb_cb_modify_args
*args
)
295 struct static_nexthop
*nh
;
299 nh
= nb_running_get_entry(args
->dnode
, NULL
, true);
300 pos
= yang_get_list_pos(lyd_parent(args
->dnode
));
302 flog_warn(EC_LIB_NB_CB_CONFIG_APPLY
,
303 "libyang returns invalid label position");
306 /* Mapping to array = list-index -1 */
308 nh
->snh_label
.label
[index
] = yang_dnode_get_uint32(args
->dnode
, NULL
);
313 static int static_nexthop_onlink_modify(struct nb_cb_modify_args
*args
)
315 struct static_nexthop
*nh
;
316 static_types nh_type
;
318 switch (args
->event
) {
320 nh_type
= yang_dnode_get_enum(args
->dnode
, "../nh-type");
321 if ((nh_type
!= STATIC_IPV4_GATEWAY_IFNAME
)
322 && (nh_type
!= STATIC_IPV6_GATEWAY_IFNAME
)) {
324 args
->errmsg
, args
->errmsg_len
,
325 "nexthop type is not the ipv4 or ipv6 interface type");
326 return NB_ERR_VALIDATION
;
333 nh
= nb_running_get_entry(args
->dnode
, NULL
, true);
334 nh
->onlink
= yang_dnode_get_bool(args
->dnode
, NULL
);
341 static int static_nexthop_color_modify(struct nb_cb_modify_args
*args
)
343 struct static_nexthop
*nh
;
345 nh
= nb_running_get_entry(args
->dnode
, NULL
, true);
346 nh
->color
= yang_dnode_get_uint32(args
->dnode
, NULL
);
351 static int static_nexthop_color_destroy(struct nb_cb_destroy_args
*args
)
353 struct static_nexthop
*nh
;
355 nh
= nb_running_unset_entry(args
->dnode
);
361 static int static_nexthop_bh_type_modify(struct nb_cb_modify_args
*args
)
363 struct static_nexthop
*nh
;
364 static_types nh_type
;
366 switch (args
->event
) {
368 nh_type
= yang_dnode_get_enum(args
->dnode
, "../nh-type");
369 if (nh_type
!= STATIC_BLACKHOLE
) {
370 snprintf(args
->errmsg
, args
->errmsg_len
,
371 "nexthop type is not the blackhole type");
372 return NB_ERR_VALIDATION
;
379 nh
= nb_running_get_entry(args
->dnode
, NULL
, true);
380 nh
->bh_type
= yang_dnode_get_enum(args
->dnode
, NULL
);
388 void routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_apply_finish(
389 struct nb_cb_apply_finish_args
*args
)
391 struct static_nexthop
*nh
;
392 struct static_path
*pn
;
393 struct route_node
*rn
;
394 const struct lyd_node
*pn_dnode
;
395 const struct lyd_node
*rn_dnode
;
398 struct stable_info
*info
;
401 nh_type
= yang_dnode_get_enum(args
->dnode
, "./nh-type");
402 ifname
= yang_dnode_get_string(args
->dnode
, "./interface");
403 nh_vrf
= yang_dnode_get_string(args
->dnode
, "./vrf");
405 nh
= nb_running_get_entry(args
->dnode
, NULL
, true);
407 pn_dnode
= yang_dnode_get_parent(args
->dnode
, "path-list");
408 pn
= nb_running_get_entry(pn_dnode
, NULL
, true);
410 rn_dnode
= yang_dnode_get_parent(pn_dnode
, "route-list");
411 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
412 info
= route_table_get_info(rn
->table
);
414 static_install_nexthop(rn
, pn
, nh
, info
->safi
, info
->svrf
, ifname
,
419 void routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_apply_finish(
420 struct nb_cb_apply_finish_args
*args
)
422 struct static_nexthop
*nh
;
423 struct static_path
*pn
;
424 struct route_node
*rn
;
425 struct route_node
*src_rn
;
426 const struct lyd_node
*pn_dnode
;
427 const struct lyd_node
*rn_dnode
;
428 const struct lyd_node
*src_dnode
;
431 struct stable_info
*info
;
434 nh_type
= yang_dnode_get_enum(args
->dnode
, "./nh-type");
435 ifname
= yang_dnode_get_string(args
->dnode
, "./interface");
436 nh_vrf
= yang_dnode_get_string(args
->dnode
, "./vrf");
438 nh
= nb_running_get_entry(args
->dnode
, NULL
, true);
440 pn_dnode
= yang_dnode_get_parent(args
->dnode
, "path-list");
441 pn
= nb_running_get_entry(pn_dnode
, NULL
, true);
443 src_dnode
= yang_dnode_get_parent(pn_dnode
, "src-list");
444 src_rn
= nb_running_get_entry(src_dnode
, NULL
, true);
446 rn_dnode
= yang_dnode_get_parent(src_dnode
, "route-list");
447 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
448 info
= route_table_get_info(rn
->table
);
450 static_install_nexthop(src_rn
, pn
, nh
, info
->safi
, info
->svrf
, ifname
,
453 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_pre_validate(
454 struct nb_cb_pre_validate_args
*args
)
456 const struct lyd_node
*mls_dnode
;
459 mls_dnode
= yang_dnode_get(args
->dnode
, "./mpls-label-stack");
460 count
= yang_get_list_elements_count(lyd_child(mls_dnode
));
462 if (count
> MPLS_MAX_LABELS
) {
463 snprintf(args
->errmsg
, args
->errmsg_len
,
464 "Too many labels, Enter %d or fewer",
466 return NB_ERR_VALIDATION
;
471 int routing_control_plane_protocols_name_validate(
472 struct nb_cb_create_args
*args
)
476 name
= yang_dnode_get_string(args
->dnode
, "./name");
477 if (!strmatch(name
, "staticd")) {
478 snprintf(args
->errmsg
, args
->errmsg_len
,
479 "static routing supports only one instance with name staticd");
480 return NB_ERR_VALIDATION
;
486 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list
488 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_create(
489 struct nb_cb_create_args
*args
)
492 struct static_vrf
*s_vrf
;
493 struct route_node
*rn
;
494 const struct lyd_node
*vrf_dnode
;
495 struct prefix prefix
;
496 const char *afi_safi
;
501 switch (args
->event
) {
503 yang_dnode_get_prefix(&prefix
, args
->dnode
, "./prefix");
504 afi_safi
= yang_dnode_get_string(args
->dnode
, "./afi-safi");
505 yang_afi_safi_identity2value(afi_safi
, &afi
, &safi
);
506 prefix_afi
= family2afi(prefix
.family
);
507 if (afi
!= prefix_afi
) {
509 EC_LIB_NB_CB_CONFIG_VALIDATE
,
510 "route node %s creation failed",
511 yang_dnode_get_string(args
->dnode
, "./prefix"));
512 return NB_ERR_VALIDATION
;
519 vrf_dnode
= yang_dnode_get_parent(args
->dnode
,
520 "control-plane-protocol");
521 vrf
= nb_running_get_entry(vrf_dnode
, NULL
, true);
524 yang_dnode_get_prefix(&prefix
, args
->dnode
, "./prefix");
525 afi_safi
= yang_dnode_get_string(args
->dnode
, "./afi-safi");
526 yang_afi_safi_identity2value(afi_safi
, &afi
, &safi
);
528 rn
= static_add_route(afi
, safi
, &prefix
, NULL
, s_vrf
);
531 EC_LIB_NB_CB_CONFIG_APPLY
,
532 "route node %s creation failed",
533 yang_dnode_get_string(args
->dnode
, "./prefix"));
536 if (vrf
->vrf_id
== VRF_UNKNOWN
)
538 args
->errmsg
, args
->errmsg_len
,
539 "Static Route to %s not installed currently because dependent config not fully available",
540 yang_dnode_get_string(args
->dnode
, "./prefix"));
541 nb_running_set_entry(args
->dnode
, rn
);
547 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_destroy(
548 struct nb_cb_destroy_args
*args
)
550 struct route_node
*rn
;
551 struct stable_info
*info
;
553 switch (args
->event
) {
559 rn
= nb_running_unset_entry(args
->dnode
);
560 info
= route_table_get_info(rn
->table
);
561 static_del_route(rn
, info
->safi
, info
->svrf
);
569 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list
571 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_create(
572 struct nb_cb_create_args
*args
)
574 return static_path_list_create(args
);
577 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_destroy(
578 struct nb_cb_destroy_args
*args
)
580 const struct lyd_node
*rn_dnode
;
581 struct route_node
*rn
;
582 struct stable_info
*info
;
584 switch (args
->event
) {
590 rn_dnode
= yang_dnode_get_parent(args
->dnode
, "route-list");
591 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
592 info
= route_table_get_info(rn
->table
);
593 static_path_list_destroy(args
, rn_dnode
, info
);
601 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/tag
603 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_tag_modify(
604 struct nb_cb_modify_args
*args
)
606 struct stable_info
*info
;
607 struct route_node
*rn
;
608 const struct lyd_node
*rn_dnode
;
610 switch (args
->event
) {
616 rn_dnode
= yang_dnode_get_parent(args
->dnode
, "route-list");
617 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
618 info
= route_table_get_info(rn
->table
);
619 static_path_list_tag_modify(args
, rn_dnode
, info
);
628 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop
630 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_create(
631 struct nb_cb_create_args
*args
)
633 struct route_node
*rn
;
634 const struct lyd_node
*rn_dnode
;
635 struct stable_info
*info
;
637 switch (args
->event
) {
639 rn_dnode
= yang_dnode_get_parent(args
->dnode
, "route-list");
640 if (static_nexthop_create(args
, rn_dnode
, NULL
) != NB_OK
)
641 return NB_ERR_VALIDATION
;
647 rn_dnode
= yang_dnode_get_parent(args
->dnode
, "route-list");
648 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
649 info
= route_table_get_info(rn
->table
);
651 if (static_nexthop_create(args
, rn_dnode
, info
) != NB_OK
)
652 return NB_ERR_INCONSISTENCY
;
658 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_destroy(
659 struct nb_cb_destroy_args
*args
)
661 struct route_node
*rn
;
662 const struct lyd_node
*rn_dnode
;
663 struct stable_info
*info
;
665 switch (args
->event
) {
671 rn_dnode
= yang_dnode_get_parent(args
->dnode
, "route-list");
672 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
673 info
= route_table_get_info(rn
->table
);
675 if (static_nexthop_destroy(args
, rn_dnode
, info
) != NB_OK
)
684 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/bh-type
686 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_bh_type_modify(
687 struct nb_cb_modify_args
*args
)
689 return static_nexthop_bh_type_modify(args
);
694 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/onlink
696 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_onlink_modify(
697 struct nb_cb_modify_args
*args
)
699 return static_nexthop_onlink_modify(args
);
704 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/srte-color
706 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_color_modify(
707 struct nb_cb_modify_args
*args
)
709 switch (args
->event
) {
715 if (static_nexthop_color_modify(args
) != NB_OK
)
723 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_color_destroy(
724 struct nb_cb_destroy_args
*args
)
726 switch (args
->event
) {
732 if (static_nexthop_color_destroy(args
) != NB_OK
)
741 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/mpls-label-stack/entry
743 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_create(
744 struct nb_cb_create_args
*args
)
746 return nexthop_mpls_label_stack_entry_create(args
);
749 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_destroy(
750 struct nb_cb_destroy_args
*args
)
752 return nexthop_mpls_label_stack_entry_destroy(args
);
757 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/mpls-label-stack/entry/label
759 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_label_modify(
760 struct nb_cb_modify_args
*args
)
762 switch (args
->event
) {
768 if (static_nexthop_mpls_label_modify(args
) != NB_OK
)
775 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_label_destroy(
776 struct nb_cb_destroy_args
*args
)
779 * No operation is required in this call back.
780 * nexthop_mpls_label_stack_entry_destroy() will take care
781 * to reset the label vaue.
783 switch (args
->event
) {
795 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/mpls-label-stack/entry/ttl
797 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_ttl_modify(
798 struct nb_cb_modify_args
*args
)
800 switch (args
->event
) {
811 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_ttl_destroy(
812 struct nb_cb_destroy_args
*args
)
814 switch (args
->event
) {
827 * /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
829 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_traffic_class_modify(
830 struct nb_cb_modify_args
*args
)
832 switch (args
->event
) {
843 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_traffic_class_destroy(
844 struct nb_cb_destroy_args
*args
)
846 switch (args
->event
) {
859 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list
861 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_create(
862 struct nb_cb_create_args
*args
)
864 struct static_vrf
*s_vrf
;
865 struct route_node
*rn
;
866 struct route_node
*src_rn
;
867 struct prefix_ipv6 src_prefix
= {};
868 struct stable_info
*info
;
870 safi_t safi
= SAFI_UNICAST
;
872 switch (args
->event
) {
878 rn
= nb_running_get_entry(args
->dnode
, NULL
, true);
879 info
= route_table_get_info(rn
->table
);
881 yang_dnode_get_ipv6p(&src_prefix
, args
->dnode
, "./src-prefix");
882 afi
= family2afi(src_prefix
.family
);
884 static_add_route(afi
, safi
, &rn
->p
, &src_prefix
, s_vrf
);
886 flog_warn(EC_LIB_NB_CB_CONFIG_APPLY
,
887 "src rn %s creation failed",
888 yang_dnode_get_string(args
->dnode
,
892 nb_running_set_entry(args
->dnode
, src_rn
);
898 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_destroy(
899 struct nb_cb_destroy_args
*args
)
901 struct route_node
*src_rn
;
902 struct route_node
*rn
;
903 struct stable_info
*info
;
904 const struct lyd_node
*rn_dnode
;
906 switch (args
->event
) {
912 src_rn
= nb_running_unset_entry(args
->dnode
);
913 rn_dnode
= yang_dnode_get_parent(args
->dnode
, "route-list");
914 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
915 info
= route_table_get_info(rn
->table
);
916 static_del_route(src_rn
, info
->safi
, info
->svrf
);
925 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list
927 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_create(
928 struct nb_cb_create_args
*args
)
930 return static_path_list_create(args
);
933 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_destroy(
934 struct nb_cb_destroy_args
*args
)
936 struct route_node
*rn
;
937 const struct lyd_node
*rn_dnode
;
938 const struct lyd_node
*srn_dnode
;
939 struct stable_info
*info
;
941 switch (args
->event
) {
947 srn_dnode
= yang_dnode_get_parent(args
->dnode
, "src-list");
948 rn_dnode
= yang_dnode_get_parent(srn_dnode
, "route-list");
949 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
950 info
= route_table_get_info(rn
->table
);
951 static_path_list_destroy(args
, srn_dnode
, info
);
959 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/tag
961 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_tag_modify(
962 struct nb_cb_modify_args
*args
)
964 struct stable_info
*info
;
965 struct route_node
*rn
;
966 const struct lyd_node
*srn_dnode
;
967 const struct lyd_node
*rn_dnode
;
969 switch (args
->event
) {
975 srn_dnode
= yang_dnode_get_parent(args
->dnode
, "src-list");
976 rn_dnode
= yang_dnode_get_parent(srn_dnode
, "route-list");
977 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
978 info
= route_table_get_info(rn
->table
);
979 static_path_list_tag_modify(args
, srn_dnode
, info
);
987 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/frr-nexthops/nexthop
989 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_create(
990 struct nb_cb_create_args
*args
)
992 struct route_node
*rn
;
993 const struct lyd_node
*rn_dnode
;
994 const struct lyd_node
*src_dnode
;
995 struct stable_info
*info
;
997 switch (args
->event
) {
999 rn_dnode
= yang_dnode_get_parent(args
->dnode
, "route-list");
1000 if (static_nexthop_create(args
, rn_dnode
, NULL
) != NB_OK
)
1001 return NB_ERR_VALIDATION
;
1007 src_dnode
= yang_dnode_get_parent(args
->dnode
, "src-list");
1008 rn_dnode
= yang_dnode_get_parent(src_dnode
, "route-list");
1009 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
1010 info
= route_table_get_info(rn
->table
);
1012 if (static_nexthop_create(args
, src_dnode
, info
) != NB_OK
)
1013 return NB_ERR_VALIDATION
;
1020 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_destroy(
1021 struct nb_cb_destroy_args
*args
)
1023 struct route_node
*rn
;
1024 const struct lyd_node
*rn_dnode
;
1025 const struct lyd_node
*src_dnode
;
1026 struct stable_info
*info
;
1028 switch (args
->event
) {
1029 case NB_EV_VALIDATE
:
1034 src_dnode
= yang_dnode_get_parent(args
->dnode
, "src-list");
1035 rn_dnode
= yang_dnode_get_parent(src_dnode
, "route-list");
1036 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
1037 info
= route_table_get_info(rn
->table
);
1039 if (static_nexthop_destroy(args
, rn_dnode
, info
) != NB_OK
)
1048 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/frr-nexthops/nexthop/bh-type
1050 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_bh_type_modify(
1051 struct nb_cb_modify_args
*args
)
1053 return static_nexthop_bh_type_modify(args
);
1058 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/frr-nexthops/nexthop/onlink
1060 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_onlink_modify(
1061 struct nb_cb_modify_args
*args
)
1063 return static_nexthop_onlink_modify(args
);
1068 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/frr-nexthops/nexthop/srte-color
1070 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_color_modify(
1071 struct nb_cb_modify_args
*args
)
1073 switch (args
->event
) {
1074 case NB_EV_VALIDATE
:
1079 if (static_nexthop_color_modify(args
) != NB_OK
)
1088 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_color_destroy(
1089 struct nb_cb_destroy_args
*args
)
1091 switch (args
->event
) {
1092 case NB_EV_VALIDATE
:
1097 if (static_nexthop_color_destroy(args
) != NB_OK
)
1106 * /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
1108 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_create(
1109 struct nb_cb_create_args
*args
)
1111 return nexthop_mpls_label_stack_entry_create(args
);
1114 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_destroy(
1115 struct nb_cb_destroy_args
*args
)
1117 return nexthop_mpls_label_stack_entry_destroy(args
);
1122 * /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
1124 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_label_modify(
1125 struct nb_cb_modify_args
*args
)
1127 switch (args
->event
) {
1128 case NB_EV_VALIDATE
:
1133 if (static_nexthop_mpls_label_modify(args
) != NB_OK
)
1140 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_label_destroy(
1141 struct nb_cb_destroy_args
*args
)
1144 * No operation is required in this call back.
1145 * nexthop_mpls_label_stack_entry_destroy() will take care
1146 * to reset the label vaue.
1148 switch (args
->event
) {
1149 case NB_EV_VALIDATE
:
1160 * /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
1162 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_ttl_modify(
1163 struct nb_cb_modify_args
*args
)
1165 switch (args
->event
) {
1166 case NB_EV_VALIDATE
:
1176 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_ttl_destroy(
1177 struct nb_cb_destroy_args
*args
)
1179 switch (args
->event
) {
1180 case NB_EV_VALIDATE
:
1192 * /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
1194 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(
1195 struct nb_cb_modify_args
*args
)
1197 switch (args
->event
) {
1198 case NB_EV_VALIDATE
:
1208 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(
1209 struct nb_cb_destroy_args
*args
)
1211 switch (args
->event
) {
1212 case NB_EV_VALIDATE
: