@@ -15,7 +15,8 @@ use unf_cni_state::{ |
15 | 15 | use unf_ebpf_common::locality::{ABI_VERSION, PACKET_DSR_PENDING, PacketInput}; |
16 | 16 | use unf_encryption::EncryptionLocalityContext; |
17 | 17 | use unf_locality::{ |
18 | | - IncarnationGate, LeasedLocalityBank, LocalityObservationWorker, LocalityRuntimeMaps, |
| 18 | + IncarnationGate, KernelLocalityBank, LeasedLocalityBank, LocalityAdmission, |
| 19 | + LocalityApplyComponent, LocalityObservationWorker, LocalityRuntimeMaps, |
19 | 20 | }; |
20 | 21 | use unf_route::NativeRoutePlan; |
21 | 22 |
|
@@ -377,6 +378,17 @@ pub async fn verify( |
377 | 378 | // remain live. Revoking the nonce below cannot be repaired by route state. |
378 | 379 | probe(&mut object, "target-route-restored-v4", v4, &wire4, 7)?; |
379 | 380 | probe(&mut object, "target-route-restored-v6", v6, &wire6, 7)?; |
| 381 | + let admission = verify_admission( |
| 382 | + runtime, |
| 383 | + &mut object, |
| 384 | + &bank, |
| 385 | + journal, |
| 386 | + gate, |
| 387 | + current, |
| 388 | + target_route, |
| 389 | + [v4, v6], |
| 390 | + ) |
| 391 | + .await?; |
380 | 392 | pair( |
381 | 393 | &mut delivery, |
382 | 394 | &mut object, |
@@ -400,10 +412,10 @@ pub async fn verify( |
400 | 412 | false, |
401 | 413 | )?; |
402 | 414 | ensure!( |
403 | | - bank.publish(&mut runtime, journal, gate, current).is_err(), |
| 415 | + admission.publish(&bank, journal, gate, current).is_err(), |
404 | 416 | "stale original journal cut accepted" |
405 | 417 | ); |
406 | | - runtime.withdraw()?; |
| 418 | + admission.withdraw()?; |
407 | 419 | if let Some(delivery) = &delivery { |
408 | 420 | delivery.finish()?; |
409 | 421 | } |
@@ -416,3 +428,65 @@ pub async fn verify( |
416 | 428 | fn runtime_from(object: &Ebpf) -> Result<LocalityRuntimeMaps> { |
417 | 429 | runtime(object) |
418 | 430 | } |
| 431 | + |
| 432 | +#[allow(clippy::too_many_arguments)] // Exact live fixture authorities, never reopened pins. |
| 433 | +async fn verify_admission( |
| 434 | + runtime: LocalityRuntimeMaps, |
| 435 | + object: &mut Ebpf, |
| 436 | + bank: &KernelLocalityBank, |
| 437 | + journal: &AttachmentJournal, |
| 438 | + gate: &IncarnationGate, |
| 439 | + context: &EncryptionLocalityContext, |
| 440 | + route: &NativeRoutePlan, |
| 441 | + inputs: [PacketInput; 2], |
| 442 | +) -> Result<LocalityAdmission> { |
| 443 | + use LocalityApplyComponent::{Identity, Routing}; |
| 444 | + let admission = LocalityAdmission::new(runtime)?; |
| 445 | + let [v4, v6] = inputs; |
| 446 | + let wire4 = packet(v4); |
| 447 | + let wire6 = packet(v6); |
| 448 | + probe(object, "coordinator-startup-withdrawn", v4, &wire4, 2)?; |
| 449 | + let identity = admission.begin(Identity)?; |
| 450 | + let routing = admission.begin(Routing)?; |
| 451 | + identity.complete(context.identity_epoch, context.identity_revision)?; |
| 452 | + ensure!( |
| 453 | + admission.publish(bank, journal, gate, context).is_err(), |
| 454 | + "pending route writer admitted" |
| 455 | + ); |
| 456 | + probe(object, "coordinator-route-pending", v4, &wire4, 2)?; |
| 457 | + // Simulate a real route update interrupted before commit, not merely a |
| 458 | + // fabricated status flag. Drop leaves it failed even after route rollback. |
| 459 | + route.delete().await?; |
| 460 | + drop(routing); |
| 461 | + route.apply().await?; |
| 462 | + ensure!( |
| 463 | + admission.publish(bank, journal, gate, context).is_err(), |
| 464 | + "cancelled route writer admitted" |
| 465 | + ); |
| 466 | + probe(object, "coordinator-route-cancelled", v4, &wire4, 2)?; |
| 467 | + let routing = admission.begin(Routing)?; |
| 468 | + route.readback().await?; |
| 469 | + routing.complete(context.identity_epoch, context.routing_revision)?; |
| 470 | + admission.publish(bank, journal, gate, context)?; |
| 471 | + probe(object, "coordinator-recovered-v4", v4, &wire4, 7)?; |
| 472 | + probe(object, "coordinator-recovered-v6", v6, &wire6, 7)?; |
| 473 | + let identity = admission.begin(Identity)?; |
| 474 | + let routing = admission.begin(Routing)?; |
| 475 | + drop(identity); |
| 476 | + routing.complete(context.identity_epoch, context.routing_revision)?; |
| 477 | + ensure!( |
| 478 | + admission.publish(bank, journal, gate, context).is_err(), |
| 479 | + "route completion masked failed identity writer" |
| 480 | + ); |
| 481 | + probe(object, "coordinator-identity-cancelled", v4, &wire4, 2)?; |
| 482 | + admission |
| 483 | + .begin(Identity)? |
| 484 | + .complete(context.identity_epoch, context.identity_revision)?; |
| 485 | + admission.publish(bank, journal, gate, context)?; |
| 486 | + probe(object, "coordinator-settled-v4", v4, &wire4, 7)?; |
| 487 | + probe(object, "coordinator-settled-v6", v6, &wire6, 7)?; |
| 488 | + println!( |
| 489 | + "kernel-locality-admission: PASS decisions=8 pending-writer-denied=true cancelled-writer-denied=true rollback-not-rearmed=true production-integration=false" |
| 490 | + ); |
| 491 | + Ok(admission) |
| 492 | +} |