Commit 270771d
committed
northbound: enforce valid YANG CRUD callbacks at compile time
Not every YANG node structurally supports every CRUD operation (e.g. a
leaf with a plain default and no when/case can't be deleted, list keys
can't be modified or deleted). This was only checked at daemon startup
(validate_callback), so an invalid registration like .delete_apply()
on such a node compiled fine and only surfaced as a runtime crash.
Make YangPath and CallbacksBuilder a typestate: yang_codegen now emits
a zero-sized Caps marker per node and implements SupportsCreate/
SupportsModify/SupportsDelete/SupportsLookup on it based on the same
CallbackOp::is_valid rules enforced at runtime today. CallbacksBuilder's
create_*/modify_*/delete_*/lookup methods are now gated on the matching
trait, so an invalid registration fails to compile instead of panicking
at startup.
Drop validate_callback, now fully superseded. validate_callbacks
(checks for missing, not invalid, callbacks) is unaffected. Basically
making sure invalid calls are caught at compile time not at runtime.
Concern raised when invalid callbacks were made in a boolean Yang Path:
PR: holo-routing#133
Comment: holo-routing#133 (comment)
Signed-off-by: Paul Wekesa <paul1tw1@gmail.com>1 parent 047398b commit 270771d
4 files changed
Lines changed: 145 additions & 54 deletions
File tree
- holo-daemon/src/northbound
- holo-northbound/src
- yang_codegen
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
801 | 801 | | |
802 | 802 | | |
803 | 803 | | |
804 | | - | |
| 804 | + | |
805 | 805 | | |
806 | 806 | | |
807 | 807 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | | - | |
71 | | - | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
72 | 84 | | |
73 | 85 | | |
74 | 86 | | |
| |||
91 | 103 | | |
92 | 104 | | |
93 | 105 | | |
94 | | - | |
| 106 | + | |
95 | 107 | | |
96 | 108 | | |
97 | 109 | | |
| |||
298 | 310 | | |
299 | 311 | | |
300 | 312 | | |
301 | | - | |
| 313 | + | |
302 | 314 | | |
303 | 315 | | |
304 | 316 | | |
305 | | - | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
306 | 322 | | |
307 | | - | |
308 | | - | |
| 323 | + | |
| 324 | + | |
309 | 325 | | |
310 | 326 | | |
311 | 327 | | |
312 | | - | |
313 | | - | |
314 | | - | |
315 | | - | |
316 | | - | |
317 | | - | |
318 | 328 | | |
319 | 329 | | |
320 | 330 | | |
| |||
352 | 362 | | |
353 | 363 | | |
354 | 364 | | |
355 | | - | |
356 | | - | |
357 | | - | |
358 | | - | |
359 | | - | |
| 365 | + | |
| 366 | + | |
360 | 367 | | |
| 368 | + | |
361 | 369 | | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
362 | 399 | | |
363 | 400 | | |
364 | 401 | | |
| |||
373 | 410 | | |
374 | 411 | | |
375 | 412 | | |
| 413 | + | |
376 | 414 | | |
377 | | - | |
378 | | - | |
379 | | - | |
380 | | - | |
381 | | - | |
382 | | - | |
383 | | - | |
384 | | - | |
385 | | - | |
386 | | - | |
387 | | - | |
388 | | - | |
389 | | - | |
390 | | - | |
391 | | - | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
392 | 420 | | |
393 | 421 | | |
394 | 422 | | |
| |||
403 | 431 | | |
404 | 432 | | |
405 | 433 | | |
| 434 | + | |
406 | 435 | | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
407 | 441 | | |
408 | | - | |
409 | | - | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
410 | 454 | | |
411 | 455 | | |
412 | 456 | | |
413 | | - | |
| 457 | + | |
414 | 458 | | |
415 | 459 | | |
| 460 | + | |
416 | 461 | | |
417 | | - | |
418 | | - | |
419 | | - | |
420 | | - | |
421 | | - | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
422 | 468 | | |
423 | 469 | | |
424 | 470 | | |
425 | 471 | | |
426 | 472 | | |
427 | 473 | | |
428 | | - | |
| 474 | + | |
429 | 475 | | |
430 | 476 | | |
431 | 477 | | |
| |||
446 | 492 | | |
447 | 493 | | |
448 | 494 | | |
449 | | - | |
450 | | - | |
| 495 | + | |
| 496 | + | |
451 | 497 | | |
452 | 498 | | |
453 | 499 | | |
454 | 500 | | |
455 | 501 | | |
456 | | - | |
| 502 | + | |
457 | 503 | | |
458 | 504 | | |
459 | 505 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | | - | |
69 | | - | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
70 | 77 | | |
71 | 78 | | |
72 | 79 | | |
| |||
96 | 103 | | |
97 | 104 | | |
98 | 105 | | |
99 | | - | |
100 | | - | |
101 | | - | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
102 | 109 | | |
103 | 110 | | |
104 | 111 | | |
105 | | - | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
106 | 130 | | |
107 | 131 | | |
108 | 132 | | |
109 | 133 | | |
110 | 134 | | |
111 | | - | |
| 135 | + | |
112 | 136 | | |
113 | 137 | | |
114 | 138 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
231 | 231 | | |
232 | 232 | | |
233 | 233 | | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
234 | 255 | | |
235 | 256 | | |
236 | 257 | | |
237 | 258 | | |
238 | | - | |
| 259 | + | |
239 | 260 | | |
240 | 261 | | |
241 | 262 | | |
| |||
0 commit comments