1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//! Route management via PF_ROUTE routing socket.
//!
//! Adds or removes a host route for the container subnet through a given
//! bridge interface. This is the only way the daemon modifies the host
//! routing table — all intelligence lives in the daemon's route_reconciler.
use ;
use Ipv4Net;
/// Adds a route for `subnet` via `iface`.
///
/// Uses the PF_ROUTE routing socket with RTM_ADD. If the route already
/// exists, atomically replaces it via RTM_CHANGE (fixes the "File exists"
/// bug where a stale route pointing to a different gateway was kept).
///
/// Idempotent: re-adding the same route succeeds.
/// Removes the route for `subnet`.
///
/// Uses the PF_ROUTE routing socket with RTM_DELETE.
/// Idempotent: returns Ok if the route is already absent.
/// Converts a helper `Subnet` to an `arcbox_route::Ipv4Net`.
///
/// `Subnet` already guarantees valid CIDR + no host bits + private range,
/// so this conversion is infallible in practice.