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 struct nexthop_iter
{
111 static int nexthop_iter_cb(const struct lyd_node
*dnode
, void *arg
)
113 struct nexthop_iter
*iter
= arg
;
116 nh_type
= yang_dnode_get_enum(dnode
, "./nh-type");
118 if (nh_type
== STATIC_BLACKHOLE
)
119 iter
->blackhole
= true;
123 return YANG_ITER_CONTINUE
;
126 static bool static_nexthop_create(struct nb_cb_create_args
*args
,
127 const struct lyd_node
*rn_dnode
,
128 struct stable_info
*info
)
130 const struct lyd_node
*pn_dnode
;
131 struct nexthop_iter iter
;
132 struct route_node
*rn
;
133 struct static_path
*pn
;
134 struct ipaddr ipaddr
;
135 struct static_nexthop
*nh
;
140 switch (args
->event
) {
142 ifname
= yang_dnode_get_string(args
->dnode
, "./interface");
143 if (ifname
!= NULL
) {
144 if (strcasecmp(ifname
, "Null0") == 0
145 || strcasecmp(ifname
, "reject") == 0
146 || strcasecmp(ifname
, "blackhole") == 0) {
147 snprintf(args
->errmsg
, args
->errmsg_len
,
148 "%s: Nexthop interface name can not be from reserved keywords(Null0, reject, blackhole)",
150 return NB_ERR_VALIDATION
;
155 iter
.blackhole
= false;
157 pn_dnode
= yang_dnode_get_parent(args
->dnode
, "path-list");
158 yang_dnode_iterate(nexthop_iter_cb
, &iter
, pn_dnode
,
159 "./frr-nexthops/nexthop");
161 if (iter
.blackhole
&& iter
.count
> 1) {
163 args
->errmsg
, args
->errmsg_len
,
164 "Route can not have blackhole and non-blackhole nexthops simultaneously");
165 return NB_ERR_VALIDATION
;
172 yang_dnode_get_ip(&ipaddr
, args
->dnode
, "./gateway");
173 nh_type
= yang_dnode_get_enum(args
->dnode
, "./nh-type");
174 ifname
= yang_dnode_get_string(args
->dnode
, "./interface");
175 nh_vrf
= yang_dnode_get_string(args
->dnode
, "./vrf");
176 pn
= nb_running_get_entry(args
->dnode
, NULL
, true);
177 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
179 if (!static_add_nexthop_validate(nh_vrf
, nh_type
, &ipaddr
))
181 EC_LIB_NB_CB_CONFIG_VALIDATE
,
182 "Warning!! Local connected address is configured as Gateway IP((%s))",
183 yang_dnode_get_string(args
->dnode
,
185 nh
= static_add_nexthop(rn
, pn
, info
->safi
, info
->svrf
, nh_type
,
186 &ipaddr
, ifname
, nh_vrf
, 0);
187 nb_running_set_entry(args
->dnode
, nh
);
194 static bool static_nexthop_destroy(struct nb_cb_destroy_args
*args
,
195 const struct lyd_node
*rn_dnode
,
196 struct stable_info
*info
)
198 struct route_node
*rn
;
199 struct static_path
*pn
;
200 const struct lyd_node
*pn_dnode
;
201 struct static_nexthop
*nh
;
204 nh
= nb_running_unset_entry(args
->dnode
);
205 pn_dnode
= yang_dnode_get_parent(args
->dnode
, "path-list");
206 pn
= nb_running_get_entry(pn_dnode
, NULL
, true);
207 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
209 ret
= static_delete_nexthop(rn
, pn
, info
->safi
, info
->svrf
, nh
);
211 char buf
[SRCDEST2STR_BUFFER
];
213 flog_warn(EC_LIB_NB_CB_CONFIG_APPLY
,
214 "%s : nh [%d:%s:%s:%s] nexthop destroy failed",
215 srcdest_rnode2str(rn
, buf
, sizeof(buf
)),
216 yang_dnode_get_enum(args
->dnode
, "./nh-type"),
217 yang_dnode_get_string(args
->dnode
, "./interface"),
218 yang_dnode_get_string(args
->dnode
, "./gateway"),
219 yang_dnode_get_string(args
->dnode
, "./vrf"));
226 static int nexthop_mpls_label_stack_entry_create(struct nb_cb_create_args
*args
)
228 struct static_nexthop
*nh
;
232 switch (args
->event
) {
236 args
->errmsg
, args
->errmsg_len
,
237 "%% MPLS not turned on in kernel ignoring static route");
238 return NB_ERR_VALIDATION
;
245 nh
= nb_running_get_entry(args
->dnode
, NULL
, true);
246 pos
= yang_get_list_pos(args
->dnode
);
248 flog_warn(EC_LIB_NB_CB_CONFIG_APPLY
,
249 "libyang returns invalid label position");
252 /* Mapping to array = list-index -1 */
254 nh
->snh_label
.label
[index
] = 0;
255 nh
->snh_label
.num_labels
++;
263 nexthop_mpls_label_stack_entry_destroy(struct nb_cb_destroy_args
*args
)
265 struct static_nexthop
*nh
;
269 switch (args
->event
) {
275 nh
= nb_running_get_entry(args
->dnode
, NULL
, true);
276 pos
= yang_get_list_pos(args
->dnode
);
278 flog_warn(EC_LIB_NB_CB_CONFIG_APPLY
,
279 "libyang returns invalid label position");
283 nh
->snh_label
.label
[index
] = 0;
284 nh
->snh_label
.num_labels
--;
291 static int static_nexthop_mpls_label_modify(struct nb_cb_modify_args
*args
)
293 struct static_nexthop
*nh
;
297 nh
= nb_running_get_entry(args
->dnode
, NULL
, true);
298 pos
= yang_get_list_pos(args
->dnode
->parent
);
300 flog_warn(EC_LIB_NB_CB_CONFIG_APPLY
,
301 "libyang returns invalid label position");
304 /* Mapping to array = list-index -1 */
306 nh
->snh_label
.label
[index
] = yang_dnode_get_uint32(args
->dnode
, NULL
);
311 static int static_nexthop_onlink_modify(struct nb_cb_modify_args
*args
)
313 struct static_nexthop
*nh
;
314 static_types nh_type
;
316 switch (args
->event
) {
318 nh_type
= yang_dnode_get_enum(args
->dnode
, "../nh-type");
319 if ((nh_type
!= STATIC_IPV4_GATEWAY_IFNAME
)
320 && (nh_type
!= STATIC_IPV6_GATEWAY_IFNAME
)) {
322 args
->errmsg
, args
->errmsg_len
,
323 "nexthop type is not the ipv4 or ipv6 interface type");
324 return NB_ERR_VALIDATION
;
331 nh
= nb_running_get_entry(args
->dnode
, NULL
, true);
332 nh
->onlink
= yang_dnode_get_bool(args
->dnode
, NULL
);
339 static int static_nexthop_color_modify(struct nb_cb_modify_args
*args
)
341 struct static_nexthop
*nh
;
343 nh
= nb_running_get_entry(args
->dnode
, NULL
, true);
344 nh
->color
= yang_dnode_get_uint32(args
->dnode
, NULL
);
349 static int static_nexthop_color_destroy(struct nb_cb_destroy_args
*args
)
351 struct static_nexthop
*nh
;
353 nh
= nb_running_unset_entry(args
->dnode
);
359 static int static_nexthop_bh_type_modify(struct nb_cb_modify_args
*args
)
361 struct static_nexthop
*nh
;
362 static_types nh_type
;
364 switch (args
->event
) {
366 nh_type
= yang_dnode_get_enum(args
->dnode
, "../nh-type");
367 if (nh_type
!= STATIC_BLACKHOLE
) {
368 snprintf(args
->errmsg
, args
->errmsg_len
,
369 "nexthop type is not the blackhole type");
370 return NB_ERR_VALIDATION
;
377 nh
= nb_running_get_entry(args
->dnode
, NULL
, true);
378 nh
->bh_type
= yang_dnode_get_enum(args
->dnode
, NULL
);
386 void routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_apply_finish(
387 struct nb_cb_apply_finish_args
*args
)
389 struct static_nexthop
*nh
;
390 struct static_path
*pn
;
391 struct route_node
*rn
;
392 const struct lyd_node
*pn_dnode
;
393 const struct lyd_node
*rn_dnode
;
396 struct stable_info
*info
;
399 nh_type
= yang_dnode_get_enum(args
->dnode
, "./nh-type");
400 ifname
= yang_dnode_get_string(args
->dnode
, "./interface");
401 nh_vrf
= yang_dnode_get_string(args
->dnode
, "./vrf");
403 nh
= nb_running_get_entry(args
->dnode
, NULL
, true);
405 pn_dnode
= yang_dnode_get_parent(args
->dnode
, "path-list");
406 pn
= nb_running_get_entry(pn_dnode
, NULL
, true);
408 rn_dnode
= yang_dnode_get_parent(pn_dnode
, "route-list");
409 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
410 info
= route_table_get_info(rn
->table
);
412 static_install_nexthop(rn
, pn
, nh
, info
->safi
, info
->svrf
, ifname
,
417 void routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_apply_finish(
418 struct nb_cb_apply_finish_args
*args
)
420 struct static_nexthop
*nh
;
421 struct static_path
*pn
;
422 struct route_node
*rn
;
423 struct route_node
*src_rn
;
424 const struct lyd_node
*pn_dnode
;
425 const struct lyd_node
*rn_dnode
;
426 const struct lyd_node
*src_dnode
;
429 struct stable_info
*info
;
432 nh_type
= yang_dnode_get_enum(args
->dnode
, "./nh-type");
433 ifname
= yang_dnode_get_string(args
->dnode
, "./interface");
434 nh_vrf
= yang_dnode_get_string(args
->dnode
, "./vrf");
436 nh
= nb_running_get_entry(args
->dnode
, NULL
, true);
438 pn_dnode
= yang_dnode_get_parent(args
->dnode
, "path-list");
439 pn
= nb_running_get_entry(pn_dnode
, NULL
, true);
441 src_dnode
= yang_dnode_get_parent(pn_dnode
, "src-list");
442 src_rn
= nb_running_get_entry(src_dnode
, NULL
, true);
444 rn_dnode
= yang_dnode_get_parent(src_dnode
, "route-list");
445 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
446 info
= route_table_get_info(rn
->table
);
448 static_install_nexthop(src_rn
, pn
, nh
, info
->safi
, info
->svrf
, ifname
,
451 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_pre_validate(
452 struct nb_cb_pre_validate_args
*args
)
454 const struct lyd_node
*mls_dnode
;
457 mls_dnode
= yang_dnode_get(args
->dnode
, "./mpls-label-stack");
458 count
= yang_get_list_elements_count(yang_dnode_get_child(mls_dnode
));
460 if (count
> MPLS_MAX_LABELS
) {
461 snprintf(args
->errmsg
, args
->errmsg_len
,
462 "Too many labels, Enter %d or fewer",
464 return NB_ERR_VALIDATION
;
469 int routing_control_plane_protocols_name_validate(
470 struct nb_cb_create_args
*args
)
474 name
= yang_dnode_get_string(args
->dnode
, "./name");
475 if (!strmatch(name
, "staticd")) {
476 snprintf(args
->errmsg
, args
->errmsg_len
,
477 "static routing supports only one instance with name staticd");
478 return NB_ERR_VALIDATION
;
484 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list
486 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_create(
487 struct nb_cb_create_args
*args
)
490 struct static_vrf
*s_vrf
;
491 struct route_node
*rn
;
492 const struct lyd_node
*vrf_dnode
;
493 struct prefix prefix
;
494 const char *afi_safi
;
499 switch (args
->event
) {
501 yang_dnode_get_prefix(&prefix
, args
->dnode
, "./prefix");
502 afi_safi
= yang_dnode_get_string(args
->dnode
, "./afi-safi");
503 yang_afi_safi_identity2value(afi_safi
, &afi
, &safi
);
504 prefix_afi
= family2afi(prefix
.family
);
505 if (afi
!= prefix_afi
) {
507 EC_LIB_NB_CB_CONFIG_VALIDATE
,
508 "route node %s creation failed",
509 yang_dnode_get_string(args
->dnode
, "./prefix"));
510 return NB_ERR_VALIDATION
;
517 vrf_dnode
= yang_dnode_get_parent(args
->dnode
,
518 "control-plane-protocol");
519 vrf
= nb_running_get_entry(vrf_dnode
, NULL
, true);
522 yang_dnode_get_prefix(&prefix
, args
->dnode
, "./prefix");
523 afi_safi
= yang_dnode_get_string(args
->dnode
, "./afi-safi");
524 yang_afi_safi_identity2value(afi_safi
, &afi
, &safi
);
526 rn
= static_add_route(afi
, safi
, &prefix
, NULL
, s_vrf
);
529 EC_LIB_NB_CB_CONFIG_APPLY
,
530 "route node %s creation failed",
531 yang_dnode_get_string(args
->dnode
, "./prefix"));
534 if (vrf
->vrf_id
== VRF_UNKNOWN
)
536 args
->errmsg
, args
->errmsg_len
,
537 "Static Route to %s not installed currently because dependent config not fully available",
538 yang_dnode_get_string(args
->dnode
, "./prefix"));
539 nb_running_set_entry(args
->dnode
, rn
);
545 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_destroy(
546 struct nb_cb_destroy_args
*args
)
548 struct route_node
*rn
;
549 struct stable_info
*info
;
551 switch (args
->event
) {
557 rn
= nb_running_unset_entry(args
->dnode
);
558 info
= route_table_get_info(rn
->table
);
559 static_del_route(rn
, info
->safi
, info
->svrf
);
567 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list
569 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_create(
570 struct nb_cb_create_args
*args
)
572 return static_path_list_create(args
);
575 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_destroy(
576 struct nb_cb_destroy_args
*args
)
578 const struct lyd_node
*rn_dnode
;
579 struct route_node
*rn
;
580 struct stable_info
*info
;
582 switch (args
->event
) {
588 rn_dnode
= yang_dnode_get_parent(args
->dnode
, "route-list");
589 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
590 info
= route_table_get_info(rn
->table
);
591 static_path_list_destroy(args
, rn_dnode
, info
);
599 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/tag
601 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_tag_modify(
602 struct nb_cb_modify_args
*args
)
604 struct stable_info
*info
;
605 struct route_node
*rn
;
606 const struct lyd_node
*rn_dnode
;
608 switch (args
->event
) {
614 rn_dnode
= yang_dnode_get_parent(args
->dnode
, "route-list");
615 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
616 info
= route_table_get_info(rn
->table
);
617 static_path_list_tag_modify(args
, rn_dnode
, info
);
626 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop
628 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_create(
629 struct nb_cb_create_args
*args
)
631 struct route_node
*rn
;
632 const struct lyd_node
*rn_dnode
;
633 struct stable_info
*info
;
635 switch (args
->event
) {
637 rn_dnode
= yang_dnode_get_parent(args
->dnode
, "route-list");
638 if (static_nexthop_create(args
, rn_dnode
, NULL
) != NB_OK
)
639 return NB_ERR_VALIDATION
;
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_create(args
, rn_dnode
, info
) != NB_OK
)
650 return NB_ERR_INCONSISTENCY
;
656 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_destroy(
657 struct nb_cb_destroy_args
*args
)
659 struct route_node
*rn
;
660 const struct lyd_node
*rn_dnode
;
661 struct stable_info
*info
;
663 switch (args
->event
) {
669 rn_dnode
= yang_dnode_get_parent(args
->dnode
, "route-list");
670 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
671 info
= route_table_get_info(rn
->table
);
673 if (static_nexthop_destroy(args
, rn_dnode
, info
) != NB_OK
)
682 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/bh-type
684 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_bh_type_modify(
685 struct nb_cb_modify_args
*args
)
687 return static_nexthop_bh_type_modify(args
);
690 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_bh_type_destroy(
691 struct nb_cb_destroy_args
*args
)
693 /* blackhole type has a boolean type with default value,
694 * so no need to do any operations in destroy callback
696 switch (args
->event
) {
708 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/onlink
710 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_onlink_modify(
711 struct nb_cb_modify_args
*args
)
713 return static_nexthop_onlink_modify(args
);
718 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/srte-color
720 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_color_modify(
721 struct nb_cb_modify_args
*args
)
723 switch (args
->event
) {
729 if (static_nexthop_color_modify(args
) != NB_OK
)
737 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_color_destroy(
738 struct nb_cb_destroy_args
*args
)
740 switch (args
->event
) {
746 if (static_nexthop_color_destroy(args
) != NB_OK
)
755 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/mpls-label-stack/entry
757 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_create(
758 struct nb_cb_create_args
*args
)
760 return nexthop_mpls_label_stack_entry_create(args
);
763 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_destroy(
764 struct nb_cb_destroy_args
*args
)
766 return nexthop_mpls_label_stack_entry_destroy(args
);
771 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/mpls-label-stack/entry/label
773 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_label_modify(
774 struct nb_cb_modify_args
*args
)
776 switch (args
->event
) {
782 if (static_nexthop_mpls_label_modify(args
) != NB_OK
)
789 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_label_destroy(
790 struct nb_cb_destroy_args
*args
)
793 * No operation is required in this call back.
794 * nexthop_mpls_label_stack_entry_destroy() will take care
795 * to reset the label vaue.
797 switch (args
->event
) {
809 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/mpls-label-stack/entry/ttl
811 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_ttl_modify(
812 struct nb_cb_modify_args
*args
)
814 switch (args
->event
) {
825 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_ttl_destroy(
826 struct nb_cb_destroy_args
*args
)
828 switch (args
->event
) {
841 * /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
843 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_traffic_class_modify(
844 struct nb_cb_modify_args
*args
)
846 switch (args
->event
) {
857 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_traffic_class_destroy(
858 struct nb_cb_destroy_args
*args
)
860 switch (args
->event
) {
873 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list
875 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_create(
876 struct nb_cb_create_args
*args
)
878 struct static_vrf
*s_vrf
;
879 struct route_node
*rn
;
880 struct route_node
*src_rn
;
881 struct prefix_ipv6 src_prefix
= {};
882 struct stable_info
*info
;
884 safi_t safi
= SAFI_UNICAST
;
886 switch (args
->event
) {
892 rn
= nb_running_get_entry(args
->dnode
, NULL
, true);
893 info
= route_table_get_info(rn
->table
);
895 yang_dnode_get_ipv6p(&src_prefix
, args
->dnode
, "./src-prefix");
896 afi
= family2afi(src_prefix
.family
);
898 static_add_route(afi
, safi
, &rn
->p
, &src_prefix
, s_vrf
);
900 flog_warn(EC_LIB_NB_CB_CONFIG_APPLY
,
901 "src rn %s creation failed",
902 yang_dnode_get_string(args
->dnode
,
906 nb_running_set_entry(args
->dnode
, src_rn
);
912 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_destroy(
913 struct nb_cb_destroy_args
*args
)
915 struct route_node
*src_rn
;
916 struct route_node
*rn
;
917 struct stable_info
*info
;
918 const struct lyd_node
*rn_dnode
;
920 switch (args
->event
) {
926 src_rn
= nb_running_unset_entry(args
->dnode
);
927 rn_dnode
= yang_dnode_get_parent(args
->dnode
, "route-list");
928 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
929 info
= route_table_get_info(rn
->table
);
930 static_del_route(src_rn
, info
->safi
, info
->svrf
);
939 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list
941 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_create(
942 struct nb_cb_create_args
*args
)
944 return static_path_list_create(args
);
947 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_destroy(
948 struct nb_cb_destroy_args
*args
)
950 struct route_node
*rn
;
951 const struct lyd_node
*rn_dnode
;
952 const struct lyd_node
*srn_dnode
;
953 struct stable_info
*info
;
955 switch (args
->event
) {
961 srn_dnode
= yang_dnode_get_parent(args
->dnode
, "src-list");
962 rn_dnode
= yang_dnode_get_parent(srn_dnode
, "route-list");
963 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
964 info
= route_table_get_info(rn
->table
);
965 static_path_list_destroy(args
, srn_dnode
, info
);
973 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/tag
975 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_tag_modify(
976 struct nb_cb_modify_args
*args
)
978 struct stable_info
*info
;
979 struct route_node
*rn
;
980 const struct lyd_node
*srn_dnode
;
981 const struct lyd_node
*rn_dnode
;
983 switch (args
->event
) {
989 srn_dnode
= yang_dnode_get_parent(args
->dnode
, "src-list");
990 rn_dnode
= yang_dnode_get_parent(srn_dnode
, "route-list");
991 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
992 info
= route_table_get_info(rn
->table
);
993 static_path_list_tag_modify(args
, srn_dnode
, info
);
1001 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/frr-nexthops/nexthop
1003 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_create(
1004 struct nb_cb_create_args
*args
)
1006 struct route_node
*rn
;
1007 const struct lyd_node
*rn_dnode
;
1008 const struct lyd_node
*src_dnode
;
1009 struct stable_info
*info
;
1011 switch (args
->event
) {
1012 case NB_EV_VALIDATE
:
1013 rn_dnode
= yang_dnode_get_parent(args
->dnode
, "route-list");
1014 if (static_nexthop_create(args
, rn_dnode
, NULL
) != NB_OK
)
1015 return NB_ERR_VALIDATION
;
1021 src_dnode
= yang_dnode_get_parent(args
->dnode
, "src-list");
1022 rn_dnode
= yang_dnode_get_parent(src_dnode
, "route-list");
1023 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
1024 info
= route_table_get_info(rn
->table
);
1026 if (static_nexthop_create(args
, src_dnode
, info
) != NB_OK
)
1027 return NB_ERR_VALIDATION
;
1034 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_destroy(
1035 struct nb_cb_destroy_args
*args
)
1037 struct route_node
*rn
;
1038 const struct lyd_node
*rn_dnode
;
1039 const struct lyd_node
*src_dnode
;
1040 struct stable_info
*info
;
1042 switch (args
->event
) {
1043 case NB_EV_VALIDATE
:
1048 src_dnode
= yang_dnode_get_parent(args
->dnode
, "src-list");
1049 rn_dnode
= yang_dnode_get_parent(src_dnode
, "route-list");
1050 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
1051 info
= route_table_get_info(rn
->table
);
1053 if (static_nexthop_destroy(args
, rn_dnode
, info
) != NB_OK
)
1062 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/frr-nexthops/nexthop/bh-type
1064 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_bh_type_modify(
1065 struct nb_cb_modify_args
*args
)
1067 return static_nexthop_bh_type_modify(args
);
1070 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_bh_type_destroy(
1071 struct nb_cb_destroy_args
*args
)
1073 /* blackhole type has a boolean type with default value,
1074 * so no need to do any operations in destroy callback
1076 switch (args
->event
) {
1077 case NB_EV_VALIDATE
:
1089 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/frr-nexthops/nexthop/onlink
1091 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_onlink_modify(
1092 struct nb_cb_modify_args
*args
)
1094 return static_nexthop_onlink_modify(args
);
1099 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/frr-nexthops/nexthop/srte-color
1101 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_color_modify(
1102 struct nb_cb_modify_args
*args
)
1104 switch (args
->event
) {
1105 case NB_EV_VALIDATE
:
1110 if (static_nexthop_color_modify(args
) != NB_OK
)
1119 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_color_destroy(
1120 struct nb_cb_destroy_args
*args
)
1122 switch (args
->event
) {
1123 case NB_EV_VALIDATE
:
1128 if (static_nexthop_color_destroy(args
) != NB_OK
)
1137 * /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
1139 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_create(
1140 struct nb_cb_create_args
*args
)
1142 return nexthop_mpls_label_stack_entry_create(args
);
1145 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_destroy(
1146 struct nb_cb_destroy_args
*args
)
1148 return nexthop_mpls_label_stack_entry_destroy(args
);
1153 * /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
1155 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_label_modify(
1156 struct nb_cb_modify_args
*args
)
1158 switch (args
->event
) {
1159 case NB_EV_VALIDATE
:
1164 if (static_nexthop_mpls_label_modify(args
) != NB_OK
)
1171 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_label_destroy(
1172 struct nb_cb_destroy_args
*args
)
1175 * No operation is required in this call back.
1176 * nexthop_mpls_label_stack_entry_destroy() will take care
1177 * to reset the label vaue.
1179 switch (args
->event
) {
1180 case NB_EV_VALIDATE
:
1191 * /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
1193 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_ttl_modify(
1194 struct nb_cb_modify_args
*args
)
1196 switch (args
->event
) {
1197 case NB_EV_VALIDATE
:
1207 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_ttl_destroy(
1208 struct nb_cb_destroy_args
*args
)
1210 switch (args
->event
) {
1211 case NB_EV_VALIDATE
:
1223 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/frr-nexthops/nexthop/mpls-label-stack/entry/traffic-class
1225 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(
1226 struct nb_cb_modify_args
*args
)
1228 switch (args
->event
) {
1229 case NB_EV_VALIDATE
:
1239 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(
1240 struct nb_cb_destroy_args
*args
)
1242 switch (args
->event
) {
1243 case NB_EV_VALIDATE
: