RoutingPolicyRule.SuppressPrefixLength, config_parse_routing_policy_rule, ROUTING_POLICY_RULE_SUPPRESS_PREFIXLEN, 0
RoutingPolicyRule.Type, config_parse_routing_policy_rule, ROUTING_POLICY_RULE_ACTION, 0
Route.Gateway, config_parse_route_section, ROUTE_GATEWAY, 0
-Route.Destination, config_parse_destination, 0, 0
-Route.Source, config_parse_destination, 0, 0
-Route.Metric, config_parse_route_priority, 0, 0
-Route.Scope, config_parse_route_scope, 0, 0
-Route.PreferredSource, config_parse_preferred_src, 0, 0
-Route.Table, config_parse_route_table, 0, 0
+Route.Destination, config_parse_route_section, ROUTE_DESTINATION, 0
+Route.Source, config_parse_route_section, ROUTE_DESTINATION, 0
+Route.Metric, config_parse_route_section, ROUTE_PRIORITY, 0
+Route.Scope, config_parse_route_section, ROUTE_SCOPE, 0
+Route.PreferredSource, config_parse_route_section, ROUTE_PREFERRED_SOURCE, 0
+Route.Table, config_parse_route_section, ROUTE_TABLE, 0
Route.GatewayOnLink, config_parse_route_section, ROUTE_GATEWAY_ONLINK, 0
Route.GatewayOnlink, config_parse_route_section, ROUTE_GATEWAY_ONLINK, 0
-Route.IPv6Preference, config_parse_ipv6_route_preference, 0, 0
-Route.Protocol, config_parse_route_protocol, 0, 0
-Route.Type, config_parse_route_type, 0, 0
+Route.IPv6Preference, config_parse_route_section, ROUTE_PREFERENCE, 0
+Route.Protocol, config_parse_route_section, ROUTE_PROTOCOL, 0
+Route.Type, config_parse_route_section, ROUTE_TYPE, 0
Route.MultiPathRoute, config_parse_route_section, ROUTE_MULTIPATH, 0
Route.NextHop, config_parse_route_section, ROUTE_NEXTHOP, 0
Route.MTUBytes, config_parse_route_section, ROUTE_METRIC_MTU, 0
return 0;
}
-int config_parse_preferred_src(
+static int config_parse_preferred_src(
const char *unit,
const char *filename,
unsigned line,
void *data,
void *userdata) {
- Network *network = userdata;
- _cleanup_(route_unref_or_set_invalidp) Route *route = NULL;
+ Route *route = ASSERT_PTR(userdata);
int r;
- assert(filename);
- assert(section);
- assert(lvalue);
assert(rvalue);
- assert(data);
-
- r = route_new_static(network, filename, section_line, &route);
- if (r == -ENOMEM)
- return log_oom();
- if (r < 0) {
- log_syntax(unit, LOG_WARNING, filename, line, r,
- "Failed to allocate route, ignoring assignment: %m");
- return 0;
- }
if (route->family == AF_UNSPEC)
r = in_addr_from_string_auto(rvalue, &route->family, &route->prefsrc);
if (r < 0)
return log_syntax_parse_error(unit, filename, line, r, lvalue, rvalue);
- TAKE_PTR(route);
- return 0;
+ return 1;
}
-int config_parse_destination(
+static int config_parse_route_destination(
const char *unit,
const char *filename,
unsigned line,
void *data,
void *userdata) {
- Network *network = userdata;
- _cleanup_(route_unref_or_set_invalidp) Route *route = NULL;
+ Route *route = ASSERT_PTR(userdata);
union in_addr_union *buffer;
unsigned char *prefixlen;
int r;
- assert(filename);
- assert(section);
assert(lvalue);
assert(rvalue);
- assert(data);
-
- r = route_new_static(network, filename, section_line, &route);
- if (r == -ENOMEM)
- return log_oom();
- if (r < 0) {
- log_syntax(unit, LOG_WARNING, filename, line, r,
- "Failed to allocate route, ignoring assignment: %m");
- return 0;
- }
if (streq(lvalue, "Destination")) {
buffer = &route->dst;
return log_syntax_parse_error(unit, filename, line, r, lvalue, rvalue);
(void) in_addr_mask(route->family, buffer, *prefixlen);
-
- TAKE_PTR(route);
- return 0;
+ return 1;
}
-int config_parse_route_priority(
+static int config_parse_route_priority(
const char *unit,
const char *filename,
unsigned line,
void *data,
void *userdata) {
- Network *network = userdata;
- _cleanup_(route_unref_or_set_invalidp) Route *route = NULL;
+ Route *route = ASSERT_PTR(userdata);
int r;
- assert(filename);
- assert(section);
- assert(lvalue);
assert(rvalue);
- assert(data);
-
- r = route_new_static(network, filename, section_line, &route);
- if (r == -ENOMEM)
- return log_oom();
- if (r < 0) {
- log_syntax(unit, LOG_WARNING, filename, line, r,
- "Failed to allocate route, ignoring assignment: %m");
- return 0;
- }
r = safe_atou32(rvalue, &route->priority);
if (r < 0)
return log_syntax_parse_error(unit, filename, line, r, lvalue, rvalue);
route->priority_set = true;
- TAKE_PTR(route);
- return 0;
+ return 1;
}
-int config_parse_route_scope(
+static int config_parse_route_scope(
const char *unit,
const char *filename,
unsigned line,
void *data,
void *userdata) {
- Network *network = userdata;
- _cleanup_(route_unref_or_set_invalidp) Route *route = NULL;
+ Route *route = ASSERT_PTR(userdata);
int r;
- assert(filename);
- assert(section);
- assert(lvalue);
assert(rvalue);
- assert(data);
-
- r = route_new_static(network, filename, section_line, &route);
- if (r == -ENOMEM)
- return log_oom();
- if (r < 0) {
- log_syntax(unit, LOG_WARNING, filename, line, r,
- "Failed to allocate route, ignoring assignment: %m");
- return 0;
- }
r = route_scope_from_string(rvalue);
if (r < 0)
route->scope = r;
route->scope_set = true;
- TAKE_PTR(route);
- return 0;
+ return 1;
}
-int config_parse_route_table(
+static int config_parse_route_table(
const char *unit,
const char *filename,
unsigned line,
void *data,
void *userdata) {
- _cleanup_(route_unref_or_set_invalidp) Route *route = NULL;
- Network *network = userdata;
+ Route *route = ASSERT_PTR(userdata);
+ Manager *manager = ASSERT_PTR(ASSERT_PTR(route->network)->manager);
int r;
- assert(filename);
- assert(section);
- assert(lvalue);
assert(rvalue);
- assert(data);
- r = route_new_static(network, filename, section_line, &route);
- if (r == -ENOMEM)
- return log_oom();
- if (r < 0) {
- log_syntax(unit, LOG_WARNING, filename, line, r,
- "Failed to allocate route, ignoring assignment: %m");
- return 0;
- }
-
- r = manager_get_route_table_from_string(network->manager, rvalue, &route->table);
+ r = manager_get_route_table_from_string(manager, rvalue, &route->table);
if (r < 0)
return log_syntax_parse_error(unit, filename, line, r, lvalue, rvalue);
route->table_set = true;
- TAKE_PTR(route);
- return 0;
+ return 1;
}
-int config_parse_ipv6_route_preference(
+static int config_parse_route_preference(
const char *unit,
const char *filename,
unsigned line,
void *data,
void *userdata) {
- Network *network = userdata;
- _cleanup_(route_unref_or_set_invalidp) Route *route = NULL;
- int r;
+ Route *route = ASSERT_PTR(userdata);
- r = route_new_static(network, filename, section_line, &route);
- if (r == -ENOMEM)
- return log_oom();
- if (r < 0) {
- log_syntax(unit, LOG_WARNING, filename, line, r,
- "Failed to allocate route, ignoring assignment: %m");
- return 0;
- }
+ assert(rvalue);
if (streq(rvalue, "low"))
route->pref = SD_NDISC_PREFERENCE_LOW;
return log_syntax_parse_error(unit, filename, line, 0, lvalue, rvalue);
route->pref_set = true;
- TAKE_PTR(route);
- return 0;
+ return 1;
}
-int config_parse_route_protocol(
+static int config_parse_route_protocol(
const char *unit,
const char *filename,
unsigned line,
void *data,
void *userdata) {
- Network *network = userdata;
- _cleanup_(route_unref_or_set_invalidp) Route *route = NULL;
+ unsigned char *p = ASSERT_PTR(data);
int r;
- r = route_new_static(network, filename, section_line, &route);
- if (r == -ENOMEM)
- return log_oom();
- if (r < 0) {
- log_syntax(unit, LOG_WARNING, filename, line, r,
- "Failed to allocate route, ignoring assignment: %m");
- return 0;
- }
+ assert(rvalue);
r = route_protocol_from_string(rvalue);
if (r < 0)
return log_syntax_parse_error(unit, filename, line, r, lvalue, rvalue);
- route->protocol = r;
-
- TAKE_PTR(route);
- return 0;
+ *p = (unsigned char) r;
+ return 1;
}
-int config_parse_route_type(
+static int config_parse_route_type(
const char *unit,
const char *filename,
unsigned line,
void *data,
void *userdata) {
- Network *network = userdata;
- _cleanup_(route_unref_or_set_invalidp) Route *route = NULL;
+ unsigned char *p = ASSERT_PTR(data);
int r;
- r = route_new_static(network, filename, section_line, &route);
- if (r == -ENOMEM)
- return log_oom();
- if (r < 0) {
- log_syntax(unit, LOG_WARNING, filename, line, r,
- "Failed to allocate route, ignoring assignment: %m");
- return 0;
- }
+ assert(rvalue);
r = route_type_from_string(rvalue);
if (r < 0)
return log_syntax_parse_error(unit, filename, line, r, lvalue, rvalue);
- route->type = (unsigned char) r;
-
- TAKE_PTR(route);
- return 0;
+ *p = (unsigned char) r;
+ return 1;
}
int config_parse_route_section(
void *userdata) {
static const ConfigSectionParser table[_ROUTE_CONF_PARSER_MAX] = {
+ [ROUTE_DESTINATION] = { .parser = config_parse_route_destination, .ltype = 0, .offset = 0, },
+ [ROUTE_PREFERRED_SOURCE] = { .parser = config_parse_preferred_src, .ltype = 0, .offset = 0, },
+ [ROUTE_PRIORITY] = { .parser = config_parse_route_priority, .ltype = 0, .offset = 0, },
+ [ROUTE_SCOPE] = { .parser = config_parse_route_scope, .ltype = 0, .offset = 0, },
+ [ROUTE_TABLE] = { .parser = config_parse_route_table, .ltype = 0, .offset = 0, },
+ [ROUTE_PREFERENCE] = { .parser = config_parse_route_preference, .ltype = 0, .offset = 0, },
+ [ROUTE_PROTOCOL] = { .parser = config_parse_route_protocol, .ltype = 0, .offset = offsetof(Route, protocol), },
+ [ROUTE_TYPE] = { .parser = config_parse_route_type, .ltype = 0, .offset = offsetof(Route, type), },
[ROUTE_GATEWAY_NETWORK] = { .parser = config_parse_gateway, .ltype = 0, .offset = 0, },
[ROUTE_GATEWAY] = { .parser = config_parse_gateway, .ltype = 1, .offset = 0, },
[ROUTE_GATEWAY_ONLINK] = { .parser = config_parse_tristate, .ltype = 0, .offset = offsetof(Route, gateway_onlink), },