]> git.proxmox.com Git - mirror_frr.git/blame - staticd/static_nb_config.c
Merge pull request #9019 from pjdruddy/ospfv3-early-break-list-walk
[mirror_frr.git] / staticd / static_nb_config.c
CommitLineData
88fa5104 1/*
2 * Copyright (C) 2018 Vmware
3 * Vishal Dhingra
4 *
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)
8 * any later version.
9 *
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
13 * more details.
14 *
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
18 */
1f8031f7
DL
19#include <zebra.h>
20
88fa5104 21#include "northbound.h"
22#include "libfrr.h"
23#include "log.h"
24#include "lib_errors.h"
25#include "prefix.h"
26#include "table.h"
27#include "vrf.h"
28#include "nexthop.h"
29#include "srcdest_table.h"
30
31#include "static_vrf.h"
32#include "static_routes.h"
33#include "static_nb.h"
34
35
36static int static_path_list_create(struct nb_cb_create_args *args)
37{
38 struct route_node *rn;
39 struct static_path *pn;
ef4b6b22 40 const struct lyd_node *vrf_dnode;
41 const char *vrf;
88fa5104 42 uint8_t distance;
ef4b6b22 43 uint32_t table_id;
88fa5104 44
45 switch (args->event) {
46 case NB_EV_VALIDATE:
ef4b6b22 47 vrf_dnode = yang_dnode_get_parent(args->dnode,
48 "control-plane-protocol");
49 vrf = yang_dnode_get_string(vrf_dnode, "./vrf");
50 table_id = yang_dnode_get_uint32(args->dnode, "./table-id");
51
52 /*
53 * TableId is not applicable for VRF. Consider the case of
54 * l3mdev, there is one uint32_t space to work with.
55 * A l3mdev device points at a specific table that it
56 * relates to and a set of interfaces it belongs to.
57 */
58 if (table_id && (strcmp(vrf, vrf_get_default_name()) != 0)
59 && !vrf_is_backend_netns()) {
60 snprintf(
61 args->errmsg, args->errmsg_len,
62 "%% table param only available when running on netns-based vrfs");
63 return NB_ERR_VALIDATION;
64 }
65 break;
88fa5104 66 case NB_EV_ABORT:
67 case NB_EV_PREPARE:
68 break;
69 case NB_EV_APPLY:
70 rn = nb_running_get_entry(args->dnode, NULL, true);
71 distance = yang_dnode_get_uint8(args->dnode, "./distance");
ef4b6b22 72 table_id = yang_dnode_get_uint32(args->dnode, "./table-id");
73 pn = static_add_path(rn, table_id, distance);
88fa5104 74 nb_running_set_entry(args->dnode, pn);
75 }
76
77 return NB_OK;
78}
79
4067e951 80static int static_path_list_destroy(struct nb_cb_destroy_args *args)
88fa5104 81{
88fa5104 82 struct static_path *pn;
83
4067e951
IR
84 switch (args->event) {
85 case NB_EV_VALIDATE:
86 case NB_EV_PREPARE:
87 case NB_EV_ABORT:
88 break;
89 case NB_EV_APPLY:
90 pn = nb_running_unset_entry(args->dnode);
91 static_del_path(pn);
92 break;
93 }
94
95 return NB_OK;
88fa5104 96}
97
4067e951 98static int static_path_list_tag_modify(struct nb_cb_modify_args *args)
88fa5104 99{
100 struct static_path *pn;
88fa5104 101
4067e951
IR
102 switch (args->event) {
103 case NB_EV_VALIDATE:
104 case NB_EV_ABORT:
105 case NB_EV_PREPARE:
106 break;
107 case NB_EV_APPLY:
108 pn = nb_running_get_entry(args->dnode, NULL, true);
109 pn->tag = yang_dnode_get_uint32(args->dnode, NULL);
110 static_install_path(pn);
111 break;
112 }
88fa5104 113
4067e951 114 return NB_OK;
88fa5104 115}
116
cd07806b
IR
117struct nexthop_iter {
118 int count;
119 bool blackhole;
120};
121
122static int nexthop_iter_cb(const struct lyd_node *dnode, void *arg)
123{
124 struct nexthop_iter *iter = arg;
125 int nh_type;
126
127 nh_type = yang_dnode_get_enum(dnode, "./nh-type");
128
129 if (nh_type == STATIC_BLACKHOLE)
130 iter->blackhole = true;
131
132 iter->count++;
133
134 return YANG_ITER_CONTINUE;
135}
136
4067e951 137static bool static_nexthop_create(struct nb_cb_create_args *args)
88fa5104 138{
cd07806b
IR
139 const struct lyd_node *pn_dnode;
140 struct nexthop_iter iter;
88fa5104 141 struct static_path *pn;
142 struct ipaddr ipaddr;
143 struct static_nexthop *nh;
144 int nh_type;
145 const char *ifname;
146 const char *nh_vrf;
147
148 switch (args->event) {
149 case NB_EV_VALIDATE:
150 ifname = yang_dnode_get_string(args->dnode, "./interface");
151 if (ifname != NULL) {
152 if (strcasecmp(ifname, "Null0") == 0
153 || strcasecmp(ifname, "reject") == 0
154 || strcasecmp(ifname, "blackhole") == 0) {
155 snprintf(args->errmsg, args->errmsg_len,
156 "%s: Nexthop interface name can not be from reserved keywords(Null0, reject, blackhole)",
157 ifname);
158 return NB_ERR_VALIDATION;
159 }
160 }
cd07806b
IR
161
162 iter.count = 0;
163 iter.blackhole = false;
164
165 pn_dnode = yang_dnode_get_parent(args->dnode, "path-list");
166 yang_dnode_iterate(nexthop_iter_cb, &iter, pn_dnode,
167 "./frr-nexthops/nexthop");
168
169 if (iter.blackhole && iter.count > 1) {
170 snprintf(
171 args->errmsg, args->errmsg_len,
172 "Route can not have blackhole and non-blackhole nexthops simultaneously");
173 return NB_ERR_VALIDATION;
174 }
88fa5104 175 break;
176 case NB_EV_PREPARE:
177 case NB_EV_ABORT:
178 break;
179 case NB_EV_APPLY:
180 yang_dnode_get_ip(&ipaddr, args->dnode, "./gateway");
181 nh_type = yang_dnode_get_enum(args->dnode, "./nh-type");
182 ifname = yang_dnode_get_string(args->dnode, "./interface");
183 nh_vrf = yang_dnode_get_string(args->dnode, "./vrf");
184 pn = nb_running_get_entry(args->dnode, NULL, true);
88fa5104 185
ddd45515 186 if (!static_add_nexthop_validate(nh_vrf, nh_type, &ipaddr))
88fa5104 187 flog_warn(
188 EC_LIB_NB_CB_CONFIG_VALIDATE,
189 "Warning!! Local connected address is configured as Gateway IP((%s))",
190 yang_dnode_get_string(args->dnode,
191 "./gateway"));
4067e951
IR
192 nh = static_add_nexthop(pn, nh_type, &ipaddr, ifname, nh_vrf,
193 0);
88fa5104 194 nb_running_set_entry(args->dnode, nh);
195 break;
196 }
197
198 return NB_OK;
199}
200
4067e951 201static bool static_nexthop_destroy(struct nb_cb_destroy_args *args)
88fa5104 202{
88fa5104 203 struct static_nexthop *nh;
88fa5104 204
4067e951
IR
205 switch (args->event) {
206 case NB_EV_VALIDATE:
207 case NB_EV_PREPARE:
208 case NB_EV_ABORT:
209 break;
210 case NB_EV_APPLY:
211 nh = nb_running_unset_entry(args->dnode);
212 static_delete_nexthop(nh);
213 break;
88fa5104 214 }
215
216 return NB_OK;
217}
218
219static int nexthop_mpls_label_stack_entry_create(struct nb_cb_create_args *args)
220{
221 struct static_nexthop *nh;
222 uint32_t pos;
223 uint8_t index;
224
225 switch (args->event) {
226 case NB_EV_VALIDATE:
b2f6ab67 227 if (!mpls_enabled) {
228 snprintf(
229 args->errmsg, args->errmsg_len,
230 "%% MPLS not turned on in kernel ignoring static route");
231 return NB_ERR_VALIDATION;
232 }
233 break;
88fa5104 234 case NB_EV_PREPARE:
235 case NB_EV_ABORT:
236 break;
237 case NB_EV_APPLY:
238 nh = nb_running_get_entry(args->dnode, NULL, true);
239 pos = yang_get_list_pos(args->dnode);
240 if (!pos) {
241 flog_warn(EC_LIB_NB_CB_CONFIG_APPLY,
242 "libyang returns invalid label position");
243 return NB_ERR;
244 }
245 /* Mapping to array = list-index -1 */
246 index = pos - 1;
247 nh->snh_label.label[index] = 0;
248 nh->snh_label.num_labels++;
249 break;
250 }
251
252 return NB_OK;
253}
254
255static int
256nexthop_mpls_label_stack_entry_destroy(struct nb_cb_destroy_args *args)
257{
258 struct static_nexthop *nh;
259 uint32_t pos;
260 uint8_t index;
261
262 switch (args->event) {
263 case NB_EV_VALIDATE:
264 case NB_EV_PREPARE:
265 case NB_EV_ABORT:
266 break;
267 case NB_EV_APPLY:
268 nh = nb_running_get_entry(args->dnode, NULL, true);
269 pos = yang_get_list_pos(args->dnode);
270 if (!pos) {
271 flog_warn(EC_LIB_NB_CB_CONFIG_APPLY,
272 "libyang returns invalid label position");
273 return NB_ERR;
274 }
275 index = pos - 1;
276 nh->snh_label.label[index] = 0;
277 nh->snh_label.num_labels--;
278 break;
279 }
280
281 return NB_OK;
282}
283
284static int static_nexthop_mpls_label_modify(struct nb_cb_modify_args *args)
285{
286 struct static_nexthop *nh;
287 uint32_t pos;
288 uint8_t index;
289
290 nh = nb_running_get_entry(args->dnode, NULL, true);
3bb513c3 291 pos = yang_get_list_pos(lyd_parent(args->dnode));
88fa5104 292 if (!pos) {
293 flog_warn(EC_LIB_NB_CB_CONFIG_APPLY,
294 "libyang returns invalid label position");
295 return NB_ERR;
296 }
297 /* Mapping to array = list-index -1 */
298 index = pos - 1;
299 nh->snh_label.label[index] = yang_dnode_get_uint32(args->dnode, NULL);
300
301 return NB_OK;
302}
303
304static int static_nexthop_onlink_modify(struct nb_cb_modify_args *args)
305{
306 struct static_nexthop *nh;
6dfc022f 307 static_types nh_type;
88fa5104 308
6dfc022f
CS
309 switch (args->event) {
310 case NB_EV_VALIDATE:
311 nh_type = yang_dnode_get_enum(args->dnode, "../nh-type");
312 if ((nh_type != STATIC_IPV4_GATEWAY_IFNAME)
313 && (nh_type != STATIC_IPV6_GATEWAY_IFNAME)) {
314 snprintf(
315 args->errmsg, args->errmsg_len,
316 "nexthop type is not the ipv4 or ipv6 interface type");
317 return NB_ERR_VALIDATION;
318 }
319 break;
320 case NB_EV_PREPARE:
321 case NB_EV_ABORT:
322 break;
323 case NB_EV_APPLY:
324 nh = nb_running_get_entry(args->dnode, NULL, true);
325 nh->onlink = yang_dnode_get_bool(args->dnode, NULL);
326 break;
327 }
88fa5104 328
329 return NB_OK;
330}
331
065276ae
SM
332static int static_nexthop_color_modify(struct nb_cb_modify_args *args)
333{
334 struct static_nexthop *nh;
335
336 nh = nb_running_get_entry(args->dnode, NULL, true);
337 nh->color = yang_dnode_get_uint32(args->dnode, NULL);
338
339 return NB_OK;
340}
341
342static int static_nexthop_color_destroy(struct nb_cb_destroy_args *args)
343{
344 struct static_nexthop *nh;
345
346 nh = nb_running_unset_entry(args->dnode);
347 nh->color = 0;
348
349 return NB_OK;
350}
351
88fa5104 352static int static_nexthop_bh_type_modify(struct nb_cb_modify_args *args)
353{
354 struct static_nexthop *nh;
6dfc022f 355 static_types nh_type;
88fa5104 356
6dfc022f
CS
357 switch (args->event) {
358 case NB_EV_VALIDATE:
359 nh_type = yang_dnode_get_enum(args->dnode, "../nh-type");
360 if (nh_type != STATIC_BLACKHOLE) {
361 snprintf(args->errmsg, args->errmsg_len,
362 "nexthop type is not the blackhole type");
363 return NB_ERR_VALIDATION;
364 }
365 break;
366 case NB_EV_PREPARE:
367 case NB_EV_ABORT:
368 break;
369 case NB_EV_APPLY:
370 nh = nb_running_get_entry(args->dnode, NULL, true);
371 nh->bh_type = yang_dnode_get_enum(args->dnode, NULL);
372 break;
373 }
88fa5104 374
375 return NB_OK;
376}
377
88fa5104 378void routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_apply_finish(
379 struct nb_cb_apply_finish_args *args)
380{
381 struct static_nexthop *nh;
88fa5104 382
383 nh = nb_running_get_entry(args->dnode, NULL, true);
384
4067e951 385 static_install_nexthop(nh);
88fa5104 386}
387
88fa5104 388void routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_apply_finish(
389 struct nb_cb_apply_finish_args *args)
390{
391 struct static_nexthop *nh;
88fa5104 392
393 nh = nb_running_get_entry(args->dnode, NULL, true);
394
4067e951 395 static_install_nexthop(nh);
88fa5104 396}
4067e951 397
88fa5104 398int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_pre_validate(
399 struct nb_cb_pre_validate_args *args)
400{
401 const struct lyd_node *mls_dnode;
402 uint32_t count;
403
404 mls_dnode = yang_dnode_get(args->dnode, "./mpls-label-stack");
3bb513c3 405 count = yang_get_list_elements_count(lyd_child(mls_dnode));
88fa5104 406
407 if (count > MPLS_MAX_LABELS) {
408 snprintf(args->errmsg, args->errmsg_len,
409 "Too many labels, Enter %d or fewer",
410 MPLS_MAX_LABELS);
411 return NB_ERR_VALIDATION;
412 }
413 return NB_OK;
414}
415
416int routing_control_plane_protocols_name_validate(
417 struct nb_cb_create_args *args)
418{
419 const char *name;
420
421 name = yang_dnode_get_string(args->dnode, "./name");
422 if (!strmatch(name, "staticd")) {
423 snprintf(args->errmsg, args->errmsg_len,
424 "static routing supports only one instance with name staticd");
425 return NB_ERR_VALIDATION;
426 }
427 return NB_OK;
428}
429/*
430 * XPath:
431 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list
432 */
433int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_create(
434 struct nb_cb_create_args *args)
435{
436 struct vrf *vrf;
437 struct static_vrf *s_vrf;
438 struct route_node *rn;
439 const struct lyd_node *vrf_dnode;
440 struct prefix prefix;
314825ff 441 const char *afi_safi;
442 afi_t prefix_afi;
88fa5104 443 afi_t afi;
314825ff 444 safi_t safi;
88fa5104 445
446 switch (args->event) {
447 case NB_EV_VALIDATE:
314825ff 448 yang_dnode_get_prefix(&prefix, args->dnode, "./prefix");
449 afi_safi = yang_dnode_get_string(args->dnode, "./afi-safi");
450 yang_afi_safi_identity2value(afi_safi, &afi, &safi);
451 prefix_afi = family2afi(prefix.family);
452 if (afi != prefix_afi) {
453 flog_warn(
454 EC_LIB_NB_CB_CONFIG_VALIDATE,
455 "route node %s creation failed",
456 yang_dnode_get_string(args->dnode, "./prefix"));
457 return NB_ERR_VALIDATION;
458 }
459 break;
88fa5104 460 case NB_EV_PREPARE:
461 case NB_EV_ABORT:
462 break;
463 case NB_EV_APPLY:
464 vrf_dnode = yang_dnode_get_parent(args->dnode,
465 "control-plane-protocol");
466 vrf = nb_running_get_entry(vrf_dnode, NULL, true);
467 s_vrf = vrf->info;
468
469 yang_dnode_get_prefix(&prefix, args->dnode, "./prefix");
314825ff 470 afi_safi = yang_dnode_get_string(args->dnode, "./afi-safi");
471 yang_afi_safi_identity2value(afi_safi, &afi, &safi);
88fa5104 472
473 rn = static_add_route(afi, safi, &prefix, NULL, s_vrf);
b2f6ab67 474 if (vrf->vrf_id == VRF_UNKNOWN)
475 snprintf(
476 args->errmsg, args->errmsg_len,
477 "Static Route to %s not installed currently because dependent config not fully available",
478 yang_dnode_get_string(args->dnode, "./prefix"));
88fa5104 479 nb_running_set_entry(args->dnode, rn);
480 break;
481 }
482 return NB_OK;
483}
484
485int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_destroy(
486 struct nb_cb_destroy_args *args)
487{
488 struct route_node *rn;
88fa5104 489
490 switch (args->event) {
491 case NB_EV_VALIDATE:
492 case NB_EV_PREPARE:
493 case NB_EV_ABORT:
494 break;
495 case NB_EV_APPLY:
496 rn = nb_running_unset_entry(args->dnode);
4067e951 497 static_del_route(rn);
88fa5104 498 break;
499 }
500 return NB_OK;
501}
502
503/*
504 * XPath:
505 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list
506 */
507int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_create(
508 struct nb_cb_create_args *args)
509{
510 return static_path_list_create(args);
511}
512
513int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_destroy(
514 struct nb_cb_destroy_args *args)
515{
4067e951 516 return static_path_list_destroy(args);
88fa5104 517}
518
519/*
520 * XPath:
521 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/tag
522 */
523int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_tag_modify(
524 struct nb_cb_modify_args *args)
525{
4067e951 526 return static_path_list_tag_modify(args);
88fa5104 527}
528
88fa5104 529/*
530 * XPath:
531 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop
532 */
533int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_create(
534 struct nb_cb_create_args *args)
535{
4067e951 536 return static_nexthop_create(args);
88fa5104 537}
538
539int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_destroy(
540 struct nb_cb_destroy_args *args)
541{
4067e951 542 return static_nexthop_destroy(args);
88fa5104 543}
544
545/*
546 * XPath:
547 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/bh-type
548 */
549int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_bh_type_modify(
550 struct nb_cb_modify_args *args)
551{
6dfc022f 552 return static_nexthop_bh_type_modify(args);
88fa5104 553}
554
88fa5104 555/*
556 * XPath:
557 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/onlink
558 */
559int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_onlink_modify(
560 struct nb_cb_modify_args *args)
561{
6dfc022f 562 return static_nexthop_onlink_modify(args);
88fa5104 563}
065276ae
SM
564
565/*
566 * XPath:
567 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/srte-color
568 */
569int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_color_modify(
570 struct nb_cb_modify_args *args)
571{
572 switch (args->event) {
573 case NB_EV_VALIDATE:
574 case NB_EV_PREPARE:
575 case NB_EV_ABORT:
576 break;
577 case NB_EV_APPLY:
578 if (static_nexthop_color_modify(args) != NB_OK)
579 return NB_ERR;
580
581 break;
582 }
583 return NB_OK;
584}
585
586int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_color_destroy(
587 struct nb_cb_destroy_args *args)
588{
589 switch (args->event) {
590 case NB_EV_VALIDATE:
591 case NB_EV_PREPARE:
592 case NB_EV_ABORT:
593 break;
594 case NB_EV_APPLY:
595 if (static_nexthop_color_destroy(args) != NB_OK)
596 return NB_ERR;
597 break;
598 }
599 return NB_OK;
600}
601
88fa5104 602/*
603 * XPath:
604 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/mpls-label-stack/entry
605 */
606int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_create(
607 struct nb_cb_create_args *args)
608{
609 return nexthop_mpls_label_stack_entry_create(args);
610}
611
612int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_destroy(
613 struct nb_cb_destroy_args *args)
614{
615 return nexthop_mpls_label_stack_entry_destroy(args);
616}
617
618/*
619 * XPath:
620 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/mpls-label-stack/entry/label
621 */
622int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_label_modify(
623 struct nb_cb_modify_args *args)
624{
625 switch (args->event) {
626 case NB_EV_VALIDATE:
627 case NB_EV_PREPARE:
628 case NB_EV_ABORT:
629 break;
630 case NB_EV_APPLY:
631 if (static_nexthop_mpls_label_modify(args) != NB_OK)
632 return NB_ERR;
633 break;
634 }
635 return NB_OK;
636}
637
638int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_label_destroy(
639 struct nb_cb_destroy_args *args)
640{
641 /*
642 * No operation is required in this call back.
643 * nexthop_mpls_label_stack_entry_destroy() will take care
644 * to reset the label vaue.
645 */
646 switch (args->event) {
647 case NB_EV_VALIDATE:
648 case NB_EV_PREPARE:
649 case NB_EV_ABORT:
650 case NB_EV_APPLY:
651 break;
652 }
653 return NB_OK;
654}
655
656/*
657 * XPath:
658 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/mpls-label-stack/entry/ttl
659 */
660int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_ttl_modify(
661 struct nb_cb_modify_args *args)
662{
663 switch (args->event) {
664 case NB_EV_VALIDATE:
665 case NB_EV_PREPARE:
666 case NB_EV_ABORT:
667 case NB_EV_APPLY:
668 break;
669 }
670
671 return NB_OK;
672}
673
674int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_ttl_destroy(
675 struct nb_cb_destroy_args *args)
676{
677 switch (args->event) {
678 case NB_EV_VALIDATE:
679 case NB_EV_PREPARE:
680 case NB_EV_ABORT:
681 case NB_EV_APPLY:
682 break;
683 }
684
685 return NB_OK;
686}
687
688/*
689 * XPath:
690 * /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
691 */
692int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_traffic_class_modify(
693 struct nb_cb_modify_args *args)
694{
695 switch (args->event) {
696 case NB_EV_VALIDATE:
697 case NB_EV_PREPARE:
698 case NB_EV_ABORT:
699 case NB_EV_APPLY:
700 break;
701 }
702
703 return NB_OK;
704}
705
706int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_traffic_class_destroy(
707 struct nb_cb_destroy_args *args)
708{
709 switch (args->event) {
710 case NB_EV_VALIDATE:
711 case NB_EV_PREPARE:
712 case NB_EV_ABORT:
713 case NB_EV_APPLY:
714 break;
715 }
716
717 return NB_OK;
718}
719
720/*
721 * XPath:
722 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list
723 */
724int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_create(
725 struct nb_cb_create_args *args)
726{
727 struct static_vrf *s_vrf;
728 struct route_node *rn;
729 struct route_node *src_rn;
730 struct prefix_ipv6 src_prefix = {};
731 struct stable_info *info;
732 afi_t afi;
733 safi_t safi = SAFI_UNICAST;
734
735 switch (args->event) {
736 case NB_EV_VALIDATE:
737 case NB_EV_PREPARE:
738 case NB_EV_ABORT:
739 break;
740 case NB_EV_APPLY:
741 rn = nb_running_get_entry(args->dnode, NULL, true);
742 info = route_table_get_info(rn->table);
743 s_vrf = info->svrf;
744 yang_dnode_get_ipv6p(&src_prefix, args->dnode, "./src-prefix");
745 afi = family2afi(src_prefix.family);
746 src_rn =
747 static_add_route(afi, safi, &rn->p, &src_prefix, s_vrf);
88fa5104 748 nb_running_set_entry(args->dnode, src_rn);
749 break;
750 }
751 return NB_OK;
752}
753
754int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_destroy(
755 struct nb_cb_destroy_args *args)
756{
757 struct route_node *src_rn;
88fa5104 758
759 switch (args->event) {
760 case NB_EV_VALIDATE:
761 case NB_EV_PREPARE:
762 case NB_EV_ABORT:
763 break;
764 case NB_EV_APPLY:
765 src_rn = nb_running_unset_entry(args->dnode);
4067e951 766 static_del_route(src_rn);
88fa5104 767 break;
768 }
769
770 return NB_OK;
771}
772
773/*
774 * XPath:
775 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list
776 */
777int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_create(
778 struct nb_cb_create_args *args)
779{
780 return static_path_list_create(args);
781}
782
783int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_destroy(
784 struct nb_cb_destroy_args *args)
785{
4067e951 786 return static_path_list_destroy(args);
88fa5104 787}
788
789/*
790 * XPath:
791 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/tag
792 */
793int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_tag_modify(
794 struct nb_cb_modify_args *args)
795{
4067e951 796 return static_path_list_tag_modify(args);
88fa5104 797}
798
88fa5104 799/*
800 * XPath:
801 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/frr-nexthops/nexthop
802 */
803int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_create(
804 struct nb_cb_create_args *args)
805{
4067e951 806 return static_nexthop_create(args);
88fa5104 807}
808
809int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_destroy(
810 struct nb_cb_destroy_args *args)
811{
4067e951 812 return static_nexthop_destroy(args);
88fa5104 813}
814
815/*
816 * XPath:
817 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/frr-nexthops/nexthop/bh-type
818 */
819int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_bh_type_modify(
820 struct nb_cb_modify_args *args)
821{
6dfc022f 822 return static_nexthop_bh_type_modify(args);
88fa5104 823}
824
88fa5104 825/*
826 * XPath:
827 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/frr-nexthops/nexthop/onlink
828 */
829int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_onlink_modify(
830 struct nb_cb_modify_args *args)
831{
6dfc022f 832 return static_nexthop_onlink_modify(args);
88fa5104 833}
834
065276ae
SM
835/*
836 * XPath:
837 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/frr-nexthops/nexthop/srte-color
838 */
839int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_color_modify(
840 struct nb_cb_modify_args *args)
841{
842 switch (args->event) {
843 case NB_EV_VALIDATE:
844 case NB_EV_PREPARE:
845 case NB_EV_ABORT:
846 break;
847 case NB_EV_APPLY:
848 if (static_nexthop_color_modify(args) != NB_OK)
849 return NB_ERR;
850
851 break;
852 }
853 return NB_OK;
854}
855
856
857int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_color_destroy(
858 struct nb_cb_destroy_args *args)
859{
860 switch (args->event) {
861 case NB_EV_VALIDATE:
862 case NB_EV_PREPARE:
863 case NB_EV_ABORT:
864 break;
865 case NB_EV_APPLY:
866 if (static_nexthop_color_destroy(args) != NB_OK)
867 return NB_ERR;
868 break;
869 }
870 return NB_OK;
871}
872
88fa5104 873/*
874 * XPath:
875 * /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
876 */
877int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_create(
878 struct nb_cb_create_args *args)
879{
880 return nexthop_mpls_label_stack_entry_create(args);
881}
882
883int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_destroy(
884 struct nb_cb_destroy_args *args)
885{
886 return nexthop_mpls_label_stack_entry_destroy(args);
887}
888
889/*
890 * XPath:
891 * /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
892 */
893int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_label_modify(
894 struct nb_cb_modify_args *args)
895{
896 switch (args->event) {
897 case NB_EV_VALIDATE:
898 case NB_EV_PREPARE:
899 case NB_EV_ABORT:
900 break;
901 case NB_EV_APPLY:
902 if (static_nexthop_mpls_label_modify(args) != NB_OK)
903 return NB_ERR;
904 break;
905 }
906 return NB_OK;
907}
908
909int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_label_destroy(
910 struct nb_cb_destroy_args *args)
911{
912 /*
913 * No operation is required in this call back.
914 * nexthop_mpls_label_stack_entry_destroy() will take care
915 * to reset the label vaue.
916 */
917 switch (args->event) {
918 case NB_EV_VALIDATE:
919 case NB_EV_PREPARE:
920 case NB_EV_ABORT:
921 case NB_EV_APPLY:
922 break;
923 }
924 return NB_OK;
925}
926
927/*
928 * XPath:
929 * /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
930 */
931int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_ttl_modify(
932 struct nb_cb_modify_args *args)
933{
934 switch (args->event) {
935 case NB_EV_VALIDATE:
936 case NB_EV_PREPARE:
937 case NB_EV_ABORT:
938 case NB_EV_APPLY:
939 break;
940 }
941
942 return NB_OK;
943}
944
945int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_ttl_destroy(
946 struct nb_cb_destroy_args *args)
947{
948 switch (args->event) {
949 case NB_EV_VALIDATE:
950 case NB_EV_PREPARE:
951 case NB_EV_ABORT:
952 case NB_EV_APPLY:
953 break;
954 }
955
956 return NB_OK;
957}
958
959/*
960 * XPath:
961 * /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
962 */
963int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_traffic_class_modify(
964 struct nb_cb_modify_args *args)
965{
966 switch (args->event) {
967 case NB_EV_VALIDATE:
968 case NB_EV_PREPARE:
969 case NB_EV_ABORT:
970 case NB_EV_APPLY:
971 break;
972 }
973
974 return NB_OK;
975}
976
977int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_traffic_class_destroy(
978 struct nb_cb_destroy_args *args)
979{
980 switch (args->event) {
981 case NB_EV_VALIDATE:
982 case NB_EV_PREPARE:
983 case NB_EV_ABORT:
984 case NB_EV_APPLY:
985 break;
986 }
987
988 return NB_OK;
989}