Line data Source code
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 0 : static int static_path_list_create(struct nb_cb_create_args *args)
37 : {
38 0 : struct route_node *rn;
39 0 : struct static_path *pn;
40 0 : const struct lyd_node *vrf_dnode;
41 0 : const char *vrf;
42 0 : uint8_t distance;
43 0 : uint32_t table_id;
44 :
45 0 : switch (args->event) {
46 0 : case NB_EV_VALIDATE:
47 0 : vrf_dnode = yang_dnode_get_parent(args->dnode,
48 : "control-plane-protocol");
49 0 : vrf = yang_dnode_get_string(vrf_dnode, "./vrf");
50 0 : 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 0 : if (table_id && (strcmp(vrf, vrf_get_default_name()) != 0)
59 0 : && !vrf_is_backend_netns()) {
60 0 : snprintf(
61 : args->errmsg, args->errmsg_len,
62 : "%% table param only available when running on netns-based vrfs");
63 0 : return NB_ERR_VALIDATION;
64 : }
65 : break;
66 : case NB_EV_ABORT:
67 : case NB_EV_PREPARE:
68 : break;
69 0 : case NB_EV_APPLY:
70 0 : rn = nb_running_get_entry(args->dnode, NULL, true);
71 0 : distance = yang_dnode_get_uint8(args->dnode, "./distance");
72 0 : table_id = yang_dnode_get_uint32(args->dnode, "./table-id");
73 0 : pn = static_add_path(rn, table_id, distance);
74 0 : nb_running_set_entry(args->dnode, pn);
75 : }
76 :
77 : return NB_OK;
78 : }
79 :
80 0 : static int static_path_list_destroy(struct nb_cb_destroy_args *args)
81 : {
82 0 : struct static_path *pn;
83 :
84 0 : switch (args->event) {
85 : case NB_EV_VALIDATE:
86 : case NB_EV_PREPARE:
87 : case NB_EV_ABORT:
88 : break;
89 0 : case NB_EV_APPLY:
90 0 : pn = nb_running_unset_entry(args->dnode);
91 0 : static_del_path(pn);
92 0 : break;
93 : }
94 :
95 0 : return NB_OK;
96 : }
97 :
98 0 : static int static_path_list_tag_modify(struct nb_cb_modify_args *args)
99 : {
100 0 : struct static_path *pn;
101 :
102 0 : switch (args->event) {
103 : case NB_EV_VALIDATE:
104 : case NB_EV_ABORT:
105 : case NB_EV_PREPARE:
106 : break;
107 0 : case NB_EV_APPLY:
108 0 : pn = nb_running_get_entry(args->dnode, NULL, true);
109 0 : pn->tag = yang_dnode_get_uint32(args->dnode, NULL);
110 0 : static_install_path(pn);
111 0 : break;
112 : }
113 :
114 0 : return NB_OK;
115 : }
116 :
117 : struct nexthop_iter {
118 : uint32_t count;
119 : bool blackhole;
120 : };
121 :
122 0 : static int nexthop_iter_cb(const struct lyd_node *dnode, void *arg)
123 : {
124 0 : struct nexthop_iter *iter = arg;
125 0 : enum static_nh_type nh_type;
126 :
127 0 : nh_type = yang_dnode_get_enum(dnode, "./nh-type");
128 :
129 0 : if (nh_type == STATIC_BLACKHOLE)
130 0 : iter->blackhole = true;
131 :
132 0 : iter->count++;
133 :
134 0 : return YANG_ITER_CONTINUE;
135 : }
136 :
137 0 : static bool static_nexthop_create(struct nb_cb_create_args *args)
138 : {
139 0 : const struct lyd_node *pn_dnode;
140 0 : struct nexthop_iter iter;
141 0 : struct static_path *pn;
142 0 : struct ipaddr ipaddr;
143 0 : struct static_nexthop *nh;
144 0 : enum static_nh_type nh_type;
145 0 : const char *ifname;
146 0 : const char *nh_vrf;
147 :
148 0 : switch (args->event) {
149 0 : case NB_EV_VALIDATE:
150 0 : ifname = yang_dnode_get_string(args->dnode, "./interface");
151 0 : if (ifname != NULL) {
152 0 : if (strcasecmp(ifname, "Null0") == 0
153 0 : || strcasecmp(ifname, "reject") == 0
154 0 : || strcasecmp(ifname, "blackhole") == 0) {
155 0 : snprintf(args->errmsg, args->errmsg_len,
156 : "%s: Nexthop interface name can not be from reserved keywords(Null0, reject, blackhole)",
157 : ifname);
158 0 : return NB_ERR_VALIDATION;
159 : }
160 : }
161 :
162 0 : iter.count = 0;
163 0 : iter.blackhole = false;
164 :
165 0 : pn_dnode = yang_dnode_get_parent(args->dnode, "path-list");
166 0 : yang_dnode_iterate(nexthop_iter_cb, &iter, pn_dnode,
167 : "./frr-nexthops/nexthop");
168 :
169 0 : if (iter.blackhole && iter.count > 1) {
170 0 : snprintf(
171 : args->errmsg, args->errmsg_len,
172 : "Route cannot have blackhole and non-blackhole nexthops simultaneously");
173 0 : return NB_ERR_VALIDATION;
174 0 : } else if (iter.count > zebra_ecmp_count) {
175 0 : snprintf(args->errmsg, args->errmsg_len,
176 : "Route cannot have more than %d ECMP nexthops",
177 : zebra_ecmp_count);
178 0 : return NB_ERR_VALIDATION;
179 : }
180 : break;
181 : case NB_EV_PREPARE:
182 : case NB_EV_ABORT:
183 : break;
184 0 : case NB_EV_APPLY:
185 0 : yang_dnode_get_ip(&ipaddr, args->dnode, "./gateway");
186 0 : nh_type = yang_dnode_get_enum(args->dnode, "./nh-type");
187 0 : ifname = yang_dnode_get_string(args->dnode, "./interface");
188 0 : nh_vrf = yang_dnode_get_string(args->dnode, "./vrf");
189 0 : pn = nb_running_get_entry(args->dnode, NULL, true);
190 :
191 0 : if (!static_add_nexthop_validate(nh_vrf, nh_type, &ipaddr))
192 0 : 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 0 : nh = static_add_nexthop(pn, nh_type, &ipaddr, ifname, nh_vrf,
198 : 0);
199 0 : nb_running_set_entry(args->dnode, nh);
200 0 : break;
201 : }
202 :
203 : return NB_OK;
204 : }
205 :
206 0 : static bool static_nexthop_destroy(struct nb_cb_destroy_args *args)
207 : {
208 0 : struct static_nexthop *nh;
209 :
210 0 : switch (args->event) {
211 : case NB_EV_VALIDATE:
212 : case NB_EV_PREPARE:
213 : case NB_EV_ABORT:
214 : break;
215 0 : case NB_EV_APPLY:
216 0 : nh = nb_running_unset_entry(args->dnode);
217 0 : static_delete_nexthop(nh);
218 0 : break;
219 : }
220 :
221 0 : return NB_OK;
222 : }
223 :
224 0 : static int nexthop_mpls_label_stack_entry_create(struct nb_cb_create_args *args)
225 : {
226 0 : struct static_nexthop *nh;
227 0 : uint32_t pos;
228 0 : uint8_t index;
229 :
230 0 : switch (args->event) {
231 0 : case NB_EV_VALIDATE:
232 0 : if (!mpls_enabled) {
233 0 : snprintf(
234 : args->errmsg, args->errmsg_len,
235 : "%% MPLS not turned on in kernel ignoring static route");
236 0 : return NB_ERR_VALIDATION;
237 : }
238 : break;
239 : case NB_EV_PREPARE:
240 : case NB_EV_ABORT:
241 : break;
242 0 : case NB_EV_APPLY:
243 0 : nh = nb_running_get_entry(args->dnode, NULL, true);
244 0 : pos = yang_get_list_pos(args->dnode);
245 0 : if (!pos) {
246 0 : flog_warn(EC_LIB_NB_CB_CONFIG_APPLY,
247 : "libyang returns invalid label position");
248 0 : return NB_ERR;
249 : }
250 : /* Mapping to array = list-index -1 */
251 0 : index = pos - 1;
252 0 : nh->snh_label.label[index] = 0;
253 0 : nh->snh_label.num_labels++;
254 0 : break;
255 : }
256 :
257 : return NB_OK;
258 : }
259 :
260 : static int
261 0 : nexthop_mpls_label_stack_entry_destroy(struct nb_cb_destroy_args *args)
262 : {
263 0 : struct static_nexthop *nh;
264 0 : uint32_t pos;
265 0 : uint8_t index;
266 0 : uint old_num_labels;
267 :
268 0 : switch (args->event) {
269 : case NB_EV_VALIDATE:
270 : case NB_EV_PREPARE:
271 : case NB_EV_ABORT:
272 : break;
273 0 : case NB_EV_APPLY:
274 0 : nh = nb_running_get_entry(args->dnode, NULL, true);
275 0 : pos = yang_get_list_pos(args->dnode);
276 0 : if (!pos) {
277 0 : flog_warn(EC_LIB_NB_CB_CONFIG_APPLY,
278 : "libyang returns invalid label position");
279 0 : return NB_ERR;
280 : }
281 0 : index = pos - 1;
282 0 : old_num_labels = nh->snh_label.num_labels;
283 0 : nh->snh_label.label[index] = 0;
284 0 : nh->snh_label.num_labels--;
285 :
286 0 : if (old_num_labels != nh->snh_label.num_labels)
287 0 : nh->state = STATIC_START;
288 : break;
289 : }
290 :
291 : return NB_OK;
292 : }
293 :
294 0 : static int static_nexthop_mpls_label_modify(struct nb_cb_modify_args *args)
295 : {
296 0 : struct static_nexthop *nh;
297 0 : uint32_t pos;
298 0 : uint8_t index;
299 0 : mpls_label_t old_label;
300 :
301 0 : nh = nb_running_get_entry(args->dnode, NULL, true);
302 0 : pos = yang_get_list_pos(lyd_parent(args->dnode));
303 0 : if (!pos) {
304 0 : flog_warn(EC_LIB_NB_CB_CONFIG_APPLY,
305 : "libyang returns invalid label position");
306 0 : return NB_ERR;
307 : }
308 : /* Mapping to array = list-index -1 */
309 0 : index = pos - 1;
310 :
311 0 : old_label = nh->snh_label.label[index];
312 0 : nh->snh_label.label[index] = yang_dnode_get_uint32(args->dnode, NULL);
313 :
314 0 : if (old_label != nh->snh_label.label[index])
315 0 : nh->state = STATIC_START;
316 :
317 : return NB_OK;
318 : }
319 :
320 0 : static int static_nexthop_onlink_modify(struct nb_cb_modify_args *args)
321 : {
322 0 : struct static_nexthop *nh;
323 0 : enum static_nh_type nh_type;
324 0 : bool old_onlink;
325 :
326 0 : switch (args->event) {
327 0 : case NB_EV_VALIDATE:
328 0 : nh_type = yang_dnode_get_enum(args->dnode, "../nh-type");
329 0 : if ((nh_type != STATIC_IPV4_GATEWAY_IFNAME)
330 0 : && (nh_type != STATIC_IPV6_GATEWAY_IFNAME)) {
331 0 : snprintf(
332 : args->errmsg, args->errmsg_len,
333 : "nexthop type is not the ipv4 or ipv6 interface type");
334 0 : return NB_ERR_VALIDATION;
335 : }
336 : break;
337 : case NB_EV_PREPARE:
338 : case NB_EV_ABORT:
339 : break;
340 0 : case NB_EV_APPLY:
341 0 : nh = nb_running_get_entry(args->dnode, NULL, true);
342 0 : old_onlink = nh->onlink;
343 0 : nh->onlink = yang_dnode_get_bool(args->dnode, NULL);
344 :
345 0 : if (old_onlink != nh->onlink)
346 0 : nh->state = STATIC_START;
347 : break;
348 : }
349 :
350 : return NB_OK;
351 : }
352 :
353 0 : static int static_nexthop_color_modify(struct nb_cb_modify_args *args)
354 : {
355 0 : struct static_nexthop *nh;
356 0 : uint32_t old_color;
357 :
358 0 : nh = nb_running_get_entry(args->dnode, NULL, true);
359 0 : old_color = nh->color;
360 0 : nh->color = yang_dnode_get_uint32(args->dnode, NULL);
361 :
362 0 : if (old_color != nh->color)
363 0 : nh->state = STATIC_START;
364 :
365 0 : return NB_OK;
366 : }
367 :
368 0 : static int static_nexthop_color_destroy(struct nb_cb_destroy_args *args)
369 : {
370 0 : struct static_nexthop *nh;
371 0 : uint32_t old_color;
372 :
373 0 : nh = nb_running_get_entry(args->dnode, NULL, true);
374 0 : old_color = nh->color;
375 0 : nh->color = 0;
376 :
377 0 : if (old_color != nh->color)
378 0 : nh->state = STATIC_START;
379 :
380 0 : return NB_OK;
381 : }
382 :
383 0 : static int static_nexthop_bh_type_modify(struct nb_cb_modify_args *args)
384 : {
385 0 : struct static_nexthop *nh;
386 0 : enum static_nh_type nh_type;
387 :
388 0 : switch (args->event) {
389 0 : case NB_EV_VALIDATE:
390 0 : nh_type = yang_dnode_get_enum(args->dnode, "../nh-type");
391 0 : if (nh_type != STATIC_BLACKHOLE) {
392 0 : snprintf(args->errmsg, args->errmsg_len,
393 : "nexthop type is not the blackhole type");
394 0 : return NB_ERR_VALIDATION;
395 : }
396 : break;
397 : case NB_EV_PREPARE:
398 : case NB_EV_ABORT:
399 : break;
400 0 : case NB_EV_APPLY:
401 0 : nh = nb_running_get_entry(args->dnode, NULL, true);
402 0 : nh->bh_type = yang_dnode_get_enum(args->dnode, NULL);
403 0 : break;
404 : }
405 :
406 : return NB_OK;
407 : }
408 :
409 0 : 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 0 : struct static_nexthop *nh;
413 :
414 0 : nh = nb_running_get_entry(args->dnode, NULL, true);
415 :
416 0 : static_install_nexthop(nh);
417 0 : }
418 :
419 0 : 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 0 : struct static_nexthop *nh;
423 :
424 0 : nh = nb_running_get_entry(args->dnode, NULL, true);
425 :
426 0 : static_install_nexthop(nh);
427 0 : }
428 :
429 0 : 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 0 : const struct lyd_node *mls_dnode;
433 0 : uint32_t count;
434 :
435 0 : mls_dnode = yang_dnode_get(args->dnode, "./mpls-label-stack");
436 0 : count = yang_get_list_elements_count(lyd_child(mls_dnode));
437 :
438 0 : if (count > MPLS_MAX_LABELS) {
439 0 : snprintf(args->errmsg, args->errmsg_len,
440 : "Too many labels, Enter %d or fewer",
441 : MPLS_MAX_LABELS);
442 0 : return NB_ERR_VALIDATION;
443 : }
444 : return NB_OK;
445 : }
446 :
447 0 : int routing_control_plane_protocols_name_validate(
448 : struct nb_cb_create_args *args)
449 : {
450 0 : const char *name;
451 :
452 0 : name = yang_dnode_get_string(args->dnode, "./name");
453 0 : if (!strmatch(name, "staticd")) {
454 0 : snprintf(args->errmsg, args->errmsg_len,
455 : "static routing supports only one instance with name staticd");
456 0 : 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 0 : int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_create(
465 : struct nb_cb_create_args *args)
466 : {
467 0 : struct vrf *vrf;
468 0 : struct static_vrf *s_vrf;
469 0 : struct route_node *rn;
470 0 : const struct lyd_node *vrf_dnode;
471 0 : struct prefix prefix;
472 0 : const char *afi_safi;
473 0 : afi_t prefix_afi;
474 0 : afi_t afi;
475 0 : safi_t safi;
476 :
477 0 : switch (args->event) {
478 0 : case NB_EV_VALIDATE:
479 0 : yang_dnode_get_prefix(&prefix, args->dnode, "./prefix");
480 0 : afi_safi = yang_dnode_get_string(args->dnode, "./afi-safi");
481 0 : yang_afi_safi_identity2value(afi_safi, &afi, &safi);
482 0 : prefix_afi = family2afi(prefix.family);
483 0 : if (afi != prefix_afi) {
484 0 : flog_warn(
485 : EC_LIB_NB_CB_CONFIG_VALIDATE,
486 : "route node %s creation failed",
487 : yang_dnode_get_string(args->dnode, "./prefix"));
488 0 : return NB_ERR_VALIDATION;
489 : }
490 : break;
491 : case NB_EV_PREPARE:
492 : case NB_EV_ABORT:
493 : break;
494 0 : case NB_EV_APPLY:
495 0 : vrf_dnode = yang_dnode_get_parent(args->dnode,
496 : "control-plane-protocol");
497 0 : vrf = nb_running_get_entry(vrf_dnode, NULL, true);
498 0 : s_vrf = vrf->info;
499 :
500 0 : yang_dnode_get_prefix(&prefix, args->dnode, "./prefix");
501 0 : afi_safi = yang_dnode_get_string(args->dnode, "./afi-safi");
502 0 : yang_afi_safi_identity2value(afi_safi, &afi, &safi);
503 :
504 0 : rn = static_add_route(afi, safi, &prefix, NULL, s_vrf);
505 0 : if (vrf->vrf_id == VRF_UNKNOWN)
506 0 : 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 0 : nb_running_set_entry(args->dnode, rn);
511 0 : break;
512 : }
513 : return NB_OK;
514 : }
515 :
516 0 : int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_destroy(
517 : struct nb_cb_destroy_args *args)
518 : {
519 0 : struct route_node *rn;
520 :
521 0 : switch (args->event) {
522 : case NB_EV_VALIDATE:
523 : case NB_EV_PREPARE:
524 : case NB_EV_ABORT:
525 : break;
526 0 : case NB_EV_APPLY:
527 0 : rn = nb_running_unset_entry(args->dnode);
528 0 : static_del_route(rn);
529 0 : break;
530 : }
531 0 : 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 0 : int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_create(
539 : struct nb_cb_create_args *args)
540 : {
541 0 : return static_path_list_create(args);
542 : }
543 :
544 0 : int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_destroy(
545 : struct nb_cb_destroy_args *args)
546 : {
547 0 : 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 0 : int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_tag_modify(
555 : struct nb_cb_modify_args *args)
556 : {
557 0 : 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 0 : 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 0 : return static_nexthop_create(args);
568 : }
569 :
570 0 : 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 0 : 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 0 : 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 0 : 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 0 : 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 0 : 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 0 : 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 0 : switch (args->event) {
604 : case NB_EV_VALIDATE:
605 : case NB_EV_PREPARE:
606 : case NB_EV_ABORT:
607 : break;
608 0 : case NB_EV_APPLY:
609 0 : if (static_nexthop_color_modify(args) != NB_OK)
610 : return NB_ERR;
611 :
612 : break;
613 : }
614 : return NB_OK;
615 : }
616 :
617 0 : 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 0 : switch (args->event) {
621 : case NB_EV_VALIDATE:
622 : case NB_EV_PREPARE:
623 : case NB_EV_ABORT:
624 : break;
625 0 : case NB_EV_APPLY:
626 0 : 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 0 : 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 0 : return nexthop_mpls_label_stack_entry_create(args);
641 : }
642 :
643 0 : 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 0 : 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 0 : 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 0 : switch (args->event) {
657 : case NB_EV_VALIDATE:
658 : case NB_EV_PREPARE:
659 : case NB_EV_ABORT:
660 : break;
661 0 : case NB_EV_APPLY:
662 0 : if (static_nexthop_mpls_label_modify(args) != NB_OK)
663 : return NB_ERR;
664 : break;
665 : }
666 : return NB_OK;
667 : }
668 :
669 0 : 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 0 : 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 0 : 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 0 : 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 0 : 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 0 : return NB_OK;
703 : }
704 :
705 0 : 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 0 : 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 0 : 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 0 : 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 0 : 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 0 : return NB_OK;
735 : }
736 :
737 0 : 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 0 : 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 0 : 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 0 : int route_next_hop_bfd_create(struct nb_cb_create_args *args)
756 : {
757 0 : struct static_nexthop *sn;
758 :
759 0 : if (args->event != NB_EV_APPLY)
760 : return NB_OK;
761 :
762 0 : sn = nb_running_get_entry(args->dnode, NULL, true);
763 0 : static_next_hop_bfd_monitor_enable(sn, args->dnode);
764 0 : return NB_OK;
765 : }
766 :
767 0 : int route_next_hop_bfd_destroy(struct nb_cb_destroy_args *args)
768 : {
769 0 : struct static_nexthop *sn;
770 :
771 0 : if (args->event != NB_EV_APPLY)
772 : return NB_OK;
773 :
774 0 : sn = nb_running_get_entry(args->dnode, NULL, true);
775 0 : static_next_hop_bfd_monitor_disable(sn);
776 0 : 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 0 : int route_next_hop_bfd_source_modify(struct nb_cb_modify_args *args)
784 : {
785 0 : struct static_nexthop *sn;
786 0 : struct ipaddr source;
787 :
788 0 : if (args->event != NB_EV_APPLY)
789 : return NB_OK;
790 :
791 0 : sn = nb_running_get_entry(args->dnode, NULL, true);
792 0 : yang_dnode_get_ip(&source, args->dnode, NULL);
793 0 : static_next_hop_bfd_source(sn, &source);
794 0 : return NB_OK;
795 : }
796 :
797 0 : int route_next_hop_bfd_source_destroy(struct nb_cb_destroy_args *args)
798 : {
799 0 : struct static_nexthop *sn;
800 :
801 0 : if (args->event != NB_EV_APPLY)
802 : return NB_OK;
803 :
804 0 : sn = nb_running_get_entry(args->dnode, NULL, true);
805 0 : static_next_hop_bfd_auto_source(sn);
806 0 : 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 0 : int route_next_hop_bfd_multi_hop_modify(struct nb_cb_modify_args *args)
814 : {
815 0 : struct static_nexthop *sn;
816 :
817 0 : if (args->event != NB_EV_APPLY)
818 : return NB_OK;
819 :
820 0 : sn = nb_running_get_entry(args->dnode, NULL, true);
821 0 : static_next_hop_bfd_multi_hop(sn,
822 0 : yang_dnode_get_bool(args->dnode, NULL));
823 :
824 0 : 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 0 : int route_next_hop_bfd_profile_modify(struct nb_cb_modify_args *args)
832 : {
833 0 : struct static_nexthop *sn;
834 :
835 0 : if (args->event != NB_EV_APPLY)
836 : return NB_OK;
837 :
838 0 : sn = nb_running_get_entry(args->dnode, NULL, true);
839 0 : static_next_hop_bfd_profile(sn,
840 : yang_dnode_get_string(args->dnode, NULL));
841 :
842 0 : return NB_OK;
843 : }
844 :
845 0 : int route_next_hop_bfd_profile_destroy(struct nb_cb_destroy_args *args)
846 : {
847 0 : struct static_nexthop *sn;
848 :
849 0 : if (args->event != NB_EV_APPLY)
850 : return NB_OK;
851 :
852 0 : sn = nb_running_get_entry(args->dnode, NULL, true);
853 0 : static_next_hop_bfd_profile(sn, NULL);
854 :
855 0 : 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 0 : int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_create(
863 : struct nb_cb_create_args *args)
864 : {
865 0 : struct static_vrf *s_vrf;
866 0 : struct route_node *rn;
867 0 : struct route_node *src_rn;
868 0 : struct prefix_ipv6 src_prefix = {};
869 0 : struct stable_info *info;
870 0 : afi_t afi;
871 0 : safi_t safi = SAFI_UNICAST;
872 :
873 0 : switch (args->event) {
874 : case NB_EV_VALIDATE:
875 : case NB_EV_PREPARE:
876 : case NB_EV_ABORT:
877 : break;
878 0 : case NB_EV_APPLY:
879 0 : rn = nb_running_get_entry(args->dnode, NULL, true);
880 0 : info = route_table_get_info(rn->table);
881 0 : s_vrf = info->svrf;
882 0 : yang_dnode_get_ipv6p(&src_prefix, args->dnode, "./src-prefix");
883 0 : afi = family2afi(src_prefix.family);
884 0 : src_rn =
885 0 : static_add_route(afi, safi, &rn->p, &src_prefix, s_vrf);
886 0 : nb_running_set_entry(args->dnode, src_rn);
887 0 : break;
888 : }
889 0 : return NB_OK;
890 : }
891 :
892 0 : int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_destroy(
893 : struct nb_cb_destroy_args *args)
894 : {
895 0 : struct route_node *src_rn;
896 :
897 0 : switch (args->event) {
898 : case NB_EV_VALIDATE:
899 : case NB_EV_PREPARE:
900 : case NB_EV_ABORT:
901 : break;
902 0 : case NB_EV_APPLY:
903 0 : src_rn = nb_running_unset_entry(args->dnode);
904 0 : static_del_route(src_rn);
905 0 : break;
906 : }
907 :
908 0 : 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 0 : 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 0 : return static_path_list_create(args);
919 : }
920 :
921 0 : 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 0 : 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 0 : 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 0 : 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 0 : 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 0 : return static_nexthop_create(args);
945 : }
946 :
947 0 : 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 0 : 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 0 : 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 0 : 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 0 : 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 0 : 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 0 : 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 0 : switch (args->event) {
981 : case NB_EV_VALIDATE:
982 : case NB_EV_PREPARE:
983 : case NB_EV_ABORT:
984 : break;
985 0 : case NB_EV_APPLY:
986 0 : if (static_nexthop_color_modify(args) != NB_OK)
987 : return NB_ERR;
988 :
989 : break;
990 : }
991 : return NB_OK;
992 : }
993 :
994 :
995 0 : 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 0 : switch (args->event) {
999 : case NB_EV_VALIDATE:
1000 : case NB_EV_PREPARE:
1001 : case NB_EV_ABORT:
1002 : break;
1003 0 : case NB_EV_APPLY:
1004 0 : 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 0 : 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 0 : return nexthop_mpls_label_stack_entry_create(args);
1019 : }
1020 :
1021 0 : 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 0 : 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 0 : 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 0 : switch (args->event) {
1035 : case NB_EV_VALIDATE:
1036 : case NB_EV_PREPARE:
1037 : case NB_EV_ABORT:
1038 : break;
1039 0 : case NB_EV_APPLY:
1040 0 : if (static_nexthop_mpls_label_modify(args) != NB_OK)
1041 : return NB_ERR;
1042 : break;
1043 : }
1044 : return NB_OK;
1045 : }
1046 :
1047 0 : 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 0 : 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 0 : 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 0 : 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 0 : 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 0 : return NB_OK;
1081 : }
1082 :
1083 0 : 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 0 : 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 0 : 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 0 : 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 0 : 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 0 : return NB_OK;
1113 : }
1114 :
1115 0 : 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 0 : 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 0 : return NB_OK;
1127 : }
|