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(info
->svrf
, 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);
152 char buf
[SRCDEST2STR_BUFFER
];
155 EC_LIB_NB_CB_CONFIG_APPLY
,
156 "%s : nh [%d:%s:%s:%s] nexthop creation failed",
157 srcdest_rnode2str(rn
, buf
, sizeof(buf
)),
159 yang_dnode_get_string(args
->dnode
, "./gateway"),
163 nb_running_set_entry(args
->dnode
, nh
);
170 static bool static_nexthop_destroy(struct nb_cb_destroy_args
*args
,
171 const struct lyd_node
*rn_dnode
,
172 struct stable_info
*info
)
174 struct route_node
*rn
;
175 struct static_path
*pn
;
176 const struct lyd_node
*pn_dnode
;
177 struct static_nexthop
*nh
;
180 nh
= nb_running_unset_entry(args
->dnode
);
181 pn_dnode
= yang_dnode_get_parent(args
->dnode
, "path-list");
182 pn
= nb_running_get_entry(pn_dnode
, NULL
, true);
183 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
185 ret
= static_delete_nexthop(rn
, pn
, info
->safi
, info
->svrf
, nh
);
187 char buf
[SRCDEST2STR_BUFFER
];
189 flog_warn(EC_LIB_NB_CB_CONFIG_APPLY
,
190 "%s : nh [%d:%s:%s:%s] nexthop destroy failed",
191 srcdest_rnode2str(rn
, buf
, sizeof(buf
)),
192 yang_dnode_get_enum(args
->dnode
, "./nh-type"),
193 yang_dnode_get_string(args
->dnode
, "./interface"),
194 yang_dnode_get_string(args
->dnode
, "./gateway"),
195 yang_dnode_get_string(args
->dnode
, "./vrf"));
202 static int nexthop_mpls_label_stack_entry_create(struct nb_cb_create_args
*args
)
204 struct static_nexthop
*nh
;
208 switch (args
->event
) {
212 args
->errmsg
, args
->errmsg_len
,
213 "%% MPLS not turned on in kernel ignoring static route");
214 return NB_ERR_VALIDATION
;
221 nh
= nb_running_get_entry(args
->dnode
, NULL
, true);
222 pos
= yang_get_list_pos(args
->dnode
);
224 flog_warn(EC_LIB_NB_CB_CONFIG_APPLY
,
225 "libyang returns invalid label position");
228 /* Mapping to array = list-index -1 */
230 nh
->snh_label
.label
[index
] = 0;
231 nh
->snh_label
.num_labels
++;
239 nexthop_mpls_label_stack_entry_destroy(struct nb_cb_destroy_args
*args
)
241 struct static_nexthop
*nh
;
245 switch (args
->event
) {
251 nh
= nb_running_get_entry(args
->dnode
, NULL
, true);
252 pos
= yang_get_list_pos(args
->dnode
);
254 flog_warn(EC_LIB_NB_CB_CONFIG_APPLY
,
255 "libyang returns invalid label position");
259 nh
->snh_label
.label
[index
] = 0;
260 nh
->snh_label
.num_labels
--;
267 static int static_nexthop_mpls_label_modify(struct nb_cb_modify_args
*args
)
269 struct static_nexthop
*nh
;
273 nh
= nb_running_get_entry(args
->dnode
, NULL
, true);
274 pos
= yang_get_list_pos(args
->dnode
->parent
);
276 flog_warn(EC_LIB_NB_CB_CONFIG_APPLY
,
277 "libyang returns invalid label position");
280 /* Mapping to array = list-index -1 */
282 nh
->snh_label
.label
[index
] = yang_dnode_get_uint32(args
->dnode
, NULL
);
287 static int static_nexthop_onlink_modify(struct nb_cb_modify_args
*args
)
289 struct static_nexthop
*nh
;
290 static_types nh_type
;
292 switch (args
->event
) {
294 nh_type
= yang_dnode_get_enum(args
->dnode
, "../nh-type");
295 if ((nh_type
!= STATIC_IPV4_GATEWAY_IFNAME
)
296 && (nh_type
!= STATIC_IPV6_GATEWAY_IFNAME
)) {
298 args
->errmsg
, args
->errmsg_len
,
299 "nexthop type is not the ipv4 or ipv6 interface type");
300 return NB_ERR_VALIDATION
;
307 nh
= nb_running_get_entry(args
->dnode
, NULL
, true);
308 nh
->onlink
= yang_dnode_get_bool(args
->dnode
, NULL
);
315 static int static_nexthop_color_modify(struct nb_cb_modify_args
*args
)
317 struct static_nexthop
*nh
;
319 nh
= nb_running_get_entry(args
->dnode
, NULL
, true);
320 nh
->color
= yang_dnode_get_uint32(args
->dnode
, NULL
);
325 static int static_nexthop_color_destroy(struct nb_cb_destroy_args
*args
)
327 struct static_nexthop
*nh
;
329 nh
= nb_running_unset_entry(args
->dnode
);
335 static int static_nexthop_bh_type_modify(struct nb_cb_modify_args
*args
)
337 struct static_nexthop
*nh
;
338 static_types nh_type
;
340 switch (args
->event
) {
342 nh_type
= yang_dnode_get_enum(args
->dnode
, "../nh-type");
343 if (nh_type
!= STATIC_BLACKHOLE
) {
344 snprintf(args
->errmsg
, args
->errmsg_len
,
345 "nexthop type is not the blackhole type");
346 return NB_ERR_VALIDATION
;
353 nh
= nb_running_get_entry(args
->dnode
, NULL
, true);
354 nh
->bh_type
= yang_dnode_get_enum(args
->dnode
, NULL
);
362 void routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_apply_finish(
363 struct nb_cb_apply_finish_args
*args
)
365 struct static_nexthop
*nh
;
366 struct static_path
*pn
;
367 struct route_node
*rn
;
368 const struct lyd_node
*pn_dnode
;
369 const struct lyd_node
*rn_dnode
;
372 struct stable_info
*info
;
375 nh_type
= yang_dnode_get_enum(args
->dnode
, "./nh-type");
376 ifname
= yang_dnode_get_string(args
->dnode
, "./interface");
377 nh_vrf
= yang_dnode_get_string(args
->dnode
, "./vrf");
379 nh
= nb_running_get_entry(args
->dnode
, NULL
, true);
381 pn_dnode
= yang_dnode_get_parent(args
->dnode
, "path-list");
382 pn
= nb_running_get_entry(pn_dnode
, NULL
, true);
384 rn_dnode
= yang_dnode_get_parent(pn_dnode
, "route-list");
385 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
386 info
= route_table_get_info(rn
->table
);
388 static_install_nexthop(rn
, pn
, nh
, info
->safi
, info
->svrf
, ifname
,
393 void routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_apply_finish(
394 struct nb_cb_apply_finish_args
*args
)
396 struct static_nexthop
*nh
;
397 struct static_path
*pn
;
398 struct route_node
*rn
;
399 struct route_node
*src_rn
;
400 const struct lyd_node
*pn_dnode
;
401 const struct lyd_node
*rn_dnode
;
402 const struct lyd_node
*src_dnode
;
405 struct stable_info
*info
;
408 nh_type
= yang_dnode_get_enum(args
->dnode
, "./nh-type");
409 ifname
= yang_dnode_get_string(args
->dnode
, "./interface");
410 nh_vrf
= yang_dnode_get_string(args
->dnode
, "./vrf");
412 nh
= nb_running_get_entry(args
->dnode
, NULL
, true);
414 pn_dnode
= yang_dnode_get_parent(args
->dnode
, "path-list");
415 pn
= nb_running_get_entry(pn_dnode
, NULL
, true);
417 src_dnode
= yang_dnode_get_parent(pn_dnode
, "src-list");
418 src_rn
= nb_running_get_entry(src_dnode
, NULL
, true);
420 rn_dnode
= yang_dnode_get_parent(src_dnode
, "route-list");
421 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
422 info
= route_table_get_info(rn
->table
);
424 static_install_nexthop(src_rn
, pn
, nh
, info
->safi
, info
->svrf
, ifname
,
427 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_pre_validate(
428 struct nb_cb_pre_validate_args
*args
)
430 const struct lyd_node
*mls_dnode
;
433 mls_dnode
= yang_dnode_get(args
->dnode
, "./mpls-label-stack");
434 count
= yang_get_list_elements_count(yang_dnode_get_child(mls_dnode
));
436 if (count
> MPLS_MAX_LABELS
) {
437 snprintf(args
->errmsg
, args
->errmsg_len
,
438 "Too many labels, Enter %d or fewer",
440 return NB_ERR_VALIDATION
;
445 int routing_control_plane_protocols_name_validate(
446 struct nb_cb_create_args
*args
)
450 name
= yang_dnode_get_string(args
->dnode
, "./name");
451 if (!strmatch(name
, "staticd")) {
452 snprintf(args
->errmsg
, args
->errmsg_len
,
453 "static routing supports only one instance with name staticd");
454 return NB_ERR_VALIDATION
;
460 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list
462 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_create(
463 struct nb_cb_create_args
*args
)
466 struct static_vrf
*s_vrf
;
467 struct route_node
*rn
;
468 const struct lyd_node
*vrf_dnode
;
469 struct prefix prefix
;
470 const char *afi_safi
;
475 switch (args
->event
) {
477 yang_dnode_get_prefix(&prefix
, args
->dnode
, "./prefix");
478 afi_safi
= yang_dnode_get_string(args
->dnode
, "./afi-safi");
479 yang_afi_safi_identity2value(afi_safi
, &afi
, &safi
);
480 prefix_afi
= family2afi(prefix
.family
);
481 if (afi
!= prefix_afi
) {
483 EC_LIB_NB_CB_CONFIG_VALIDATE
,
484 "route node %s creation failed",
485 yang_dnode_get_string(args
->dnode
, "./prefix"));
486 return NB_ERR_VALIDATION
;
493 vrf_dnode
= yang_dnode_get_parent(args
->dnode
,
494 "control-plane-protocol");
495 vrf
= nb_running_get_entry(vrf_dnode
, NULL
, true);
498 yang_dnode_get_prefix(&prefix
, args
->dnode
, "./prefix");
499 afi_safi
= yang_dnode_get_string(args
->dnode
, "./afi-safi");
500 yang_afi_safi_identity2value(afi_safi
, &afi
, &safi
);
502 rn
= static_add_route(afi
, safi
, &prefix
, NULL
, s_vrf
);
505 EC_LIB_NB_CB_CONFIG_APPLY
,
506 "route node %s creation failed",
507 yang_dnode_get_string(args
->dnode
, "./prefix"));
510 if (vrf
->vrf_id
== VRF_UNKNOWN
)
512 args
->errmsg
, args
->errmsg_len
,
513 "Static Route to %s not installed currently because dependent config not fully available",
514 yang_dnode_get_string(args
->dnode
, "./prefix"));
515 nb_running_set_entry(args
->dnode
, rn
);
521 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_destroy(
522 struct nb_cb_destroy_args
*args
)
524 struct route_node
*rn
;
525 struct stable_info
*info
;
527 switch (args
->event
) {
533 rn
= nb_running_unset_entry(args
->dnode
);
534 info
= route_table_get_info(rn
->table
);
535 static_del_route(rn
, info
->safi
, info
->svrf
);
543 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list
545 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_create(
546 struct nb_cb_create_args
*args
)
548 return static_path_list_create(args
);
551 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_destroy(
552 struct nb_cb_destroy_args
*args
)
554 const struct lyd_node
*rn_dnode
;
555 struct route_node
*rn
;
556 struct stable_info
*info
;
558 switch (args
->event
) {
564 rn_dnode
= yang_dnode_get_parent(args
->dnode
, "route-list");
565 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
566 info
= route_table_get_info(rn
->table
);
567 static_path_list_destroy(args
, rn_dnode
, info
);
575 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/tag
577 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_tag_modify(
578 struct nb_cb_modify_args
*args
)
580 struct stable_info
*info
;
581 struct route_node
*rn
;
582 const struct lyd_node
*rn_dnode
;
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_tag_modify(args
, rn_dnode
, info
);
602 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop
604 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_create(
605 struct nb_cb_create_args
*args
)
607 struct route_node
*rn
;
608 const struct lyd_node
*rn_dnode
;
609 struct stable_info
*info
;
611 switch (args
->event
) {
613 rn_dnode
= yang_dnode_get_parent(args
->dnode
, "route-list");
614 if (static_nexthop_create(args
, rn_dnode
, NULL
) != NB_OK
)
615 return NB_ERR_VALIDATION
;
621 rn_dnode
= yang_dnode_get_parent(args
->dnode
, "route-list");
622 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
623 info
= route_table_get_info(rn
->table
);
625 if (static_nexthop_create(args
, rn_dnode
, info
) != NB_OK
)
626 return NB_ERR_INCONSISTENCY
;
632 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_destroy(
633 struct nb_cb_destroy_args
*args
)
635 struct route_node
*rn
;
636 const struct lyd_node
*rn_dnode
;
637 struct stable_info
*info
;
639 switch (args
->event
) {
645 rn_dnode
= yang_dnode_get_parent(args
->dnode
, "route-list");
646 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
647 info
= route_table_get_info(rn
->table
);
649 if (static_nexthop_destroy(args
, rn_dnode
, info
) != NB_OK
)
658 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/bh-type
660 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_bh_type_modify(
661 struct nb_cb_modify_args
*args
)
663 return static_nexthop_bh_type_modify(args
);
666 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_bh_type_destroy(
667 struct nb_cb_destroy_args
*args
)
669 /* blackhole type has a boolean type with default value,
670 * so no need to do any operations in destroy callback
672 switch (args
->event
) {
684 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/onlink
686 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_onlink_modify(
687 struct nb_cb_modify_args
*args
)
689 return static_nexthop_onlink_modify(args
);
694 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/srte-color
696 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_color_modify(
697 struct nb_cb_modify_args
*args
)
699 switch (args
->event
) {
705 if (static_nexthop_color_modify(args
) != NB_OK
)
713 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_color_destroy(
714 struct nb_cb_destroy_args
*args
)
716 switch (args
->event
) {
722 if (static_nexthop_color_destroy(args
) != NB_OK
)
731 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/mpls-label-stack/entry
733 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_create(
734 struct nb_cb_create_args
*args
)
736 return nexthop_mpls_label_stack_entry_create(args
);
739 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_destroy(
740 struct nb_cb_destroy_args
*args
)
742 return nexthop_mpls_label_stack_entry_destroy(args
);
747 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/mpls-label-stack/entry/label
749 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_label_modify(
750 struct nb_cb_modify_args
*args
)
752 switch (args
->event
) {
758 if (static_nexthop_mpls_label_modify(args
) != NB_OK
)
765 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_label_destroy(
766 struct nb_cb_destroy_args
*args
)
769 * No operation is required in this call back.
770 * nexthop_mpls_label_stack_entry_destroy() will take care
771 * to reset the label vaue.
773 switch (args
->event
) {
785 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/mpls-label-stack/entry/ttl
787 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_ttl_modify(
788 struct nb_cb_modify_args
*args
)
790 switch (args
->event
) {
801 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_ttl_destroy(
802 struct nb_cb_destroy_args
*args
)
804 switch (args
->event
) {
817 * /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
819 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_traffic_class_modify(
820 struct nb_cb_modify_args
*args
)
822 switch (args
->event
) {
833 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_traffic_class_destroy(
834 struct nb_cb_destroy_args
*args
)
836 switch (args
->event
) {
849 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list
851 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_create(
852 struct nb_cb_create_args
*args
)
854 struct static_vrf
*s_vrf
;
855 struct route_node
*rn
;
856 struct route_node
*src_rn
;
857 struct prefix_ipv6 src_prefix
= {};
858 struct stable_info
*info
;
860 safi_t safi
= SAFI_UNICAST
;
862 switch (args
->event
) {
868 rn
= nb_running_get_entry(args
->dnode
, NULL
, true);
869 info
= route_table_get_info(rn
->table
);
871 yang_dnode_get_ipv6p(&src_prefix
, args
->dnode
, "./src-prefix");
872 afi
= family2afi(src_prefix
.family
);
874 static_add_route(afi
, safi
, &rn
->p
, &src_prefix
, s_vrf
);
876 flog_warn(EC_LIB_NB_CB_CONFIG_APPLY
,
877 "src rn %s creation failed",
878 yang_dnode_get_string(args
->dnode
,
882 nb_running_set_entry(args
->dnode
, src_rn
);
888 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_destroy(
889 struct nb_cb_destroy_args
*args
)
891 struct route_node
*src_rn
;
892 struct route_node
*rn
;
893 struct stable_info
*info
;
894 const struct lyd_node
*rn_dnode
;
896 switch (args
->event
) {
902 src_rn
= nb_running_unset_entry(args
->dnode
);
903 rn_dnode
= yang_dnode_get_parent(args
->dnode
, "route-list");
904 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
905 info
= route_table_get_info(rn
->table
);
906 static_del_route(src_rn
, info
->safi
, info
->svrf
);
915 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list
917 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_create(
918 struct nb_cb_create_args
*args
)
920 return static_path_list_create(args
);
923 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_destroy(
924 struct nb_cb_destroy_args
*args
)
926 struct route_node
*rn
;
927 const struct lyd_node
*rn_dnode
;
928 const struct lyd_node
*srn_dnode
;
929 struct stable_info
*info
;
931 switch (args
->event
) {
937 srn_dnode
= yang_dnode_get_parent(args
->dnode
, "src-list");
938 rn_dnode
= yang_dnode_get_parent(srn_dnode
, "route-list");
939 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
940 info
= route_table_get_info(rn
->table
);
941 static_path_list_destroy(args
, srn_dnode
, info
);
949 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/tag
951 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_tag_modify(
952 struct nb_cb_modify_args
*args
)
954 struct stable_info
*info
;
955 struct route_node
*rn
;
956 const struct lyd_node
*srn_dnode
;
957 const struct lyd_node
*rn_dnode
;
959 switch (args
->event
) {
965 srn_dnode
= yang_dnode_get_parent(args
->dnode
, "src-list");
966 rn_dnode
= yang_dnode_get_parent(srn_dnode
, "route-list");
967 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
968 info
= route_table_get_info(rn
->table
);
969 static_path_list_tag_modify(args
, srn_dnode
, info
);
977 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/frr-nexthops/nexthop
979 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_create(
980 struct nb_cb_create_args
*args
)
982 struct route_node
*rn
;
983 const struct lyd_node
*rn_dnode
;
984 const struct lyd_node
*src_dnode
;
985 struct stable_info
*info
;
987 switch (args
->event
) {
989 rn_dnode
= yang_dnode_get_parent(args
->dnode
, "route-list");
990 if (static_nexthop_create(args
, rn_dnode
, NULL
) != NB_OK
)
991 return NB_ERR_VALIDATION
;
997 src_dnode
= yang_dnode_get_parent(args
->dnode
, "src-list");
998 rn_dnode
= yang_dnode_get_parent(src_dnode
, "route-list");
999 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
1000 info
= route_table_get_info(rn
->table
);
1002 if (static_nexthop_create(args
, src_dnode
, info
) != NB_OK
)
1003 return NB_ERR_VALIDATION
;
1010 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_destroy(
1011 struct nb_cb_destroy_args
*args
)
1013 struct route_node
*rn
;
1014 const struct lyd_node
*rn_dnode
;
1015 const struct lyd_node
*src_dnode
;
1016 struct stable_info
*info
;
1018 switch (args
->event
) {
1019 case NB_EV_VALIDATE
:
1024 src_dnode
= yang_dnode_get_parent(args
->dnode
, "src-list");
1025 rn_dnode
= yang_dnode_get_parent(src_dnode
, "route-list");
1026 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
1027 info
= route_table_get_info(rn
->table
);
1029 if (static_nexthop_destroy(args
, rn_dnode
, info
) != NB_OK
)
1038 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/frr-nexthops/nexthop/bh-type
1040 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_bh_type_modify(
1041 struct nb_cb_modify_args
*args
)
1043 return static_nexthop_bh_type_modify(args
);
1046 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_bh_type_destroy(
1047 struct nb_cb_destroy_args
*args
)
1049 /* blackhole type has a boolean type with default value,
1050 * so no need to do any operations in destroy callback
1052 switch (args
->event
) {
1053 case NB_EV_VALIDATE
:
1065 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/frr-nexthops/nexthop/onlink
1067 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_onlink_modify(
1068 struct nb_cb_modify_args
*args
)
1070 return static_nexthop_onlink_modify(args
);
1075 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/frr-nexthops/nexthop/srte-color
1077 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_color_modify(
1078 struct nb_cb_modify_args
*args
)
1080 switch (args
->event
) {
1081 case NB_EV_VALIDATE
:
1086 if (static_nexthop_color_modify(args
) != NB_OK
)
1095 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_color_destroy(
1096 struct nb_cb_destroy_args
*args
)
1098 switch (args
->event
) {
1099 case NB_EV_VALIDATE
:
1104 if (static_nexthop_color_destroy(args
) != NB_OK
)
1113 * /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
1115 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_create(
1116 struct nb_cb_create_args
*args
)
1118 return nexthop_mpls_label_stack_entry_create(args
);
1121 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_destroy(
1122 struct nb_cb_destroy_args
*args
)
1124 return nexthop_mpls_label_stack_entry_destroy(args
);
1129 * /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
1131 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_label_modify(
1132 struct nb_cb_modify_args
*args
)
1134 switch (args
->event
) {
1135 case NB_EV_VALIDATE
:
1140 if (static_nexthop_mpls_label_modify(args
) != NB_OK
)
1147 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_label_destroy(
1148 struct nb_cb_destroy_args
*args
)
1151 * No operation is required in this call back.
1152 * nexthop_mpls_label_stack_entry_destroy() will take care
1153 * to reset the label vaue.
1155 switch (args
->event
) {
1156 case NB_EV_VALIDATE
:
1167 * /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
1169 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_ttl_modify(
1170 struct nb_cb_modify_args
*args
)
1172 switch (args
->event
) {
1173 case NB_EV_VALIDATE
:
1183 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_ttl_destroy(
1184 struct nb_cb_destroy_args
*args
)
1186 switch (args
->event
) {
1187 case NB_EV_VALIDATE
:
1199 * /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
1201 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(
1202 struct nb_cb_modify_args
*args
)
1204 switch (args
->event
) {
1205 case NB_EV_VALIDATE
:
1215 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(
1216 struct nb_cb_destroy_args
*args
)
1218 switch (args
->event
) {
1219 case NB_EV_VALIDATE
: