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
;
291 nh
= nb_running_get_entry(args
->dnode
, NULL
, true);
292 nh
->onlink
= yang_dnode_get_bool(args
->dnode
, NULL
);
297 static int static_nexthop_color_modify(struct nb_cb_modify_args
*args
)
299 struct static_nexthop
*nh
;
301 nh
= nb_running_get_entry(args
->dnode
, NULL
, true);
302 nh
->color
= yang_dnode_get_uint32(args
->dnode
, NULL
);
307 static int static_nexthop_color_destroy(struct nb_cb_destroy_args
*args
)
309 struct static_nexthop
*nh
;
311 nh
= nb_running_unset_entry(args
->dnode
);
317 static int static_nexthop_bh_type_modify(struct nb_cb_modify_args
*args
)
319 struct static_nexthop
*nh
;
321 nh
= nb_running_get_entry(args
->dnode
, NULL
, true);
322 nh
->bh_type
= yang_dnode_get_enum(args
->dnode
, NULL
);
328 void routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_apply_finish(
329 struct nb_cb_apply_finish_args
*args
)
331 struct static_nexthop
*nh
;
332 struct static_path
*pn
;
333 struct route_node
*rn
;
334 const struct lyd_node
*pn_dnode
;
335 const struct lyd_node
*rn_dnode
;
338 struct stable_info
*info
;
341 nh_type
= yang_dnode_get_enum(args
->dnode
, "./nh-type");
342 ifname
= yang_dnode_get_string(args
->dnode
, "./interface");
343 nh_vrf
= yang_dnode_get_string(args
->dnode
, "./vrf");
345 nh
= nb_running_get_entry(args
->dnode
, NULL
, true);
347 pn_dnode
= yang_dnode_get_parent(args
->dnode
, "path-list");
348 pn
= nb_running_get_entry(pn_dnode
, NULL
, true);
350 rn_dnode
= yang_dnode_get_parent(pn_dnode
, "route-list");
351 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
352 info
= route_table_get_info(rn
->table
);
354 static_install_nexthop(rn
, pn
, nh
, info
->safi
, info
->svrf
, ifname
,
359 void routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_apply_finish(
360 struct nb_cb_apply_finish_args
*args
)
362 struct static_nexthop
*nh
;
363 struct static_path
*pn
;
364 struct route_node
*rn
;
365 struct route_node
*src_rn
;
366 const struct lyd_node
*pn_dnode
;
367 const struct lyd_node
*rn_dnode
;
368 const struct lyd_node
*src_dnode
;
371 struct stable_info
*info
;
374 nh_type
= yang_dnode_get_enum(args
->dnode
, "./nh-type");
375 ifname
= yang_dnode_get_string(args
->dnode
, "./interface");
376 nh_vrf
= yang_dnode_get_string(args
->dnode
, "./vrf");
378 nh
= nb_running_get_entry(args
->dnode
, NULL
, true);
380 pn_dnode
= yang_dnode_get_parent(args
->dnode
, "path-list");
381 pn
= nb_running_get_entry(pn_dnode
, NULL
, true);
383 src_dnode
= yang_dnode_get_parent(pn_dnode
, "src-list");
384 src_rn
= nb_running_get_entry(src_dnode
, NULL
, true);
386 rn_dnode
= yang_dnode_get_parent(src_dnode
, "route-list");
387 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
388 info
= route_table_get_info(rn
->table
);
390 static_install_nexthop(src_rn
, pn
, nh
, info
->safi
, info
->svrf
, ifname
,
393 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_pre_validate(
394 struct nb_cb_pre_validate_args
*args
)
396 const struct lyd_node
*mls_dnode
;
399 mls_dnode
= yang_dnode_get(args
->dnode
, "./mpls-label-stack");
400 count
= yang_get_list_elements_count(yang_dnode_get_child(mls_dnode
));
402 if (count
> MPLS_MAX_LABELS
) {
403 snprintf(args
->errmsg
, args
->errmsg_len
,
404 "Too many labels, Enter %d or fewer",
406 return NB_ERR_VALIDATION
;
411 int routing_control_plane_protocols_name_validate(
412 struct nb_cb_create_args
*args
)
416 name
= yang_dnode_get_string(args
->dnode
, "./name");
417 if (!strmatch(name
, "staticd")) {
418 snprintf(args
->errmsg
, args
->errmsg_len
,
419 "static routing supports only one instance with name staticd");
420 return NB_ERR_VALIDATION
;
426 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list
428 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_create(
429 struct nb_cb_create_args
*args
)
432 struct static_vrf
*s_vrf
;
433 struct route_node
*rn
;
434 const struct lyd_node
*vrf_dnode
;
435 struct prefix prefix
;
436 const char *afi_safi
;
441 switch (args
->event
) {
443 yang_dnode_get_prefix(&prefix
, args
->dnode
, "./prefix");
444 afi_safi
= yang_dnode_get_string(args
->dnode
, "./afi-safi");
445 yang_afi_safi_identity2value(afi_safi
, &afi
, &safi
);
446 prefix_afi
= family2afi(prefix
.family
);
447 if (afi
!= prefix_afi
) {
449 EC_LIB_NB_CB_CONFIG_VALIDATE
,
450 "route node %s creation failed",
451 yang_dnode_get_string(args
->dnode
, "./prefix"));
452 return NB_ERR_VALIDATION
;
459 vrf_dnode
= yang_dnode_get_parent(args
->dnode
,
460 "control-plane-protocol");
461 vrf
= nb_running_get_entry(vrf_dnode
, NULL
, true);
464 yang_dnode_get_prefix(&prefix
, args
->dnode
, "./prefix");
465 afi_safi
= yang_dnode_get_string(args
->dnode
, "./afi-safi");
466 yang_afi_safi_identity2value(afi_safi
, &afi
, &safi
);
468 rn
= static_add_route(afi
, safi
, &prefix
, NULL
, s_vrf
);
471 EC_LIB_NB_CB_CONFIG_APPLY
,
472 "route node %s creation failed",
473 yang_dnode_get_string(args
->dnode
, "./prefix"));
476 if (vrf
->vrf_id
== VRF_UNKNOWN
)
478 args
->errmsg
, args
->errmsg_len
,
479 "Static Route to %s not installed currently because dependent config not fully available",
480 yang_dnode_get_string(args
->dnode
, "./prefix"));
481 nb_running_set_entry(args
->dnode
, rn
);
487 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_destroy(
488 struct nb_cb_destroy_args
*args
)
490 struct route_node
*rn
;
491 struct stable_info
*info
;
493 switch (args
->event
) {
499 rn
= nb_running_unset_entry(args
->dnode
);
500 info
= route_table_get_info(rn
->table
);
501 static_del_route(rn
, info
->safi
, info
->svrf
);
509 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list
511 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_create(
512 struct nb_cb_create_args
*args
)
514 return static_path_list_create(args
);
517 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_destroy(
518 struct nb_cb_destroy_args
*args
)
520 const struct lyd_node
*rn_dnode
;
521 struct route_node
*rn
;
522 struct stable_info
*info
;
524 switch (args
->event
) {
530 rn_dnode
= yang_dnode_get_parent(args
->dnode
, "route-list");
531 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
532 info
= route_table_get_info(rn
->table
);
533 static_path_list_destroy(args
, rn_dnode
, info
);
541 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/tag
543 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_tag_modify(
544 struct nb_cb_modify_args
*args
)
546 struct stable_info
*info
;
547 struct route_node
*rn
;
548 const struct lyd_node
*rn_dnode
;
550 switch (args
->event
) {
556 rn_dnode
= yang_dnode_get_parent(args
->dnode
, "route-list");
557 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
558 info
= route_table_get_info(rn
->table
);
559 static_path_list_tag_modify(args
, rn_dnode
, info
);
568 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop
570 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_create(
571 struct nb_cb_create_args
*args
)
573 struct route_node
*rn
;
574 const struct lyd_node
*rn_dnode
;
575 struct stable_info
*info
;
577 switch (args
->event
) {
579 rn_dnode
= yang_dnode_get_parent(args
->dnode
, "route-list");
580 if (static_nexthop_create(args
, rn_dnode
, NULL
) != NB_OK
)
581 return NB_ERR_VALIDATION
;
587 rn_dnode
= yang_dnode_get_parent(args
->dnode
, "route-list");
588 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
589 info
= route_table_get_info(rn
->table
);
591 if (static_nexthop_create(args
, rn_dnode
, info
) != NB_OK
)
592 return NB_ERR_VALIDATION
;
598 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_destroy(
599 struct nb_cb_destroy_args
*args
)
601 struct route_node
*rn
;
602 const struct lyd_node
*rn_dnode
;
603 struct stable_info
*info
;
605 switch (args
->event
) {
611 rn_dnode
= yang_dnode_get_parent(args
->dnode
, "route-list");
612 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
613 info
= route_table_get_info(rn
->table
);
615 if (static_nexthop_destroy(args
, rn_dnode
, info
) != NB_OK
)
624 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/bh-type
626 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_bh_type_modify(
627 struct nb_cb_modify_args
*args
)
629 switch (args
->event
) {
635 if (static_nexthop_bh_type_modify(args
) != NB_OK
)
642 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_bh_type_destroy(
643 struct nb_cb_destroy_args
*args
)
645 /* blackhole type has a boolean type with default value,
646 * so no need to do any operations in destroy callback
648 switch (args
->event
) {
660 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/onlink
662 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_onlink_modify(
663 struct nb_cb_modify_args
*args
)
665 switch (args
->event
) {
671 if (static_nexthop_onlink_modify(args
) != NB_OK
)
678 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_onlink_destroy(
679 struct nb_cb_destroy_args
*args
)
681 /* onlink has a boolean type with default value,
682 * so no need to do any operations in destroy callback
684 switch (args
->event
) {
696 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/srte-color
698 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_color_modify(
699 struct nb_cb_modify_args
*args
)
701 switch (args
->event
) {
707 if (static_nexthop_color_modify(args
) != NB_OK
)
715 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_color_destroy(
716 struct nb_cb_destroy_args
*args
)
718 switch (args
->event
) {
724 if (static_nexthop_color_destroy(args
) != NB_OK
)
733 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/mpls-label-stack/entry
735 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_create(
736 struct nb_cb_create_args
*args
)
738 return nexthop_mpls_label_stack_entry_create(args
);
741 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_destroy(
742 struct nb_cb_destroy_args
*args
)
744 return nexthop_mpls_label_stack_entry_destroy(args
);
749 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/mpls-label-stack/entry/label
751 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_label_modify(
752 struct nb_cb_modify_args
*args
)
754 switch (args
->event
) {
760 if (static_nexthop_mpls_label_modify(args
) != NB_OK
)
767 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_label_destroy(
768 struct nb_cb_destroy_args
*args
)
771 * No operation is required in this call back.
772 * nexthop_mpls_label_stack_entry_destroy() will take care
773 * to reset the label vaue.
775 switch (args
->event
) {
787 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/mpls-label-stack/entry/ttl
789 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_ttl_modify(
790 struct nb_cb_modify_args
*args
)
792 switch (args
->event
) {
803 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_ttl_destroy(
804 struct nb_cb_destroy_args
*args
)
806 switch (args
->event
) {
819 * /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
821 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_traffic_class_modify(
822 struct nb_cb_modify_args
*args
)
824 switch (args
->event
) {
835 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_traffic_class_destroy(
836 struct nb_cb_destroy_args
*args
)
838 switch (args
->event
) {
851 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list
853 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_create(
854 struct nb_cb_create_args
*args
)
856 struct static_vrf
*s_vrf
;
857 struct route_node
*rn
;
858 struct route_node
*src_rn
;
859 struct prefix_ipv6 src_prefix
= {};
860 struct stable_info
*info
;
862 safi_t safi
= SAFI_UNICAST
;
864 switch (args
->event
) {
870 rn
= nb_running_get_entry(args
->dnode
, NULL
, true);
871 info
= route_table_get_info(rn
->table
);
873 yang_dnode_get_ipv6p(&src_prefix
, args
->dnode
, "./src-prefix");
874 afi
= family2afi(src_prefix
.family
);
876 static_add_route(afi
, safi
, &rn
->p
, &src_prefix
, s_vrf
);
878 flog_warn(EC_LIB_NB_CB_CONFIG_APPLY
,
879 "src rn %s creation failed",
880 yang_dnode_get_string(args
->dnode
,
884 nb_running_set_entry(args
->dnode
, src_rn
);
890 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_destroy(
891 struct nb_cb_destroy_args
*args
)
893 struct route_node
*src_rn
;
894 struct route_node
*rn
;
895 struct stable_info
*info
;
896 const struct lyd_node
*rn_dnode
;
898 switch (args
->event
) {
904 src_rn
= nb_running_unset_entry(args
->dnode
);
905 rn_dnode
= yang_dnode_get_parent(args
->dnode
, "route-list");
906 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
907 info
= route_table_get_info(rn
->table
);
908 static_del_route(src_rn
, info
->safi
, info
->svrf
);
917 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list
919 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_create(
920 struct nb_cb_create_args
*args
)
922 return static_path_list_create(args
);
925 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_destroy(
926 struct nb_cb_destroy_args
*args
)
928 struct route_node
*rn
;
929 const struct lyd_node
*rn_dnode
;
930 const struct lyd_node
*srn_dnode
;
931 struct stable_info
*info
;
933 switch (args
->event
) {
939 srn_dnode
= yang_dnode_get_parent(args
->dnode
, "src-list");
940 rn_dnode
= yang_dnode_get_parent(srn_dnode
, "route-list");
941 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
942 info
= route_table_get_info(rn
->table
);
943 static_path_list_destroy(args
, srn_dnode
, info
);
951 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/tag
953 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_tag_modify(
954 struct nb_cb_modify_args
*args
)
956 struct stable_info
*info
;
957 struct route_node
*rn
;
958 const struct lyd_node
*srn_dnode
;
959 const struct lyd_node
*rn_dnode
;
961 switch (args
->event
) {
967 srn_dnode
= yang_dnode_get_parent(args
->dnode
, "src-list");
968 rn_dnode
= yang_dnode_get_parent(srn_dnode
, "route-list");
969 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
970 info
= route_table_get_info(rn
->table
);
971 static_path_list_tag_modify(args
, srn_dnode
, info
);
979 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/frr-nexthops/nexthop
981 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_create(
982 struct nb_cb_create_args
*args
)
984 struct route_node
*rn
;
985 const struct lyd_node
*rn_dnode
;
986 const struct lyd_node
*src_dnode
;
987 struct stable_info
*info
;
989 switch (args
->event
) {
991 rn_dnode
= yang_dnode_get_parent(args
->dnode
, "route-list");
992 if (static_nexthop_create(args
, rn_dnode
, NULL
) != NB_OK
)
993 return NB_ERR_VALIDATION
;
999 src_dnode
= yang_dnode_get_parent(args
->dnode
, "src-list");
1000 rn_dnode
= yang_dnode_get_parent(src_dnode
, "route-list");
1001 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
1002 info
= route_table_get_info(rn
->table
);
1004 if (static_nexthop_create(args
, src_dnode
, info
) != NB_OK
)
1005 return NB_ERR_VALIDATION
;
1012 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_destroy(
1013 struct nb_cb_destroy_args
*args
)
1015 struct route_node
*rn
;
1016 const struct lyd_node
*rn_dnode
;
1017 const struct lyd_node
*src_dnode
;
1018 struct stable_info
*info
;
1020 switch (args
->event
) {
1021 case NB_EV_VALIDATE
:
1026 src_dnode
= yang_dnode_get_parent(args
->dnode
, "src-list");
1027 rn_dnode
= yang_dnode_get_parent(src_dnode
, "route-list");
1028 rn
= nb_running_get_entry(rn_dnode
, NULL
, true);
1029 info
= route_table_get_info(rn
->table
);
1031 if (static_nexthop_destroy(args
, rn_dnode
, info
) != NB_OK
)
1040 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/frr-nexthops/nexthop/bh-type
1042 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_bh_type_modify(
1043 struct nb_cb_modify_args
*args
)
1045 switch (args
->event
) {
1046 case NB_EV_VALIDATE
:
1051 if (static_nexthop_bh_type_modify(args
) != NB_OK
)
1058 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_bh_type_destroy(
1059 struct nb_cb_destroy_args
*args
)
1061 /* blackhole type has a boolean type with default value,
1062 * so no need to do any operations in destroy callback
1064 switch (args
->event
) {
1065 case NB_EV_VALIDATE
:
1077 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/frr-nexthops/nexthop/onlink
1079 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_onlink_modify(
1080 struct nb_cb_modify_args
*args
)
1082 switch (args
->event
) {
1083 case NB_EV_VALIDATE
:
1088 if (static_nexthop_onlink_modify(args
) != NB_OK
)
1097 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_onlink_destroy(
1098 struct nb_cb_destroy_args
*args
)
1100 /* onlink has a boolean type with default value,
1101 * so no need to do any operations in destroy callback
1103 switch (args
->event
) {
1104 case NB_EV_VALIDATE
:
1115 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/frr-nexthops/nexthop/srte-color
1117 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_color_modify(
1118 struct nb_cb_modify_args
*args
)
1120 switch (args
->event
) {
1121 case NB_EV_VALIDATE
:
1126 if (static_nexthop_color_modify(args
) != NB_OK
)
1135 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_color_destroy(
1136 struct nb_cb_destroy_args
*args
)
1138 switch (args
->event
) {
1139 case NB_EV_VALIDATE
:
1144 if (static_nexthop_color_destroy(args
) != NB_OK
)
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
1155 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_create(
1156 struct nb_cb_create_args
*args
)
1158 return nexthop_mpls_label_stack_entry_create(args
);
1161 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_destroy(
1162 struct nb_cb_destroy_args
*args
)
1164 return nexthop_mpls_label_stack_entry_destroy(args
);
1169 * /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
1171 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_label_modify(
1172 struct nb_cb_modify_args
*args
)
1174 switch (args
->event
) {
1175 case NB_EV_VALIDATE
:
1180 if (static_nexthop_mpls_label_modify(args
) != NB_OK
)
1187 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_label_destroy(
1188 struct nb_cb_destroy_args
*args
)
1191 * No operation is required in this call back.
1192 * nexthop_mpls_label_stack_entry_destroy() will take care
1193 * to reset the label vaue.
1195 switch (args
->event
) {
1196 case NB_EV_VALIDATE
:
1207 * /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
1209 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_ttl_modify(
1210 struct nb_cb_modify_args
*args
)
1212 switch (args
->event
) {
1213 case NB_EV_VALIDATE
:
1223 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_ttl_destroy(
1224 struct nb_cb_destroy_args
*args
)
1226 switch (args
->event
) {
1227 case NB_EV_VALIDATE
:
1239 * /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
1241 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(
1242 struct nb_cb_modify_args
*args
)
1244 switch (args
->event
) {
1245 case NB_EV_VALIDATE
:
1255 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(
1256 struct nb_cb_destroy_args
*args
)
1258 switch (args
->event
) {
1259 case NB_EV_VALIDATE
: