pub struct Tracker {
units: BTreeMap<UnitId, Standing>,
unattributed: BTreeMap<(ChangeKind, String), Option<String>>,
virtual_ifaces: BTreeSet<String>,
invocations: BTreeMap<UnitId, Invocation>,
lost_unplaced: bool,
pre_attach: BTreeMap<(ChangeKind, String), Option<String>>,
route_through: BTreeMap<String, String>,
latched: BTreeMap<UnitId, Latch>,
next_latch: BTreeMap<UnitId, Latch>,
}Expand description
Each unit’s current footprint, kept from the kernel’s reports (or the
fake’s script). apply takes one attributed change; lost records an
event the ring buffer dropped; view renders what the files carry.
Fields§
§units: BTreeMap<UnitId, Standing>§unattributed: BTreeMap<(ChangeKind, String), Option<String>>Steering changes that stand, attributed to nobody, with the interface a route goes out of.
virtual_ifaces: BTreeSet<String>Links that something created (a link kind; or created through netlink while watched, which a physical NIC never is). §12d’s steering route is one over “an interface it created”: a default route over the machine’s own NIC is not one, watched or found at attach.
invocations: BTreeMap<UnitId, Invocation>Each unit’s latest invocation seen (not kept across restarts: the cgroups are read again on attach).
lost_unplaced: boolA lost event could not be placed: everything counts as unattributed until the watch restarts (which re-reads the kernel’s state).
pre_attach: BTreeMap<(ChangeKind, String), Option<String>>Steering objects found standing on attach that no footprint claimed: made while nobody watched (§12d, fail closed). Each clears when its object is removed.
route_through: BTreeMap<String, String>Steering routes found standing on attach over an interface a unit claims (object → interface): they protect through that interface.
latched: BTreeMap<UnitId, Latch>Per unit with an invocation: what made its current invocation protecting at any point (crate docs, “The hold’s order”).
next_latch: BTreeMap<UnitId, Latch>Per unit: what made it protecting while it had no live invocation (none known yet, or the current one ended). An ended invocation does nothing more, so this is the next one’s, applied before its cgroup was seen (made between the cgroups drain and the ring drain).
Implementations§
Source§impl Tracker
impl Tracker
pub fn apply(&mut self, c: &Change)
fn apply_change(&mut self, c: &Change)
Sourcepub fn attach(
previous: &Claims,
standing: &[Change],
virtual_ifaces: &BTreeSet<String>,
) -> Tracker
pub fn attach( previous: &Claims, standing: &[Change], virtual_ifaces: &BTreeSet<String>, ) -> Tracker
§12d, on every attach (boot or restart): start from the claims kept
before (.state, or the footprint files’ iface lines when it is
gone), keep each claim whose object still stands in standing (a
snapshot of the kernel’s steering state, as changes), drop the rest,
and record every standing steering object nobody claims as
pre-attach: it was made while nobody watched. A restart therefore
never downgrades a footprint, and a change made in the gap fails
closed until its object is gone.
virtual_ifaces are the standing links that something created (they
have a link kind: dummy, wireguard, tun, …). An unclaimed steering
route counts as pre-attach only over one of those, or over no
interface: a default route over a physical NIC no unit created (the
machine’s own uplink) is not “an interface it created” (§12d).
Sourcepub fn claims_from_files(view: &FootprintView) -> Claims
pub fn claims_from_files(view: &FootprintView) -> Claims
The claims the footprint files carry (each iface line), for an
attach when .state is gone.
pub fn add_endpoint(&mut self, unit: &UnitId, e: Endpoint)
Sourcepub fn set_invocation(&mut self, unit: &UnitId, inv: Invocation) -> bool
pub fn set_invocation(&mut self, unit: &UnitId, inv: Invocation) -> bool
The unit’s latest invocation as its cgroup shows it; whether it
changed. A new invocation (a new id, or a new cgroup whose id is
not read yet) resets the latch; an id read late, or ended, does not.
Sourcepub fn set_virtual(&mut self, live: BTreeSet<String>)
pub fn set_virtual(&mut self, live: BTreeSet<String>)
The virtual links standing now (host::read_virtual_ifaces): read
live each tick, so a tun made by ioctl or a link moved in from
another netns is never taken for a physical NIC. An interface gone
from it no longer counts for what stands, but stays in the latch of
an invocation it made protecting.
Sourcefn relatch(&mut self)
fn relatch(&mut self)
Latch what makes each unit protecting now: into its current invocation’s latch, and while it has no live one, into the next’s.
Sourcepub fn lost(&mut self, unit: Option<&UnitId>)
pub fn lost(&mut self, unit: Option<&UnitId>)
An event was lost. With the unit known, its footprint is marked unattributed; without, the global marker stands.
Sourcepub fn footprint(&self, unit: &UnitId, at: u64) -> Footprint
pub fn footprint(&self, unit: &UnitId, at: u64) -> Footprint
The footprint of unit now, confirmed at at: what stands, and
what its current invocation latched.
Sourcefn standing(
&self,
unit: &UnitId,
) -> (bool, BTreeSet<String>, BTreeSet<Endpoint>)
fn standing( &self, unit: &UnitId, ) -> (bool, BTreeSet<String>, BTreeSet<Endpoint>)
Whether what stands of unit’s changes protects, and the iface
and endpoint lines that go with it.
Sourcefn steering_ifaces(&self) -> BTreeSet<String>
fn steering_ifaces(&self) -> BTreeSet<String>
Interfaces some standing steering route goes out of, whoever made it.
Sourcepub fn view(
&self,
watch: WatchState,
tools: &[UnitId],
now: u64,
) -> FootprintView
pub fn view( &self, watch: WatchState, tools: &[UnitId], now: u64, ) -> FootprintView
What the files carry: a footprint for every network tool in tools
(absent from the tracker: protecting no), confirmed at now.