ndisc: accept unknown ip6-privacy value

The value can be unknown for different reasons:

 - we don't have a value saved in NMDevice's "ip6_saved_properties"
   because NM was restarted or because the device didn't have an
   ifindex when it became managed.

 - the value read from /proc is outside the allowed range (kernel
   allows "echo 42 > /proc/sys/net/ipv6/conf/enp1s0/use_tempaddr")

Note that the second case was already possible before commit
797f3cafee ('device: fall back to saved use_tempaddr value instead
of rereading /proc').

If we can't determine the previous value, pass "unknown" to ndisc; it
will generate a l3cd with "unknown" ip6-privacy, which means to not
set the value when committing the configuration.

Fixes: 797f3cafee ('device: fall back to saved use_tempaddr value instead of rereading /proc')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1907
This commit is contained in:
Beniamino Galvani 2024-03-28 10:25:06 +01:00
parent b4e3095522
commit f58b281ef4

View file

@ -1853,6 +1853,7 @@ _config_init(NMNDiscConfig *config, const NMNDiscConfig *src)
g_return_if_fail(
NM_IN_SET(config->node_type, NM_NDISC_NODE_TYPE_HOST, NM_NDISC_NODE_TYPE_ROUTER));
g_return_if_fail(NM_IN_SET(config->ip6_privacy,
NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN,
NM_SETTING_IP6_CONFIG_PRIVACY_DISABLED,
NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_PUBLIC_ADDR,
NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_TEMP_ADDR));