GeezerVison is showing github.com — feat(dataplane): bridge policy-first forwarding to sealed locality banks · arencloud/unf@843d810
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: .containerignore +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 8 | 8 | !.artifacts/unf-device-observation | 9 | 9 | !.artifacts/unf-device-lease | 10 | 10 | !.artifacts/unf-locality-bank | | 11 | +!.artifacts/unf-main-locality-test | 11 | 12 | !.artifacts/unf-locality-fixture | 12 | 13 | target/ | 13 | 14 | ebpf/unf-ebpf-tc/target/ | |
Collapse file Copy file name to clipboardExpand all lines: bins/unf-agent/src/main.rs +70-8Lines changed: 70 additions & 8 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -7715,8 +7715,26 @@ fn attach_dataplane_programs<'ebpf>( | 7715 | 7715 | } | 7716 | 7716 |
| 7717 | 7717 | fn load_dataplane_tail_programs(ebpf: &mut Ebpf) -> Result<()> { | 7718 | | - let mut program_fds = Vec::with_capacity(DATAPLANE_TAIL_PROGRAM_NAMES.len()); | 7719 | | - for program_name in DATAPLANE_TAIL_PROGRAM_NAMES { | | 7718 | + load_tail_program_array( | | 7719 | + ebpf, | | 7720 | + DATAPLANE_TAIL_CALL_MAP_NAME, | | 7721 | + &DATAPLANE_TAIL_PROGRAM_NAMES, | | 7722 | + )?; | | 7723 | + load_tail_program_array( | | 7724 | + ebpf, | | 7725 | + "UL_RESUME_V1", | | 7726 | + &[ | | 7727 | + "unf_locality_resume_v4", | | 7728 | + "unf_locality_resume_v6", | | 7729 | + "unf_locality_nat_v4", | | 7730 | + "unf_locality_nat_v6", | | 7731 | + ], | | 7732 | + ) | | 7733 | +} | | 7734 | + | | 7735 | +fn load_tail_program_array(ebpf: &mut Ebpf, map_name: &str, names: &[&str]) -> Result<()> { | | 7736 | + let mut program_fds = Vec::with_capacity(names.len()); | | 7737 | + for program_name in names { | 7720 | 7738 | let program: &mut SchedClassifier = ebpf | 7721 | 7739 | .program_mut(program_name) | 7722 | 7740 | .with_context(|| format!("eBPF object does not contain program {program_name}"))? | @@ -7733,11 +7751,11 @@ fn load_dataplane_tail_programs(ebpf: &mut Ebpf) -> Result<()> { | 7733 | 7751 | .with_context(|| format!("clone {program_name} program descriptor"))?, | 7734 | 7752 | ); | 7735 | 7753 | } | 7736 | | - let mut tail_calls = | 7737 | | - AyaProgramArray::try_from(ebpf.map_mut(DATAPLANE_TAIL_CALL_MAP_NAME).with_context( | 7738 | | - || format!("eBPF object does not contain {DATAPLANE_TAIL_CALL_MAP_NAME}"), | 7739 | | - )?) | 7740 | | - .with_context(|| format!("open {DATAPLANE_TAIL_CALL_MAP_NAME} program array"))?; | | 7754 | + let mut tail_calls = AyaProgramArray::try_from( | | 7755 | + ebpf.map_mut(map_name) | | 7756 | + .with_context(|| format!("eBPF object does not contain {map_name}"))?, | | 7757 | + ) | | 7758 | + .with_context(|| format!("open {map_name} program array"))?; | 7741 | 7759 | for (index, program_fd) in program_fds.iter().enumerate() { | 7742 | 7760 | let index = u32::try_from(index).context("dataplane tail program index exceeds u32")?; | 7743 | 7761 | tail_calls | @@ -23721,8 +23739,18 @@ mod tests { | 23721 | 23739 |
| 23722 | 23740 | #[test] | 23723 | 23741 | #[ignore = "requires root BPF program execution and UNF_EBPF_OBJECT"] | 23724 | | - #[allow(clippy::too_many_lines)] | 23725 | 23742 | fn privileged_encryption_finalizer_is_dual_stack_late_bound_and_fail_closed() { | | 23743 | + verify_encryption_finalizer(false); | | 23744 | + } | | 23745 | + | | 23746 | + #[test] | | 23747 | + #[ignore = "requires root BPF program execution and UNF_EBPF_OBJECT"] | | 23748 | + fn privileged_locality_bridge_missing_bank_keeps_exact_encryption_and_marks() { | | 23749 | + verify_encryption_finalizer(true); | | 23750 | + } | | 23751 | + | | 23752 | + #[allow(clippy::too_many_lines)] | | 23753 | + fn verify_encryption_finalizer(locality_bridge: bool) { | 23726 | 23754 | const POLICY_REVISION: u64 = 12; | 23727 | 23755 | const SERVICE_REVISION: u64 = 13; | 23728 | 23756 | const EGRESS_REVISION: u64 = 14; | @@ -23969,6 +23997,26 @@ mod tests { | 23969 | 23997 | .set(0, encryption_maps::encode_map_config(&config), 0) | 23970 | 23998 | .unwrap(); | 23971 | 23999 |
| | 24000 | + let locality_input = if locality_bridge { | | 24001 | + // Actual main runtime maps, not status flags. No bank is selected: | | 24002 | + // the new bridge must populate its ABI and continue the ordinary | | 24003 | + // Required/Native path without repeating the policy preamble. | | 24004 | + let mut fence = | | 24005 | + AyaArray::<_, [u8; 32]>::try_from(ebpf.take_map("UL_FENCE_V1").unwrap()).unwrap(); | | 24006 | + let mut value = [0; 32]; | | 24007 | + value[..8].copy_from_slice(&7_u64.to_ne_bytes()); | | 24008 | + value[8..16].copy_from_slice(&3_u64.to_ne_bytes()); | | 24009 | + value[16..24].copy_from_slice(&9_u64.to_ne_bytes()); | | 24010 | + value[24..26].copy_from_slice(&unf_ebpf_common::locality::ABI_VERSION.to_ne_bytes()); | | 24011 | + fence.set(0, value, 0).unwrap(); | | 24012 | + Some( | | 24013 | + AyaPerCpuArray::<_, [u8; 80]>::try_from(ebpf.take_map("UL_INPUT_V1").unwrap()) | | 24014 | + .unwrap(), | | 24015 | + ) | | 24016 | + } else { | | 24017 | + None | | 24018 | + }; | | 24019 | + | 23972 | 24020 | let packet_v4 = ipv4_packet(6, source_v4, destination_v4, 40_000, 443); | 23973 | 24021 | let packet_v6 = ipv6_packet(6, source_v6, destination_v6, 40_001, 443); | 23974 | 24022 | let host_mark = 0x00aa_b100; | @@ -23995,10 +24043,24 @@ mod tests { | 23995 | 24043 | run_tc(&mut ebpf, "unf_observe_ingress", &packet_v4).0, | 23996 | 24044 | TC_ACT_PIPE | 23997 | 24045 | ); | | 24046 | + if let Some(input) = &locality_input { | | 24047 | + assert!(input.get(&0, 0).unwrap().iter().any(|row| row[70] == 4 | | 24048 | + && row[24..28] == source_v4.octets() | | 24049 | + && row[40..44] == destination_v4.octets() | | 24050 | + && row[72..74] == 40_000_u16.to_be_bytes() | | 24051 | + && row[74..76] == 443_u16.to_be_bytes())); | | 24052 | + } | 23998 | 24053 | assert_eq!( | 23999 | 24054 | run_tc(&mut ebpf, "unf_observe_ingress", &packet_v6).0, | 24000 | 24055 | TC_ACT_PIPE | 24001 | 24056 | ); | | 24057 | + if let Some(input) = &locality_input { | | 24058 | + assert!(input.get(&0, 0).unwrap().iter().any(|row| row[70] == 6 | | 24059 | + && row[24..40] == source_v6.octets() | | 24060 | + && row[40..56] == destination_v6.octets() | | 24061 | + && row[72..74] == 40_001_u16.to_be_bytes() | | 24062 | + && row[74..76] == 443_u16.to_be_bytes())); | | 24063 | + } | 24002 | 24064 | let native_syn = ipv4_packet(6, native_source_v4, native_destination_v4, 40_003, 8081); | 24003 | 24065 | assert_eq!( | 24004 | 24066 | run_tc(&mut ebpf, "unf_observe_ingress", &native_syn).0, | |
Collapse file Copy file name to clipboard +47Lines changed: 47 additions & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +# ADR 0432: Policy-first locality forward bridge | | 2 | + | | 3 | +Date: 2026-09-21 | | 4 | + | | 5 | +Status: implemented and locally checked; kernel/runtime qualification pending | | 6 | + | | 7 | +The actual main TC finalizer now prepares the fixed-width locality input only | | 8 | +after packet policy, Service frontend handling and explicit egress ownership. | | 9 | +It requires a structurally valid admitted encryption cut, current policy and | | 10 | +Service revisions, matching active identity configuration and the applied | | 11 | +locality fence. A wholly empty/quiescent admitted cut is structurally valid, | | 12 | +but remains **inactive for ordinary transport**; it cannot create an implicit | | 13 | +Native decision. Local delivery still requires the complete sealed bank. | | 14 | + | | 15 | +Original pre-Service-SNAT source ownership and the final selected backend come | | 16 | +from the policy observation. Ports come from the actual post-translation wire | | 17 | +tuple. The bank independently verifies placement, incarnation leases, devices | | 18 | +and actual route/MAC ownership before redirect. A missing bank or bank miss | | 19 | +resumes the existing ordinary encryption selection; it never grants Native. | | 20 | + | | 21 | +Four versioned resume entries are installed in the already owned locality map, | | 22 | +without changing the existing twelve-slot core tail array. Normal resumes start | | 23 | +after the policy/Service/egress preamble. Local DSR uses a separate reversible | | 24 | +NAT continuation, rebuilds input and re-enters the bank for every check again. | | 25 | +Missing NAT continuation or withdrawn selection cannot return a blind PIPE. | | 26 | +Top-level dispatch avoids retaining an extra BPF subprogram stack frame across | | 27 | +tail calls or ordinary transport selection. | | 28 | + | | 29 | +The next isolated `kernel-main-bridge` gate loads the actual main ELF and all | | 30 | +continuations with four exact existing/expanded agent test cases: ordinary | | 31 | +encryption, armed locality fence with missing bank, source egress precedence, | | 32 | +and dual-stack DSR. It checks that exactly one test actually ran per invocation. | | 33 | +It uses anonymous maps and BPF_PROG_TEST_RUN, not live TC attachment or packet | | 34 | +delivery. The diagnostic limit is two CPUs/2 GiB for repeated full-map test | | 35 | +allocation, not a production resource requirement or stabilization result. | | 36 | + | | 37 | +Local verification: 909 workspace tests pass, 27 explicitly ignored (including | | 38 | +the new privileged bridge case); strict all-target Clippy and main BPF release | | 39 | +compilation pass. Shell syntax/formatting checks pass. The new immutable image | | 40 | +must pass cl02 before identical-image Kind. Successful compilation does not | | 41 | +establish verifier acceptance or packet correctness. | | 42 | + | | 43 | +Reverse-Service early-return policy/transport composition remains an explicit | | 44 | +gap, as do actual selected-bank delivery through the main hook, complete | | 45 | +publisher/writer integration, crash-stage cleanup, restart continuity and | | 46 | +L3/L4/L5/Q. Do not roll this partial bridge onto the live fleet or promote the | | 47 | +phase based on this isolated gate. Both production fleets remain `45d85d5`. |
Collapse file Copy file name to clipboardExpand all lines: docs/development/phase9-attested-encryption-fabric-plan.md +3Lines changed: 3 additions & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -71,6 +71,9 @@ and measured stabilization remain pending. | 71 | 71 | ADR 0431 qualifies mixed-MTU observation and actual selection readback with | 72 | 72 | the complete startup/bank/socket diagnostic on cl02 then identical-image Kind. | 73 | 73 | Production state is unchanged; full runtime and L3/L4/L5/Q remain open. | | 74 | +ADR 0432 implements the policy-first forward bridge and dedicated continuation | | 75 | +loading. Actual-main kernel qualification, reverse-Service composition, full | | 76 | +publisher/writer delivery and restart continuity remain pending; no live rollout. | 74 | 77 | ADRs 0381–0382 | 75 | 78 | qualify the isolated joint attachment/route observation on cl02 then Kind; | 76 | 79 | ADR 0383 verifies stale-safe journal cuts locally. ADR 0384 implements the | |
Collapse file Copy file name to clipboardExpand all lines: docs/development/phase9-required-locality-plan.md +4Lines changed: 4 additions & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -162,6 +162,10 @@ qualification remains open, and this is not an S1 resource measurement. | 162 | 162 | ADR 0431 passes the expanded mixed-MTU/selected-program diagnostic on cl02 then | 163 | 163 | identical `5f03031` Kind, preserving journals and reviewing all retained logs. | 164 | 164 | Actual publisher/writer/packet composition and L3/L4/L5/Q remain open. | | 165 | +ADR 0432 adds the actual policy-first forward bridge and four dedicated | | 166 | +continuations, including local DSR NAT revalidation and ordinary missing-bank | | 167 | +fallback. Its real-main verifier/TestRun gate must pass cl02 before Kind. | | 168 | +Reverse-Service composition and complete live delivery remain open; no rollout. | 165 | 169 |
| 166 | 170 | ## Safety and efficiency boundary | 167 | 171 |
| |
Collapse file Copy file name to clipboardExpand all lines: docs/project-status.md +4Lines changed: 4 additions & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -966,6 +966,10 @@ ADR 0431 passes the complete mixed-MTU/selection-readback diagnostic on cl02 | 966 | 966 | then identical-image Kind. Existing journals are unchanged; all current/init | 967 | 967 | and retained logs are reviewed, with warnings retained. Real publisher/writer/ | 968 | 968 | packet composition and L3/L4/L5/Q remain open. | | 969 | +ADR 0432 adds policy-first forward dispatch to the sealed bank, ordinary | | 970 | +encryption fallback and separate DSR NAT/revalidation continuations. Local | | 971 | +checks pass; actual-main cl02-before-Kind kernel checks, reverse-Service | | 972 | +composition and full runtime delivery/recovery remain open. No rollout occurs. | 969 | 973 | ADR 0338 closes the staging guard's init-container failure/restart gap before | 970 | 974 | the matching Kind rollout; no live image changes occur in that metadata slice. | 971 | 975 | Required locality/replica coverage, full lifecycle requalification and S1–S5 | |
Collapse file Copy file name to clipboardExpand all lines: ebpf/unf-ebpf-common/src/lib.rs +68-1Lines changed: 68 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -1136,18 +1136,29 @@ pub const fn encryption_transport_is_usable( | 1136 | 1136 | /// identity-pair decisions; missing authority remains fail closed. | 1137 | 1137 | #[must_use] | 1138 | 1138 | pub const fn encryption_config_is_active(config: &EncryptionMapConfig) -> bool { | | 1139 | + encryption_config_has_admitted_cut(config) && config.decision_count > 0 | | 1140 | +} | | 1141 | + | | 1142 | +/// Structural bounds for an admitted cut, including a wholly empty/quiescent | | 1143 | +/// generation. This is NOT transport authority: ordinary encryption still | | 1144 | +/// requires `encryption_config_is_active` and an exact usable decision. The | | 1145 | +/// local device consumer additionally requires current policy/Service revisions | | 1146 | +/// and independent per-address, per-incarnation kernel proofs. | | 1147 | +#[must_use] | | 1148 | +pub const fn encryption_config_has_admitted_cut(config: &EncryptionMapConfig) -> bool { | 1139 | 1149 | config.schema_version == ENCRYPTION_MAP_ABI_VERSION | 1140 | 1150 | && config.active_bank < ENCRYPTION_BANK_COUNT | 1141 | 1151 | && config.generation != 0 | 1142 | 1152 | && config.policy_revision != 0 | 1143 | 1153 | && config.service_revision != 0 | 1144 | 1154 | && config.egress_revision != 0 | 1145 | 1155 | && config.epoch_count <= 2 | 1146 | | - && config.decision_count > 0 | 1147 | 1156 | && config.decision_count <= ENCRYPTION_DECISION_MAP_CAPACITY | 1148 | 1157 | && config.transport_count <= ENCRYPTION_TRANSPORT_MAP_CAPACITY | 1149 | 1158 | && (config.epoch_count > 0) == (config.transport_count > 0) | 1150 | 1159 | && config.path_count <= ENCRYPTION_PATH_MAP_CAPACITY | | 1160 | + && (config.decision_count > 0 | | 1161 | + || (config.transport_count == 0 && config.epoch_count == 0 && config.path_count == 0)) | 1151 | 1162 | } | 1152 | 1163 |
| 1153 | 1164 | /// Replays the fixed-width identity decision invariants in the TC consumer. | @@ -1988,6 +1999,62 @@ mod tests { | 1988 | 1999 | assert!(!encryption_disposition_is_valid(0)); | 1989 | 2000 | } | 1990 | 2001 |
| | 2002 | + #[test] | | 2003 | + fn empty_admitted_cut_is_not_transport_authority() { | | 2004 | + let config = EncryptionMapConfig { | | 2005 | + generation: 11, | | 2006 | + policy_revision: 12, | | 2007 | + service_revision: 13, | | 2008 | + egress_revision: 14, | | 2009 | + decision_count: 0, | | 2010 | + transport_count: 0, | | 2011 | + schema_version: ENCRYPTION_MAP_ABI_VERSION, | | 2012 | + active_bank: 1, | | 2013 | + epoch_count: 0, | | 2014 | + path_count: 0, | | 2015 | + }; | | 2016 | + assert!(encryption_config_has_admitted_cut(&config)); | | 2017 | + assert!(!encryption_config_is_active(&config)); | | 2018 | + for changed in [ | | 2019 | + EncryptionMapConfig { | | 2020 | + generation: 0, | | 2021 | + ..config | | 2022 | + }, | | 2023 | + EncryptionMapConfig { | | 2024 | + policy_revision: 0, | | 2025 | + ..config | | 2026 | + }, | | 2027 | + EncryptionMapConfig { | | 2028 | + service_revision: 0, | | 2029 | + ..config | | 2030 | + }, | | 2031 | + EncryptionMapConfig { | | 2032 | + egress_revision: 0, | | 2033 | + ..config | | 2034 | + }, | | 2035 | + EncryptionMapConfig { | | 2036 | + schema_version: 0, | | 2037 | + ..config | | 2038 | + }, | | 2039 | + EncryptionMapConfig { | | 2040 | + active_bank: ENCRYPTION_BANK_COUNT, | | 2041 | + ..config | | 2042 | + }, | | 2043 | + EncryptionMapConfig { | | 2044 | + epoch_count: 1, | | 2045 | + transport_count: 1, | | 2046 | + ..config | | 2047 | + }, | | 2048 | + EncryptionMapConfig { | | 2049 | + path_count: 1, | | 2050 | + ..config | | 2051 | + }, | | 2052 | + ] { | | 2053 | + assert!(!encryption_config_has_admitted_cut(&changed)); | | 2054 | + assert!(!encryption_config_is_active(&changed)); | | 2055 | + } | | 2056 | + } | | 2057 | + | 1991 | 2058 | #[test] | 1992 | 2059 | fn encryption_packet_authority_is_exact_revision_bound_and_temporal() { | 1993 | 2060 | let config = EncryptionMapConfig { | |
|