]> git.proxmox.com Git - mirror_frr.git/blame - staticd/static_nb_config.c
isisd: fix recreating the LS TED after re-enabling MPLS TE
[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 117struct nexthop_iter {
1f7ab1a2 118 uint32_t count;
cd07806b
IR
119 bool blackhole;
120};
121
122static int nexthop_iter_cb(const struct lyd_node *dnode, void *arg)
123{
124 struct nexthop_iter *iter = arg;
9ccaa12d 125 enum static_nh_type nh_type;
cd07806b
IR
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;
9ccaa12d 144 enum static_nh_type nh_type;
88fa5104 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,
423e32cb 172 "Route cannot have blackhole and non-blackhole nexthops simultaneously");
cd07806b 173 return NB_ERR_VALIDATION;
1f7ab1a2
MS
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;
cd07806b 179 }
88fa5104 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);
88fa5104 190
ddd45515 191 if (!static_add_nexthop_validate(nh_vrf, nh_type, &ipaddr))
88fa5104 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"));
4067e951
IR
197 nh = static_add_nexthop(pn, nh_type, &ipaddr, ifname, nh_vrf,
198 0);
88fa5104 199 nb_running_set_entry(args->dnode, nh);
200 break;
201 }
202
203 return NB_OK;
204}
205
4067e951 206static bool static_nexthop_destroy(struct nb_cb_destroy_args *args)
88fa5104 207{
88fa5104 208 struct static_nexthop *nh;
88fa5104 209
4067e951
IR
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;
88fa5104 219 }
220
221 return NB_OK;
222}
223
224static 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:
b2f6ab67 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;
88fa5104 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
260static int
261nexthop_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;
eb6249d2 266 uint old_num_labels;
88fa5104 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;
eb6249d2 282 old_num_labels = nh->snh_label.num_labels;
88fa5104 283 nh->snh_label.label[index] = 0;
284 nh->snh_label.num_labels--;
eb6249d2
DS
285
286 if (old_num_labels != nh->snh_label.num_labels)
287 nh->state = STATIC_START;
88fa5104 288 break;
289 }
290
291 return NB_OK;
292}
293
294static 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;
eb6249d2 299 mpls_label_t old_label;
88fa5104 300
301 nh = nb_running_get_entry(args->dnode, NULL, true);
3bb513c3 302 pos = yang_get_list_pos(lyd_parent(args->dnode));
88fa5104 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;
eb6249d2
DS
310
311 old_label = nh->snh_label.label[index];
88fa5104 312 nh->snh_label.label[index] = yang_dnode_get_uint32(args->dnode, NULL);
313
eb6249d2
DS
314 if (old_label != nh->snh_label.label[index])
315 nh->state = STATIC_START;
316
88fa5104 317 return NB_OK;
318}
319
320static int static_nexthop_onlink_modify(struct nb_cb_modify_args *args)
321{
322 struct static_nexthop *nh;
9ccaa12d 323 enum static_nh_type nh_type;
eb6249d2 324 bool old_onlink;
88fa5104 325
6dfc022f
CS
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);
eb6249d2 342 old_onlink = nh->onlink;
6dfc022f 343 nh->onlink = yang_dnode_get_bool(args->dnode, NULL);
eb6249d2
DS
344
345 if (old_onlink != nh->onlink)
346 nh->state = STATIC_START;
6dfc022f
CS
347 break;
348 }
88fa5104 349
350 return NB_OK;
351}
352
065276ae
SM
353static int static_nexthop_color_modify(struct nb_cb_modify_args *args)
354{
355 struct static_nexthop *nh;
eb6249d2 356 uint32_t old_color;
065276ae
SM
357
358 nh = nb_running_get_entry(args->dnode, NULL, true);
eb6249d2 359 old_color = nh->color;
065276ae
SM
360 nh->color = yang_dnode_get_uint32(args->dnode, NULL);
361
eb6249d2
DS
362 if (old_color != nh->color)
363 nh->state = STATIC_START;
364
065276ae
SM
365 return NB_OK;
366}
367
368static int static_nexthop_color_destroy(struct nb_cb_destroy_args *args)
369{
370 struct static_nexthop *nh;
eb6249d2 371 uint32_t old_color;
065276ae
SM
372
373 nh = nb_running_unset_entry(args->dnode);
eb6249d2 374 old_color = nh->color;
065276ae
SM
375 nh->color = 0;
376
eb6249d2
DS
377 if (old_color != nh->color)
378 nh->state = STATIC_START;
379
065276ae
SM
380 return NB_OK;
381}
382
88fa5104 383static int static_nexthop_bh_type_modify(struct nb_cb_modify_args *args)
384{
385 struct static_nexthop *nh;
9ccaa12d 386 enum static_nh_type nh_type;
88fa5104 387
6dfc022f
CS
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 }
88fa5104 405
406 return NB_OK;
407}
408
88fa5104 409void 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;
88fa5104 413
414 nh = nb_running_get_entry(args->dnode, NULL, true);
415
4067e951 416 static_install_nexthop(nh);
88fa5104 417}
418
88fa5104 419void 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;
88fa5104 423
424 nh = nb_running_get_entry(args->dnode, NULL, true);
425
4067e951 426 static_install_nexthop(nh);
88fa5104 427}
4067e951 428
88fa5104 429int 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");
3bb513c3 436 count = yang_get_list_elements_count(lyd_child(mls_dnode));
88fa5104 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
447int 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 */
464int 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;
314825ff 472 const char *afi_safi;
473 afi_t prefix_afi;
88fa5104 474 afi_t afi;
314825ff 475 safi_t safi;
88fa5104 476
477 switch (args->event) {
478 case NB_EV_VALIDATE:
314825ff 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;
88fa5104 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");
314825ff 501 afi_safi = yang_dnode_get_string(args->dnode, "./afi-safi");
502 yang_afi_safi_identity2value(afi_safi, &afi, &safi);
88fa5104 503
504 rn = static_add_route(afi, safi, &prefix, NULL, s_vrf);
b2f6ab67 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"));
88fa5104 510 nb_running_set_entry(args->dnode, rn);
511 break;
512 }
513 return NB_OK;
514}
515
516int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_destroy(
517 struct nb_cb_destroy_args *args)
518{
519 struct route_node *rn;
88fa5104 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);
4067e951 528 static_del_route(rn);
88fa5104 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 */
538int 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
544int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_destroy(
545 struct nb_cb_destroy_args *args)
546{
4067e951 547 return static_path_list_destroy(args);
88fa5104 548}
549
550/*
551 * XPath:
552 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/tag
553 */
554int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_tag_modify(
555 struct nb_cb_modify_args *args)
556{
4067e951 557 return static_path_list_tag_modify(args);
88fa5104 558}
559
88fa5104 560/*
561 * XPath:
562 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop
563 */
564int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_create(
565 struct nb_cb_create_args *args)
566{
4067e951 567 return static_nexthop_create(args);
88fa5104 568}
569
570int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_destroy(
571 struct nb_cb_destroy_args *args)
572{
4067e951 573 return static_nexthop_destroy(args);
88fa5104 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 */
580int 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{
6dfc022f 583 return static_nexthop_bh_type_modify(args);
88fa5104 584}
585
88fa5104 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 */
590int 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{
6dfc022f 593 return static_nexthop_onlink_modify(args);
88fa5104 594}
065276ae
SM
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 */
600int 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
617int 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
88fa5104 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 */
637int 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
643int 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 */
653int 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
669int 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 */
691int 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
705int 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 */
723int 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
737int 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/src-list
754 */
755int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_create(
756 struct nb_cb_create_args *args)
757{
758 struct static_vrf *s_vrf;
759 struct route_node *rn;
760 struct route_node *src_rn;
761 struct prefix_ipv6 src_prefix = {};
762 struct stable_info *info;
763 afi_t afi;
764 safi_t safi = SAFI_UNICAST;
765
766 switch (args->event) {
767 case NB_EV_VALIDATE:
768 case NB_EV_PREPARE:
769 case NB_EV_ABORT:
770 break;
771 case NB_EV_APPLY:
772 rn = nb_running_get_entry(args->dnode, NULL, true);
773 info = route_table_get_info(rn->table);
774 s_vrf = info->svrf;
775 yang_dnode_get_ipv6p(&src_prefix, args->dnode, "./src-prefix");
776 afi = family2afi(src_prefix.family);
777 src_rn =
778 static_add_route(afi, safi, &rn->p, &src_prefix, s_vrf);
88fa5104 779 nb_running_set_entry(args->dnode, src_rn);
780 break;
781 }
782 return NB_OK;
783}
784
785int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_destroy(
786 struct nb_cb_destroy_args *args)
787{
788 struct route_node *src_rn;
88fa5104 789
790 switch (args->event) {
791 case NB_EV_VALIDATE:
792 case NB_EV_PREPARE:
793 case NB_EV_ABORT:
794 break;
795 case NB_EV_APPLY:
796 src_rn = nb_running_unset_entry(args->dnode);
4067e951 797 static_del_route(src_rn);
88fa5104 798 break;
799 }
800
801 return NB_OK;
802}
803
804/*
805 * XPath:
806 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list
807 */
808int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_create(
809 struct nb_cb_create_args *args)
810{
811 return static_path_list_create(args);
812}
813
814int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_destroy(
815 struct nb_cb_destroy_args *args)
816{
4067e951 817 return static_path_list_destroy(args);
88fa5104 818}
819
820/*
821 * XPath:
822 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/tag
823 */
824int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_tag_modify(
825 struct nb_cb_modify_args *args)
826{
4067e951 827 return static_path_list_tag_modify(args);
88fa5104 828}
829
88fa5104 830/*
831 * XPath:
832 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/frr-nexthops/nexthop
833 */
834int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_create(
835 struct nb_cb_create_args *args)
836{
4067e951 837 return static_nexthop_create(args);
88fa5104 838}
839
840int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_destroy(
841 struct nb_cb_destroy_args *args)
842{
4067e951 843 return static_nexthop_destroy(args);
88fa5104 844}
845
846/*
847 * XPath:
848 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/frr-nexthops/nexthop/bh-type
849 */
850int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_bh_type_modify(
851 struct nb_cb_modify_args *args)
852{
6dfc022f 853 return static_nexthop_bh_type_modify(args);
88fa5104 854}
855
88fa5104 856/*
857 * XPath:
858 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/frr-nexthops/nexthop/onlink
859 */
860int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_onlink_modify(
861 struct nb_cb_modify_args *args)
862{
6dfc022f 863 return static_nexthop_onlink_modify(args);
88fa5104 864}
865
065276ae
SM
866/*
867 * XPath:
868 * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/frr-nexthops/nexthop/srte-color
869 */
870int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_color_modify(
871 struct nb_cb_modify_args *args)
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 if (static_nexthop_color_modify(args) != NB_OK)
880 return NB_ERR;
881
882 break;
883 }
884 return NB_OK;
885}
886
887
888int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_color_destroy(
889 struct nb_cb_destroy_args *args)
890{
891 switch (args->event) {
892 case NB_EV_VALIDATE:
893 case NB_EV_PREPARE:
894 case NB_EV_ABORT:
895 break;
896 case NB_EV_APPLY:
897 if (static_nexthop_color_destroy(args) != NB_OK)
898 return NB_ERR;
899 break;
900 }
901 return NB_OK;
902}
903
88fa5104 904/*
905 * XPath:
906 * /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
907 */
908int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_create(
909 struct nb_cb_create_args *args)
910{
911 return nexthop_mpls_label_stack_entry_create(args);
912}
913
914int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_destroy(
915 struct nb_cb_destroy_args *args)
916{
917 return nexthop_mpls_label_stack_entry_destroy(args);
918}
919
920/*
921 * XPath:
922 * /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
923 */
924int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_label_modify(
925 struct nb_cb_modify_args *args)
926{
927 switch (args->event) {
928 case NB_EV_VALIDATE:
929 case NB_EV_PREPARE:
930 case NB_EV_ABORT:
931 break;
932 case NB_EV_APPLY:
933 if (static_nexthop_mpls_label_modify(args) != NB_OK)
934 return NB_ERR;
935 break;
936 }
937 return NB_OK;
938}
939
940int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_label_destroy(
941 struct nb_cb_destroy_args *args)
942{
943 /*
944 * No operation is required in this call back.
945 * nexthop_mpls_label_stack_entry_destroy() will take care
946 * to reset the label vaue.
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 return NB_OK;
956}
957
958/*
959 * XPath:
960 * /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
961 */
962int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_ttl_modify(
963 struct nb_cb_modify_args *args)
964{
965 switch (args->event) {
966 case NB_EV_VALIDATE:
967 case NB_EV_PREPARE:
968 case NB_EV_ABORT:
969 case NB_EV_APPLY:
970 break;
971 }
972
973 return NB_OK;
974}
975
976int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_ttl_destroy(
977 struct nb_cb_destroy_args *args)
978{
979 switch (args->event) {
980 case NB_EV_VALIDATE:
981 case NB_EV_PREPARE:
982 case NB_EV_ABORT:
983 case NB_EV_APPLY:
984 break;
985 }
986
987 return NB_OK;
988}
989
990/*
991 * XPath:
992 * /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
993 */
994int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_traffic_class_modify(
995 struct nb_cb_modify_args *args)
996{
997 switch (args->event) {
998 case NB_EV_VALIDATE:
999 case NB_EV_PREPARE:
1000 case NB_EV_ABORT:
1001 case NB_EV_APPLY:
1002 break;
1003 }
1004
1005 return NB_OK;
1006}
1007
1008int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_traffic_class_destroy(
1009 struct nb_cb_destroy_args *args)
1010{
1011 switch (args->event) {
1012 case NB_EV_VALIDATE:
1013 case NB_EV_PREPARE:
1014 case NB_EV_ABORT:
1015 case NB_EV_APPLY:
1016 break;
1017 }
1018
1019 return NB_OK;
1020}