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.

GroupCounters
Seatsseen_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)
Evaluationjudged, permissive, parse_errors, fail_closed
Verdictsverdict_pass, verdict_drop, verdict_reject, reject_degraded
Effects yieldedfx_tags, fx_counts, fx_reports, fx_prompts
Ingestionlast_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 storestag_writes, tag_untracked, tag_refused, count_writes, count_key_absent, count_refused, reports_emitted, counter_cells
The Flow layerflow_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)
Refusalsrefusals_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 factsidentity_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 REJECT it 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_untracked or tag_refused;
  • a count it could not land → count_key_absent or count_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 #

  • attributed is the winning rule's path relative to its layer key, UTF-8, NUL-terminated, truncated to PEIOS_NTFE_EV_ATTR_LEN − 1 bytes (95), which may split a multi-byte character. Two reserved values: backstop (nothing yielded) and fail-closed (evaluation failed).
  • effects packs 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_kind is meaningful only when verdict is PEIOS_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_REJUDGED marks a Flow-layer evaluation that replaced a stale sentence (policy change or time edge). A packet answered by a current sentence produces no event at all.
  • layer 2 is Flow; seat 4 is LOCAL_OUT. A Flow event's direction is 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_family is 4, all 16 when 6, undefined when 0. Ports are 0 when the fact was absent — check protocol.
  • flow_state 0 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 Flow events only and zero elsewhere. local_kind / remote_kind are PEIOS_NTFE_EV_LOCAL_*: ABSENT (0) for a non-Flow event, and for remote whenever the other end is not local; remote is filled only on a loopback flow. For a PROGRAM end, *_guid, *_pid and *_comm are the process facts at the socket's stamp, *_user the token's user SID and *_service its 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). *_unresolved says the end could not be attributed and was reported as the kernel's or as absent.

Counter records #

  • name is the stream name (a rule's COUNT(Name)), NUL-terminated; hash is its FNV-1a identity as the kernel keys tables.
  • keyspec says which of src_addr, dst_addr, ifindex are meaningful for this cell's key; the others are zero. family is 4, 6, or 0 when no address fact is keyed.
  • window_secs[i] / window_value[i] for i < n_windows are the table's windows and this cell's current value in each; total is cumulative since the cell was created (or migrated — see The stores); last_secs is CLOCK_REALTIME seconds of the last write, for staleness.
  • The dump lists every table's cells consecutively; group by (name, keyspec) to reconstruct tables.

Flow records #

  • id is 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_port carries the echo id and icmp_type/icmp_code the type and code; dst_port is 0.
  • direction, ifindex and loopback are meaningful only when judged is 1: they were recorded at the Flow layer's first judgment. A flow with judged == 0 has 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 == 0 is empty. sentence_expires_at 0 means never. sentence_rule_hash is FNV-1a-64 (offset 0xcbf29ce484222325, prime 0x100000001b3) of the whole attributing path relative to the layer key, however long — not of the event's truncated attributed. backstop hashes like any other path; fail-closed is never a sentence's, since a failed evaluation is not cached.
  • packets/bytes are conntrack's accounting, original then reply; NTFE turns conntrack accounting on at init (net.netfilter.nf_conntrack_acct).
  • timeout_secs is the entry's remaining lifetime as conntrack sees it; start_secs is CLOCK_REALTIME seconds when conntrack created it.
  • tag_hash/tag_value hold up to PEIOS_NTFE_FLOW_MAX_TAGS (8) present tags by name hash and value; n_tags is 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] is PEIOS_NTFE_EV_LOCAL_* (ABSENT = not resolved; ABSENT with owner_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_guid 16 bytes per slot, owner_comm 16, owner_user 68, owner_service 32 — 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 (connected when it also has a peer and so receives from one address only). addr all zero is the wildcard; ifindex is SO_BINDTODEVICE, 0 for any; reuseport marks a member of a SO_REUSEPORT group, of which each member is listed. v6only says an AF_INET6 socket 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_kind is PROGRAM or KERNEL (a socket nobody stamped reads KERNEL with owner_unresolved set).
  • 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.

Edit this page