]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: introduce IPV6_PRIVACY_EXTENSIONS_KERNEL enum value
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 29 Jun 2023 09:51:58 +0000 (18:51 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 29 Jun 2023 12:40:47 +0000 (21:40 +0900)
No functional change. Preparation for using the _INVALID value in later
commit.

src/network/networkd-sysctl.c
src/network/networkd-sysctl.h

index 51a697a667d672d418200d838847511adbedd8ce..729bd68dabbdbfd6a90850e71898811509aef2b6 100644 (file)
@@ -100,8 +100,8 @@ static int link_set_ipv6_privacy_extensions(Link *link) {
         if (!link->network)
                 return 0;
 
-        // this is the special "kernel" value
-        if (link->network->ipv6_privacy_extensions == _IPV6_PRIVACY_EXTENSIONS_INVALID)
+        /* When "kernel", do not update the setting. */
+        if (link->network->ipv6_privacy_extensions == IPV6_PRIVACY_EXTENSIONS_KERNEL)
                 return 0;
 
         return sysctl_write_ip_property_int(AF_INET6, link->ifname, "use_tempaddr", (int) link->network->ipv6_privacy_extensions);
@@ -307,44 +307,13 @@ int link_set_sysctl(Link *link) {
 }
 
 static const char* const ipv6_privacy_extensions_table[_IPV6_PRIVACY_EXTENSIONS_MAX] = {
-        [IPV6_PRIVACY_EXTENSIONS_NO] = "no",
+        [IPV6_PRIVACY_EXTENSIONS_NO]            = "no",
         [IPV6_PRIVACY_EXTENSIONS_PREFER_PUBLIC] = "prefer-public",
-        [IPV6_PRIVACY_EXTENSIONS_YES] = "yes",
+        [IPV6_PRIVACY_EXTENSIONS_YES]           = "yes",
+        [IPV6_PRIVACY_EXTENSIONS_KERNEL]        = "kernel",
 };
 
 DEFINE_STRING_TABLE_LOOKUP_WITH_BOOLEAN(ipv6_privacy_extensions, IPv6PrivacyExtensions,
                                         IPV6_PRIVACY_EXTENSIONS_YES);
-
-int config_parse_ipv6_privacy_extensions(
-                const char* unit,
-                const char *filename,
-                unsigned line,
-                const char *section,
-                unsigned section_line,
-                const char *lvalue,
-                int ltype,
-                const char *rvalue,
-                void *data,
-                void *userdata) {
-
-        IPv6PrivacyExtensions s, *ipv6_privacy_extensions = ASSERT_PTR(data);
-
-        assert(filename);
-        assert(lvalue);
-        assert(rvalue);
-
-        s = ipv6_privacy_extensions_from_string(rvalue);
-        if (s < 0) {
-                if (streq(rvalue, "kernel"))
-                        s = _IPV6_PRIVACY_EXTENSIONS_INVALID;
-                else {
-                        log_syntax(unit, LOG_WARNING, filename, line, 0,
-                                   "Failed to parse IPv6 privacy extensions option, ignoring: %s", rvalue);
-                        return 0;
-                }
-        }
-
-        *ipv6_privacy_extensions = s;
-
-        return 0;
-}
+DEFINE_CONFIG_PARSE_ENUM(config_parse_ipv6_privacy_extensions, ipv6_privacy_extensions, IPv6PrivacyExtensions,
+                         "Failed to parse IPv6 privacy extensions option");
index cb1db10fe8758ec0f956ddca40b31a3d31cc8eb7..df5d6e08ffa68b426371e8991f06e55b27004525 100644 (file)
@@ -11,7 +11,8 @@ typedef enum IPv6PrivacyExtensions {
         /* The values map to the kernel's /proc/sys/net/ipv6/conf/xxx/use_tempaddr values */
         IPV6_PRIVACY_EXTENSIONS_NO,
         IPV6_PRIVACY_EXTENSIONS_PREFER_PUBLIC,
-        IPV6_PRIVACY_EXTENSIONS_YES, /* aka prefer-temporary */
+        IPV6_PRIVACY_EXTENSIONS_YES,    /* aka prefer-temporary */
+        IPV6_PRIVACY_EXTENSIONS_KERNEL, /* keep the kernel's default value */
         _IPV6_PRIVACY_EXTENSIONS_MAX,
         _IPV6_PRIVACY_EXTENSIONS_INVALID = -EINVAL,
 } IPv6PrivacyExtensions;