]>
Commit | Line | Data |
---|---|---|
ce45ffe7 CS |
1 | /* |
2 | * Copyright (C) 2019 Cumulus Networks, Inc. | |
3 | * Chirag Shah | |
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 | ||
20 | #include <zebra.h> | |
21 | ||
22 | #include "lib/log.h" | |
23 | #include "lib/northbound.h" | |
2dbe669b | 24 | #include "lib/printfrr.h" |
ce45ffe7 CS |
25 | #include "libfrr.h" |
26 | #include "lib/command.h" | |
27 | #include "lib/routemap.h" | |
ce45ffe7 CS |
28 | #include "zebra/zebra_nb.h" |
29 | #include "zebra/rib.h" | |
09268680 CS |
30 | #include "zebra_nb.h" |
31 | #include "zebra/interface.h" | |
32 | #include "zebra/connected.h" | |
9d86e091 | 33 | #include "zebra/zebra_router.h" |
5a634c34 | 34 | #include "zebra/debug.h" |
e2bcfa39 CS |
35 | #include "zebra/zebra_vxlan_private.h" |
36 | #include "zebra/zebra_vxlan.h" | |
ce45ffe7 CS |
37 | |
38 | /* | |
39 | * XPath: /frr-zebra:zebra/mcast-rpf-lookup | |
40 | */ | |
60ee8be1 | 41 | int zebra_mcast_rpf_lookup_modify(struct nb_cb_modify_args *args) |
ce45ffe7 | 42 | { |
60ee8be1 | 43 | switch (args->event) { |
ce45ffe7 CS |
44 | case NB_EV_VALIDATE: |
45 | case NB_EV_PREPARE: | |
46 | case NB_EV_ABORT: | |
47 | case NB_EV_APPLY: | |
48 | /* TODO: implement me. */ | |
49 | break; | |
50 | } | |
51 | ||
52 | return NB_OK; | |
53 | } | |
54 | ||
55 | /* | |
56 | * XPath: /frr-zebra:zebra/ip-forwarding | |
57 | */ | |
60ee8be1 | 58 | int zebra_ip_forwarding_modify(struct nb_cb_modify_args *args) |
ce45ffe7 | 59 | { |
60ee8be1 | 60 | switch (args->event) { |
ce45ffe7 CS |
61 | case NB_EV_VALIDATE: |
62 | case NB_EV_PREPARE: | |
63 | case NB_EV_ABORT: | |
64 | case NB_EV_APPLY: | |
65 | /* TODO: implement me. */ | |
66 | break; | |
67 | } | |
68 | ||
69 | return NB_OK; | |
70 | } | |
71 | ||
60ee8be1 | 72 | int zebra_ip_forwarding_destroy(struct nb_cb_destroy_args *args) |
ce45ffe7 | 73 | { |
60ee8be1 | 74 | switch (args->event) { |
ce45ffe7 CS |
75 | case NB_EV_VALIDATE: |
76 | case NB_EV_PREPARE: | |
77 | case NB_EV_ABORT: | |
78 | case NB_EV_APPLY: | |
79 | /* TODO: implement me. */ | |
80 | break; | |
81 | } | |
82 | ||
83 | return NB_OK; | |
84 | } | |
85 | ||
86 | /* | |
87 | * XPath: /frr-zebra:zebra/ipv6-forwarding | |
88 | */ | |
60ee8be1 | 89 | int zebra_ipv6_forwarding_modify(struct nb_cb_modify_args *args) |
ce45ffe7 | 90 | { |
60ee8be1 | 91 | switch (args->event) { |
ce45ffe7 CS |
92 | case NB_EV_VALIDATE: |
93 | case NB_EV_PREPARE: | |
94 | case NB_EV_ABORT: | |
95 | case NB_EV_APPLY: | |
96 | /* TODO: implement me. */ | |
97 | break; | |
98 | } | |
99 | ||
100 | return NB_OK; | |
101 | } | |
102 | ||
60ee8be1 | 103 | int zebra_ipv6_forwarding_destroy(struct nb_cb_destroy_args *args) |
ce45ffe7 | 104 | { |
60ee8be1 | 105 | switch (args->event) { |
ce45ffe7 CS |
106 | case NB_EV_VALIDATE: |
107 | case NB_EV_PREPARE: | |
108 | case NB_EV_ABORT: | |
109 | case NB_EV_APPLY: | |
110 | /* TODO: implement me. */ | |
111 | break; | |
112 | } | |
113 | ||
114 | return NB_OK; | |
115 | } | |
116 | ||
117 | /* | |
118 | * XPath: /frr-zebra:zebra/workqueue-hold-timer | |
119 | */ | |
60ee8be1 | 120 | int zebra_workqueue_hold_timer_modify(struct nb_cb_modify_args *args) |
ce45ffe7 | 121 | { |
60ee8be1 | 122 | switch (args->event) { |
ce45ffe7 CS |
123 | case NB_EV_VALIDATE: |
124 | case NB_EV_PREPARE: | |
125 | case NB_EV_ABORT: | |
126 | case NB_EV_APPLY: | |
127 | /* TODO: implement me. */ | |
128 | break; | |
129 | } | |
130 | ||
131 | return NB_OK; | |
132 | } | |
133 | ||
134 | /* | |
135 | * XPath: /frr-zebra:zebra/zapi-packets | |
136 | */ | |
60ee8be1 | 137 | int zebra_zapi_packets_modify(struct nb_cb_modify_args *args) |
ce45ffe7 | 138 | { |
60ee8be1 | 139 | switch (args->event) { |
ce45ffe7 CS |
140 | case NB_EV_VALIDATE: |
141 | case NB_EV_PREPARE: | |
142 | case NB_EV_ABORT: | |
143 | case NB_EV_APPLY: | |
144 | /* TODO: implement me. */ | |
145 | break; | |
146 | } | |
147 | ||
148 | return NB_OK; | |
149 | } | |
150 | ||
151 | /* | |
152 | * XPath: /frr-zebra:zebra/import-kernel-table/table-id | |
153 | */ | |
60ee8be1 | 154 | int zebra_import_kernel_table_table_id_modify(struct nb_cb_modify_args *args) |
ce45ffe7 | 155 | { |
60ee8be1 | 156 | switch (args->event) { |
ce45ffe7 CS |
157 | case NB_EV_VALIDATE: |
158 | case NB_EV_PREPARE: | |
159 | case NB_EV_ABORT: | |
160 | case NB_EV_APPLY: | |
161 | /* TODO: implement me. */ | |
162 | break; | |
163 | } | |
164 | ||
165 | return NB_OK; | |
166 | } | |
167 | ||
60ee8be1 | 168 | int zebra_import_kernel_table_table_id_destroy(struct nb_cb_destroy_args *args) |
ce45ffe7 | 169 | { |
60ee8be1 | 170 | switch (args->event) { |
ce45ffe7 CS |
171 | case NB_EV_VALIDATE: |
172 | case NB_EV_PREPARE: | |
173 | case NB_EV_ABORT: | |
174 | case NB_EV_APPLY: | |
175 | /* TODO: implement me. */ | |
176 | break; | |
177 | } | |
178 | ||
179 | return NB_OK; | |
180 | } | |
181 | ||
182 | /* | |
183 | * XPath: /frr-zebra:zebra/import-kernel-table/distance | |
184 | */ | |
60ee8be1 | 185 | int zebra_import_kernel_table_distance_modify(struct nb_cb_modify_args *args) |
ce45ffe7 | 186 | { |
60ee8be1 | 187 | switch (args->event) { |
ce45ffe7 CS |
188 | case NB_EV_VALIDATE: |
189 | case NB_EV_PREPARE: | |
190 | case NB_EV_ABORT: | |
191 | case NB_EV_APPLY: | |
192 | /* TODO: implement me. */ | |
193 | break; | |
194 | } | |
195 | ||
196 | return NB_OK; | |
197 | } | |
198 | ||
199 | /* | |
200 | * XPath: /frr-zebra:zebra/import-kernel-table/route-map | |
201 | */ | |
60ee8be1 | 202 | int zebra_import_kernel_table_route_map_modify(struct nb_cb_modify_args *args) |
ce45ffe7 | 203 | { |
60ee8be1 | 204 | switch (args->event) { |
ce45ffe7 CS |
205 | case NB_EV_VALIDATE: |
206 | case NB_EV_PREPARE: | |
207 | case NB_EV_ABORT: | |
208 | case NB_EV_APPLY: | |
209 | /* TODO: implement me. */ | |
210 | break; | |
211 | } | |
212 | ||
213 | return NB_OK; | |
214 | } | |
215 | ||
60ee8be1 | 216 | int zebra_import_kernel_table_route_map_destroy(struct nb_cb_destroy_args *args) |
ce45ffe7 | 217 | { |
60ee8be1 | 218 | switch (args->event) { |
ce45ffe7 CS |
219 | case NB_EV_VALIDATE: |
220 | case NB_EV_PREPARE: | |
221 | case NB_EV_ABORT: | |
222 | case NB_EV_APPLY: | |
223 | /* TODO: implement me. */ | |
224 | break; | |
225 | } | |
226 | ||
227 | return NB_OK; | |
228 | } | |
229 | ||
230 | /* | |
231 | * XPath: /frr-zebra:zebra/allow-external-route-update | |
232 | */ | |
60ee8be1 | 233 | int zebra_allow_external_route_update_create(struct nb_cb_create_args *args) |
ce45ffe7 | 234 | { |
60ee8be1 | 235 | switch (args->event) { |
ce45ffe7 CS |
236 | case NB_EV_VALIDATE: |
237 | case NB_EV_PREPARE: | |
238 | case NB_EV_ABORT: | |
239 | case NB_EV_APPLY: | |
240 | /* TODO: implement me. */ | |
241 | break; | |
242 | } | |
243 | ||
244 | return NB_OK; | |
245 | } | |
246 | ||
60ee8be1 | 247 | int zebra_allow_external_route_update_destroy(struct nb_cb_destroy_args *args) |
ce45ffe7 | 248 | { |
60ee8be1 | 249 | switch (args->event) { |
ce45ffe7 CS |
250 | case NB_EV_VALIDATE: |
251 | case NB_EV_PREPARE: | |
252 | case NB_EV_ABORT: | |
253 | case NB_EV_APPLY: | |
254 | /* TODO: implement me. */ | |
255 | break; | |
256 | } | |
257 | ||
258 | return NB_OK; | |
259 | } | |
260 | ||
261 | /* | |
262 | * XPath: /frr-zebra:zebra/dplane-queue-limit | |
263 | */ | |
60ee8be1 | 264 | int zebra_dplane_queue_limit_modify(struct nb_cb_modify_args *args) |
ce45ffe7 | 265 | { |
60ee8be1 | 266 | switch (args->event) { |
ce45ffe7 CS |
267 | case NB_EV_VALIDATE: |
268 | case NB_EV_PREPARE: | |
269 | case NB_EV_ABORT: | |
270 | case NB_EV_APPLY: | |
271 | /* TODO: implement me. */ | |
272 | break; | |
273 | } | |
274 | ||
275 | return NB_OK; | |
276 | } | |
277 | ||
ce45ffe7 CS |
278 | /* |
279 | * XPath: /frr-zebra:zebra/debugs/debug-events | |
280 | */ | |
60ee8be1 | 281 | int zebra_debugs_debug_events_modify(struct nb_cb_modify_args *args) |
ce45ffe7 | 282 | { |
60ee8be1 | 283 | switch (args->event) { |
ce45ffe7 CS |
284 | case NB_EV_VALIDATE: |
285 | case NB_EV_PREPARE: | |
286 | case NB_EV_ABORT: | |
287 | case NB_EV_APPLY: | |
288 | /* TODO: implement me. */ | |
289 | break; | |
290 | } | |
291 | ||
292 | return NB_OK; | |
293 | } | |
294 | ||
60ee8be1 | 295 | int zebra_debugs_debug_events_destroy(struct nb_cb_destroy_args *args) |
ce45ffe7 | 296 | { |
60ee8be1 | 297 | switch (args->event) { |
ce45ffe7 CS |
298 | case NB_EV_VALIDATE: |
299 | case NB_EV_PREPARE: | |
300 | case NB_EV_ABORT: | |
301 | case NB_EV_APPLY: | |
302 | /* TODO: implement me. */ | |
303 | break; | |
304 | } | |
305 | ||
306 | return NB_OK; | |
307 | } | |
308 | ||
309 | /* | |
310 | * XPath: /frr-zebra:zebra/debugs/debug-zapi-send | |
311 | */ | |
60ee8be1 | 312 | int zebra_debugs_debug_zapi_send_modify(struct nb_cb_modify_args *args) |
ce45ffe7 | 313 | { |
60ee8be1 | 314 | switch (args->event) { |
ce45ffe7 CS |
315 | case NB_EV_VALIDATE: |
316 | case NB_EV_PREPARE: | |
317 | case NB_EV_ABORT: | |
318 | case NB_EV_APPLY: | |
319 | /* TODO: implement me. */ | |
320 | break; | |
321 | } | |
322 | ||
323 | return NB_OK; | |
324 | } | |
325 | ||
60ee8be1 | 326 | int zebra_debugs_debug_zapi_send_destroy(struct nb_cb_destroy_args *args) |
ce45ffe7 | 327 | { |
60ee8be1 | 328 | switch (args->event) { |
ce45ffe7 CS |
329 | case NB_EV_VALIDATE: |
330 | case NB_EV_PREPARE: | |
331 | case NB_EV_ABORT: | |
332 | case NB_EV_APPLY: | |
333 | /* TODO: implement me. */ | |
334 | break; | |
335 | } | |
336 | ||
337 | return NB_OK; | |
338 | } | |
339 | ||
340 | /* | |
341 | * XPath: /frr-zebra:zebra/debugs/debug-zapi-recv | |
342 | */ | |
60ee8be1 | 343 | int zebra_debugs_debug_zapi_recv_modify(struct nb_cb_modify_args *args) |
ce45ffe7 | 344 | { |
60ee8be1 | 345 | switch (args->event) { |
ce45ffe7 CS |
346 | case NB_EV_VALIDATE: |
347 | case NB_EV_PREPARE: | |
348 | case NB_EV_ABORT: | |
349 | case NB_EV_APPLY: | |
350 | /* TODO: implement me. */ | |
351 | break; | |
352 | } | |
353 | ||
354 | return NB_OK; | |
355 | } | |
356 | ||
60ee8be1 | 357 | int zebra_debugs_debug_zapi_recv_destroy(struct nb_cb_destroy_args *args) |
ce45ffe7 | 358 | { |
60ee8be1 | 359 | switch (args->event) { |
ce45ffe7 CS |
360 | case NB_EV_VALIDATE: |
361 | case NB_EV_PREPARE: | |
362 | case NB_EV_ABORT: | |
363 | case NB_EV_APPLY: | |
364 | /* TODO: implement me. */ | |
365 | break; | |
366 | } | |
367 | ||
368 | return NB_OK; | |
369 | } | |
370 | ||
371 | /* | |
372 | * XPath: /frr-zebra:zebra/debugs/debug-zapi-detail | |
373 | */ | |
60ee8be1 | 374 | int zebra_debugs_debug_zapi_detail_modify(struct nb_cb_modify_args *args) |
ce45ffe7 | 375 | { |
60ee8be1 | 376 | switch (args->event) { |
ce45ffe7 CS |
377 | case NB_EV_VALIDATE: |
378 | case NB_EV_PREPARE: | |
379 | case NB_EV_ABORT: | |
380 | case NB_EV_APPLY: | |
381 | /* TODO: implement me. */ | |
382 | break; | |
383 | } | |
384 | ||
385 | return NB_OK; | |
386 | } | |
387 | ||
60ee8be1 | 388 | int zebra_debugs_debug_zapi_detail_destroy(struct nb_cb_destroy_args *args) |
ce45ffe7 | 389 | { |
60ee8be1 | 390 | switch (args->event) { |
ce45ffe7 CS |
391 | case NB_EV_VALIDATE: |
392 | case NB_EV_PREPARE: | |
393 | case NB_EV_ABORT: | |
394 | case NB_EV_APPLY: | |
395 | /* TODO: implement me. */ | |
396 | break; | |
397 | } | |
398 | ||
399 | return NB_OK; | |
400 | } | |
401 | ||
402 | /* | |
403 | * XPath: /frr-zebra:zebra/debugs/debug-kernel | |
404 | */ | |
60ee8be1 | 405 | int zebra_debugs_debug_kernel_modify(struct nb_cb_modify_args *args) |
ce45ffe7 | 406 | { |
60ee8be1 | 407 | switch (args->event) { |
ce45ffe7 CS |
408 | case NB_EV_VALIDATE: |
409 | case NB_EV_PREPARE: | |
410 | case NB_EV_ABORT: | |
411 | case NB_EV_APPLY: | |
412 | /* TODO: implement me. */ | |
413 | break; | |
414 | } | |
415 | ||
416 | return NB_OK; | |
417 | } | |
418 | ||
60ee8be1 | 419 | int zebra_debugs_debug_kernel_destroy(struct nb_cb_destroy_args *args) |
ce45ffe7 | 420 | { |
60ee8be1 | 421 | switch (args->event) { |
ce45ffe7 CS |
422 | case NB_EV_VALIDATE: |
423 | case NB_EV_PREPARE: | |
424 | case NB_EV_ABORT: | |
425 | case NB_EV_APPLY: | |
426 | /* TODO: implement me. */ | |
427 | break; | |
428 | } | |
429 | ||
430 | return NB_OK; | |
431 | } | |
432 | ||
433 | /* | |
434 | * XPath: /frr-zebra:zebra/debugs/debug-kernel-msg-send | |
435 | */ | |
60ee8be1 | 436 | int zebra_debugs_debug_kernel_msg_send_modify(struct nb_cb_modify_args *args) |
ce45ffe7 | 437 | { |
60ee8be1 | 438 | switch (args->event) { |
ce45ffe7 CS |
439 | case NB_EV_VALIDATE: |
440 | case NB_EV_PREPARE: | |
441 | case NB_EV_ABORT: | |
442 | case NB_EV_APPLY: | |
443 | /* TODO: implement me. */ | |
444 | break; | |
445 | } | |
446 | ||
447 | return NB_OK; | |
448 | } | |
449 | ||
60ee8be1 | 450 | int zebra_debugs_debug_kernel_msg_send_destroy(struct nb_cb_destroy_args *args) |
ce45ffe7 | 451 | { |
60ee8be1 | 452 | switch (args->event) { |
ce45ffe7 CS |
453 | case NB_EV_VALIDATE: |
454 | case NB_EV_PREPARE: | |
455 | case NB_EV_ABORT: | |
456 | case NB_EV_APPLY: | |
457 | /* TODO: implement me. */ | |
458 | break; | |
459 | } | |
460 | ||
461 | return NB_OK; | |
462 | } | |
463 | ||
464 | /* | |
465 | * XPath: /frr-zebra:zebra/debugs/debug-kernel-msg-recv | |
466 | */ | |
60ee8be1 | 467 | int zebra_debugs_debug_kernel_msg_recv_modify(struct nb_cb_modify_args *args) |
ce45ffe7 | 468 | { |
60ee8be1 | 469 | switch (args->event) { |
ce45ffe7 CS |
470 | case NB_EV_VALIDATE: |
471 | case NB_EV_PREPARE: | |
472 | case NB_EV_ABORT: | |
473 | case NB_EV_APPLY: | |
474 | /* TODO: implement me. */ | |
475 | break; | |
476 | } | |
477 | ||
478 | return NB_OK; | |
479 | } | |
480 | ||
60ee8be1 | 481 | int zebra_debugs_debug_kernel_msg_recv_destroy(struct nb_cb_destroy_args *args) |
ce45ffe7 | 482 | { |
60ee8be1 | 483 | switch (args->event) { |
ce45ffe7 CS |
484 | case NB_EV_VALIDATE: |
485 | case NB_EV_PREPARE: | |
486 | case NB_EV_ABORT: | |
487 | case NB_EV_APPLY: | |
488 | /* TODO: implement me. */ | |
489 | break; | |
490 | } | |
491 | ||
492 | return NB_OK; | |
493 | } | |
494 | ||
495 | /* | |
496 | * XPath: /frr-zebra:zebra/debugs/debug-rib | |
497 | */ | |
60ee8be1 | 498 | int zebra_debugs_debug_rib_modify(struct nb_cb_modify_args *args) |
ce45ffe7 | 499 | { |
60ee8be1 | 500 | switch (args->event) { |
ce45ffe7 CS |
501 | case NB_EV_VALIDATE: |
502 | case NB_EV_PREPARE: | |
503 | case NB_EV_ABORT: | |
504 | case NB_EV_APPLY: | |
505 | /* TODO: implement me. */ | |
506 | break; | |
507 | } | |
508 | ||
509 | return NB_OK; | |
510 | } | |
511 | ||
60ee8be1 | 512 | int zebra_debugs_debug_rib_destroy(struct nb_cb_destroy_args *args) |
ce45ffe7 | 513 | { |
60ee8be1 | 514 | switch (args->event) { |
ce45ffe7 CS |
515 | case NB_EV_VALIDATE: |
516 | case NB_EV_PREPARE: | |
517 | case NB_EV_ABORT: | |
518 | case NB_EV_APPLY: | |
519 | /* TODO: implement me. */ | |
520 | break; | |
521 | } | |
522 | ||
523 | return NB_OK; | |
524 | } | |
525 | ||
526 | /* | |
527 | * XPath: /frr-zebra:zebra/debugs/debug-rib-detail | |
528 | */ | |
60ee8be1 | 529 | int zebra_debugs_debug_rib_detail_modify(struct nb_cb_modify_args *args) |
ce45ffe7 | 530 | { |
60ee8be1 | 531 | switch (args->event) { |
ce45ffe7 CS |
532 | case NB_EV_VALIDATE: |
533 | case NB_EV_PREPARE: | |
534 | case NB_EV_ABORT: | |
535 | case NB_EV_APPLY: | |
536 | /* TODO: implement me. */ | |
537 | break; | |
538 | } | |
539 | ||
540 | return NB_OK; | |
541 | } | |
542 | ||
60ee8be1 | 543 | int zebra_debugs_debug_rib_detail_destroy(struct nb_cb_destroy_args *args) |
ce45ffe7 | 544 | { |
60ee8be1 | 545 | switch (args->event) { |
ce45ffe7 CS |
546 | case NB_EV_VALIDATE: |
547 | case NB_EV_PREPARE: | |
548 | case NB_EV_ABORT: | |
549 | case NB_EV_APPLY: | |
550 | /* TODO: implement me. */ | |
551 | break; | |
552 | } | |
553 | ||
554 | return NB_OK; | |
555 | } | |
556 | ||
557 | /* | |
558 | * XPath: /frr-zebra:zebra/debugs/debug-fpm | |
559 | */ | |
60ee8be1 | 560 | int zebra_debugs_debug_fpm_modify(struct nb_cb_modify_args *args) |
ce45ffe7 | 561 | { |
60ee8be1 | 562 | switch (args->event) { |
ce45ffe7 CS |
563 | case NB_EV_VALIDATE: |
564 | case NB_EV_PREPARE: | |
565 | case NB_EV_ABORT: | |
566 | case NB_EV_APPLY: | |
567 | /* TODO: implement me. */ | |
568 | break; | |
569 | } | |
570 | ||
571 | return NB_OK; | |
572 | } | |
573 | ||
60ee8be1 | 574 | int zebra_debugs_debug_fpm_destroy(struct nb_cb_destroy_args *args) |
ce45ffe7 | 575 | { |
60ee8be1 | 576 | switch (args->event) { |
ce45ffe7 CS |
577 | case NB_EV_VALIDATE: |
578 | case NB_EV_PREPARE: | |
579 | case NB_EV_ABORT: | |
580 | case NB_EV_APPLY: | |
581 | /* TODO: implement me. */ | |
582 | break; | |
583 | } | |
584 | ||
585 | return NB_OK; | |
586 | } | |
587 | ||
588 | /* | |
589 | * XPath: /frr-zebra:zebra/debugs/debug-nht | |
590 | */ | |
60ee8be1 | 591 | int zebra_debugs_debug_nht_modify(struct nb_cb_modify_args *args) |
ce45ffe7 | 592 | { |
60ee8be1 | 593 | switch (args->event) { |
ce45ffe7 CS |
594 | case NB_EV_VALIDATE: |
595 | case NB_EV_PREPARE: | |
596 | case NB_EV_ABORT: | |
597 | case NB_EV_APPLY: | |
598 | /* TODO: implement me. */ | |
599 | break; | |
600 | } | |
601 | ||
602 | return NB_OK; | |
603 | } | |
604 | ||
60ee8be1 | 605 | int zebra_debugs_debug_nht_destroy(struct nb_cb_destroy_args *args) |
ce45ffe7 | 606 | { |
60ee8be1 | 607 | switch (args->event) { |
ce45ffe7 CS |
608 | case NB_EV_VALIDATE: |
609 | case NB_EV_PREPARE: | |
610 | case NB_EV_ABORT: | |
611 | case NB_EV_APPLY: | |
612 | /* TODO: implement me. */ | |
613 | break; | |
614 | } | |
615 | ||
616 | return NB_OK; | |
617 | } | |
618 | ||
619 | /* | |
620 | * XPath: /frr-zebra:zebra/debugs/debug-nht-detail | |
621 | */ | |
60ee8be1 | 622 | int zebra_debugs_debug_nht_detail_modify(struct nb_cb_modify_args *args) |
ce45ffe7 | 623 | { |
60ee8be1 | 624 | switch (args->event) { |
ce45ffe7 CS |
625 | case NB_EV_VALIDATE: |
626 | case NB_EV_PREPARE: | |
627 | case NB_EV_ABORT: | |
628 | case NB_EV_APPLY: | |
629 | /* TODO: implement me. */ | |
630 | break; | |
631 | } | |
632 | ||
633 | return NB_OK; | |
634 | } | |
635 | ||
60ee8be1 | 636 | int zebra_debugs_debug_nht_detail_destroy(struct nb_cb_destroy_args *args) |
ce45ffe7 | 637 | { |
60ee8be1 | 638 | switch (args->event) { |
ce45ffe7 CS |
639 | case NB_EV_VALIDATE: |
640 | case NB_EV_PREPARE: | |
641 | case NB_EV_ABORT: | |
642 | case NB_EV_APPLY: | |
643 | /* TODO: implement me. */ | |
644 | break; | |
645 | } | |
646 | ||
647 | return NB_OK; | |
648 | } | |
649 | ||
650 | /* | |
651 | * XPath: /frr-zebra:zebra/debugs/debug-mpls | |
652 | */ | |
60ee8be1 | 653 | int zebra_debugs_debug_mpls_modify(struct nb_cb_modify_args *args) |
ce45ffe7 | 654 | { |
60ee8be1 | 655 | switch (args->event) { |
ce45ffe7 CS |
656 | case NB_EV_VALIDATE: |
657 | case NB_EV_PREPARE: | |
658 | case NB_EV_ABORT: | |
659 | case NB_EV_APPLY: | |
660 | /* TODO: implement me. */ | |
661 | break; | |
662 | } | |
663 | ||
664 | return NB_OK; | |
665 | } | |
666 | ||
60ee8be1 | 667 | int zebra_debugs_debug_mpls_destroy(struct nb_cb_destroy_args *args) |
ce45ffe7 | 668 | { |
60ee8be1 | 669 | switch (args->event) { |
ce45ffe7 CS |
670 | case NB_EV_VALIDATE: |
671 | case NB_EV_PREPARE: | |
672 | case NB_EV_ABORT: | |
673 | case NB_EV_APPLY: | |
674 | /* TODO: implement me. */ | |
675 | break; | |
676 | } | |
677 | ||
678 | return NB_OK; | |
679 | } | |
680 | ||
681 | /* | |
682 | * XPath: /frr-zebra:zebra/debugs/debug-vxlan | |
683 | */ | |
60ee8be1 | 684 | int zebra_debugs_debug_vxlan_modify(struct nb_cb_modify_args *args) |
ce45ffe7 | 685 | { |
60ee8be1 | 686 | switch (args->event) { |
ce45ffe7 CS |
687 | case NB_EV_VALIDATE: |
688 | case NB_EV_PREPARE: | |
689 | case NB_EV_ABORT: | |
690 | case NB_EV_APPLY: | |
691 | /* TODO: implement me. */ | |
692 | break; | |
693 | } | |
694 | ||
695 | return NB_OK; | |
696 | } | |
697 | ||
60ee8be1 | 698 | int zebra_debugs_debug_vxlan_destroy(struct nb_cb_destroy_args *args) |
ce45ffe7 | 699 | { |
60ee8be1 | 700 | switch (args->event) { |
ce45ffe7 CS |
701 | case NB_EV_VALIDATE: |
702 | case NB_EV_PREPARE: | |
703 | case NB_EV_ABORT: | |
704 | case NB_EV_APPLY: | |
705 | /* TODO: implement me. */ | |
706 | break; | |
707 | } | |
708 | ||
709 | return NB_OK; | |
710 | } | |
711 | ||
712 | /* | |
713 | * XPath: /frr-zebra:zebra/debugs/debug-pw | |
714 | */ | |
60ee8be1 | 715 | int zebra_debugs_debug_pw_modify(struct nb_cb_modify_args *args) |
ce45ffe7 | 716 | { |
60ee8be1 | 717 | switch (args->event) { |
ce45ffe7 CS |
718 | case NB_EV_VALIDATE: |
719 | case NB_EV_PREPARE: | |
720 | case NB_EV_ABORT: | |
721 | case NB_EV_APPLY: | |
722 | /* TODO: implement me. */ | |
723 | break; | |
724 | } | |
725 | ||
726 | return NB_OK; | |
727 | } | |
728 | ||
60ee8be1 | 729 | int zebra_debugs_debug_pw_destroy(struct nb_cb_destroy_args *args) |
ce45ffe7 | 730 | { |
60ee8be1 | 731 | switch (args->event) { |
ce45ffe7 CS |
732 | case NB_EV_VALIDATE: |
733 | case NB_EV_PREPARE: | |
734 | case NB_EV_ABORT: | |
735 | case NB_EV_APPLY: | |
736 | /* TODO: implement me. */ | |
737 | break; | |
738 | } | |
739 | ||
740 | return NB_OK; | |
741 | } | |
742 | ||
743 | /* | |
744 | * XPath: /frr-zebra:zebra/debugs/debug-dplane | |
745 | */ | |
60ee8be1 | 746 | int zebra_debugs_debug_dplane_modify(struct nb_cb_modify_args *args) |
ce45ffe7 | 747 | { |
60ee8be1 | 748 | switch (args->event) { |
ce45ffe7 CS |
749 | case NB_EV_VALIDATE: |
750 | case NB_EV_PREPARE: | |
751 | case NB_EV_ABORT: | |
752 | case NB_EV_APPLY: | |
753 | /* TODO: implement me. */ | |
754 | break; | |
755 | } | |
756 | ||
757 | return NB_OK; | |
758 | } | |
759 | ||
60ee8be1 | 760 | int zebra_debugs_debug_dplane_destroy(struct nb_cb_destroy_args *args) |
ce45ffe7 | 761 | { |
60ee8be1 | 762 | switch (args->event) { |
ce45ffe7 CS |
763 | case NB_EV_VALIDATE: |
764 | case NB_EV_PREPARE: | |
765 | case NB_EV_ABORT: | |
766 | case NB_EV_APPLY: | |
767 | /* TODO: implement me. */ | |
768 | break; | |
769 | } | |
770 | ||
771 | return NB_OK; | |
772 | } | |
773 | ||
774 | /* | |
775 | * XPath: /frr-zebra:zebra/debugs/debug-dplane-detail | |
776 | */ | |
60ee8be1 | 777 | int zebra_debugs_debug_dplane_detail_modify(struct nb_cb_modify_args *args) |
ce45ffe7 | 778 | { |
60ee8be1 | 779 | switch (args->event) { |
ce45ffe7 CS |
780 | case NB_EV_VALIDATE: |
781 | case NB_EV_PREPARE: | |
782 | case NB_EV_ABORT: | |
783 | case NB_EV_APPLY: | |
784 | /* TODO: implement me. */ | |
785 | break; | |
786 | } | |
787 | ||
788 | return NB_OK; | |
789 | } | |
790 | ||
60ee8be1 | 791 | int zebra_debugs_debug_dplane_detail_destroy(struct nb_cb_destroy_args *args) |
ce45ffe7 | 792 | { |
60ee8be1 | 793 | switch (args->event) { |
ce45ffe7 CS |
794 | case NB_EV_VALIDATE: |
795 | case NB_EV_PREPARE: | |
796 | case NB_EV_ABORT: | |
797 | case NB_EV_APPLY: | |
798 | /* TODO: implement me. */ | |
799 | break; | |
800 | } | |
801 | ||
802 | return NB_OK; | |
803 | } | |
804 | ||
805 | /* | |
806 | * XPath: /frr-zebra:zebra/debugs/debug-mlag | |
807 | */ | |
60ee8be1 | 808 | int zebra_debugs_debug_mlag_modify(struct nb_cb_modify_args *args) |
ce45ffe7 | 809 | { |
60ee8be1 | 810 | switch (args->event) { |
ce45ffe7 CS |
811 | case NB_EV_VALIDATE: |
812 | case NB_EV_PREPARE: | |
813 | case NB_EV_ABORT: | |
814 | case NB_EV_APPLY: | |
815 | /* TODO: implement me. */ | |
816 | break; | |
817 | } | |
818 | ||
819 | return NB_OK; | |
820 | } | |
821 | ||
60ee8be1 | 822 | int zebra_debugs_debug_mlag_destroy(struct nb_cb_destroy_args *args) |
ce45ffe7 | 823 | { |
60ee8be1 | 824 | switch (args->event) { |
ce45ffe7 CS |
825 | case NB_EV_VALIDATE: |
826 | case NB_EV_PREPARE: | |
827 | case NB_EV_ABORT: | |
828 | case NB_EV_APPLY: | |
829 | /* TODO: implement me. */ | |
830 | break; | |
831 | } | |
832 | ||
833 | return NB_OK; | |
834 | } | |
835 | ||
836 | /* | |
b00f3e4b | 837 | * XPath: /frr-interface:lib/interface/frr-zebra:zebra/ip-addrs |
ce45ffe7 | 838 | */ |
60ee8be1 | 839 | int lib_interface_zebra_ip_addrs_create(struct nb_cb_create_args *args) |
ce45ffe7 | 840 | { |
09268680 CS |
841 | struct interface *ifp; |
842 | struct prefix prefix; | |
09268680 | 843 | |
09268680 | 844 | // addr_family = yang_dnode_get_enum(dnode, "./address-family"); |
60ee8be1 | 845 | yang_dnode_get_prefix(&prefix, args->dnode, "./ip-prefix"); |
09268680 CS |
846 | apply_mask(&prefix); |
847 | ||
60ee8be1 | 848 | switch (args->event) { |
ce45ffe7 | 849 | case NB_EV_VALIDATE: |
09268680 CS |
850 | if (prefix.family == AF_INET |
851 | && ipv4_martian(&prefix.u.prefix4)) { | |
2dbe669b DA |
852 | snprintfrr(args->errmsg, args->errmsg_len, |
853 | "invalid address %pFX", &prefix); | |
09268680 CS |
854 | return NB_ERR_VALIDATION; |
855 | } else if (prefix.family == AF_INET6 | |
856 | && ipv6_martian(&prefix.u.prefix6)) { | |
2dbe669b DA |
857 | snprintfrr(args->errmsg, args->errmsg_len, |
858 | "invalid address %pFX", &prefix); | |
09268680 CS |
859 | return NB_ERR_VALIDATION; |
860 | } | |
861 | break; | |
ce45ffe7 CS |
862 | case NB_EV_PREPARE: |
863 | case NB_EV_ABORT: | |
09268680 | 864 | break; |
ce45ffe7 | 865 | case NB_EV_APPLY: |
4ba756ed | 866 | ifp = nb_running_get_entry(args->dnode, NULL, true); |
09268680 CS |
867 | if (prefix.family == AF_INET) |
868 | if_ip_address_install(ifp, &prefix, NULL, NULL); | |
869 | else if (prefix.family == AF_INET6) | |
870 | if_ipv6_address_install(ifp, &prefix, NULL); | |
871 | ||
ce45ffe7 CS |
872 | break; |
873 | } | |
874 | ||
875 | return NB_OK; | |
876 | } | |
877 | ||
60ee8be1 | 878 | int lib_interface_zebra_ip_addrs_destroy(struct nb_cb_destroy_args *args) |
ce45ffe7 | 879 | { |
09268680 CS |
880 | struct interface *ifp; |
881 | struct prefix prefix; | |
882 | struct connected *ifc; | |
883 | ||
60ee8be1 | 884 | yang_dnode_get_prefix(&prefix, args->dnode, "./ip-prefix"); |
09268680 CS |
885 | apply_mask(&prefix); |
886 | ||
60ee8be1 | 887 | switch (args->event) { |
ce45ffe7 | 888 | case NB_EV_VALIDATE: |
4ba756ed IR |
889 | ifp = nb_running_get_entry(args->dnode, NULL, false); |
890 | if (!ifp) | |
891 | return NB_OK; | |
892 | ||
09268680 CS |
893 | if (prefix.family == AF_INET) { |
894 | /* Check current interface address. */ | |
895 | ifc = connected_check_ptp(ifp, &prefix, NULL); | |
896 | if (!ifc) { | |
10bdc68f RW |
897 | snprintf(args->errmsg, args->errmsg_len, |
898 | "interface %s Can't find address\n", | |
899 | ifp->name); | |
09268680 CS |
900 | return NB_ERR_VALIDATION; |
901 | } | |
902 | } else if (prefix.family == AF_INET6) { | |
903 | /* Check current interface address. */ | |
904 | ifc = connected_check(ifp, &prefix); | |
905 | if (!ifc) { | |
10bdc68f RW |
906 | snprintf(args->errmsg, args->errmsg_len, |
907 | "interface can't find address %s", | |
908 | ifp->name); | |
09268680 CS |
909 | return NB_ERR_VALIDATION; |
910 | } | |
911 | } else | |
912 | return NB_ERR_VALIDATION; | |
913 | ||
914 | /* This is not configured address. */ | |
915 | if (!CHECK_FLAG(ifc->conf, ZEBRA_IFC_CONFIGURED)) { | |
10bdc68f RW |
916 | snprintf(args->errmsg, args->errmsg_len, |
917 | "interface %s not configured", ifp->name); | |
09268680 CS |
918 | return NB_ERR_VALIDATION; |
919 | } | |
920 | ||
921 | /* This is not real address or interface is not active. */ | |
922 | if (!CHECK_FLAG(ifc->conf, ZEBRA_IFC_QUEUED) | |
923 | || !CHECK_FLAG(ifp->status, ZEBRA_INTERFACE_ACTIVE)) { | |
924 | listnode_delete(ifp->connected, ifc); | |
925 | connected_free(&ifc); | |
926 | return NB_ERR_VALIDATION; | |
927 | } | |
928 | break; | |
ce45ffe7 CS |
929 | case NB_EV_PREPARE: |
930 | case NB_EV_ABORT: | |
09268680 | 931 | break; |
ce45ffe7 | 932 | case NB_EV_APPLY: |
4ba756ed | 933 | ifp = nb_running_get_entry(args->dnode, NULL, true); |
09268680 | 934 | if_ip_address_uinstall(ifp, &prefix); |
ce45ffe7 CS |
935 | break; |
936 | } | |
937 | ||
938 | return NB_OK; | |
939 | } | |
940 | ||
941 | /* | |
b00f3e4b | 942 | * XPath: /frr-interface:lib/interface/frr-zebra:zebra/ip-addrs/label |
ce45ffe7 | 943 | */ |
60ee8be1 | 944 | int lib_interface_zebra_ip_addrs_label_modify(struct nb_cb_modify_args *args) |
ce45ffe7 | 945 | { |
60ee8be1 | 946 | switch (args->event) { |
ce45ffe7 CS |
947 | case NB_EV_VALIDATE: |
948 | case NB_EV_PREPARE: | |
949 | case NB_EV_ABORT: | |
950 | case NB_EV_APPLY: | |
951 | /* TODO: implement me. */ | |
952 | break; | |
953 | } | |
954 | ||
955 | return NB_OK; | |
956 | } | |
957 | ||
60ee8be1 | 958 | int lib_interface_zebra_ip_addrs_label_destroy(struct nb_cb_destroy_args *args) |
ce45ffe7 | 959 | { |
60ee8be1 | 960 | switch (args->event) { |
ce45ffe7 CS |
961 | case NB_EV_VALIDATE: |
962 | case NB_EV_PREPARE: | |
963 | case NB_EV_ABORT: | |
964 | case NB_EV_APPLY: | |
965 | /* TODO: implement me. */ | |
966 | break; | |
967 | } | |
968 | ||
969 | return NB_OK; | |
970 | } | |
971 | ||
972 | /* | |
b00f3e4b | 973 | * XPath: /frr-interface:lib/interface/frr-zebra:zebra/ip-addrs/ip4-peer |
ce45ffe7 | 974 | */ |
60ee8be1 | 975 | int lib_interface_zebra_ip_addrs_ip4_peer_modify(struct nb_cb_modify_args *args) |
ce45ffe7 | 976 | { |
60ee8be1 | 977 | switch (args->event) { |
ce45ffe7 CS |
978 | case NB_EV_VALIDATE: |
979 | case NB_EV_PREPARE: | |
980 | case NB_EV_ABORT: | |
981 | case NB_EV_APPLY: | |
982 | /* TODO: implement me. */ | |
983 | break; | |
984 | } | |
985 | ||
986 | return NB_OK; | |
987 | } | |
988 | ||
60ee8be1 RW |
989 | int lib_interface_zebra_ip_addrs_ip4_peer_destroy( |
990 | struct nb_cb_destroy_args *args) | |
ce45ffe7 | 991 | { |
60ee8be1 | 992 | switch (args->event) { |
ce45ffe7 CS |
993 | case NB_EV_VALIDATE: |
994 | case NB_EV_PREPARE: | |
995 | case NB_EV_ABORT: | |
996 | case NB_EV_APPLY: | |
997 | /* TODO: implement me. */ | |
998 | break; | |
999 | } | |
1000 | ||
1001 | return NB_OK; | |
1002 | } | |
1003 | ||
1004 | /* | |
1005 | * XPath: /frr-interface:lib/interface/frr-zebra:zebra/multicast | |
1006 | */ | |
60ee8be1 | 1007 | int lib_interface_zebra_multicast_modify(struct nb_cb_modify_args *args) |
ce45ffe7 | 1008 | { |
60ee8be1 | 1009 | if (args->event != NB_EV_APPLY) |
09268680 CS |
1010 | return NB_OK; |
1011 | ||
1012 | struct interface *ifp; | |
1013 | ||
60ee8be1 | 1014 | ifp = nb_running_get_entry(args->dnode, NULL, true); |
09268680 CS |
1015 | |
1016 | if_multicast_set(ifp); | |
ce45ffe7 CS |
1017 | |
1018 | return NB_OK; | |
1019 | } | |
1020 | ||
60ee8be1 | 1021 | int lib_interface_zebra_multicast_destroy(struct nb_cb_destroy_args *args) |
ce45ffe7 | 1022 | { |
60ee8be1 | 1023 | if (args->event != NB_EV_APPLY) |
09268680 CS |
1024 | return NB_OK; |
1025 | ||
1026 | struct interface *ifp; | |
1027 | ||
60ee8be1 | 1028 | ifp = nb_running_get_entry(args->dnode, NULL, true); |
09268680 CS |
1029 | |
1030 | if_multicast_unset(ifp); | |
ce45ffe7 CS |
1031 | |
1032 | return NB_OK; | |
1033 | } | |
1034 | ||
1035 | /* | |
1036 | * XPath: /frr-interface:lib/interface/frr-zebra:zebra/link-detect | |
1037 | */ | |
60ee8be1 | 1038 | int lib_interface_zebra_link_detect_modify(struct nb_cb_modify_args *args) |
ce45ffe7 | 1039 | { |
60ee8be1 | 1040 | if (args->event != NB_EV_APPLY) |
09268680 CS |
1041 | return NB_OK; |
1042 | ||
1043 | struct interface *ifp; | |
1044 | bool link_detect; | |
1045 | ||
60ee8be1 RW |
1046 | ifp = nb_running_get_entry(args->dnode, NULL, true); |
1047 | link_detect = yang_dnode_get_bool(args->dnode, "./link-detect"); | |
09268680 CS |
1048 | |
1049 | if_linkdetect(ifp, link_detect); | |
ce45ffe7 CS |
1050 | |
1051 | return NB_OK; | |
1052 | } | |
1053 | ||
60ee8be1 | 1054 | int lib_interface_zebra_link_detect_destroy(struct nb_cb_destroy_args *args) |
ce45ffe7 | 1055 | { |
60ee8be1 | 1056 | if (args->event != NB_EV_APPLY) |
09268680 CS |
1057 | return NB_OK; |
1058 | ||
1059 | struct interface *ifp; | |
1060 | bool link_detect; | |
1061 | ||
60ee8be1 RW |
1062 | ifp = nb_running_get_entry(args->dnode, NULL, true); |
1063 | link_detect = yang_dnode_get_bool(args->dnode, "./link-detect"); | |
09268680 CS |
1064 | |
1065 | if_linkdetect(ifp, link_detect); | |
ce45ffe7 CS |
1066 | |
1067 | return NB_OK; | |
1068 | } | |
1069 | ||
1070 | /* | |
1071 | * XPath: /frr-interface:lib/interface/frr-zebra:zebra/shutdown | |
1072 | */ | |
60ee8be1 | 1073 | int lib_interface_zebra_shutdown_modify(struct nb_cb_modify_args *args) |
ce45ffe7 | 1074 | { |
4ba756ed IR |
1075 | if (args->event != NB_EV_APPLY) |
1076 | return NB_OK; | |
1077 | ||
09268680 CS |
1078 | struct interface *ifp; |
1079 | ||
60ee8be1 | 1080 | ifp = nb_running_get_entry(args->dnode, NULL, true); |
09268680 CS |
1081 | |
1082 | if_shutdown(ifp); | |
ce45ffe7 CS |
1083 | |
1084 | return NB_OK; | |
1085 | } | |
1086 | ||
60ee8be1 | 1087 | int lib_interface_zebra_shutdown_destroy(struct nb_cb_destroy_args *args) |
ce45ffe7 | 1088 | { |
4ba756ed IR |
1089 | if (args->event != NB_EV_APPLY) |
1090 | return NB_OK; | |
1091 | ||
09268680 CS |
1092 | struct interface *ifp; |
1093 | ||
60ee8be1 | 1094 | ifp = nb_running_get_entry(args->dnode, NULL, true); |
09268680 CS |
1095 | |
1096 | if_no_shutdown(ifp); | |
ce45ffe7 CS |
1097 | |
1098 | return NB_OK; | |
1099 | } | |
1100 | ||
1101 | /* | |
1102 | * XPath: /frr-interface:lib/interface/frr-zebra:zebra/bandwidth | |
1103 | */ | |
60ee8be1 | 1104 | int lib_interface_zebra_bandwidth_modify(struct nb_cb_modify_args *args) |
ce45ffe7 | 1105 | { |
60ee8be1 | 1106 | if (args->event != NB_EV_APPLY) |
09268680 CS |
1107 | return NB_OK; |
1108 | ||
1109 | struct interface *ifp; | |
1110 | uint32_t bandwidth; | |
1111 | ||
60ee8be1 RW |
1112 | ifp = nb_running_get_entry(args->dnode, NULL, true); |
1113 | bandwidth = yang_dnode_get_uint32(args->dnode, "./bandwidth"); | |
09268680 CS |
1114 | |
1115 | ifp->bandwidth = bandwidth; | |
1116 | ||
1117 | /* force protocols to recalculate routes due to cost change */ | |
1118 | if (if_is_operative(ifp)) | |
1119 | zebra_interface_up_update(ifp); | |
ce45ffe7 CS |
1120 | |
1121 | return NB_OK; | |
1122 | } | |
1123 | ||
60ee8be1 | 1124 | int lib_interface_zebra_bandwidth_destroy(struct nb_cb_destroy_args *args) |
ce45ffe7 | 1125 | { |
60ee8be1 | 1126 | if (args->event != NB_EV_APPLY) |
09268680 CS |
1127 | return NB_OK; |
1128 | ||
1129 | struct interface *ifp; | |
1130 | ||
60ee8be1 | 1131 | ifp = nb_running_get_entry(args->dnode, NULL, true); |
09268680 CS |
1132 | |
1133 | ifp->bandwidth = 0; | |
1134 | ||
1135 | /* force protocols to recalculate routes due to cost change */ | |
1136 | if (if_is_operative(ifp)) | |
1137 | zebra_interface_up_update(ifp); | |
ce45ffe7 CS |
1138 | |
1139 | return NB_OK; | |
1140 | } | |
1141 | ||
e2bcfa39 CS |
1142 | /* |
1143 | * XPath: /frr-vrf:lib/vrf/frr-zebra:zebra/l3vni-id | |
1144 | */ | |
1145 | int lib_vrf_zebra_l3vni_id_modify(struct nb_cb_modify_args *args) | |
1146 | { | |
1147 | struct vrf *vrf; | |
1148 | struct zebra_vrf *zvrf; | |
1149 | vni_t vni = 0; | |
05843a27 | 1150 | struct zebra_l3vni *zl3vni = NULL; |
e2bcfa39 CS |
1151 | char err[ERR_STR_SZ]; |
1152 | bool pfx_only = false; | |
1153 | const struct lyd_node *pn_dnode; | |
1154 | const char *vrfname; | |
1155 | ||
1156 | switch (args->event) { | |
1157 | case NB_EV_PREPARE: | |
1158 | case NB_EV_ABORT: | |
a446dc58 | 1159 | return NB_OK; |
e2bcfa39 | 1160 | case NB_EV_VALIDATE: |
e2bcfa39 CS |
1161 | vni = yang_dnode_get_uint32(args->dnode, NULL); |
1162 | /* Get vrf info from parent node, reject configuration | |
1163 | * if zebra vrf already mapped to different vni id. | |
1164 | */ | |
1165 | pn_dnode = yang_dnode_get_parent(args->dnode, "vrf"); | |
c331ef16 | 1166 | vrfname = yang_dnode_get_string(pn_dnode, "./name"); |
1167 | zvrf = zebra_vrf_lookup_by_name(vrfname); | |
1168 | if (!zvrf) { | |
1169 | snprintf(args->errmsg, args->errmsg_len, | |
1170 | "zebra vrf info not found for vrf:%s.", | |
1171 | vrfname); | |
1172 | return NB_ERR_VALIDATION; | |
1173 | } | |
1174 | if (zvrf->l3vni && zvrf->l3vni != vni) { | |
1175 | snprintf( | |
1176 | args->errmsg, args->errmsg_len, | |
1177 | "vni %u cannot be configured as vni %u is already configured under the vrf", | |
1178 | vni, zvrf->l3vni); | |
1179 | return NB_ERR_VALIDATION; | |
e2bcfa39 CS |
1180 | } |
1181 | ||
1182 | /* Check if this VNI is already present in the system */ | |
1183 | zl3vni = zl3vni_lookup(vni); | |
1184 | if (zl3vni) { | |
a446dc58 CS |
1185 | snprintf(args->errmsg, args->errmsg_len, |
1186 | "VNI %u is already configured as L3-VNI", vni); | |
e2bcfa39 CS |
1187 | return NB_ERR_VALIDATION; |
1188 | } | |
1189 | ||
1190 | break; | |
1191 | case NB_EV_APPLY: | |
1192 | ||
1193 | vrf = nb_running_get_entry(args->dnode, NULL, true); | |
a446dc58 | 1194 | zvrf = zebra_vrf_lookup_by_name(vrf->name); |
e2bcfa39 CS |
1195 | vni = yang_dnode_get_uint32(args->dnode, NULL); |
1196 | /* Note: This covers lib_vrf_zebra_prefix_only_modify() config | |
1197 | * along with l3vni config | |
1198 | */ | |
1199 | pfx_only = yang_dnode_get_bool(args->dnode, "../prefix-only"); | |
1200 | ||
1201 | if (zebra_vxlan_process_vrf_vni_cmd(zvrf, vni, err, ERR_STR_SZ, | |
1202 | pfx_only ? 1 : 0, 1) | |
1203 | != 0) { | |
1204 | if (IS_ZEBRA_DEBUG_VXLAN) | |
a446dc58 CS |
1205 | snprintf( |
1206 | args->errmsg, args->errmsg_len, | |
e2bcfa39 CS |
1207 | "vrf vni %u mapping failed with error: %s", |
1208 | vni, err); | |
1209 | return NB_ERR; | |
1210 | } | |
1211 | ||
e2bcfa39 CS |
1212 | break; |
1213 | } | |
1214 | ||
1215 | return NB_OK; | |
1216 | } | |
1217 | ||
1218 | int lib_vrf_zebra_l3vni_id_destroy(struct nb_cb_destroy_args *args) | |
1219 | { | |
1220 | struct vrf *vrf; | |
1221 | struct zebra_vrf *zvrf; | |
1222 | vni_t vni = 0; | |
1223 | char err[ERR_STR_SZ]; | |
1224 | uint8_t filter = 0; | |
1225 | ||
1226 | switch (args->event) { | |
1227 | case NB_EV_PREPARE: | |
1228 | case NB_EV_ABORT: | |
1229 | case NB_EV_VALIDATE: | |
a446dc58 | 1230 | return NB_OK; |
e2bcfa39 CS |
1231 | case NB_EV_APPLY: |
1232 | vrf = nb_running_get_entry(args->dnode, NULL, true); | |
a446dc58 | 1233 | zvrf = zebra_vrf_lookup_by_name(vrf->name); |
e2bcfa39 CS |
1234 | vni = yang_dnode_get_uint32(args->dnode, NULL); |
1235 | ||
1236 | if (!zl3vni_lookup(vni)) | |
1237 | return NB_OK; | |
1238 | ||
a446dc58 CS |
1239 | if (zvrf->l3vni != vni) { |
1240 | snprintf(args->errmsg, args->errmsg_len, | |
1241 | "vrf %s has different vni %u mapped", | |
1242 | vrf->name, zvrf->l3vni); | |
e2bcfa39 | 1243 | return NB_ERR; |
a446dc58 | 1244 | } |
e2bcfa39 CS |
1245 | |
1246 | if (is_l3vni_for_prefix_routes_only(zvrf->l3vni)) | |
1247 | filter = 1; | |
1248 | ||
1249 | if (zebra_vxlan_process_vrf_vni_cmd(zvrf, vni, err, ERR_STR_SZ, | |
1250 | filter, 0) | |
1251 | != 0) { | |
1252 | if (IS_ZEBRA_DEBUG_VXLAN) | |
1253 | zlog_debug( | |
1254 | "vrf vni %u unmapping failed with error: %s", | |
1255 | vni, err); | |
1256 | return NB_ERR; | |
1257 | } | |
1258 | ||
e2bcfa39 CS |
1259 | break; |
1260 | } | |
1261 | ||
1262 | return NB_OK; | |
1263 | } | |
1264 | ||
1265 | /* | |
1266 | * XPath: /frr-vrf:lib/vrf/frr-zebra:zebra/prefix-only | |
1267 | */ | |
1268 | int lib_vrf_zebra_prefix_only_modify(struct nb_cb_modify_args *args) | |
1269 | { | |
1270 | switch (args->event) { | |
1271 | case NB_EV_VALIDATE: | |
1272 | case NB_EV_PREPARE: | |
1273 | case NB_EV_ABORT: | |
1274 | case NB_EV_APPLY: | |
1275 | /* TODO: implement me. */ | |
1276 | break; | |
1277 | } | |
1278 | ||
1279 | return NB_OK; | |
1280 | } |