device: add IPv6 sysfs existence check in some ipv6 sysctl functions.
when the kernel boot parameter ipv6.disable=1 is set, NetworkManager attempts to read files under /proc/sys/net/ipv6, resulting in numerous error messages in the debug logs. For example: NetworkManager[758]: <debug> [1726699000.9384] platform-linux: error reading /proc/sys/net/ipv6/conf/lo/disable_ipv6: Failed to open file "/proc/sys/net/ipv6/conf/lo/disable_ipv6": No such file or directory NetworkManager[758]: <debug> [1726699000.9400] platform-linux: error reading /proc/sys/net/ipv6/conf/lo/accept_ra: Failed to open file "/proc/sys/net/ipv6/conf/lo/accept_ra": No such file or directory NetworkManager[758]: <debug> [1726699000.9401] platform-linux: error reading /proc/sys/net/ipv6/conf/lo/disable_ipv6: Failed to open file "/proc/sys/net/ipv6/conf/lo/disable_ipv6": No such file or directory NetworkManager[758]: <debug> [1726699000.9401] platform-linux: error reading /proc/sys/net/ipv6/conf/lo/hop_limit: Failed to open file "/proc/sys/net/ipv6/conf/lo/hop_limit": No such file or directory NetworkManager[758]: <debug> [1726699000.9401] platform-linux: error reading /proc/sys/net/ipv6/conf/lo/use_tempaddr: Failed to open file "/proc/sys/net/ipv6/conf/lo/use_tempaddr": No such file or directory NetworkManager[758]: <debug> [1726699000.9401] platform-linux: error reading /proc/sys/net/ipv6/conf/lo/temp_valid_lft: Failed to open file "/proc/sys/net/ipv6/conf/lo/temp_valid_lft": No such file or directory NetworkManager[758]: <debug> [1726699000.9401] platform-linux: error reading /proc/sys/net/ipv6/conf/lo/temp_prefered_lft: Failed to open file "/proc/sys/net/ipv6/conf/lo/temp_prefered_lft": No such file or directory ... This also results unnecessary system calls by attempting to open non-existent sysfs. This patch adds checks in some ipv6 sysctl functions to verify the existence of /proc/sys/net/ipv6. While there are still other paths that attempts to open IPv6 sysfs, this eliminates many reading errors. https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2040
This commit is contained in:

committed by
Lubomir Rintel

parent
6c18fda519
commit
7fc9711c54
@@ -12817,6 +12817,9 @@ _dev_sysctl_save_ip6_properties(NMDevice *self)
|
||||
if (!ifname)
|
||||
return;
|
||||
|
||||
if (!g_file_test("/proc/sys/net/ipv6", G_FILE_TEST_IS_DIR))
|
||||
return;
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS(ip6_properties_to_save); i++) {
|
||||
value =
|
||||
nm_platform_sysctl_ip_conf_get(platform, AF_INET6, ifname, ip6_properties_to_save[i]);
|
||||
@@ -12836,6 +12839,9 @@ _dev_sysctl_restore_ip6_properties(NMDevice *self)
|
||||
gpointer key;
|
||||
gpointer value;
|
||||
|
||||
if (!g_file_test("/proc/sys/net/ipv6", G_FILE_TEST_IS_DIR))
|
||||
return;
|
||||
|
||||
g_hash_table_iter_init(&iter, priv->ip6_saved_properties);
|
||||
while (g_hash_table_iter_next(&iter, &key, &value))
|
||||
nm_device_sysctl_ip_conf_set(self, AF_INET6, key, value);
|
||||
@@ -16953,6 +16959,9 @@ deactivate_reset_hw_addr(NMDevice *self)
|
||||
static void
|
||||
ip6_managed_setup(NMDevice *self)
|
||||
{
|
||||
if (!g_file_test("/proc/sys/net/ipv6", G_FILE_TEST_IS_DIR))
|
||||
return;
|
||||
|
||||
_dev_addrgenmode6_set(self, NM_IN6_ADDR_GEN_MODE_NONE);
|
||||
_dev_sysctl_set_disable_ipv6(self, FALSE);
|
||||
nm_device_sysctl_ip_conf_set(self, AF_INET6, "accept_ra", "0");
|
||||
|
Reference in New Issue
Block a user