Skip to content

Commit

Permalink
nixos/networkd: add BridgeMDB option
Browse files Browse the repository at this point in the history
  • Loading branch information
apfelkuchen6 committed Mar 16, 2023
1 parent d646f7c commit ae15b86
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions nixos/modules/system/boot/networkd.nix
Original file line number Diff line number Diff line change
Expand Up @@ -1013,6 +1013,16 @@ let
(assertRange "VNI" 1 16777215)
(assertValueOneOf "AssociatedWith" [ "use" "self" "master" "router" ])
];

sectionBridgeMDB = checkUnitConfig "BridgeMDB" [
(assertOnlyFields [
"MulticastGroupAddress"
"VLANId"
])
(assertHasField "MulticastGroupAddress")
(assertInt "VLANId")
(assertRange "VLANId" 0 4094)
];
};
};

Expand Down Expand Up @@ -1463,6 +1473,21 @@ let
};
};

bridgeMDBOptions = {
options = {
bridgeMDBConfig = mkOption {
default = {};
example = { MulticastGroupAddress = "ff02::1:2:3:4"; VLANId = 10; };
type = types.addCheck (types.attrsOf unitOption) check.network.sectionBridgeMDB;
description = lib.mdDoc ''
Each attribute in this set specifies an option in the
`[BridgeMDB]` section of the unit. See
{manpage}`systemd.network(5)` for details.
'';
};
};
};

networkOptions = commonNetworkOptions // {

linkConfig = mkOption {
Expand Down Expand Up @@ -1623,6 +1648,16 @@ let
'';
};

bridgeMDBs = mkOption {
default = [];
example = [ { bridgeMDBConfig = { MulticastGroupAddress = "ff02::1:2:3:4"; VLANId = 10; } ; } ];
type = with types; listOf (submodule bridgeMDBOptions);
description = lib.mdDoc ''
A list of BridgeMDB sections to be added to the unit. See
{manpage}`systemd.network(5)` for details.
'';
};

name = mkOption {
type = types.nullOr types.str;
default = null;
Expand Down Expand Up @@ -2038,6 +2073,10 @@ let
[BridgeFDB]
${attrsToSection x.bridgeFDBConfig}
'')
+ flip concatMapStrings def.bridgeMDBs (x: ''
[BridgeMDB]
${attrsToSection x.bridgeMDBConfig}
'')
+ def.extraConfig;
};

Expand Down

0 comments on commit ae15b86

Please sign in to comment.