From 1f6627a829353c5ee85f8b4692635f5504498157 Mon Sep 17 00:00:00 2001 From: Molly Miller Date: Wed, 27 Nov 2024 11:26:59 +0100 Subject: [PATCH] router: fix radvd config to use correct interface name PL-133201 --- ...-133201-radvd-fix-interface-names_scriv.md | 21 +++++++++++++ nixos/roles/router/radvd.nix | 31 ++++++++++--------- 2 files changed, 37 insertions(+), 15 deletions(-) create mode 100644 changelog.d/20241127_112609_PL-133201-radvd-fix-interface-names_scriv.md diff --git a/changelog.d/20241127_112609_PL-133201-radvd-fix-interface-names_scriv.md b/changelog.d/20241127_112609_PL-133201-radvd-fix-interface-names_scriv.md new file mode 100644 index 000000000..1a22e1761 --- /dev/null +++ b/changelog.d/20241127_112609_PL-133201-radvd-fix-interface-names_scriv.md @@ -0,0 +1,21 @@ + + +### Impact + + + +### NixOS XX.XX platform + +- router: fix radvd config generation to use the correct derived + interface name. (PL-133201) diff --git a/nixos/roles/router/radvd.nix b/nixos/roles/router/radvd.nix index 7b8628790..81527a67c 100644 --- a/nixos/roles/router/radvd.nix +++ b/nixos/roles/router/radvd.nix @@ -6,6 +6,7 @@ let role = config.flyingcircus.roles.router; inherit (config) fclib; + inherit (config.flyingcircus) location static; blockIndent = width: text: let # Create a string of `width` number of spaces. @@ -15,15 +16,15 @@ let fclib.unlines ([(head lines)] ++ (fclib.indentWith spaces (tail lines))); - vlans = - lib.filterAttrs - (vlan: networkAttrs: networkAttrs != []) - (lib.mapAttrs - (vlan: interface: - if lib.elem vlan ["lo" "ipmi" "tr" "sto" "stb"] - then [] - else (filter (na: na.addresses != []) interface.v6.networkAttrs)) - fclib.network); + ifaces = listToAttrs + (filter (iface: iface.value.networkAttrs != []) + (map (vlan: lib.nameValuePair vlan ( + let iface = fclib.network."${vlan}"; + in { + inherit (iface) interface; + networkAttrs = filter (attr: attr.addresses != []) iface.v6.networkAttrs; + } + )) static.floatingGatewayNetworks."${location}")); mkPrefixBlock = { network, prefixLength, ... }: '' prefix ${network}/${toString prefixLength} { @@ -32,24 +33,24 @@ let }; ''; - mkInterfaceBlock = vlan: networkAttrs: + mkInterfaceBlock = vlan: iface: let - interfaceName = if vlan == "ws" then "br${vlan}" else "eth${vlan}"; - prefixConfigurations = lib.concatMapStringsSep "\n\n" mkPrefixBlock networkAttrs; + prefixConfigurations = lib.concatMapStringsSep "\n\n" mkPrefixBlock iface.networkAttrs; in '' - # ${vlan} VLAN - interface ${interfaceName} { + # ${vlan} network + interface ${iface.interface} { AdvSendAdvert on; AdvOtherConfigFlag on; ${blockIndent 2 prefixConfigurations} }; ''; + in { config = lib.mkIf (role.enable && role.isPrimary) { services.radvd = { enable = true; - config = lib.concatStringsSep "\n\n" (lib.mapAttrsToList mkInterfaceBlock vlans); + config = lib.concatStringsSep "\n\n" (lib.mapAttrsToList mkInterfaceBlock ifaces); }; }; }