nixos/networkd: DHCPv6PrefixDelegation -> DHCPPrefixDelegation

Adapt to changes introduced in Systemd 250:

> The [DHCPv6PrefixDelegation] section in .network file is renamed to
> [DHCPPrefixDelegation], as now the prefix delegation is also
> supported with DHCPv4 protocol by enabling the Use6RD= setting.

Replaces the `dhcpV6PrefixDelegationConfig` with
`dhcpPrefixDelegationConfig` and throws an error if the old option is
used.

Also adapt the respective IPv6 prefix delegation test.
This commit is contained in:
Vincent Haupert 2022-10-09 00:00:18 +02:00
parent e6cf6a32d9
commit bc8d6d8f96
2 changed files with 19 additions and 9 deletions

View file

@ -526,7 +526,7 @@ let
"IPv6ProxyNDP"
"IPv6ProxyNDPAddress"
"IPv6SendRA"
"DHCPv6PrefixDelegation"
"DHCPPrefixDelegation"
"IPv6MTUBytes"
"Bridge"
"Bond"
@ -569,7 +569,7 @@ let
(assertValueOneOf "IPv4ProxyARP" boolValues)
(assertValueOneOf "IPv6ProxyNDP" boolValues)
(assertValueOneOf "IPv6SendRA" boolValues)
(assertValueOneOf "DHCPv6PrefixDelegation" boolValues)
(assertValueOneOf "DHCPPrefixDelegation" boolValues)
(assertByteFormat "IPv6MTUBytes")
(assertValueOneOf "ActiveSlave" boolValues)
(assertValueOneOf "PrimarySlave" boolValues)
@ -766,15 +766,20 @@ let
(assertInt "IAID")
];
sectionDHCPv6PrefixDelegation = checkUnitConfig "DHCPv6PrefixDelegation" [
sectionDHCPPrefixDelegation = checkUnitConfig "DHCPPrefixDelegation" [
(assertOnlyFields [
"UplinkInterface"
"SubnetId"
"Announce"
"Assign"
"Token"
"ManageTemporaryAddress"
"RouteMetric"
])
(assertValueOneOf "Announce" boolValues)
(assertValueOneOf "Assign" boolValues)
(assertValueOneOf "ManageTemporaryAddress" boolValues)
(assertRange "RouteMetric" 0 4294967295)
];
sectionIPv6AcceptRA = checkUnitConfig "IPv6AcceptRA" [
@ -1338,12 +1343,17 @@ let
};
dhcpV6PrefixDelegationConfig = mkOption {
visible = false;
apply = _: throw "The option `systemd.network.networks.<name>.dhcpV6PrefixDelegationConfig` has been renamed to `systemd.network.networks.<name>.dhcpPrefixDelegationConfig`.";
};
dhcpPrefixDelegationConfig = mkOption {
default = {};
example = { SubnetId = "auto"; Announce = true; };
type = types.addCheck (types.attrsOf unitOption) check.network.sectionDHCPv6PrefixDelegation;
type = types.addCheck (types.attrsOf unitOption) check.network.sectionDHCPPrefixDelegation;
description = lib.mdDoc ''
Each attribute in this set specifies an option in the
`[DHCPv6PrefixDelegation]` section of the unit. See
`[DHCPPrefixDelegation]` section of the unit. See
{manpage}`systemd.network(5)` for details.
'';
};
@ -1789,9 +1799,9 @@ let
[DHCPv6]
${attrsToSection def.dhcpV6Config}
''
+ optionalString (def.dhcpV6PrefixDelegationConfig != { }) ''
[DHCPv6PrefixDelegation]
${attrsToSection def.dhcpV6PrefixDelegationConfig}
+ optionalString (def.dhcpPrefixDelegationConfig != { }) ''
[DHCPPrefixDelegation]
${attrsToSection def.dhcpPrefixDelegationConfig}
''
+ optionalString (def.ipv6AcceptRAConfig != { }) ''
[IPv6AcceptRA]

View file

@ -176,7 +176,7 @@ import ./make-test-python.nix ({pkgs, ...}: {
IPv6AcceptRA = false;
# Delegate prefixes from the DHCPv6 PD pool.
DHCPv6PrefixDelegation = true;
DHCPPrefixDelegation = true;
IPv6SendRA = true;
};