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
);
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
) {
229 nh
= nb_running_get_entry(args
->dnode
, NULL
, true);
230 pos
= yang_get_list_pos(args
->dnode
);
232 flog_warn(EC_LIB_NB_CB_CONFIG_APPLY
,
233 "libyang returns invalid label position");
236 /* Mapping to array = list-index -1 */
238 nh
->snh_label
.label
[index
] = 0;
239 nh
->snh_label
.num_labels
++;
247 nexthop_mpls_label_stack_entry_destroy(struct nb_cb_destroy_args
*args
)
249 struct static_nexthop
*nh
;
253 switch (args
->event
) {
259 nh
= nb_running_get_entry(args
->dnode
, NULL
, true);
260 pos
= yang_get_list_pos(args
->dnode
);
262 flog_warn(EC_LIB_NB_CB_CONFIG_APPLY
,
263 "libyang returns invalid label position");
267 nh
->snh_label
.label
[index
] = 0;
268 nh
->snh_label
.num_labels
--;
275 static int static_nexthop_mpls_label_modify(struct nb_cb_modify_args
*args
)
277 struct static_nexthop
*nh
;
281 nh
= nb_running_get_entry(args
->dnode
, NULL
, true);
282 pos
= yang_get_list_pos(args
->dnode
->parent
);
284 flog_warn(EC_LIB_NB_CB_CONFIG_APPLY
,
285 "libyang returns invalid label position");
288 /* Mapping to array = list-index -1 */
290 nh
->snh_label
.label
[index
] = yang_dnode_get_uint32(args
->dnode
, NULL
);
295 static int static_nexthop_onlink_modify(struct nb_cb_modify_args
*args
)
297 struct static_nexthop
*nh
;
299 nh
= nb_running_get_entry(args
->dnode
, NULL
, true);
300 nh
->onlink
= yang_dnode_get_bool(args
->dnode
, NULL
);
305 static int static_nexthop_bh_type_modify(struct nb_cb_modify_args
*args
)
307 struct static_nexthop
*nh
;
309 nh
= nb_running_get_entry(args
->dnode
, NULL
, true);
310 nh
->bh_type
= yang_dnode_get_enum(args
->dnode
, NULL
);
316 void routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_apply_finish(
317 struct nb_cb_apply_finish_args
*args
)
319 struct static_nexthop
*nh
;
320 struct static_path
*pn
;
321 struct route_node
*rn
;
322 const struct lyd_node
*pn_dnode
;
323 const struct lyd_node
*rn_dnode
;
326 struct stable_info
*info
;
329 nh_type
= yang_dnode_get_enum(args
->dnode
, "./nh-type");
330 ifname
= yang_dnode_get_string(args
->dnode
, "./interface");
331 nh_vrf
= yang_dnode_get_string(args
->dnode
, "./vrf");
333 nh
= nb_running_get_entry(args
->dnode
, NULL
, true);
335 pn_dnode
= yang_dnode_get_parent(args
->dnode
, "path-list");
336 pn
= nb_running_get_entry(pn_dnode
, NULL
, true);
338 rn_dnode
= yang_dnode_get_parent(pn_dnode
, "route-list");
339 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
340 info
= route_table_get_info(rn
->table
);
342 static_install_nexthop(rn
, pn
, nh
, info
->safi
, info
->svrf
, ifname
,
347 void routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_apply_finish(
348 struct nb_cb_apply_finish_args
*args
)
350 struct static_nexthop
*nh
;
351 struct static_path
*pn
;
352 struct route_node
*rn
;
353 struct route_node
*src_rn
;
354 const struct lyd_node
*pn_dnode
;
355 const struct lyd_node
*rn_dnode
;
356 const struct lyd_node
*src_dnode
;
359 struct stable_info
*info
;
362 nh_type
= yang_dnode_get_enum(args
->dnode
, "./nh-type");
363 ifname
= yang_dnode_get_string(args
->dnode
, "./interface");
364 nh_vrf
= yang_dnode_get_string(args
->dnode
, "./vrf");
366 nh
= nb_running_get_entry(args
->dnode
, NULL
, true);
368 pn_dnode
= yang_dnode_get_parent(args
->dnode
, "path-list");
369 pn
= nb_running_get_entry(pn_dnode
, NULL
, true);
371 src_dnode
= yang_dnode_get_parent(pn_dnode
, "src-list");
372 src_rn
= nb_running_get_entry(src_dnode
, NULL
, true);
374 rn_dnode
= yang_dnode_get_parent(src_dnode
, "route-list");
375 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
376 info
= route_table_get_info(rn
->table
);
378 static_install_nexthop(src_rn
, pn
, nh
, info
->safi
, info
->svrf
, ifname
,
381 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_pre_validate(
382 struct nb_cb_pre_validate_args
*args
)
384 const struct lyd_node
*mls_dnode
;
387 mls_dnode
= yang_dnode_get(args
->dnode
, "./mpls-label-stack");
388 count
= yang_get_list_elements_count(yang_dnode_get_child(mls_dnode
));
390 if (count
> MPLS_MAX_LABELS
) {
391 snprintf(args
->errmsg
, args
->errmsg_len
,
392 "Too many labels, Enter %d or fewer",
394 return NB_ERR_VALIDATION
;
399 int routing_control_plane_protocols_name_validate(
400 struct nb_cb_create_args
*args
)
404 name
= yang_dnode_get_string(args
->dnode
, "./name");
405 if (!strmatch(name
, "staticd")) {
406 snprintf(args
->errmsg
, args
->errmsg_len
,
407 "static routing supports only one instance with name staticd");
408 return NB_ERR_VALIDATION
;
414 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list
416 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_create(
417 struct nb_cb_create_args
*args
)
420 struct static_vrf
*s_vrf
;
421 struct route_node
*rn
;
422 const struct lyd_node
*vrf_dnode
;
423 struct prefix prefix
;
424 const char *afi_safi
;
429 switch (args
->event
) {
431 yang_dnode_get_prefix(&prefix
, args
->dnode
, "./prefix");
432 afi_safi
= yang_dnode_get_string(args
->dnode
, "./afi-safi");
433 yang_afi_safi_identity2value(afi_safi
, &afi
, &safi
);
434 prefix_afi
= family2afi(prefix
.family
);
435 if (afi
!= prefix_afi
) {
437 EC_LIB_NB_CB_CONFIG_VALIDATE
,
438 "route node %s creation failed",
439 yang_dnode_get_string(args
->dnode
, "./prefix"));
440 return NB_ERR_VALIDATION
;
447 vrf_dnode
= yang_dnode_get_parent(args
->dnode
,
448 "control-plane-protocol");
449 vrf
= nb_running_get_entry(vrf_dnode
, NULL
, true);
452 yang_dnode_get_prefix(&prefix
, args
->dnode
, "./prefix");
453 afi_safi
= yang_dnode_get_string(args
->dnode
, "./afi-safi");
454 yang_afi_safi_identity2value(afi_safi
, &afi
, &safi
);
456 rn
= static_add_route(afi
, safi
, &prefix
, NULL
, s_vrf
);
459 EC_LIB_NB_CB_CONFIG_APPLY
,
460 "route node %s creation failed",
461 yang_dnode_get_string(args
->dnode
, "./prefix"));
464 nb_running_set_entry(args
->dnode
, rn
);
470 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_destroy(
471 struct nb_cb_destroy_args
*args
)
473 struct route_node
*rn
;
474 struct stable_info
*info
;
476 switch (args
->event
) {
482 rn
= nb_running_unset_entry(args
->dnode
);
483 info
= route_table_get_info(rn
->table
);
484 static_del_route(rn
, info
->safi
, info
->svrf
);
492 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list
494 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_create(
495 struct nb_cb_create_args
*args
)
497 return static_path_list_create(args
);
500 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_destroy(
501 struct nb_cb_destroy_args
*args
)
503 const struct lyd_node
*rn_dnode
;
504 struct route_node
*rn
;
505 struct stable_info
*info
;
507 switch (args
->event
) {
513 rn_dnode
= yang_dnode_get_parent(args
->dnode
, "route-list");
514 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
515 info
= route_table_get_info(rn
->table
);
516 static_path_list_destroy(args
, rn_dnode
, info
);
524 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/tag
526 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_tag_modify(
527 struct nb_cb_modify_args
*args
)
529 struct stable_info
*info
;
530 struct route_node
*rn
;
531 const struct lyd_node
*rn_dnode
;
533 switch (args
->event
) {
539 rn_dnode
= yang_dnode_get_parent(args
->dnode
, "route-list");
540 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
541 info
= route_table_get_info(rn
->table
);
542 static_path_list_tag_modify(args
, rn_dnode
, info
);
551 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/table-id
553 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_table_id_modify(
554 struct nb_cb_modify_args
*args
)
556 struct route_node
*rn
;
557 const struct lyd_node
*rn_dnode
;
558 struct stable_info
*info
;
560 switch (args
->event
) {
562 if (static_path_list_tableid_modify(args
, NULL
, NULL
) != NB_OK
)
563 return NB_ERR_VALIDATION
;
569 rn_dnode
= yang_dnode_get_parent(args
->dnode
, "route-list");
570 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
571 info
= route_table_get_info(rn
->table
);
573 if (static_path_list_tableid_modify(args
, rn_dnode
, info
)
575 return NB_ERR_VALIDATION
;
583 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop
585 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_create(
586 struct nb_cb_create_args
*args
)
588 struct route_node
*rn
;
589 const struct lyd_node
*rn_dnode
;
590 struct stable_info
*info
;
592 switch (args
->event
) {
594 rn_dnode
= yang_dnode_get_parent(args
->dnode
, "route-list");
595 if (static_nexthop_create(args
, rn_dnode
, NULL
) != NB_OK
)
596 return NB_ERR_VALIDATION
;
602 rn_dnode
= yang_dnode_get_parent(args
->dnode
, "route-list");
603 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
604 info
= route_table_get_info(rn
->table
);
606 if (static_nexthop_create(args
, rn_dnode
, info
) != NB_OK
)
607 return NB_ERR_VALIDATION
;
613 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_destroy(
614 struct nb_cb_destroy_args
*args
)
616 struct route_node
*rn
;
617 const struct lyd_node
*rn_dnode
;
618 struct stable_info
*info
;
620 switch (args
->event
) {
626 rn_dnode
= yang_dnode_get_parent(args
->dnode
, "route-list");
627 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
628 info
= route_table_get_info(rn
->table
);
630 if (static_nexthop_destroy(args
, rn_dnode
, info
) != NB_OK
)
639 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/bh-type
641 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_bh_type_modify(
642 struct nb_cb_modify_args
*args
)
644 switch (args
->event
) {
650 if (static_nexthop_bh_type_modify(args
) != NB_OK
)
657 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_bh_type_destroy(
658 struct nb_cb_destroy_args
*args
)
660 /* blackhole type has a boolean type with default value,
661 * so no need to do any operations in destroy callback
663 switch (args
->event
) {
675 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/onlink
677 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_onlink_modify(
678 struct nb_cb_modify_args
*args
)
680 switch (args
->event
) {
686 if (static_nexthop_onlink_modify(args
) != NB_OK
)
693 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_onlink_destroy(
694 struct nb_cb_destroy_args
*args
)
696 /* onlink has a boolean type with default value,
697 * so no need to do any operations in destroy callback
699 switch (args
->event
) {
710 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/mpls-label-stack/entry
712 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_create(
713 struct nb_cb_create_args
*args
)
715 return nexthop_mpls_label_stack_entry_create(args
);
718 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_destroy(
719 struct nb_cb_destroy_args
*args
)
721 return nexthop_mpls_label_stack_entry_destroy(args
);
726 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/mpls-label-stack/entry/label
728 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_label_modify(
729 struct nb_cb_modify_args
*args
)
731 switch (args
->event
) {
737 if (static_nexthop_mpls_label_modify(args
) != NB_OK
)
744 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_label_destroy(
745 struct nb_cb_destroy_args
*args
)
748 * No operation is required in this call back.
749 * nexthop_mpls_label_stack_entry_destroy() will take care
750 * to reset the label vaue.
752 switch (args
->event
) {
764 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/mpls-label-stack/entry/ttl
766 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_ttl_modify(
767 struct nb_cb_modify_args
*args
)
769 switch (args
->event
) {
780 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_ttl_destroy(
781 struct nb_cb_destroy_args
*args
)
783 switch (args
->event
) {
796 * /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
798 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_traffic_class_modify(
799 struct nb_cb_modify_args
*args
)
801 switch (args
->event
) {
812 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_traffic_class_destroy(
813 struct nb_cb_destroy_args
*args
)
815 switch (args
->event
) {
828 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list
830 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_create(
831 struct nb_cb_create_args
*args
)
833 struct static_vrf
*s_vrf
;
834 struct route_node
*rn
;
835 struct route_node
*src_rn
;
836 struct prefix_ipv6 src_prefix
= {};
837 struct stable_info
*info
;
839 safi_t safi
= SAFI_UNICAST
;
841 switch (args
->event
) {
847 rn
= nb_running_get_entry(args
->dnode
, NULL
, true);
848 info
= route_table_get_info(rn
->table
);
850 yang_dnode_get_ipv6p(&src_prefix
, args
->dnode
, "./src-prefix");
851 afi
= family2afi(src_prefix
.family
);
853 static_add_route(afi
, safi
, &rn
->p
, &src_prefix
, s_vrf
);
855 flog_warn(EC_LIB_NB_CB_CONFIG_APPLY
,
856 "src rn %s creation failed",
857 yang_dnode_get_string(args
->dnode
,
861 nb_running_set_entry(args
->dnode
, src_rn
);
867 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_destroy(
868 struct nb_cb_destroy_args
*args
)
870 struct route_node
*src_rn
;
871 struct route_node
*rn
;
872 struct stable_info
*info
;
873 const struct lyd_node
*rn_dnode
;
875 switch (args
->event
) {
881 src_rn
= nb_running_unset_entry(args
->dnode
);
882 rn_dnode
= yang_dnode_get_parent(args
->dnode
, "route-list");
883 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
884 info
= route_table_get_info(rn
->table
);
885 static_del_route(src_rn
, info
->safi
, info
->svrf
);
894 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list
896 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_create(
897 struct nb_cb_create_args
*args
)
899 return static_path_list_create(args
);
902 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_destroy(
903 struct nb_cb_destroy_args
*args
)
905 struct route_node
*rn
;
906 const struct lyd_node
*rn_dnode
;
907 const struct lyd_node
*srn_dnode
;
908 struct stable_info
*info
;
910 switch (args
->event
) {
916 srn_dnode
= yang_dnode_get_parent(args
->dnode
, "src-list");
917 rn_dnode
= yang_dnode_get_parent(srn_dnode
, "route-list");
918 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
919 info
= route_table_get_info(rn
->table
);
920 static_path_list_destroy(args
, srn_dnode
, info
);
928 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/tag
930 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_tag_modify(
931 struct nb_cb_modify_args
*args
)
933 struct stable_info
*info
;
934 struct route_node
*rn
;
935 const struct lyd_node
*srn_dnode
;
936 const struct lyd_node
*rn_dnode
;
938 switch (args
->event
) {
944 srn_dnode
= yang_dnode_get_parent(args
->dnode
, "src-list");
945 rn_dnode
= yang_dnode_get_parent(srn_dnode
, "route-list");
946 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
947 info
= route_table_get_info(rn
->table
);
948 static_path_list_tag_modify(args
, srn_dnode
, info
);
956 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/table-id
958 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_table_id_modify(
959 struct nb_cb_modify_args
*args
)
961 struct route_node
*rn
;
962 const struct lyd_node
*rn_dnode
;
963 const struct lyd_node
*src_dnode
;
964 struct stable_info
*info
;
966 switch (args
->event
) {
968 if (static_path_list_tableid_modify(args
, NULL
, NULL
) != NB_OK
)
969 return NB_ERR_VALIDATION
;
975 src_dnode
= yang_dnode_get_parent(args
->dnode
, "src-list");
976 rn_dnode
= yang_dnode_get_parent(src_dnode
, "route-list");
977 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
978 info
= route_table_get_info(rn
->table
);
980 if (static_path_list_tableid_modify(args
, src_dnode
, info
)
982 return NB_ERR_VALIDATION
;
991 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/frr-nexthops/nexthop
993 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_create(
994 struct nb_cb_create_args
*args
)
996 struct route_node
*rn
;
997 const struct lyd_node
*rn_dnode
;
998 const struct lyd_node
*src_dnode
;
999 struct stable_info
*info
;
1001 switch (args
->event
) {
1002 case NB_EV_VALIDATE
:
1003 rn_dnode
= yang_dnode_get_parent(args
->dnode
, "route-list");
1004 if (static_nexthop_create(args
, rn_dnode
, NULL
) != NB_OK
)
1005 return NB_ERR_VALIDATION
;
1011 src_dnode
= yang_dnode_get_parent(args
->dnode
, "src-list");
1012 rn_dnode
= yang_dnode_get_parent(src_dnode
, "route-list");
1013 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
1014 info
= route_table_get_info(rn
->table
);
1016 if (static_nexthop_create(args
, src_dnode
, info
) != NB_OK
)
1017 return NB_ERR_VALIDATION
;
1024 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_destroy(
1025 struct nb_cb_destroy_args
*args
)
1027 struct route_node
*rn
;
1028 const struct lyd_node
*rn_dnode
;
1029 const struct lyd_node
*src_dnode
;
1030 struct stable_info
*info
;
1032 switch (args
->event
) {
1033 case NB_EV_VALIDATE
:
1038 src_dnode
= yang_dnode_get_parent(args
->dnode
, "src-list");
1039 rn_dnode
= yang_dnode_get_parent(src_dnode
, "route-list");
1040 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
1041 info
= route_table_get_info(rn
->table
);
1043 if (static_nexthop_destroy(args
, rn_dnode
, info
) != NB_OK
)
1052 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/frr-nexthops/nexthop/bh-type
1054 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_bh_type_modify(
1055 struct nb_cb_modify_args
*args
)
1057 switch (args
->event
) {
1058 case NB_EV_VALIDATE
:
1063 if (static_nexthop_bh_type_modify(args
) != NB_OK
)
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 switch (args
->event
) {
1095 case NB_EV_VALIDATE
:
1100 if (static_nexthop_onlink_modify(args
) != NB_OK
)
1109 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_onlink_destroy(
1110 struct nb_cb_destroy_args
*args
)
1112 /* onlink has a boolean type with default value,
1113 * so no need to do any operations in destroy callback
1115 switch (args
->event
) {
1116 case NB_EV_VALIDATE
:
1127 * /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
1129 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_create(
1130 struct nb_cb_create_args
*args
)
1132 return nexthop_mpls_label_stack_entry_create(args
);
1135 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_destroy(
1136 struct nb_cb_destroy_args
*args
)
1138 return nexthop_mpls_label_stack_entry_destroy(args
);
1143 * /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
1145 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_label_modify(
1146 struct nb_cb_modify_args
*args
)
1148 switch (args
->event
) {
1149 case NB_EV_VALIDATE
:
1154 if (static_nexthop_mpls_label_modify(args
) != NB_OK
)
1161 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_label_destroy(
1162 struct nb_cb_destroy_args
*args
)
1165 * No operation is required in this call back.
1166 * nexthop_mpls_label_stack_entry_destroy() will take care
1167 * to reset the label vaue.
1169 switch (args
->event
) {
1170 case NB_EV_VALIDATE
:
1181 * /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
1183 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_ttl_modify(
1184 struct nb_cb_modify_args
*args
)
1186 switch (args
->event
) {
1187 case NB_EV_VALIDATE
:
1197 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_ttl_destroy(
1198 struct nb_cb_destroy_args
*args
)
1200 switch (args
->event
) {
1201 case NB_EV_VALIDATE
:
1213 * /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
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_modify(
1216 struct nb_cb_modify_args
*args
)
1218 switch (args
->event
) {
1219 case NB_EV_VALIDATE
:
1229 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(
1230 struct nb_cb_destroy_args
*args
)
1232 switch (args
->event
) {
1233 case NB_EV_VALIDATE
: