From: Yu Watanabe Date: Tue, 23 Apr 2024 03:45:18 +0000 (+0900) Subject: network/radv: merge two boolean flags for prefix into one X-Git-Tag: v256-rc1~34^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F32424%2Fhead;p=thirdparty%2Fsystemd.git network/radv: merge two boolean flags for prefix into one --- diff --git a/src/network/networkd-network-gperf.gperf b/src/network/networkd-network-gperf.gperf index 4124b3270fe..23e25ffc1fb 100644 --- a/src/network/networkd-network-gperf.gperf +++ b/src/network/networkd-network-gperf.gperf @@ -3,7 +3,9 @@ #if __GNUC__ >= 7 _Pragma("GCC diagnostic ignored \"-Wimplicit-fallthrough\"") #endif +#include #include + #include "conf-parser.h" #include "in-addr-prefix-util.h" #include "netem.h" @@ -409,8 +411,8 @@ IPv6SendRA.HomeAgent, config_parse_bool, IPv6SendRA.HomeAgentLifetimeSec, config_parse_router_home_agent_lifetime, 0, offsetof(Network, home_agent_lifetime_usec) IPv6SendRA.HomeAgentPreference, config_parse_uint16, 0, offsetof(Network, router_home_agent_preference) IPv6Prefix.Prefix, config_parse_prefix, 0, 0 -IPv6Prefix.OnLink, config_parse_prefix_boolean, 0, 0 -IPv6Prefix.AddressAutoconfiguration, config_parse_prefix_boolean, 0, 0 +IPv6Prefix.OnLink, config_parse_prefix_boolean, ND_OPT_PI_FLAG_ONLINK, 0 +IPv6Prefix.AddressAutoconfiguration, config_parse_prefix_boolean, ND_OPT_PI_FLAG_AUTO, 0 IPv6Prefix.ValidLifetimeSec, config_parse_prefix_lifetime, 0, 0 IPv6Prefix.PreferredLifetimeSec, config_parse_prefix_lifetime, 0, 0 IPv6Prefix.Assign, config_parse_prefix_boolean, 0, 0 diff --git a/src/network/networkd-radv.c b/src/network/networkd-radv.c index a7f89adbdaf..3d6e9a128fa 100644 --- a/src/network/networkd-radv.c +++ b/src/network/networkd-radv.c @@ -80,10 +80,9 @@ static int prefix_new_static(Network *network, const char *filename, unsigned se .network = network, .section = TAKE_PTR(n), + .flags = ND_OPT_PI_FLAG_ONLINK | ND_OPT_PI_FLAG_AUTO, .preferred_lifetime = RADV_DEFAULT_PREFERRED_LIFETIME_USEC, .valid_lifetime = RADV_DEFAULT_VALID_LIFETIME_USEC, - .onlink = true, - .address_auto_configuration = true, }; r = hashmap_ensure_put(&network->prefixes_by_section, &config_section_hash_ops, prefix->section, prefix); @@ -298,11 +297,11 @@ static int radv_set_prefix(Link *link, Prefix *prefix) { if (r < 0) return r; - r = sd_radv_prefix_set_onlink(p, prefix->onlink); + r = sd_radv_prefix_set_onlink(p, FLAGS_SET(prefix->flags, ND_OPT_PI_FLAG_ONLINK)); if (r < 0) return r; - r = sd_radv_prefix_set_address_autoconfiguration(p, prefix->address_auto_configuration); + r = sd_radv_prefix_set_address_autoconfiguration(p, FLAGS_SET(prefix->flags, ND_OPT_PI_FLAG_AUTO)); if (r < 0) return r; @@ -962,14 +961,12 @@ int config_parse_prefix_boolean( return 0; } - if (streq(lvalue, "OnLink")) - p->onlink = r; - else if (streq(lvalue, "AddressAutoconfiguration")) - p->address_auto_configuration = r; - else if (streq(lvalue, "Assign")) + if (ltype != 0) + SET_FLAG(p->flags, ltype, r); + else { + assert(streq(lvalue, "Assign")); p->assign = r; - else - assert_not_reached(); + } TAKE_PTR(p); return 0; diff --git a/src/network/networkd-radv.h b/src/network/networkd-radv.h index 569ca9e62b1..c1ec6453ce0 100644 --- a/src/network/networkd-radv.h +++ b/src/network/networkd-radv.h @@ -30,14 +30,12 @@ typedef struct Prefix { Network *network; ConfigSection *section; - struct in6_addr prefix; + uint8_t flags; uint8_t prefixlen; + struct in6_addr prefix; usec_t preferred_lifetime; usec_t valid_lifetime; - bool onlink; - bool address_auto_configuration; - bool assign; uint32_t route_metric; Set *tokens;