mirror of
https://github.com/systemd/systemd.git
synced 2025-01-11 09:18:07 +03:00
Merge pull request #13944 from yuwata/network-split-struct-prefix
network: split struct Prefix into Prefix and RoutePrefix
This commit is contained in:
commit
9087384d39
@ -145,6 +145,7 @@ static int network_resolve_stacked_netdevs(Network *network) {
|
||||
}
|
||||
|
||||
int network_verify(Network *network) {
|
||||
RoutePrefix *route_prefix, *route_prefix_next;
|
||||
RoutingPolicyRule *rule, *rule_next;
|
||||
Neighbor *neighbor, *neighbor_next;
|
||||
AddressLabel *label, *label_next;
|
||||
@ -304,9 +305,9 @@ int network_verify(Network *network) {
|
||||
if (section_is_invalid(prefix->section))
|
||||
prefix_free(prefix);
|
||||
|
||||
LIST_FOREACH_SAFE(prefixes, prefix, prefix_next, network->static_route_prefixes)
|
||||
if (section_is_invalid(prefix->section))
|
||||
route_prefix_free(prefix);
|
||||
LIST_FOREACH_SAFE(route_prefixes, route_prefix, route_prefix_next, network->static_route_prefixes)
|
||||
if (section_is_invalid(route_prefix->section))
|
||||
route_prefix_free(route_prefix);
|
||||
|
||||
LIST_FOREACH_SAFE(rules, rule, rule_next, network->rules)
|
||||
if (routing_policy_rule_section_verify(rule) < 0)
|
||||
@ -577,10 +578,11 @@ failure:
|
||||
|
||||
static Network *network_free(Network *network) {
|
||||
IPv6ProxyNDPAddress *ipv6_proxy_ndp_address;
|
||||
RoutePrefix *route_prefix;
|
||||
RoutingPolicyRule *rule;
|
||||
AddressLabel *label;
|
||||
FdbEntry *fdb_entry;
|
||||
Neighbor *neighbor;
|
||||
AddressLabel *label;
|
||||
Address *address;
|
||||
NextHop *nexthop;
|
||||
Prefix *prefix;
|
||||
@ -654,8 +656,8 @@ static Network *network_free(Network *network) {
|
||||
while ((prefix = network->static_prefixes))
|
||||
prefix_free(prefix);
|
||||
|
||||
while ((prefix = network->static_route_prefixes))
|
||||
route_prefix_free(prefix);
|
||||
while ((route_prefix = network->static_route_prefixes))
|
||||
route_prefix_free(route_prefix);
|
||||
|
||||
while ((rule = network->rules))
|
||||
routing_policy_rule_free(rule);
|
||||
|
@ -245,7 +245,7 @@ struct Network {
|
||||
LIST_HEAD(Neighbor, neighbors);
|
||||
LIST_HEAD(AddressLabel, address_labels);
|
||||
LIST_HEAD(Prefix, static_prefixes);
|
||||
LIST_HEAD(Prefix, static_route_prefixes);
|
||||
LIST_HEAD(RoutePrefix, static_route_prefixes);
|
||||
LIST_HEAD(RoutingPolicyRule, rules);
|
||||
|
||||
unsigned n_static_addresses;
|
||||
|
@ -36,7 +36,7 @@ void prefix_free(Prefix *prefix) {
|
||||
free(prefix);
|
||||
}
|
||||
|
||||
int prefix_new(Prefix **ret) {
|
||||
static int prefix_new(Prefix **ret) {
|
||||
_cleanup_(prefix_freep) Prefix *prefix = NULL;
|
||||
|
||||
prefix = new0(Prefix, 1);
|
||||
@ -101,10 +101,10 @@ static int prefix_new_static(Network *network, const char *filename,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int route_prefix_new(Prefix **ret) {
|
||||
_cleanup_(prefix_freep) Prefix *prefix = NULL;
|
||||
static int route_prefix_new(RoutePrefix **ret) {
|
||||
_cleanup_(route_prefix_freep) RoutePrefix *prefix = NULL;
|
||||
|
||||
prefix = new0(Prefix, 1);
|
||||
prefix = new0(RoutePrefix, 1);
|
||||
if (!prefix)
|
||||
return -ENOMEM;
|
||||
|
||||
@ -116,12 +116,12 @@ int route_prefix_new(Prefix **ret) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void route_prefix_free(Prefix *prefix) {
|
||||
void route_prefix_free(RoutePrefix *prefix) {
|
||||
if (!prefix)
|
||||
return;
|
||||
|
||||
if (prefix->network) {
|
||||
LIST_REMOVE(prefixes, prefix->network->static_route_prefixes, prefix);
|
||||
LIST_REMOVE(route_prefixes, prefix->network->static_route_prefixes, prefix);
|
||||
assert(prefix->network->n_static_route_prefixes > 0);
|
||||
prefix->network->n_static_route_prefixes--;
|
||||
|
||||
@ -137,9 +137,9 @@ void route_prefix_free(Prefix *prefix) {
|
||||
}
|
||||
|
||||
static int route_prefix_new_static(Network *network, const char *filename,
|
||||
unsigned section_line, Prefix **ret) {
|
||||
unsigned section_line, RoutePrefix **ret) {
|
||||
_cleanup_(network_config_section_freep) NetworkConfigSection *n = NULL;
|
||||
_cleanup_(prefix_freep) Prefix *prefix = NULL;
|
||||
_cleanup_(route_prefix_freep) RoutePrefix *prefix = NULL;
|
||||
int r;
|
||||
|
||||
assert(network);
|
||||
@ -166,7 +166,7 @@ static int route_prefix_new_static(Network *network, const char *filename,
|
||||
return r;
|
||||
|
||||
prefix->network = network;
|
||||
LIST_APPEND(prefixes, network->static_route_prefixes, prefix);
|
||||
LIST_APPEND(route_prefixes, network->static_route_prefixes, prefix);
|
||||
network->n_static_route_prefixes++;
|
||||
|
||||
if (filename) {
|
||||
@ -331,7 +331,7 @@ int config_parse_route_prefix(const char *unit,
|
||||
void *userdata) {
|
||||
|
||||
Network *network = userdata;
|
||||
_cleanup_(route_prefix_free_or_set_invalidp) Prefix *p = NULL;
|
||||
_cleanup_(route_prefix_free_or_set_invalidp) RoutePrefix *p = NULL;
|
||||
uint8_t prefixlen = 64;
|
||||
union in_addr_union in6addr;
|
||||
int r;
|
||||
@ -373,7 +373,7 @@ int config_parse_route_prefix_lifetime(const char *unit,
|
||||
void *data,
|
||||
void *userdata) {
|
||||
Network *network = userdata;
|
||||
_cleanup_(route_prefix_free_or_set_invalidp) Prefix *p = NULL;
|
||||
_cleanup_(route_prefix_free_or_set_invalidp) RoutePrefix *p = NULL;
|
||||
usec_t usec;
|
||||
int r;
|
||||
|
||||
@ -549,8 +549,9 @@ int radv_emit_dns(Link *link) {
|
||||
}
|
||||
|
||||
int radv_configure(Link *link) {
|
||||
int r;
|
||||
RoutePrefix *q;
|
||||
Prefix *p;
|
||||
int r;
|
||||
|
||||
assert(link);
|
||||
assert(link->network);
|
||||
@ -609,8 +610,8 @@ int radv_configure(Link *link) {
|
||||
return r;
|
||||
}
|
||||
|
||||
LIST_FOREACH(prefixes, p, link->network->static_route_prefixes) {
|
||||
r = sd_radv_add_route_prefix(link->radv, p->radv_route_prefix, false);
|
||||
LIST_FOREACH(route_prefixes, q, link->network->static_route_prefixes) {
|
||||
r = sd_radv_add_route_prefix(link->radv, q->radv_route_prefix, false);
|
||||
if (r == -EEXIST)
|
||||
continue;
|
||||
if (r < 0)
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "networkd-util.h"
|
||||
|
||||
typedef struct Prefix Prefix;
|
||||
typedef struct RoutePrefix RoutePrefix;
|
||||
|
||||
typedef enum RADVPrefixDelegation {
|
||||
RADV_PREFIX_DELEGATION_NONE,
|
||||
@ -26,21 +27,26 @@ struct Prefix {
|
||||
NetworkConfigSection *section;
|
||||
|
||||
sd_radv_prefix *radv_prefix;
|
||||
sd_radv_route_prefix *radv_route_prefix;
|
||||
|
||||
LIST_FIELDS(Prefix, prefixes);
|
||||
LIST_FIELDS(Prefix, route_prefixes);
|
||||
};
|
||||
|
||||
int prefix_new(Prefix **ret);
|
||||
struct RoutePrefix {
|
||||
Network *network;
|
||||
NetworkConfigSection *section;
|
||||
|
||||
sd_radv_route_prefix *radv_route_prefix;
|
||||
|
||||
LIST_FIELDS(RoutePrefix, route_prefixes);
|
||||
};
|
||||
|
||||
void prefix_free(Prefix *prefix);
|
||||
|
||||
DEFINE_NETWORK_SECTION_FUNCTIONS(Prefix, prefix_free);
|
||||
|
||||
int route_prefix_new(Prefix **ret);
|
||||
void route_prefix_free(Prefix *prefix);
|
||||
void route_prefix_free(RoutePrefix *prefix);
|
||||
|
||||
DEFINE_NETWORK_SECTION_FUNCTIONS(Prefix, route_prefix_free);
|
||||
DEFINE_NETWORK_SECTION_FUNCTIONS(RoutePrefix, route_prefix_free);
|
||||
|
||||
int radv_emit_dns(Link *link);
|
||||
int radv_configure(Link *link);
|
||||
|
Loading…
Reference in New Issue
Block a user