mirror of
https://github.com/Dasharo/systemd.git
synced 2026-03-06 15:02:31 -08:00
network/radv: merge two boolean flags for prefix into one
This commit is contained in:
@@ -3,7 +3,9 @@
|
||||
#if __GNUC__ >= 7
|
||||
_Pragma("GCC diagnostic ignored \"-Wimplicit-fallthrough\"")
|
||||
#endif
|
||||
#include <netinet/icmp6.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user