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