Event records and status semantics
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.