From b8f31e23f860316a0bf8e537773a29eeab4ef858 Mon Sep 17 00:00:00 2001 From: Jack O'Sullivan Date: Mon, 3 Aug 2026 21:33:34 +0100 Subject: [PATCH] nixos/home: Prefer dave for stream RSTP Set explicit port costs so `stream` prefers `dave` over `jim`. Trigger `mstpd` when the bridge is configured, before it is routable. --- docs/sites/home/stream.md | 5 +++-- nixos/boxes/home/routing-common/mstpd.nix | 2 +- nixos/boxes/home/stream.nix | 7 +++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/sites/home/stream.md b/docs/sites/home/stream.md index 3963a53..c380cc5 100644 --- a/docs/sites/home/stream.md +++ b/docs/sites/home/stream.md @@ -76,8 +76,9 @@ box sets: ## Switching (RSTP) `stream` is dual-homed to both switches: `lan-jim` (igc) and `lan-dave` (mlx4_en), both MTU 9000, -are enslaved to the `lan` bridge with `STP=true`. [`routing-common/mstpd.nix`](../../../nixos/boxes/home/routing-common/mstpd.nix) -runs a patched `mstpd` and forces RSTP on `lan` once it's routable, so exactly one uplink carries +are enslaved to the `lan` bridge with `STP=true`. The explicit bridge-port costs prefer +`lan-dave` at 10 over `lan-jim` at 100. [`routing-common/mstpd.nix`](../../../nixos/boxes/home/routing-common/mstpd.nix) +runs a patched `mstpd` and forces RSTP on `lan` once it is configured, so exactly one uplink carries traffic at a time. (The remaining NICs are renamed `et2`/`et5` and left unconfigured.) ## Deployment diff --git a/nixos/boxes/home/routing-common/mstpd.nix b/nixos/boxes/home/routing-common/mstpd.nix index b8a4124..8c545f8 100644 --- a/nixos/boxes/home/routing-common/mstpd.nix +++ b/nixos/boxes/home/routing-common/mstpd.nix @@ -24,7 +24,7 @@ in services = { networkd-dispatcher.rules = { configure-mstpd = { - onState = [ "routable" ]; + onState = [ "configured" ]; script = '' #!${pkgs.runtimeShell} if [ "$IFACE" = "lan" ]; then diff --git a/nixos/boxes/home/stream.nix b/nixos/boxes/home/stream.nix index 912ca45..51ac0c6 100644 --- a/nixos/boxes/home/stream.nix +++ b/nixos/boxes/home/stream.nix @@ -115,10 +115,7 @@ Name = "lan"; Kind = "bridge"; }; - extraConfig = '' - [Bridge] - STP=true - ''; + bridgeConfig.STP = true; }; }; links = { @@ -175,10 +172,12 @@ "50-lan-jim" = { matchConfig.Name = "lan-jim"; networkConfig.Bridge = "lan"; + bridgeConfig.Cost = 100; }; "50-lan-dave" = { matchConfig.Name = "lan-dave"; networkConfig.Bridge = "lan"; + bridgeConfig.Cost = 10; }; "50-wan-ifb" = {