NTFE
Single-page view · as markdown
NTFE
Peios Kernel / Userspace interfaces / Native interfaces / NTFE
Use these articles to understand ntfe in the Peios kernel.
Event records and status semantics
Peios Kernel / Userspace interfaces / Native interfaces / NTFE
One event #
An event is the decision and enough of the snapshot to find the packet
it was about: sequence number, CLOCK_REALTIME nanoseconds, the seat
and layer, the verdict and — when it was a reject — its kind, flags
(BACKSTOP, FAIL_CLOSED, REJECT_DEGRADED, REJUDGED for a Flow
evaluation that replaced a stale sentence, IDENTITY_UNRESOLVED for
one whose endpoint could not be attributed), direction, address family,
protocol, flow state, interface index, ports, ethertype, both addresses,
the stack-view length, the effect counts the evaluation yielded packed
eight bits each (tags, counts, reports, prompts, saturating), and the
attributing rule's path — the winning rule, or backstop, or
fail-closed — in a 96-byte field (PEIOS_NTFE_EV_ATTR_LEN), so a
longer path is cut to 95 bytes, at a byte rather than a character
boundary, and NUL-terminated. A Flow event also carries both
endpoints' identities as the judgment read them (The identity facts): the kind, the
process GUID, pid and comm, the user SID and the service SID — binary
SIDs, so the viewer, not the kernel, turns them into names.
The path is relative to the layer key: no-inbound/ssh, not
Machine\System\Network\Rules\Packet\no-inbound\ssh.
Status #
PEIOS_NTFE_IOC_STATUS fills struct peios_ntfe_status: the ABI version
(check it before trusting the rest — the ABI is experimental and
versioned, currently 5), the generation, whether any layer is enforcing,
the ring's confessed drops, and the engine counters. The counters are
plain 64-bit atomics rather than per-CPU — legibility over throughput
while the engine is young, to be revisited with a compiled evaluator.
| Group | Counters |
|---|---|
| Seats | seen_ingress, seen_egress, seen_local_in, seen_local_out, deferred (ingress traversals left for the IP seat), fallback_judged (ingress traversals the Packet layer judged there) |
| Evaluation | judged, permissive, parse_errors, fail_closed |
| Verdicts | verdict_pass, verdict_drop, verdict_reject, reject_degraded |
| Effects yielded | fx_tags, fx_counts, fx_reports, fx_prompts |
| Ingestion | last_ingest_error, last_ingest_t_ns, reporting_level, changes_noted and changes_walked (Ingestion and generations, in force), contexts (interfaces in the network context table) |
| The stores | tag_writes, tag_untracked, tag_refused, count_writes, count_key_absent, count_refused, reports_emitted, counter_cells |
| The Flow layer | flow_judged (evaluations, sentences written), flow_cached (packets answered by a current sentence), flow_rejudged (stale by generation), flow_expired (stale by time edge), flow_uncached (flows with no extension to hold a sentence, evaluated per packet) |
| Refusals | refusals_emitted (answers built and sent), refusals_bypassed (own refusals waved through a seat), teardowns_emitted (far-end resets for refused established TCP flows) |
| The identity facts | identity_unresolved (endpoints that could not be attributed at resolution: a socket with no KACS state, an inet socket nobody stamped, a loopback sender the inbound seat could not see) |
Two invariants a reader can check: judged equals the number of
evaluations against a live forest at any layer (Flow evaluations
included, so judged − flow_judged is the per-packet count), and
permissive counts layer evaluations that found no forest — at
generation 0, every one.
PEIOS_NTFE_IOC_COUNTERS is the counter dump described in The stores: the
caller supplies a buffer of struct peios_ntfe_counter_rec, the kernel
fills as many as fit and reports both how many it wrote and how many
cells exist, so a short buffer is visible. PEIOS_NTFE_IOC_FLOWS is the
flows dump described in The Flow layer, with the same short-buffer contract over
struct peios_ntfe_flow_rec.
Confessions, collected #
Everything NTFE declines to do is counted somewhere in the status, and the viewer shows every one of them. A reader should never have to infer a refusal from a missing effect:
- a
REJECTit could not send →reject_degraded, and the event's flag; - an evaluation it could not finish →
fail_closed, and an event; - a frame it could not describe →
parse_errors; - a tag it could not write →
tag_untrackedortag_refused; - a count it could not land →
count_key_absentorcount_refused; - a sentence it could not keep →
flow_uncached; - an endpoint it could not attribute →
identity_unresolved, and the event's flag; - a packet it did not judge because a sentence answered →
flow_cached; - a refusal it did not judge because it was its own →
refusals_bypassed; - a generation it could not accept →
last_ingest_error, and the log; - an event it could not keep →
events_dropped.
Event fields #
attributedis the winning rule's path relative to its layer key, UTF-8, NUL-terminated, truncated toPEIOS_NTFE_EV_ATTR_LEN− 1 bytes (95), which may split a multi-byte character. Two reserved values:backstop(nothing yielded) andfail-closed(evaluation failed).effectspacks the effect counts the evaluation yielded —tags | counts << 8 | reports << 16 | prompts << 24, each saturating at 255. What the stores then applied is in the status confessions, not in the event.reject_kindis meaningful only whenverdictisPEIOS_NTFE_EV_VERDICT_REJECT; a degraded reject (flags & PEIOS_NTFE_EV_F_REJECT_DEGRADED) still carries the kind the rule chose.PEIOS_NTFE_EV_F_REJUDGEDmarks aFlow-layer evaluation that replaced a stale sentence (policy change or time edge). A packet answered by a current sentence produces no event at all.layer2 isFlow;seat4 isLOCAL_OUT. AFlowevent'sdirectionis the endpoint judged: the originator's side for a normal flow, each seat's own for a loopback flow's two judgments.- Addresses: the first 4 bytes when
addr_familyis 4, all 16 when 6, undefined when 0. Ports are 0 when the fact was absent — checkprotocol. flow_state0 means the fact was absent (the ingress seat), not that the flow was untracked; untracked is 5.- The identity fields (ABI 4) are set on
Flowevents only and zero elsewhere.local_kind/remote_kindarePEIOS_NTFE_EV_LOCAL_*:ABSENT(0) for a non-Flow event, and forremotewhenever the other end is not local;remoteis filled only on a loopback flow. For aPROGRAMend,*_guid,*_pidand*_commare the process facts at the socket's stamp,*_userthe token's user SID and*_serviceits per-service SID, both binary and self-sized (byte 1 is the sub-authority count; all zero = absent — a user program has no service SID).*_unresolvedsays the end could not be attributed and was reported as the kernel's or as absent.
Counter records #
nameis the stream name (a rule'sCOUNT(Name)), NUL-terminated;hashis its FNV-1a identity as the kernel keys tables.keyspecsays which ofsrc_addr,dst_addr,ifindexare meaningful for this cell's key; the others are zero.familyis 4, 6, or 0 when no address fact is keyed.window_secs[i]/window_value[i]fori < n_windowsare the table's windows and this cell's current value in each;totalis cumulative since the cell was created (or migrated — see The stores);last_secsisCLOCK_REALTIMEseconds of the last write, for staleness.- The dump lists every table's cells consecutively; group by
(name, keyspec)to reconstruct tables.
Flow records #
idis conntrack's own id for the entry (nf_ct_get_id()), stable for the flow's life and the key to use across dumps.src_addr/dst_addr, the ports and the ICMP fields are the original-direction tuple — the originator first. For ICMP,src_portcarries the echo id andicmp_type/icmp_codethe type and code;dst_portis 0.direction,ifindexandloopbackare meaningful only whenjudgedis 1: they were recorded at the Flow layer's first judgment. A flow withjudged == 0has had no Flow judgment recorded: every packet of it that reached the flow dispatch (The Flow layer) found no Flow forest (a permissive generation) or failed closed, or none did — or it has no extension at all, and so nowhere to record one (flow_uncached; its sentences and identities read empty too).- The sentences are parallel arrays indexed by slot (UAPI records hold
scalars only): slot 0 is the flow's sentence; slot 1 is only ever
filled for a loopback flow (its inbound endpoint). A slot with
sentence_generation == 0is empty.sentence_expires_at0 means never.sentence_rule_hashis FNV-1a-64 (offset0xcbf29ce484222325, prime0x100000001b3) of the whole attributing path relative to the layer key, however long — not of the event's truncatedattributed.backstophashes like any other path;fail-closedis never a sentence's, since a failed evaluation is not cached. packets/bytesare conntrack's accounting, original then reply; NTFE turns conntrack accounting on at init (net.netfilter.nf_conntrack_acct).timeout_secsis the entry's remaining lifetime as conntrack sees it;start_secsisCLOCK_REALTIMEseconds when conntrack created it.tag_hash/tag_valuehold up toPEIOS_NTFE_FLOW_MAX_TAGS(8) present tags by name hash and value;n_tagsis the flow's total, so a value above 8 means some are not listed.- The identities (ABI 4) are per sentence slot, recorded at the flow's
first judgment and fixed:
owner_kind[slot]isPEIOS_NTFE_EV_LOCAL_*(ABSENT= not resolved;ABSENTwithowner_unresolved[slot]set = judged but unattributed, such as a loopback sender the outbound seat never recorded); the per-slot arrays are flattened at a fixed stride —owner_guid16 bytes per slot,owner_comm16,owner_user68,owner_service32 — so slot 1's user SID starts at byte 68. Slot 1 is filled only for a loopback flow.
Listener records #
- One record per socket prepared to receive: TCP in
LISTEN, and UDP / UDP-Lite bound to a port (connectedwhen it also has a peer and so receives from one address only).addrall zero is the wildcard;ifindexisSO_BINDTODEVICE, 0 for any;reuseportmarks a member of aSO_REUSEPORTgroup, of which each member is listed.v6onlysays anAF_INET6socket refuses v4-mapped traffic — a v6 socket without it answers on both families. - The owner fields are those of the flow record's slot, for the socket's
current stamp:
owner_kindisPROGRAMorKERNEL(a socket nobody stamped readsKERNELwithowner_unresolvedset). - The walk is the root namespace's tables only, copied out between hash buckets: a best-effort list of a set that changes under it.
Generated device ABI
Peios Kernel / Userspace interfaces / Native interfaces / NTFE
Every name, value, offset and size in this appendix is generated from
include/uapi/pkm/ntfe.h by tools/docs/peios-reference/generators/gen-ntfe-abi.py, with struct
layouts measured by compiling a probe against the real header.
Regenerate it whenever the ABI changes; do not edit it by hand. The
names here are the ones a program actually compiles
against.
What a compiler cannot measure -- the device's read and poll semantics, what each ioctl expects, the error vocabulary, and the bounds that are not in the header -- is in the notes appendix, NTFE ABI Notes, which this generator does not touch.
Ioctl requests #
Request numbers on /dev/peios-ntfe, packed as <linux/ioctl.h>
packs them (direction, argument size, type 'N', number).
| Constant | Value | Definition |
|---|---|---|
PEIOS_NTFE_IOC_STATUS | 0x81704E01 | _IOR(PEIOS_NTFE_IOC_TYPE, PEIOS_NTFE_IOC_STATUS_NR, struct peios_ntfe_status) |
PEIOS_NTFE_IOC_COUNTERS | 0xC0184E02 | _IOWR(PEIOS_NTFE_IOC_TYPE, PEIOS_NTFE_IOC_COUNTERS_NR, struct peios_ntfe_counters_query) |
PEIOS_NTFE_IOC_FLOWS | 0xC0184E03 | _IOWR(PEIOS_NTFE_IOC_TYPE, PEIOS_NTFE_IOC_FLOWS_NR, struct peios_ntfe_flows_query) |
PEIOS_NTFE_IOC_LISTENERS | 0xC0184E04 | _IOWR(PEIOS_NTFE_IOC_TYPE, PEIOS_NTFE_IOC_LISTENERS_NR, struct peios_ntfe_listeners_query) |
Structure layouts #
Offsets and sizes are measured, not declared.
struct peios_ntfe_event #
Total size 456 bytes.
| Offset | Size | Type | Field |
|---|---|---|---|
| 0 | 8 | __u64 | seq |
| 8 | 8 | __u64 | t_ns |
| 16 | 1 | __u8 | seat |
| 17 | 1 | __u8 | layer |
| 18 | 1 | __u8 | verdict |
| 19 | 1 | __u8 | flags |
| 20 | 1 | __u8 | direction |
| 21 | 1 | __u8 | addr_family |
| 22 | 1 | __u8 | protocol |
| 23 | 1 | __u8 | flow_state |
| 24 | 4 | __u32 | ifindex |
| 28 | 2 | __u16 | src_port |
| 30 | 2 | __u16 | dst_port |
| 32 | 2 | __u16 | ether_type |
| 34 | 1 | __u8 | reject_kind |
| 35 | 1 | __u8 | _pad0 |
| 36 | 16 | __u8[16] | src_addr |
| 52 | 16 | __u8[16] | dst_addr |
| 68 | 4 | __u32 | length |
| 72 | 4 | __u32 | effects |
| 76 | 96 | __u8[PEIOS_NTFE_EV_ATTR_LEN] | attributed |
| 172 | 4 | __u32 | _pad1 |
| 176 | 1 | __u8 | local_kind |
| 177 | 1 | __u8 | remote_kind |
| 178 | 1 | __u8 | local_unresolved |
| 179 | 1 | __u8 | remote_unresolved |
| 180 | 4 | __s32 | local_pid |
| 184 | 4 | __s32 | remote_pid |
| 188 | 16 | __u8[PEIOS_NTFE_GUID_LEN] | local_guid |
| 204 | 16 | __u8[PEIOS_NTFE_GUID_LEN] | remote_guid |
| 220 | 16 | __u8[PEIOS_NTFE_COMM_LEN] | local_comm |
| 236 | 16 | __u8[PEIOS_NTFE_COMM_LEN] | remote_comm |
| 252 | 68 | __u8[PEIOS_NTFE_SID_LEN] | local_user |
| 320 | 68 | __u8[PEIOS_NTFE_SID_LEN] | remote_user |
| 388 | 32 | __u8[PEIOS_NTFE_SERVICE_SID_LEN] | local_service |
| 420 | 32 | __u8[PEIOS_NTFE_SERVICE_SID_LEN] | remote_service |
| 452 | 4 | __u32 | _pad2 |
struct peios_ntfe_status #
Total size 368 bytes.
| Offset | Size | Type | Field |
|---|---|---|---|
| 0 | 8 | __u64 | abi |
| 8 | 8 | __u64 | generation |
| 16 | 8 | __u64 | enforcing |
| 24 | 8 | __u64 | events_dropped |
| 32 | 8 | __u64 | seen_ingress |
| 40 | 8 | __u64 | seen_egress |
| 48 | 8 | __u64 | seen_local_in |
| 56 | 8 | __u64 | deferred |
| 64 | 8 | __u64 | fallback_judged |
| 72 | 8 | __u64 | parse_errors |
| 80 | 8 | __u64 | judged |
| 88 | 8 | __u64 | permissive |
| 96 | 8 | __u64 | fail_closed |
| 104 | 8 | __u64 | verdict_pass |
| 112 | 8 | __u64 | verdict_drop |
| 120 | 8 | __u64 | verdict_reject |
| 128 | 8 | __u64 | reject_degraded |
| 136 | 8 | __u64 | fx_tags |
| 144 | 8 | __u64 | fx_counts |
| 152 | 8 | __u64 | fx_reports |
| 160 | 8 | __u64 | fx_prompts |
| 168 | 8 | __u64 | last_ingest_error |
| 176 | 8 | __u64 | last_ingest_t_ns |
| 184 | 8 | __u64 | tag_writes |
| 192 | 8 | __u64 | tag_untracked |
| 200 | 8 | __u64 | tag_refused |
| 208 | 8 | __u64 | count_writes |
| 216 | 8 | __u64 | count_key_absent |
| 224 | 8 | __u64 | count_refused |
| 232 | 8 | __u64 | reports_emitted |
| 240 | 8 | __u64 | counter_cells |
| 248 | 8 | __u64 | reporting_level |
| 256 | 8 | __u64 | seen_local_out |
| 264 | 8 | __u64 | flow_judged |
| 272 | 8 | __u64 | flow_cached |
| 280 | 8 | __u64 | flow_rejudged |
| 288 | 8 | __u64 | flow_expired |
| 296 | 8 | __u64 | flow_uncached |
| 304 | 8 | __u64 | refusals_emitted |
| 312 | 8 | __u64 | refusals_bypassed |
| 320 | 8 | __u64 | teardowns_emitted |
| 328 | 8 | __u64 | identity_unresolved |
| 336 | 8 | __u64 | changes_noted |
| 344 | 8 | __u64 | changes_walked |
| 352 | 8 | __u64 | contexts |
| 360 | 8 | __u64[1] | _reserved |
struct peios_ntfe_counter_rec #
Total size 232 bytes.
| Offset | Size | Type | Field |
|---|---|---|---|
| 0 | 64 | __u8[PEIOS_NTFE_COUNTER_NAME_LEN] | name |
| 64 | 8 | __u64 | hash |
| 72 | 1 | __u8 | keyspec |
| 73 | 1 | __u8 | family |
| 74 | 2 | __u8[2] | _pad0 |
| 76 | 4 | __s32 | ifindex |
| 80 | 16 | __u8[16] | src_addr |
| 96 | 16 | __u8[16] | dst_addr |
| 112 | 8 | __u64 | total |
| 120 | 8 | __u64 | last_secs |
| 128 | 4 | __u32 | n_windows |
| 132 | 4 | __u32 | _pad1 |
| 136 | 32 | __u32[PEIOS_NTFE_COUNTER_MAX_WINDOWS] | window_secs |
| 168 | 64 | __u64[PEIOS_NTFE_COUNTER_MAX_WINDOWS] | window_value |
struct peios_ntfe_counters_query #
Total size 24 bytes.
| Offset | Size | Type | Field |
|---|---|---|---|
| 0 | 8 | __u64 | buf |
| 8 | 4 | __u32 | buf_len |
| 12 | 4 | __u32 | count |
| 16 | 4 | __u32 | total |
| 20 | 4 | __u32 | _pad0 |
struct peios_ntfe_flow_rec #
Total size 568 bytes.
| Offset | Size | Type | Field |
|---|---|---|---|
| 0 | 4 | __u32 | id |
| 4 | 1 | __u8 | family |
| 5 | 1 | __u8 | protocol |
| 6 | 1 | __u8 | direction |
| 7 | 1 | __u8 | loopback |
| 8 | 1 | __u8 | seen_reply |
| 9 | 1 | __u8 | assured |
| 10 | 1 | __u8 | related |
| 11 | 1 | __u8 | judged |
| 12 | 4 | __s32 | ifindex |
| 16 | 4 | __u32 | timeout_secs |
| 20 | 16 | __u8[16] | src_addr |
| 36 | 16 | __u8[16] | dst_addr |
| 52 | 2 | __u16 | src_port |
| 54 | 2 | __u16 | dst_port |
| 56 | 1 | __u8 | icmp_type |
| 57 | 1 | __u8 | icmp_code |
| 58 | 1 | __u8 | n_tags |
| 59 | 5 | __u8[5] | _pad0 |
| 64 | 8 | __u64 | start_secs |
| 72 | 16 | __u64[2] | packets |
| 88 | 16 | __u64[2] | bytes |
| 104 | 16 | __u64[PEIOS_NTFE_FLOW_SENTENCES] | sentence_generation |
| 120 | 16 | __s64[PEIOS_NTFE_FLOW_SENTENCES] | sentence_expires_at |
| 136 | 16 | __u64[PEIOS_NTFE_FLOW_SENTENCES] | sentence_rule_hash |
| 152 | 2 | __u8[PEIOS_NTFE_FLOW_SENTENCES] | sentence_verdict |
| 154 | 2 | __u8[PEIOS_NTFE_FLOW_SENTENCES] | sentence_reject_kind |
| 156 | 4 | __u8[4] | _pad1 |
| 160 | 64 | __u64[PEIOS_NTFE_FLOW_MAX_TAGS] | tag_hash |
| 224 | 64 | __u64[PEIOS_NTFE_FLOW_MAX_TAGS] | tag_value |
| 288 | 2 | __u8[PEIOS_NTFE_FLOW_SENTENCES] | owner_kind |
| 290 | 2 | __u8[PEIOS_NTFE_FLOW_SENTENCES] | owner_unresolved |
| 292 | 4 | __u8[4] | _pad2 |
| 296 | 8 | __s32[PEIOS_NTFE_FLOW_SENTENCES] | owner_pid |
| 304 | 32 | __u8[32] | owner_guid |
| 336 | 32 | __u8[32] | owner_comm |
| 368 | 136 | __u8[136] | owner_user |
| 504 | 64 | __u8[64] | owner_service |
struct peios_ntfe_flows_query #
Total size 24 bytes.
| Offset | Size | Type | Field |
|---|---|---|---|
| 0 | 8 | __u64 | buf |
| 8 | 4 | __u32 | buf_len |
| 12 | 4 | __u32 | count |
| 16 | 4 | __u32 | total |
| 20 | 4 | __u32 | _pad0 |
struct peios_ntfe_listener_rec #
Total size 168 bytes.
| Offset | Size | Type | Field |
|---|---|---|---|
| 0 | 1 | __u8 | family |
| 1 | 1 | __u8 | protocol |
| 2 | 1 | __u8 | reuseport |
| 3 | 1 | __u8 | connected |
| 4 | 1 | __u8 | v6only |
| 5 | 1 | __u8 | owner_kind |
| 6 | 1 | __u8 | owner_unresolved |
| 7 | 1 | __u8 | _pad0 |
| 8 | 2 | __u16 | port |
| 10 | 2 | __u16 | _pad1 |
| 12 | 4 | __s32 | ifindex |
| 16 | 16 | __u8[16] | addr |
| 32 | 4 | __s32 | owner_pid |
| 36 | 16 | __u8[PEIOS_NTFE_GUID_LEN] | owner_guid |
| 52 | 16 | __u8[PEIOS_NTFE_COMM_LEN] | owner_comm |
| 68 | 68 | __u8[PEIOS_NTFE_SID_LEN] | owner_user |
| 136 | 32 | __u8[PEIOS_NTFE_SERVICE_SID_LEN] | owner_service |
struct peios_ntfe_listeners_query #
Total size 24 bytes.
| Offset | Size | Type | Field |
|---|---|---|---|
| 0 | 8 | __u64 | buf |
| 8 | 4 | __u32 | buf_len |
| 12 | 4 | __u32 | count |
| 16 | 4 | __u32 | total |
| 20 | 4 | __u32 | _pad0 |
Constants #
Grouped as the header groups them.
NTFE — the Network Traffic Filtering Engine: the verdict event stream and engine status.
The engine (net/ntfe) judges every traversal at its standing seats and appends one event per evaluation to a bounded ring. /dev/peios-ntfe (mode 0600; any number of openers, one reader of the stream at a time) drains it: read() returns whole events only — never a partial record — and blocks when the ring is empty unless O_NONBLOCK; poll() raises POLLIN when events are waiting. A slow reader loses the OLDEST events, and the loss is confessed in peios_ntfe_status.events_dropped (the honesty rule: drops are counted, never silent).
Events are emitted for real evaluations (a published forest judged the traversal) and for fail-closed drops; permissive traversals (a layer with no forest — all of them at generation 0) emit nothing, because there is no decision to attribute. Status tells that story instead: generation 0 means "not enforcing", loudly.
This ABI is EXPERIMENTAL while NTFE grows: no stability promise until
the design ships (PEI-598). Check abi before trusting the rest.
| Constant | Value |
|---|---|
PEIOS_NTFE_ABI_VERSION | 5 |
Which standing seat judged the traversal.
| Constant | Value |
|---|---|
PEIOS_NTFE_EV_SEAT_INGRESS | 1 |
PEIOS_NTFE_EV_SEAT_EGRESS | 2 |
PEIOS_NTFE_EV_SEAT_LOCAL_IN | 3 |
PEIOS_NTFE_EV_SEAT_LOCAL_OUT | 4 |
| Constant | Value |
|---|---|
PEIOS_NTFE_EV_LAYER_PACKET | 0 |
PEIOS_NTFE_EV_LAYER_RAWPACKET | 1 |
PEIOS_NTFE_EV_LAYER_FLOW | 2 |
The verdict, in strictness order.
| Constant | Value |
|---|---|
PEIOS_NTFE_EV_VERDICT_PASS | 0 |
PEIOS_NTFE_EV_VERDICT_REJECT | 1 |
PEIOS_NTFE_EV_VERDICT_DROP | 2 |
The story a REJECT told (meaningful iff verdict == REJECT).
| Constant | Value | Notes |
|---|---|---|
PEIOS_NTFE_EV_REJECT_REFUSED | 0 | RST / port-unreachable |
PEIOS_NTFE_EV_REJECT_PROHIBITED | 1 | admin-prohibited |
| Constant | Value |
|---|---|
PEIOS_NTFE_EV_DIR_IN | 0 |
PEIOS_NTFE_EV_DIR_OUT | 1 |
Flow state as the snapshot carried it (0 = the fact was absent).
| Constant | Value |
|---|---|
PEIOS_NTFE_EV_FLOW_ABSENT | 0 |
PEIOS_NTFE_EV_FLOW_NEW | 1 |
PEIOS_NTFE_EV_FLOW_ESTABLISHED | 2 |
PEIOS_NTFE_EV_FLOW_RELATED | 3 |
PEIOS_NTFE_EV_FLOW_INVALID | 4 |
PEIOS_NTFE_EV_FLOW_UNTRACKED | 5 |
| Constant | Value | Notes |
|---|---|---|
PEIOS_NTFE_EV_F_BACKSTOP | 0x01 | nothing yielded; DROP |
PEIOS_NTFE_EV_F_FAIL_CLOSED | 0x02 | evaluation failed; DROP |
PEIOS_NTFE_EV_F_REJECT_DEGRADED | 0x04 | REJECT emitted as DROP |
PEIOS_NTFE_EV_F_REJUDGED | 0x08 | Flow: a stale sentence re-judged |
PEIOS_NTFE_EV_F_IDENTITY_UNRESOLVED | 0x10 | Flow: an endpoint could not be attributed |
What stood at an endpoint: the Flow layer's Local / Remote facts (ABI 4).
| Constant | Value | Notes |
|---|---|---|
PEIOS_NTFE_EV_LOCAL_ABSENT | 0 | not a Flow event / not local |
PEIOS_NTFE_EV_LOCAL_PROGRAM | 1 | a process's socket |
PEIOS_NTFE_EV_LOCAL_KERNEL | 2 | the stack itself |
PEIOS_NTFE_EV_LOCAL_SHARED | 3 | inbound multicast / broadcast |
PEIOS_NTFE_EV_LOCAL_NONE | 4 | nothing receives it |
PEIOS_NTFE_EV_ATTR_LEN | 96 |
A SID's binary form: revision, sub-authority count, a 48-bit authority, up to 15 sub-authorities. Self-sized by its count byte; all zero = absent.
| Constant | Value |
|---|---|
PEIOS_NTFE_SID_LEN | 68 |
A per-service SID (S-1-5-80 + five sub-authorities) is exactly this.
| Constant | Value |
|---|---|
PEIOS_NTFE_SERVICE_SID_LEN | 32 |
PEIOS_NTFE_COMM_LEN | 16 |
PEIOS_NTFE_GUID_LEN | 16 |
One counter cell, as the counters dump reports it: the stream and key- spec of its table, the key it holds (only the facts the key-spec names are meaningful; the rest are zero), the cumulative total, and the value of every window the table answers.
| Constant | Value |
|---|---|
PEIOS_NTFE_COUNTER_NAME_LEN | 64 |
PEIOS_NTFE_COUNTER_MAX_WINDOWS | 8 |
| Constant | Value |
|---|---|
PEIOS_NTFE_KEY_SRC_ADDR | 0x01 |
PEIOS_NTFE_KEY_DST_ADDR | 0x02 |
PEIOS_NTFE_KEY_INTERFACE | 0x04 |
One live flow, as the flows dump reports it (ABI 3): conntrack's view of the flow (original-direction tuple, state, remaining lifetime, accounting), NTFE's extension (start time, the interface and direction at first judgment, the sentences, the tags). Tags are reported by hash; the policy names them.
| Constant | Value |
|---|---|
PEIOS_NTFE_FLOW_MAX_TAGS | 8 |
PEIOS_NTFE_FLOW_SENTENCES | 2 |
The listeners dump: fills buf with as many records as fit; count is
how many were written, total how many sockets the walk saw.
| Constant | Value |
|---|---|
PEIOS_NTFE_IOC_TYPE | 0x0000004E |
PEIOS_NTFE_IOC_STATUS_NR | 0x00000001 |
PEIOS_NTFE_IOC_COUNTERS_NR | 0x00000002 |
PEIOS_NTFE_IOC_FLOWS_NR | 0x00000003 |
PEIOS_NTFE_IOC_LISTENERS_NR | 0x00000004 |
Device operations and errors
Peios Kernel / Userspace interfaces / Native interfaces / NTFE
NTFE ABI Reference is generated from include/uapi/pkm/ntfe.h and holds only what a
compiler can measure. This appendix holds the rest.
Stability #
The ABI is experimental while NTFE grows (PEI-598): no stability
promise until the design ships. peios_ntfe_status.abi carries
PEIOS_NTFE_ABI_VERSION; a consumer checks it before trusting any other
field or record layout. Version 2 (the machinery slice) added the
event's reject_kind, the store confessions and counter_cells and
reporting_level in the status, and the counters ioctl. Version 3 (the
Flow layer) added the LOCAL_OUT seat and Flow layer ids, the
REJUDGED event flag, the Flow and refusal counters in the status, and
the flows ioctl. Version 4 (the identity facts) added the endpoints'
identities to the event and the flow record, the IDENTITY_UNRESOLVED
event flag and the identity_unresolved counter (in a reserved slot,
so the status kept its size). Version 5 renamed the device and every
symbol from pnp to ntfe, let more than one file hold the device open,
and added changes_noted, changes_walked and contexts to the status:
the first took one of the two reserved words version 4 left, the other
two are new, so the status grew by two words and keeps one reserved. pnpd and the kernel ship together on the
experimental edition, so the check is a guard, not a negotiation.
/dev/peios-ntfe #
A misc device, created mode 0600 and owned by uid 0. Those Unix fields
do not grant native access: KACS checks an open() using the opener's
token and the node's security descriptor
(File Descriptor Storage). On devtmpfs that descriptor is inherited from the seeded
root's, which grants GENERIC_ALL to SYSTEM alone, so the device is
SYSTEM's unless trusted userspace sets another.
| Operation | Semantics | Errors |
|---|---|---|
open() | Any number of openers. | — |
read(buf, len) | Returns whole struct peios_ntfe_event records only — never a partial one — up to 64 per call, oldest first, consuming them. Blocks on an empty ring unless O_NONBLOCK. | EINVAL — len smaller than one record; EBUSY — another open file is the stream's reader; EAGAIN — empty and non-blocking; EINTR; ENOMEM; EFAULT — the records it took are lost (below) |
poll() | POLLIN | POLLRDNORM when at least one event waits. | — |
ioctl(PEIOS_NTFE_IOC_STATUS, struct peios_ntfe_status *) | Fills the status snapshot. Cumulative counters since boot. | EFAULT |
ioctl(PEIOS_NTFE_IOC_COUNTERS, struct peios_ntfe_counters_query *) | buf/buf_len describe a user buffer of struct peios_ntfe_counter_rec; on return count is how many were written and total how many cells exist. A short buffer is not an error — the two numbers disagree. Best-effort snapshot: cells may change between records. | EFAULT; ENOMEM |
ioctl(PEIOS_NTFE_IOC_FLOWS, struct peios_ntfe_flows_query *) | Same contract over struct peios_ntfe_flow_rec: count written, total live flows the walk saw. Records are copied out between hash buckets, so the dump is a best-effort picture of a table that changes under it. | EFAULT; ENOMEM |
ioctl(PEIOS_NTFE_IOC_LISTENERS, struct peios_ntfe_listeners_query *) | Same contract over struct peios_ntfe_listener_rec: every TCP socket in the listening state and every bound UDP / UDP-Lite socket of the root network namespace, with the identity KACS stamped on it (The identity facts). total is how many the walk saw. A hash bucket holding more sockets than one copy-out batch is walked again from where the batch filled, so with room for every record count equals total. | EFAULT; ENOMEM |
| other ioctls | — | ENOTTY |
Sequence numbers are monotonic per boot. A gap between consecutive
records read is the number of events the ring overwrote while the
reader was away, plus any a faulting read() consumed; events_dropped in the status is the running
total of the overwrites. A read() that fails with EFAULT has
already taken its records off the ring: they are lost, and counted
nowhere but in that gap.