]> git.proxmox.com Git - mirror_frr.git/blob - staticd/static_nb_config.c
Merge pull request #12643 from opensourcerouting/fix/cosmetic_log_changes
[mirror_frr.git] / staticd / static_nb_config.c
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 */
19 #include <zebra.h>
20
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
36 static int static_path_list_create(struct nb_cb_create_args *args)
37 {
38 struct route_node *rn;
39 struct static_path *pn;
40 const struct lyd_node *vrf_dnode;
41 const char *vrf;
42 uint8_t distance;
43 uint32_t table_id;
44
45 switch (args->event) {
46 case NB_EV_VALIDATE:
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;
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");
72 table_id = yang_dnode_get_uint32(args->dnode, "./table-id");
73 pn = static_add_path(rn, table_id, distance);
74 nb_running_set_entry(args->dnode, pn);
75 }
76
77 return NB_OK;
78 }
79
80 static int static_path_list_destroy(struct nb_cb_destroy_args *args)
81 {
82 struct static_path *pn;
83
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;
96 }
97
98 static int static_path_list_tag_modify(struct nb_cb_modify_args *args)
99 {
100 struct static_path *pn;
101
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 }
113
114 return NB_OK;
115 }
116
117 struct nexthop_iter {
118 uint32_t count;
119 bool blackhole;
120 };
121
122 static int nexthop_iter_cb(const struct lyd_node *dnode, void *arg)
123 {
124 struct nexthop_iter *iter = arg;
125 enum static_nh_type 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
137 static bool static_nexthop_create(struct nb_cb_create_args *args)
138 {
139 const struct lyd_node *pn_dnode;
140 struct nexthop_iter iter;
141 struct static_path *pn;
142 struct ipaddr ipaddr;
143 struct static_nexthop *nh;
144 enum static_nh_type 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 }
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 cannot have blackhole and non-blackhole nexthops simultaneously");
173 return NB_ERR_VALIDATION;
174 } else if (iter.count > zebra_ecmp_count) {
175 snprintf(args->errmsg, args->errmsg_len,
176 "Route cannot have more than %d ECMP nexthops",
177 zebra_ecmp_count);
178 return NB_ERR_VALIDATION;
179 }
180 break;
181 case NB_EV_PREPARE:
182 case NB_EV_ABORT:
183 break;
184 case NB_EV_APPLY:
185 yang_dnode_get_ip(&ipaddr, args->dnode, "./gateway");
186 nh_type = yang_dnode_get_enum(args->dnode, "./nh-type");
187 ifname = yang_dnode_get_string(args->dnode, "./interface");
188 nh_vrf = yang_dnode_get_string(args->dnode, "./vrf");
189 pn = nb_running_get_entry(args->dnode, NULL, true);
190
191 if (!static_add_nexthop_validate(nh_vrf, nh_type, &ipaddr))
192 flog_warn(
193 EC_LIB_NB_CB_CONFIG_VALIDATE,
194 "Warning!! Local connected address is configured as Gateway IP((%s))",
195 yang_dnode_get_string(args->dnode,
196 "./gateway"));
197 nh = static_add_nexthop(pn, nh_type, &ipaddr, ifname, nh_vrf,
198 0);
199 nb_running_set_entry(args->dnode, nh);
200 break;
201 }
202
203 return NB_OK;
204 }
205
206 static bool static_nexthop_destroy(struct nb_cb_destroy_args *args)
207 {
208 struct static_nexthop *nh;
209
210 switch (args->event) {
211 case NB_EV_VALIDATE:
212 case NB_EV_PREPARE:
213 case NB_EV_ABORT:
214 break;
215 case NB_EV_APPLY:
216 nh = nb_running_unset_entry(args->dnode);
217 static_delete_nexthop(nh);
218 break;
219 }
220
221 return NB_OK;
222 }
223
224 static int nexthop_mpls_label_stack_entry_create(struct nb_cb_create_args *args)
225 {
226 struct static_nexthop *nh;
227 uint32_t pos;
228 uint8_t index;
229
230 switch (args->event) {
231 case NB_EV_VALIDATE:
232 if (!mpls_enabled) {
233 snprintf(
234 args->errmsg, args->errmsg_len,
235 "%% MPLS not turned on in kernel ignoring static route");
236 return NB_ERR_VALIDATION;
237 }
238 break;
239 case NB_EV_PREPARE:
240 case NB_EV_ABORT:
241 break;
242 case NB_EV_APPLY:
243 nh = nb_running_get_entry(args->dnode, NULL, true);
244 pos = yang_get_list_pos(args->dnode);
245 if (!pos) {
246 flog_warn(EC_LIB_NB_CB_CONFIG_APPLY,
247 "libyang returns invalid label position");
248 return NB_ERR;
249 }
250 /* Mapping to array = list-index -1 */
251 index = pos - 1;
252 nh->snh_label.label[index] = 0;
253 nh->snh_label.num_labels++;
254 break;
255 }
256
257 return NB_OK;
258 }
259
260 static int
261 nexthop_mpls_label_stack_entry_destroy(struct nb_cb_destroy_args *args)
262 {
263 struct static_nexthop *nh;
264 uint32_t pos;
265 uint8_t index;
266 uint old_num_labels;
267
268 switch (args->event) {
269 case NB_EV_VALIDATE:
270 case NB_EV_PREPARE:
271 case NB_EV_ABORT:
272 break;
273 case NB_EV_APPLY:
274 nh = nb_running_get_entry(args->dnode, NULL, true);
275 pos = yang_get_list_pos(args->dnode);
276 if (!pos) {
277 flog_warn(EC_LIB_NB_CB_CONFIG_APPLY,
278 "libyang returns invalid label position");
279 return NB_ERR;
280 }
281 index = pos - 1;
282 old_num_labels = nh->snh_label.num_labels;
283 nh->snh_label.label[index] = 0;
284 nh->snh_label.num_labels--;
285
286 if (old_num_labels != nh->snh_label.num_labels)
287 nh->state = STATIC_START;
288 break;
289 }
290
291 return NB_OK;
292 }
293
294 static int static_nexthop_mpls_label_modify(struct nb_cb_modify_args *args)
295 {
296 struct static_nexthop *nh;
297 uint32_t pos;
298 uint8_t index;
299 mpls_label_t old_label;
300
301 nh = nb_running_get_entry(args->dnode, NULL, true);
302 pos = yang_get_list_pos(lyd_parent(args->dnode));
303 if (!pos) {
304 flog_warn(EC_LIB_NB_CB_CONFIG_APPLY,
305 "libyang returns invalid label position");
306 return NB_ERR;
307 }
308 /* Mapping to array = list-index -1 */
309 index = pos - 1;
310
311 old_label = nh->snh_label.label[index];
312 nh->snh_label.label[index] = yang_dnode_get_uint32(args->dnode, NULL);
313
314 if (old_label != nh->snh_label.label[index])
315 nh->state = STATIC_START;
316
317 return NB_OK;
318 }
319
320 static int static_nexthop_onlink_modify(struct nb_cb_modify_args *args)
321 {
322 struct static_nexthop *nh;
323 enum static_nh_type nh_type;
324 bool old_onlink;
325
326 switch (args->event) {
327 case NB_EV_VALIDATE:
328 nh_type = yang_dnode_get_enum(args->dnode, "../nh-type");
329 if ((nh_type != STATIC_IPV4_GATEWAY_IFNAME)
330 && (nh_type != STATIC_IPV6_GATEWAY_IFNAME)) {
331 snprintf(
332 args->errmsg, args->errmsg_len,
333 "nexthop type is not the ipv4 or ipv6 interface type");
334 return NB_ERR_VALIDATION;
335 }
336 break;
337 case NB_EV_PREPARE:
338 case NB_EV_ABORT:
339 break;
340 case NB_EV_APPLY:
341 nh = nb_running_get_entry(args->dnode, NULL, true);
342 old_onlink = nh->onlink;
343 nh->onlink = yang_dnode_get_bool(args->dnode, NULL);
344
345 if (old_onlink != nh->onlink)
346 nh->state = STATIC_START;
347 break;
348 }
349
350 return NB_OK;
351 }
352
353 static int static_nexthop_color_modify(struct nb_cb_modify_args *args)
354 {
355 struct static_nexthop *nh;
356 uint32_t old_color;
357
358 nh = nb_running_get_entry(args->dnode, NULL, true);
359 old_color = nh->color;
360 nh->color = yang_dnode_get_uint32(args->dnode, NULL);
361
362 if (old_color != nh->color)
363 nh->state = STATIC_START;
364
365 return NB_OK;
366 }
367
368 static int static_nexthop_color_destroy(struct nb_cb_destroy_args *args)
369 {
370 struct static_nexthop *nh;
371 uint32_t old_color;
372
373 nh = nb_running_get_entry(args->dnode, NULL, true);
374 old_color = nh->color;
375 nh->color = 0;
376
377 if (old_color != nh->color)
378 nh->state = STATIC_START;
379
380 return NB_OK;
381 }
382
383 static int static_nexthop_bh_type_modify(struct nb_cb_modify_args *args)
384 {
385 struct static_nexthop *nh;
386 enum static_nh_type nh_type;
387
388 switch (args->event) {
389 case NB_EV_VALIDATE:
390 nh_type = yang_dnode_get_enum(args->dnode, "../nh-type");
391 if (nh_type != STATIC_BLACKHOLE) {
392 snprintf(args->errmsg, args->errmsg_len,
393 "nexthop type is not the blackhole type");
394 return NB_ERR_VALIDATION;
395 }
396 break;
397 case NB_EV_PREPARE:
398 case NB_EV_ABORT:
399 break;
400 case NB_EV_APPLY:
401 nh = nb_running_get_entry(args->dnode, NULL, true);
402 nh->bh_type = yang_dnode_get_enum(args->dnode, NULL);
403 break;
404 }
405
406 return NB_OK;
407 }
408
409 void routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_apply_finish(
410 struct nb_cb_apply_finish_args *args)
411 {
412 struct static_nexthop *nh;
413
414 nh = nb_running_get_entry(args->dnode, NULL, true);
415
416 static_install_nexthop(nh);
417 }
418
419 void routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_apply_finish(
420 struct nb_cb_apply_finish_args *args)
421 {
422 struct static_nexthop *nh;
423
424 nh = nb_running_get_entry(args->dnode, NULL, true);
425
426 static_install_nexthop(nh);
427 }
428
429 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_pre_validate(
430 struct nb_cb_pre_validate_args *args)
431 {
432 const struct lyd_node *mls_dnode;
433 uint32_t count;
434
435 mls_dnode = yang_dnode_get(args->dnode, "./mpls-label-stack");
436 count = yang_get_list_elements_count(lyd_child(mls_dnode));
437
438 if (count > MPLS_MAX_LABELS) {
439 snprintf(args->errmsg, args->errmsg_len,
440 "Too many labels, Enter %d or fewer",
441 MPLS_MAX_LABELS);
442 return NB_ERR_VALIDATION;
443 }
444 return NB_OK;
445 }
446
447 int routing_control_plane_protocols_name_validate(
448 struct nb_cb_create_args *args)
449 {
450 const char *name;
451
452 name = yang_dnode_get_string(args->dnode, "./name");
453 if (!strmatch(name, "staticd")) {
454 snprintf(args->errmsg, args->errmsg_len,
455 "static routing supports only one instance with name staticd");
456 return NB_ERR_VALIDATION;
457 }
458 return NB_OK;
459 }
460 /*
461 * XPath:
462 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list
463 */
464 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_create(
465 struct nb_cb_create_args *args)
466 {
467 struct vrf *vrf;
468 struct static_vrf *s_vrf;
469 struct route_node *rn;
470 const struct lyd_node *vrf_dnode;
471 struct prefix prefix;
472 const char *afi_safi;
473 afi_t prefix_afi;
474 afi_t afi;
475 safi_t safi;
476
477 switch (args->event) {
478 case NB_EV_VALIDATE:
479 yang_dnode_get_prefix(&prefix, args->dnode, "./prefix");
480 afi_safi = yang_dnode_get_string(args->dnode, "./afi-safi");
481 yang_afi_safi_identity2value(afi_safi, &afi, &safi);
482 prefix_afi = family2afi(prefix.family);
483 if (afi != prefix_afi) {
484 flog_warn(
485 EC_LIB_NB_CB_CONFIG_VALIDATE,
486 "route node %s creation failed",
487 yang_dnode_get_string(args->dnode, "./prefix"));
488 return NB_ERR_VALIDATION;
489 }
490 break;
491 case NB_EV_PREPARE:
492 case NB_EV_ABORT:
493 break;
494 case NB_EV_APPLY:
495 vrf_dnode = yang_dnode_get_parent(args->dnode,
496 "control-plane-protocol");
497 vrf = nb_running_get_entry(vrf_dnode, NULL, true);
498 s_vrf = vrf->info;
499
500 yang_dnode_get_prefix(&prefix, args->dnode, "./prefix");
501 afi_safi = yang_dnode_get_string(args->dnode, "./afi-safi");
502 yang_afi_safi_identity2value(afi_safi, &afi, &safi);
503
504 rn = static_add_route(afi, safi, &prefix, NULL, s_vrf);
505 if (vrf->vrf_id == VRF_UNKNOWN)
506 snprintf(
507 args->errmsg, args->errmsg_len,
508 "Static Route to %s not installed currently because dependent config not fully available",
509 yang_dnode_get_string(args->dnode, "./prefix"));
510 nb_running_set_entry(args->dnode, rn);
511 break;
512 }
513 return NB_OK;
514 }
515
516 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_destroy(
517 struct nb_cb_destroy_args *args)
518 {
519 struct route_node *rn;
520
521 switch (args->event) {
522 case NB_EV_VALIDATE:
523 case NB_EV_PREPARE:
524 case NB_EV_ABORT:
525 break;
526 case NB_EV_APPLY:
527 rn = nb_running_unset_entry(args->dnode);
528 static_del_route(rn);
529 break;
530 }
531 return NB_OK;
532 }
533
534 /*
535 * XPath:
536 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list
537 */
538 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_create(
539 struct nb_cb_create_args *args)
540 {
541 return static_path_list_create(args);
542 }
543
544 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_destroy(
545 struct nb_cb_destroy_args *args)
546 {
547 return static_path_list_destroy(args);
548 }
549
550 /*
551 * XPath:
552 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/tag
553 */
554 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_tag_modify(
555 struct nb_cb_modify_args *args)
556 {
557 return static_path_list_tag_modify(args);
558 }
559
560 /*
561 * XPath:
562 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop
563 */
564 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_create(
565 struct nb_cb_create_args *args)
566 {
567 return static_nexthop_create(args);
568 }
569
570 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_destroy(
571 struct nb_cb_destroy_args *args)
572 {
573 return static_nexthop_destroy(args);
574 }
575
576 /*
577 * XPath:
578 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/bh-type
579 */
580 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_bh_type_modify(
581 struct nb_cb_modify_args *args)
582 {
583 return static_nexthop_bh_type_modify(args);
584 }
585
586 /*
587 * XPath:
588 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/onlink
589 */
590 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_onlink_modify(
591 struct nb_cb_modify_args *args)
592 {
593 return static_nexthop_onlink_modify(args);
594 }
595
596 /*
597 * XPath:
598 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/srte-color
599 */
600 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_color_modify(
601 struct nb_cb_modify_args *args)
602 {
603 switch (args->event) {
604 case NB_EV_VALIDATE:
605 case NB_EV_PREPARE:
606 case NB_EV_ABORT:
607 break;
608 case NB_EV_APPLY:
609 if (static_nexthop_color_modify(args) != NB_OK)
610 return NB_ERR;
611
612 break;
613 }
614 return NB_OK;
615 }
616
617 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_color_destroy(
618 struct nb_cb_destroy_args *args)
619 {
620 switch (args->event) {
621 case NB_EV_VALIDATE:
622 case NB_EV_PREPARE:
623 case NB_EV_ABORT:
624 break;
625 case NB_EV_APPLY:
626 if (static_nexthop_color_destroy(args) != NB_OK)
627 return NB_ERR;
628 break;
629 }
630 return NB_OK;
631 }
632
633 /*
634 * XPath:
635 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/mpls-label-stack/entry
636 */
637 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_create(
638 struct nb_cb_create_args *args)
639 {
640 return nexthop_mpls_label_stack_entry_create(args);
641 }
642
643 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_destroy(
644 struct nb_cb_destroy_args *args)
645 {
646 return nexthop_mpls_label_stack_entry_destroy(args);
647 }
648
649 /*
650 * XPath:
651 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/mpls-label-stack/entry/label
652 */
653 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_label_modify(
654 struct nb_cb_modify_args *args)
655 {
656 switch (args->event) {
657 case NB_EV_VALIDATE:
658 case NB_EV_PREPARE:
659 case NB_EV_ABORT:
660 break;
661 case NB_EV_APPLY:
662 if (static_nexthop_mpls_label_modify(args) != NB_OK)
663 return NB_ERR;
664 break;
665 }
666 return NB_OK;
667 }
668
669 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_label_destroy(
670 struct nb_cb_destroy_args *args)
671 {
672 /*
673 * No operation is required in this call back.
674 * nexthop_mpls_label_stack_entry_destroy() will take care
675 * to reset the label vaue.
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 return NB_OK;
685 }
686
687 /*
688 * XPath:
689 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/mpls-label-stack/entry/ttl
690 */
691 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_ttl_modify(
692 struct nb_cb_modify_args *args)
693 {
694 switch (args->event) {
695 case NB_EV_VALIDATE:
696 case NB_EV_PREPARE:
697 case NB_EV_ABORT:
698 case NB_EV_APPLY:
699 break;
700 }
701
702 return NB_OK;
703 }
704
705 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_ttl_destroy(
706 struct nb_cb_destroy_args *args)
707 {
708 switch (args->event) {
709 case NB_EV_VALIDATE:
710 case NB_EV_PREPARE:
711 case NB_EV_ABORT:
712 case NB_EV_APPLY:
713 break;
714 }
715
716 return NB_OK;
717 }
718
719 /*
720 * XPath:
721 * /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
722 */
723 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_traffic_class_modify(
724 struct nb_cb_modify_args *args)
725 {
726 switch (args->event) {
727 case NB_EV_VALIDATE:
728 case NB_EV_PREPARE:
729 case NB_EV_ABORT:
730 case NB_EV_APPLY:
731 break;
732 }
733
734 return NB_OK;
735 }
736
737 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_traffic_class_destroy(
738 struct nb_cb_destroy_args *args)
739 {
740 switch (args->event) {
741 case NB_EV_VALIDATE:
742 case NB_EV_PREPARE:
743 case NB_EV_ABORT:
744 case NB_EV_APPLY:
745 break;
746 }
747
748 return NB_OK;
749 }
750
751 /*
752 * XPath:
753 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/bfd-monitoring
754 */
755 int route_next_hop_bfd_create(struct nb_cb_create_args *args)
756 {
757 struct static_nexthop *sn;
758
759 if (args->event != NB_EV_APPLY)
760 return NB_OK;
761
762 sn = nb_running_get_entry(args->dnode, NULL, true);
763 static_next_hop_bfd_monitor_enable(sn, args->dnode);
764 return NB_OK;
765 }
766
767 int route_next_hop_bfd_destroy(struct nb_cb_destroy_args *args)
768 {
769 struct static_nexthop *sn;
770
771 if (args->event != NB_EV_APPLY)
772 return NB_OK;
773
774 sn = nb_running_get_entry(args->dnode, NULL, true);
775 static_next_hop_bfd_monitor_disable(sn);
776 return NB_OK;
777 }
778
779 /*
780 * XPath:
781 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/bfd-monitoring/source
782 */
783 int route_next_hop_bfd_source_modify(struct nb_cb_modify_args *args)
784 {
785 struct static_nexthop *sn;
786 struct ipaddr source;
787
788 if (args->event != NB_EV_APPLY)
789 return NB_OK;
790
791 sn = nb_running_get_entry(args->dnode, NULL, true);
792 yang_dnode_get_ip(&source, args->dnode, NULL);
793 static_next_hop_bfd_source(sn, &source);
794 return NB_OK;
795 }
796
797 int route_next_hop_bfd_source_destroy(struct nb_cb_destroy_args *args)
798 {
799 struct static_nexthop *sn;
800
801 if (args->event != NB_EV_APPLY)
802 return NB_OK;
803
804 sn = nb_running_get_entry(args->dnode, NULL, true);
805 static_next_hop_bfd_auto_source(sn);
806 return NB_OK;
807 }
808
809 /*
810 * XPath:
811 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/bfd-monitoring/multi-hop
812 */
813 int route_next_hop_bfd_multi_hop_modify(struct nb_cb_modify_args *args)
814 {
815 struct static_nexthop *sn;
816
817 if (args->event != NB_EV_APPLY)
818 return NB_OK;
819
820 sn = nb_running_get_entry(args->dnode, NULL, true);
821 static_next_hop_bfd_multi_hop(sn,
822 yang_dnode_get_bool(args->dnode, NULL));
823
824 return NB_OK;
825 }
826
827 /*
828 * XPath:
829 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/bfd-monitoring/profile
830 */
831 int route_next_hop_bfd_profile_modify(struct nb_cb_modify_args *args)
832 {
833 struct static_nexthop *sn;
834
835 if (args->event != NB_EV_APPLY)
836 return NB_OK;
837
838 sn = nb_running_get_entry(args->dnode, NULL, true);
839 static_next_hop_bfd_profile(sn,
840 yang_dnode_get_string(args->dnode, NULL));
841
842 return NB_OK;
843 }
844
845 int route_next_hop_bfd_profile_destroy(struct nb_cb_destroy_args *args)
846 {
847 struct static_nexthop *sn;
848
849 if (args->event != NB_EV_APPLY)
850 return NB_OK;
851
852 sn = nb_running_get_entry(args->dnode, NULL, true);
853 static_next_hop_bfd_profile(sn, NULL);
854
855 return NB_OK;
856 }
857
858 /*
859 * XPath:
860 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list
861 */
862 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_create(
863 struct nb_cb_create_args *args)
864 {
865 struct static_vrf *s_vrf;
866 struct route_node *rn;
867 struct route_node *src_rn;
868 struct prefix_ipv6 src_prefix = {};
869 struct stable_info *info;
870 afi_t afi;
871 safi_t safi = SAFI_UNICAST;
872
873 switch (args->event) {
874 case NB_EV_VALIDATE:
875 case NB_EV_PREPARE:
876 case NB_EV_ABORT:
877 break;
878 case NB_EV_APPLY:
879 rn = nb_running_get_entry(args->dnode, NULL, true);
880 info = route_table_get_info(rn->table);
881 s_vrf = info->svrf;
882 yang_dnode_get_ipv6p(&src_prefix, args->dnode, "./src-prefix");
883 afi = family2afi(src_prefix.family);
884 src_rn =
885 static_add_route(afi, safi, &rn->p, &src_prefix, s_vrf);
886 nb_running_set_entry(args->dnode, src_rn);
887 break;
888 }
889 return NB_OK;
890 }
891
892 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_destroy(
893 struct nb_cb_destroy_args *args)
894 {
895 struct route_node *src_rn;
896
897 switch (args->event) {
898 case NB_EV_VALIDATE:
899 case NB_EV_PREPARE:
900 case NB_EV_ABORT:
901 break;
902 case NB_EV_APPLY:
903 src_rn = nb_running_unset_entry(args->dnode);
904 static_del_route(src_rn);
905 break;
906 }
907
908 return NB_OK;
909 }
910
911 /*
912 * XPath:
913 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list
914 */
915 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_create(
916 struct nb_cb_create_args *args)
917 {
918 return static_path_list_create(args);
919 }
920
921 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_destroy(
922 struct nb_cb_destroy_args *args)
923 {
924 return static_path_list_destroy(args);
925 }
926
927 /*
928 * XPath:
929 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/tag
930 */
931 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_tag_modify(
932 struct nb_cb_modify_args *args)
933 {
934 return static_path_list_tag_modify(args);
935 }
936
937 /*
938 * XPath:
939 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/frr-nexthops/nexthop
940 */
941 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_create(
942 struct nb_cb_create_args *args)
943 {
944 return static_nexthop_create(args);
945 }
946
947 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_destroy(
948 struct nb_cb_destroy_args *args)
949 {
950 return static_nexthop_destroy(args);
951 }
952
953 /*
954 * XPath:
955 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/frr-nexthops/nexthop/bh-type
956 */
957 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_bh_type_modify(
958 struct nb_cb_modify_args *args)
959 {
960 return static_nexthop_bh_type_modify(args);
961 }
962
963 /*
964 * XPath:
965 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/frr-nexthops/nexthop/onlink
966 */
967 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_onlink_modify(
968 struct nb_cb_modify_args *args)
969 {
970 return static_nexthop_onlink_modify(args);
971 }
972
973 /*
974 * XPath:
975 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/frr-nexthops/nexthop/srte-color
976 */
977 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_color_modify(
978 struct nb_cb_modify_args *args)
979 {
980 switch (args->event) {
981 case NB_EV_VALIDATE:
982 case NB_EV_PREPARE:
983 case NB_EV_ABORT:
984 break;
985 case NB_EV_APPLY:
986 if (static_nexthop_color_modify(args) != NB_OK)
987 return NB_ERR;
988
989 break;
990 }
991 return NB_OK;
992 }
993
994
995 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_color_destroy(
996 struct nb_cb_destroy_args *args)
997 {
998 switch (args->event) {
999 case NB_EV_VALIDATE:
1000 case NB_EV_PREPARE:
1001 case NB_EV_ABORT:
1002 break;
1003 case NB_EV_APPLY:
1004 if (static_nexthop_color_destroy(args) != NB_OK)
1005 return NB_ERR;
1006 break;
1007 }
1008 return NB_OK;
1009 }
1010
1011 /*
1012 * XPath:
1013 * /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
1014 */
1015 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_create(
1016 struct nb_cb_create_args *args)
1017 {
1018 return nexthop_mpls_label_stack_entry_create(args);
1019 }
1020
1021 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_destroy(
1022 struct nb_cb_destroy_args *args)
1023 {
1024 return nexthop_mpls_label_stack_entry_destroy(args);
1025 }
1026
1027 /*
1028 * XPath:
1029 * /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
1030 */
1031 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_label_modify(
1032 struct nb_cb_modify_args *args)
1033 {
1034 switch (args->event) {
1035 case NB_EV_VALIDATE:
1036 case NB_EV_PREPARE:
1037 case NB_EV_ABORT:
1038 break;
1039 case NB_EV_APPLY:
1040 if (static_nexthop_mpls_label_modify(args) != NB_OK)
1041 return NB_ERR;
1042 break;
1043 }
1044 return NB_OK;
1045 }
1046
1047 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_label_destroy(
1048 struct nb_cb_destroy_args *args)
1049 {
1050 /*
1051 * No operation is required in this call back.
1052 * nexthop_mpls_label_stack_entry_destroy() will take care
1053 * to reset the label vaue.
1054 */
1055 switch (args->event) {
1056 case NB_EV_VALIDATE:
1057 case NB_EV_PREPARE:
1058 case NB_EV_ABORT:
1059 case NB_EV_APPLY:
1060 break;
1061 }
1062 return NB_OK;
1063 }
1064
1065 /*
1066 * XPath:
1067 * /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
1068 */
1069 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_ttl_modify(
1070 struct nb_cb_modify_args *args)
1071 {
1072 switch (args->event) {
1073 case NB_EV_VALIDATE:
1074 case NB_EV_PREPARE:
1075 case NB_EV_ABORT:
1076 case NB_EV_APPLY:
1077 break;
1078 }
1079
1080 return NB_OK;
1081 }
1082
1083 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_ttl_destroy(
1084 struct nb_cb_destroy_args *args)
1085 {
1086 switch (args->event) {
1087 case NB_EV_VALIDATE:
1088 case NB_EV_PREPARE:
1089 case NB_EV_ABORT:
1090 case NB_EV_APPLY:
1091 break;
1092 }
1093
1094 return NB_OK;
1095 }
1096
1097 /*
1098 * XPath:
1099 * /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
1100 */
1101 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(
1102 struct nb_cb_modify_args *args)
1103 {
1104 switch (args->event) {
1105 case NB_EV_VALIDATE:
1106 case NB_EV_PREPARE:
1107 case NB_EV_ABORT:
1108 case NB_EV_APPLY:
1109 break;
1110 }
1111
1112 return NB_OK;
1113 }
1114
1115 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(
1116 struct nb_cb_destroy_args *args)
1117 {
1118 switch (args->event) {
1119 case NB_EV_VALIDATE:
1120 case NB_EV_PREPARE:
1121 case NB_EV_ABORT:
1122 case NB_EV_APPLY:
1123 break;
1124 }
1125
1126 return NB_OK;
1127 }