From: Yu Watanabe Date: Thu, 29 Jun 2023 09:51:58 +0000 (+0900) Subject: network: introduce IPV6_PRIVACY_EXTENSIONS_KERNEL enum value X-Git-Tag: v254-rc1~71^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7cab78503accb854fabab462ffd788e51c46b90a;p=thirdparty%2Fsystemd.git network: introduce IPV6_PRIVACY_EXTENSIONS_KERNEL enum value No functional change. Preparation for using the _INVALID value in later commit. --- diff --git a/src/network/networkd-sysctl.c b/src/network/networkd-sysctl.c index 51a697a667d..729bd68dabb 100644 --- a/src/network/networkd-sysctl.c +++ b/src/network/networkd-sysctl.c @@ -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"); diff --git a/src/network/networkd-sysctl.h b/src/network/networkd-sysctl.h index cb1db10fe87..df5d6e08ffa 100644 --- a/src/network/networkd-sysctl.h +++ b/src/network/networkd-sysctl.h @@ -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;