Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[21.05] Fix radvd config to use the correct interface name #1182

Merged
merged 1 commit into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!--

A new changelog entry.

Delete placeholder items that do not apply. Empty sections will be removed
automatically during release.

Leave the XX.XX as is: this is a placeholder and will be automatically filled
correctly during the release and helps when backporting over multiple platform
branches.

-->

### Impact



### NixOS XX.XX platform

- router: fix radvd config generation to use the correct derived
interface name. (PL-133201)
31 changes: 16 additions & 15 deletions nixos/roles/router/radvd.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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} {
Expand All @@ -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);
};
};
}