git.iko.soy/typeable/nixpkgs
on master help sign in
nixos/networkd: add BatmanAdvanced options (#145963)

Since systemd v248 networkd supports BatmanAdvanced. This adds the according config options to the networkd-module

commiteeac1c543d398f167f8886883824fc99266aad40 authorn0emis <22817873+n0emis@users.noreply.github.com> dateTue 16 Nov 2021, 23:41 (5 years ago) parentf03db46
1 file changed+44
nixos/modules/system/boot/networkd.nix+44
nixos/modules/system/boot/networkd.nix+44
@@ -131,6 +131,7 @@ let
131131 "fou"
132132 "xfrm"
133133 "ifb"
134+ "batadv"
134135 ])
135136 (assertByteFormat "MTUBytes")
136137 (assertMacAddress "MACAddress")
@@ -381,6 +382,29 @@ let
381382 (assertInt "Table")
382383 (assertMinimum "Table" 0)
383384 ];
385+
386+ sectionBatmanAdvanced = checkUnitConfig "BatmanAdvanced" [
387+ (assertOnlyFields [
388+ "GatewayMode"
389+ "Aggregation"
390+ "BridgeLoopAvoidance"
391+ "DistributedArpTable"
392+ "Fragmentation"
393+ "HopPenalty"
394+ "OriginatorIntervalSec"
395+ "GatewayBandwithDown"
396+ "GatewayBandwithUp"
397+ "RoutingAlgorithm"
398+ ])
399+ (assertValueOneOf "GatewayMode" ["off" "client" "server"])
400+ (assertValueOneOf "Aggregation" boolValues)
401+ (assertValueOneOf "BridgeLoopAvoidance" boolValues)
402+ (assertValueOneOf "DistributedArpTable" boolValues)
403+ (assertValueOneOf "Fragmentation" boolValues)
404+ (assertInt "HopPenalty")
405+ (assertRange "HopPenalty" 0 255)
406+ (assertValueOneOf "RoutingAlgorithm" ["batman-v" "batman-iv"])
407+ ];
384408 };
385409
386410 network = {
@@ -473,6 +497,7 @@ let
473497 "IgnoreCarrierLoss"
474498 "Xfrm"
475499 "KeepConfiguration"
500+ "BatmanAdvanced"
476501 ])
477502 # Note: For DHCP the values both, none, v4, v6 are deprecated
478503 (assertValueOneOf "DHCP" ["yes" "no" "ipv4" "ipv6"])
@@ -1056,6 +1081,21 @@ let
10561081 '';
10571082 };
10581083
1084+ batmanAdvancedConfig = mkOption {
1085+ default = {};
1086+ example = {
1087+ GatewayMode = "server";
1088+ RoutingAlgorithm = "batman-v";
1089+ };
1090+ type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionBatmanAdvanced;
1091+ description = ''
1092+ Each attribute in this set specifies an option in the
1093+ <literal>[BatmanAdvanced]</literal> section of the unit. See
1094+ <citerefentry><refentrytitle>systemd.netdev</refentrytitle>
1095+ <manvolnum>5</manvolnum></citerefentry> for details.
1096+ '';
1097+ };
1098+
10591099 };
10601100
10611101 addressOptions = {
@@ -1507,6 +1547,10 @@ let
15071547 [VRF]
15081548 ${attrsToSection def.vrfConfig}
15091549 ''
1550+ + optionalString (def.batmanAdvancedConfig != { }) ''
1551+ [BatmanAdvanced]
1552+ ${attrsToSection def.batmanAdvancedConfig}
1553+ ''
15101554 + def.extraConfig;
15111555 };
15121556