Skip to content

Commit 30a2a56

Browse files
committed
automatically generate MAC addresses for NICs
1 parent b907e0c commit 30a2a56

11 files changed

Lines changed: 363 additions & 183 deletions

File tree

‎docs/manifest.md‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,10 @@ Odorobo should provision. It contains:
3737
published ports for OCI-mode VMs. The control plane owns the attachment identity
3838
and requested MAC; the provider networking transform resolves the network to
3939
a host interface or tap device. `ports` entries use `<host>:<guest>`, with an
40-
optional `/udp` suffix (`8080:80`, `5353:53/udp`). Publishing requires both a
41-
`rootfs` and a `mac_address`, because the host learns the guest address from
42-
its DHCP lease.
40+
optional `/udp` suffix (`8080:80`, `5353:53/udp`). Publishing requires a
41+
`rootfs`. A NIC without `mac_address` gets a stable MAC derived from the VM and
42+
network IDs (`46:59:52:xx:xx:xx`), which Cloud Hypervisor, the guest config
43+
document and DHCP lease lookups all share.
4344
- `placement`: scheduling hints, including an optional node, required node labels,
4445
and affinity rules. Affinity rules support required or weighted-preferred
4546
VM/agent matching; `inverse` selects anti-affinity, with OR-ed
@@ -82,8 +83,8 @@ non-zero vCPUs and memory, and satisfy these relationships:
8283
their strictness, and `inverse` negates a rule's result. `lt` and `gt` comparisons require exactly one
8384
finite numeric value.
8485
- Every network must have a non-empty, non-whitespace ID.
85-
- Published ports require a `rootfs` and a `mac_address`; a host port may be
86-
published only once per protocol.
86+
- Published ports require a `rootfs`; a host port may be published only once per
87+
protocol.
8788
- Cloud-init must provide non-empty configuration with user-data and meta-data
8889
supplied together.
8990
- A vsock guest CID must be non-zero and its socket must be an absolute path.

‎docs/networking.md‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ Add the network to the manifest. The ID becomes the TAP name suffix and may cont
120120
"networks": [{ "id": "devnet", "mac_address": "46:59:52:67:67:67" }]
121121
```
122122

123-
Omit `mac_address` unless you need a fixed address. Two VMs on the same bridge with the same MAC receive the same lease and conflict.
123+
Without `mac_address` the agent derives one from the VM and network IDs: `46:59:52` followed by three digest bytes. It stays the same across restarts, so the guest keeps its DHCP lease. Set `mac_address` to choose the MAC yourself; two VMs on the same bridge with the same MAC receive the same lease and conflict.
124124

125125
### Guest configuration
126126

@@ -134,19 +134,18 @@ The console then shows `IP-Config: Got DHCP answer from 10.10.100.1`, with the g
134134

135135
### Publishing container ports
136136

137-
OCI-mode VMs can publish guest ports on the host. Add `ports` to a network that already has a `mac_address`; entries use `<host>:<guest>` with an optional `/udp` suffix.
137+
OCI-mode VMs can publish guest ports on the host. Add `ports` to a network; entries use `<host>:<guest>` with an optional `/udp` suffix.
138138

139139
```json
140140
"networks": [
141141
{
142142
"id": "devnet",
143-
"mac_address": "46:59:52:67:67:67",
144143
"ports": ["8080:80", "5353:53/udp"]
145144
}
146145
]
147146
```
148147

149-
Publishing only applies to VMs with a `rootfs`; a plain VM manifest that sets `ports` is rejected, as is a network without a MAC or a host port published twice for the same protocol. The same host port may be used by TCP and UDP independently.
148+
Publishing only applies to VMs with a `rootfs`; a plain VM manifest that sets `ports` is rejected, as is a host port published twice for the same protocol. The same host port may be used by TCP and UDP independently.
150149

151150
After the VM boots, the agent starts a background task that polls the dnsmasq lease file for the VM's MAC, then adds DNAT rules to a `container_dnat` prerouting chain (`priority -100`) in the `ip odorobo` table. Publishing gives up after 15 seconds and logs a warning; the VM keeps running. Rules are tagged `odorobo container <vmid> <mapping>` and are removed when the VM stops, even if its TAP already disappeared. Rules left behind by a killed agent are cleared at startup.
152151

‎docs/node-networking.md‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,15 @@ interfaces and an FRR VRF on every agent.
250250
## Synchronization recovery
251251

252252
The manager retries unacknowledged updates every five seconds. A successful node reply stops that
253-
revision's retries; a restarted network actor gets fresh acknowledgement state. Updates carry the
254-
manager lifetime and operation revision, and the node rejects conflicting or stale work.
253+
revision's retries, even when it arrives after a newer retry attempt has started; a restarted network
254+
actor gets fresh acknowledgement state. Updates carry the manager lifetime and operation revision,
255+
and the node rejects conflicting or stale work. A rejected update changes nothing on the node.
256+
257+
A node follows the last manager lifetime it accepted an update from. Once a new manager (for
258+
example after a manager restart) reaches it, the node refuses every later update from the previous
259+
one, so delayed retries from a dead manager cannot undo the new manager's networks. A second live
260+
manager would see its updates refused with `the manager that sent this update has been replaced`.
261+
The node forgets which managers it has replaced when its agent restarts.
255262

256263
A failed create schedules cleanup of any partial realization. A failed delete restores the retained
257264
network on nodes that already removed it. Cleanup keeps the old network metadata and current VNI

‎odorobo/src/actors/ip_management_actor.rs‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
use kameo::prelude::*;
22
use stable_eyre::{Report, Result};
33

4-
// idk if we ever agreed upon an OUI for fyra, but im reserving `FYR` for this
5-
// -cappy
6-
pub const FYRA_OUI: [u8; 3] = [0x46, 0x59, 0x52];
4+
use crate::manifest::FYRA_OUI;
75

86
/// Calculates a MAC address for a given IP address using the FYRA OUI prefix.
97
///

0 commit comments

Comments
 (0)