Merge master into staging-next
This commit is contained in:
@@ -144,33 +144,20 @@ let
|
||||
};
|
||||
|
||||
tempAddress = mkOption {
|
||||
type = types.enum [ "default" "enabled" "disabled" ];
|
||||
default = if cfg.enableIPv6 then "default" else "disabled";
|
||||
defaultText = literalExample ''if cfg.enableIPv6 then "default" else "disabled"'';
|
||||
type = types.enum (lib.attrNames tempaddrValues);
|
||||
default = cfg.tempAddresses;
|
||||
defaultText = literalExample ''config.networking.tempAddresses'';
|
||||
description = ''
|
||||
When IPv6 is enabled with SLAAC, this option controls the use of
|
||||
temporary address (aka privacy extensions). This is used to reduce tracking.
|
||||
The three possible values are:
|
||||
temporary address (aka privacy extensions) on this
|
||||
interface. This is used to reduce tracking.
|
||||
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>
|
||||
<literal>"default"</literal> to generate temporary addresses and use
|
||||
them by default;
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<literal>"enabled"</literal> to generate temporary addresses but keep
|
||||
using the standard EUI-64 ones by default;
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<literal>"disabled"</literal> to completely disable temporary addresses.
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
See also the global option
|
||||
<xref linkend="opt-networking.tempAddresses"/>, which
|
||||
applies to all interfaces where this is not set.
|
||||
|
||||
Possible values are:
|
||||
${tempaddrDoc}
|
||||
'';
|
||||
};
|
||||
|
||||
@@ -366,6 +353,32 @@ let
|
||||
|
||||
isHexString = s: all (c: elem c hexChars) (stringToCharacters (toLower s));
|
||||
|
||||
tempaddrValues = {
|
||||
disabled = {
|
||||
sysctl = "0";
|
||||
description = "completely disable IPv6 temporary addresses";
|
||||
};
|
||||
enabled = {
|
||||
sysctl = "1";
|
||||
description = "generate IPv6 temporary addresses but still use EUI-64 addresses as source addresses";
|
||||
};
|
||||
default = {
|
||||
sysctl = "2";
|
||||
description = "generate IPv6 temporary addresses and use these as source addresses in routing";
|
||||
};
|
||||
};
|
||||
tempaddrDoc = ''
|
||||
<itemizedlist>
|
||||
${concatStringsSep "\n" (mapAttrsToList (name: { description, ... }: ''
|
||||
<listitem>
|
||||
<para>
|
||||
<literal>"${name}"</literal> to ${description};
|
||||
</para>
|
||||
</listitem>
|
||||
'') tempaddrValues)}
|
||||
</itemizedlist>
|
||||
'';
|
||||
|
||||
in
|
||||
|
||||
{
|
||||
@@ -1039,6 +1052,21 @@ in
|
||||
'';
|
||||
};
|
||||
|
||||
networking.tempAddresses = mkOption {
|
||||
default = if cfg.enableIPv6 then "default" else "disabled";
|
||||
type = types.enum (lib.attrNames tempaddrValues);
|
||||
description = ''
|
||||
Whether to enable IPv6 Privacy Extensions for interfaces not
|
||||
configured explicitly in
|
||||
<xref linkend="opt-networking.interfaces._name_.tempAddress" />.
|
||||
|
||||
This sets the ipv6.conf.*.use_tempaddr sysctl for all
|
||||
interfaces. Possible values are:
|
||||
|
||||
${tempaddrDoc}
|
||||
'';
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -1098,7 +1126,7 @@ in
|
||||
// listToAttrs (forEach interfaces
|
||||
(i: let
|
||||
opt = i.tempAddress;
|
||||
val = { disabled = 0; enabled = 1; default = 2; }.${opt};
|
||||
val = tempaddrValues.${opt}.sysctl;
|
||||
in nameValuePair "net.ipv6.conf.${replaceChars ["."] ["/"] i.name}.use_tempaddr" val));
|
||||
|
||||
# Capabilities won't work unless we have at-least a 4.3 Linux
|
||||
@@ -1203,9 +1231,11 @@ in
|
||||
(pkgs.writeTextFile rec {
|
||||
name = "ipv6-privacy-extensions.rules";
|
||||
destination = "/etc/udev/rules.d/98-${name}";
|
||||
text = ''
|
||||
text = let
|
||||
sysctl-value = tempaddrValues.${cfg.tempAddresses}.sysctl;
|
||||
in ''
|
||||
# enable and prefer IPv6 privacy addresses by default
|
||||
ACTION=="add", SUBSYSTEM=="net", RUN+="${pkgs.bash}/bin/sh -c 'echo 2 > /proc/sys/net/ipv6/conf/%k/use_tempaddr'"
|
||||
ACTION=="add", SUBSYSTEM=="net", RUN+="${pkgs.bash}/bin/sh -c 'echo ${sysctl-value} > /proc/sys/net/ipv6/conf/%k/use_tempaddr'"
|
||||
'';
|
||||
})
|
||||
(pkgs.writeTextFile rec {
|
||||
@@ -1214,15 +1244,13 @@ in
|
||||
text = concatMapStrings (i:
|
||||
let
|
||||
opt = i.tempAddress;
|
||||
val = if opt == "disabled" then 0 else 1;
|
||||
msg = if opt == "disabled"
|
||||
then "completely disable IPv6 privacy addresses"
|
||||
else "enable IPv6 privacy addresses but prefer EUI-64 addresses";
|
||||
val = tempaddrValues.${opt}.sysctl;
|
||||
msg = tempaddrValues.${opt}.description;
|
||||
in
|
||||
''
|
||||
# override to ${msg} for ${i.name}
|
||||
ACTION=="add", SUBSYSTEM=="net", RUN+="${pkgs.procps}/bin/sysctl net.ipv6.conf.${replaceChars ["."] ["/"] i.name}.use_tempaddr=${toString val}"
|
||||
'') (filter (i: i.tempAddress != "default") interfaces);
|
||||
ACTION=="add", SUBSYSTEM=="net", RUN+="${pkgs.procps}/bin/sysctl net.ipv6.conf.${replaceChars ["."] ["/"] i.name}.use_tempaddr=${val}"
|
||||
'') (filter (i: i.tempAddress != cfg.tempAddresses) interfaces);
|
||||
})
|
||||
] ++ lib.optional (cfg.wlanInterfaces != {})
|
||||
(pkgs.writeTextFile {
|
||||
|
||||
Reference in New Issue
Block a user