Skip to main content

Tracker

Struct Tracker 

Source
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: bool

A 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

Source

pub fn apply(&mut self, c: &Change)

Source

fn apply_change(&mut self, c: &Change)

Source

pub fn claims(&self) -> Claims

What .state keeps.

Source

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).

Source

pub fn claims_from_files(view: &FootprintView) -> Claims

The claims the footprint files carry (each iface line), for an attach when .state is gone.

Source

pub fn add_endpoint(&mut self, unit: &UnitId, e: Endpoint)

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

fn steering_ifaces(&self) -> BTreeSet<String>

Interfaces some standing steering route goes out of, whoever made it.

Source

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.

Trait Implementations§

Source§

impl Clone for Tracker

Source§

fn clone(&self) -> Tracker

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Tracker

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Tracker

Source§

fn default() -> Tracker

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.