about summary refs log tree commit diff
path: root/src/core/devices/nm-device.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/devices/nm-device.c')
-rw-r--r--src/core/devices/nm-device.c57
1 files changed, 32 insertions, 25 deletions
diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c
index 5b377529..b96adefb 100644
--- a/src/core/devices/nm-device.c
+++ b/src/core/devices/nm-device.c
@@ -2273,7 +2273,6 @@ _prop_get_ipv4_dhcp_vendor_class_identifier(NMDevice *self, NMSettingIP4Config *
 static NMSettingIP6ConfigPrivacy
 _prop_get_ipv6_ip6_privacy(NMDevice *self)
 {
-    NMDevicePrivate          *priv = NM_DEVICE_GET_PRIVATE(self);
     NMSettingIP6ConfigPrivacy ip6_privacy;
     NMConnection             *connection;
 
@@ -2307,22 +2306,23 @@ _prop_get_ipv6_ip6_privacy(NMDevice *self)
     if (!nm_device_get_ip_ifindex(self))
         return NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN;
 
-    /* 3.) No valid default value configured. Fall back to the original value
-     * from before NM started. */
-    return _ip6_privacy_clamp(_nm_utils_ascii_str_to_int64(
-        g_hash_table_lookup(priv->ip6_saved_properties, "use_tempaddr"),
-        10,
-        G_MININT32,
-        G_MAXINT32,
-        NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN));
+    /* 3.) No valid default-value configured. Fallback to reading sysctl.
+     *
+     * Instead of reading static config files in /etc, just read the current sysctl value.
+     * This works as NM only writes to "/proc/sys/net/ipv6/conf/IFNAME/use_tempaddr", but leaves
+     * the "default" entry untouched. */
+    ip6_privacy = nm_platform_sysctl_get_int32(
+        nm_device_get_platform(self),
+        NMP_SYSCTL_PATHID_ABSOLUTE("/proc/sys/net/ipv6/conf/default/use_tempaddr"),
+        NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN);
+    return _ip6_privacy_clamp(ip6_privacy);
 }
 
 static gint32
 _prop_get_ipv6_temp_valid_lifetime(NMDevice *self)
 {
-    NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self);
-    gint32           temp_valid_lifetime;
-    NMConnection    *connection;
+    gint32        temp_valid_lifetime;
+    NMConnection *connection;
 
     g_return_val_if_fail(self, 0);
 
@@ -2350,22 +2350,25 @@ _prop_get_ipv6_temp_valid_lifetime(NMDevice *self)
     if (temp_valid_lifetime)
         return temp_valid_lifetime;
 
-    /* 3.) No valid default value configured. Fall back to the original value
-     * from before NM started. */
-    return _nm_utils_ascii_str_to_int64(
-        g_hash_table_lookup(priv->ip6_saved_properties, "temp_valid_lft"),
+    /* 3.) No valid default-value configured. Fallback to reading sysctl.
+     *
+     * Instead of reading static config files in /etc, just read the current sysctl value.
+     * This works as NM only writes to "/proc/sys/net/ipv6/conf/IFNAME/temp_valid_lft",
+     * but leaves the "default" entry untouched. */
+    return nm_platform_sysctl_get_int_checked(
+        nm_device_get_platform(self),
+        NMP_SYSCTL_PATHID_ABSOLUTE("/proc/sys/net/ipv6/conf/default/temp_valid_lft"),
         10,
         0,
         G_MAXINT32,
-        SECONDS_PER_WEEK /* final hardcoded fallback: 1 week */);
+        SECONDS_PER_WEEK);
 }
 
 static gint32
 _prop_get_ipv6_temp_preferred_lifetime(NMDevice *self)
 {
-    NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self);
-    gint32           temp_preferred_lifetime;
-    NMConnection    *connection;
+    gint32        temp_preferred_lifetime;
+    NMConnection *connection;
 
     g_return_val_if_fail(self, 0);
 
@@ -2393,14 +2396,18 @@ _prop_get_ipv6_temp_preferred_lifetime(NMDevice *self)
     if (temp_preferred_lifetime)
         return temp_preferred_lifetime;
 
-    /* 3.) No valid default value configured. Fall back to the original value
-     * from before NM started. */
-    return _nm_utils_ascii_str_to_int64(
-        g_hash_table_lookup(priv->ip6_saved_properties, "temp_prefered_lft"),
+    /* 3.) No valid default-value configured. Fallback to reading sysctl.
+     *
+     * Instead of reading static config files in /etc, just read the current sysctl value.
+     * This works as NM only writes to "/proc/sys/net/ipv6/conf/IFNAME/temp_prefered_lft",
+     * but leaves the "default" entry untouched. */
+    return nm_platform_sysctl_get_int_checked(
+        nm_device_get_platform(self),
+        NMP_SYSCTL_PATHID_ABSOLUTE("/proc/sys/net/ipv6/conf/default/temp_prefered_lft"),
         10,
         0,
         G_MAXINT32,
-        SECONDS_PER_DAY /* final hardcoded fallback: 1 day */);
+        SECONDS_PER_DAY);
 }
 
 static NMSettingIP6ConfigAddrGenMode