Neighbor.LinkLayerAddress, config_parse_neighbor_lladdr, 0, 0
Neighbor.MACAddress, config_parse_neighbor_lladdr, 0, 0 /* deprecated */
RoutingPolicyRule.TypeOfService, config_parse_routing_policy_rule, ROUTING_POLICY_RULE_TOS, 0
-RoutingPolicyRule.Priority, config_parse_routing_policy_rule_priority, 0, 0
-RoutingPolicyRule.GoTo, config_parse_routing_policy_rule_goto, 0, 0
-RoutingPolicyRule.Table, config_parse_routing_policy_rule_table, 0, 0
-RoutingPolicyRule.FirewallMark, config_parse_routing_policy_rule_fwmark_mask, 0, 0
-RoutingPolicyRule.From, config_parse_routing_policy_rule_prefix, 0, 0
-RoutingPolicyRule.To, config_parse_routing_policy_rule_prefix, 0, 0
+RoutingPolicyRule.Priority, config_parse_routing_policy_rule, ROUTING_POLICY_RULE_PRIORITY, 0
+RoutingPolicyRule.GoTo, config_parse_routing_policy_rule, ROUTING_POLICY_RULE_GOTO, 0
+RoutingPolicyRule.Table, config_parse_routing_policy_rule, ROUTING_POLICY_RULE_TABLE, 0
+RoutingPolicyRule.FirewallMark, config_parse_routing_policy_rule, ROUTING_POLICY_RULE_FWMARK, 0
+RoutingPolicyRule.From, config_parse_routing_policy_rule, ROUTING_POLICY_RULE_PREFIX, 0
+RoutingPolicyRule.To, config_parse_routing_policy_rule, ROUTING_POLICY_RULE_PREFIX, 0
RoutingPolicyRule.IncomingInterface, config_parse_routing_policy_rule, ROUTING_POLICY_RULE_IIF, 0
RoutingPolicyRule.OutgoingInterface, config_parse_routing_policy_rule, ROUTING_POLICY_RULE_OIF, 0
RoutingPolicyRule.IPProtocol, config_parse_routing_policy_rule, ROUTING_POLICY_RULE_IP_PROTOCOL, 0
-RoutingPolicyRule.SourcePort, config_parse_routing_policy_rule_port_range, 0, 0
-RoutingPolicyRule.DestinationPort, config_parse_routing_policy_rule_port_range, 0, 0
+RoutingPolicyRule.SourcePort, config_parse_routing_policy_rule, ROUTING_POLICY_RULE_SPORT, 0
+RoutingPolicyRule.DestinationPort, config_parse_routing_policy_rule, ROUTING_POLICY_RULE_DPORT, 0
RoutingPolicyRule.InvertRule, config_parse_routing_policy_rule, ROUTING_POLICY_RULE_INVERT, 0
RoutingPolicyRule.L3MasterDevice, config_parse_routing_policy_rule, ROUTING_POLICY_RULE_L3MDEV, 0
RoutingPolicyRule.Family, config_parse_routing_policy_rule, ROUTING_POLICY_RULE_FAMILY, 0
-RoutingPolicyRule.User, config_parse_routing_policy_rule_uid_range, 0, 0
-RoutingPolicyRule.SuppressInterfaceGroup, config_parse_routing_policy_rule_suppress, INT32_MAX, 0
-RoutingPolicyRule.SuppressPrefixLength, config_parse_routing_policy_rule_suppress, 128, 0
-RoutingPolicyRule.Type, config_parse_routing_policy_rule_type, 0, 0
+RoutingPolicyRule.User, config_parse_routing_policy_rule, ROUTING_POLICY_RULE_UID_RANGE, 0
+RoutingPolicyRule.SuppressInterfaceGroup, config_parse_routing_policy_rule, ROUTING_POLICY_RULE_SUPPRESS_IFGROUP, 0
+RoutingPolicyRule.SuppressPrefixLength, config_parse_routing_policy_rule, ROUTING_POLICY_RULE_SUPPRESS_PREFIXLEN, 0
+RoutingPolicyRule.Type, config_parse_routing_policy_rule, ROUTING_POLICY_RULE_TYPE, 0
Route.Gateway, config_parse_gateway, 0, 0
Route.Destination, config_parse_destination, 0, 0
Route.Source, config_parse_destination, 0, 0
return 0;
}
-int config_parse_routing_policy_rule_priority(
+static int config_parse_routing_policy_rule_priority(
const char *unit,
const char *filename,
unsigned line,
void *data,
void *userdata) {
- _cleanup_(routing_policy_rule_unref_or_set_invalidp) RoutingPolicyRule *rule = NULL;
- Network *network = userdata;
+ RoutingPolicyRule *rule = ASSERT_PTR(userdata);
int r;
- assert(filename);
- assert(section);
- assert(lvalue);
- assert(rvalue);
- assert(data);
-
- r = routing_policy_rule_new_static(network, filename, section_line, &rule);
- if (r < 0)
- return log_oom();
-
if (isempty(rvalue)) {
rule->priority = 0;
rule->priority_set = false;
- TAKE_PTR(rule);
- return 0;
+ return 1;
}
r = safe_atou32(rvalue, &rule->priority);
log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse RPDB rule priority, ignoring: %s", rvalue);
return 0;
}
- rule->priority_set = true;
- TAKE_PTR(rule);
- return 0;
+ rule->priority_set = true;
+ return 1;
}
-int config_parse_routing_policy_rule_goto(
+static int config_parse_routing_policy_rule_goto(
const char *unit,
const char *filename,
unsigned line,
void *data,
void *userdata) {
- _cleanup_(routing_policy_rule_unref_or_set_invalidp) RoutingPolicyRule *rule = NULL;
- Network *network = ASSERT_PTR(userdata);
+ RoutingPolicyRule *rule = ASSERT_PTR(userdata);
uint32_t priority;
int r;
- assert(filename);
assert(lvalue);
assert(rvalue);
- r = routing_policy_rule_new_static(network, filename, section_line, &rule);
- if (r < 0)
- return log_oom();
-
r = safe_atou32(rvalue, &priority);
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse %s=%s, ignoring assignment: %m", lvalue, rvalue);
rule->type = FR_ACT_GOTO;
rule->priority_goto = priority;
-
- TAKE_PTR(rule);
- return 0;
+ return 1;
}
-int config_parse_routing_policy_rule_table(
+static int config_parse_routing_policy_rule_table(
const char *unit,
const char *filename,
unsigned line,
void *data,
void *userdata) {
- _cleanup_(routing_policy_rule_unref_or_set_invalidp) RoutingPolicyRule *rule = NULL;
- Network *network = userdata;
+ RoutingPolicyRule *rule = ASSERT_PTR(userdata);
+ Manager *manager = ASSERT_PTR(ASSERT_PTR(rule->network)->manager);
+ uint32_t *table = ASSERT_PTR(data);
int r;
- assert(filename);
- assert(section);
- assert(lvalue);
assert(rvalue);
- assert(data);
- r = routing_policy_rule_new_static(network, filename, section_line, &rule);
- if (r < 0)
- return log_oom();
-
- r = manager_get_route_table_from_string(network->manager, rvalue, &rule->table);
+ r = manager_get_route_table_from_string(manager, rvalue, table);
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r,
"Could not parse RPDB rule route table \"%s\", ignoring assignment: %m", rvalue);
return 0;
}
- TAKE_PTR(rule);
- return 0;
+ return 1;
}
-int config_parse_routing_policy_rule_fwmark_mask(
+static int config_parse_routing_policy_rule_fwmark(
const char *unit,
const char *filename,
unsigned line,
void *data,
void *userdata) {
- _cleanup_(routing_policy_rule_unref_or_set_invalidp) RoutingPolicyRule *rule = NULL;
- Network *network = userdata;
+ RoutingPolicyRule *rule = ASSERT_PTR(userdata);
int r;
- assert(filename);
- assert(section);
- assert(lvalue);
assert(rvalue);
- assert(data);
-
- r = routing_policy_rule_new_static(network, filename, section_line, &rule);
- if (r < 0)
- return log_oom();
r = parse_fwmark_fwmask(rvalue, &rule->fwmark, &rule->fwmask);
if (r < 0) {
return 0;
}
- TAKE_PTR(rule);
- return 0;
+ return 1;
}
-int config_parse_routing_policy_rule_prefix(
+static int config_parse_routing_policy_rule_prefix(
const char *unit,
const char *filename,
unsigned line,
void *data,
void *userdata) {
- _cleanup_(routing_policy_rule_unref_or_set_invalidp) RoutingPolicyRule *rule = NULL;
- Network *network = userdata;
+ RoutingPolicyRule *rule = ASSERT_PTR(userdata);
union in_addr_union *buffer;
uint8_t *prefixlen;
int r;
- assert(filename);
assert(rvalue);
- r = routing_policy_rule_new_static(network, filename, section_line, &rule);
- if (r < 0)
- return log_oom();
-
if (streq_ptr(lvalue, "To")) {
buffer = &rule->to;
prefixlen = &rule->to_prefixlen;
return 0;
}
- TAKE_PTR(rule);
return 1;
}
-int config_parse_routing_policy_rule_port_range(
+static int config_parse_routing_policy_rule_port_range(
const char *unit,
const char *filename,
unsigned line,
void *data,
void *userdata) {
- _cleanup_(routing_policy_rule_unref_or_set_invalidp) RoutingPolicyRule *rule = NULL;
- Network *network = userdata;
- struct fib_rule_port_range *p;
+ struct fib_rule_port_range *p = ASSERT_PTR(data);
int r;
- assert(filename);
assert(rvalue);
- r = routing_policy_rule_new_static(network, filename, section_line, &rule);
- if (r < 0)
- return log_oom();
-
- if (streq_ptr(lvalue, "SourcePort"))
- p = &rule->sport;
- else if (streq_ptr(lvalue, "DestinationPort"))
- p = &rule->dport;
- else
- assert_not_reached();
-
r = parse_ip_port_range(rvalue, &p->start, &p->end, /* allow_zero = */ false);
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse routing policy rule port range '%s'", rvalue);
return 0;
}
- TAKE_PTR(rule);
return 1;
}
-int config_parse_routing_policy_rule_uid_range(
+static int config_parse_routing_policy_rule_uid_range(
const char *unit,
const char *filename,
unsigned line,
void *data,
void *userdata) {
- _cleanup_(routing_policy_rule_unref_or_set_invalidp) RoutingPolicyRule *rule = NULL;
- Network *network = userdata;
- struct fib_rule_uid_range *p;
+ struct fib_rule_uid_range *p = ASSERT_PTR(data);
int r;
- assert(filename);
assert(rvalue);
- r = routing_policy_rule_new_static(network, filename, section_line, &rule);
- if (r < 0)
- return log_oom();
-
- p = &rule->uid_range;
-
if (get_user_creds(&rvalue, &p->start, NULL, NULL, NULL, 0) >= 0) {
p->end = p->start;
- TAKE_PTR(rule);
return 1;
}
return 0;
}
- TAKE_PTR(rule);
return 1;
}
-int config_parse_routing_policy_rule_suppress(
+static int config_parse_routing_policy_rule_suppress(
const char *unit,
const char *filename,
unsigned line,
void *data,
void *userdata) {
- _cleanup_(routing_policy_rule_unref_or_set_invalidp) RoutingPolicyRule *rule = NULL;
- Network *network = userdata;
- int32_t val, *p;
+ int32_t val, *p = ASSERT_PTR(data);
int r;
- assert(filename);
assert(lvalue);
- r = routing_policy_rule_new_static(network, filename, section_line, &rule);
- if (r < 0)
- return log_oom();
-
- if (streq(lvalue, "SuppressPrefixLength"))
- p = &rule->suppress_prefixlen;
- else if (streq(lvalue, "SuppressInterfaceGroup"))
- p = &rule->suppress_ifgroup;
- else
- assert_not_reached();
-
if (isempty(rvalue)) {
*p = -1;
- TAKE_PTR(rule);
return 1;
}
}
*p = val;
- TAKE_PTR(rule);
return 1;
}
-int config_parse_routing_policy_rule_type(
+static int config_parse_routing_policy_rule_type(
const char *unit,
const char *filename,
unsigned line,
void *data,
void *userdata) {
- _cleanup_(routing_policy_rule_unref_or_set_invalidp) RoutingPolicyRule *rule = NULL;
- Network *network = userdata;
+ uint8_t *p = ASSERT_PTR(data);
int r;
- assert(filename);
- assert(section);
- assert(lvalue);
assert(rvalue);
- assert(data);
-
- r = routing_policy_rule_new_static(network, filename, section_line, &rule);
- if (r < 0)
- return log_oom();
r = fr_act_type_from_string(rvalue);
if (r < 0) {
return 0;
}
- rule->type = (uint8_t) r;
-
- TAKE_PTR(rule);
- return 0;
+ *p = (uint8_t) r;
+ return 1;
}
static DEFINE_CONFIG_PARSE_ENUM_WITH_DEFAULT(
[ROUTING_POLICY_RULE_IIF] = { .parser = config_parse_ifname, .ltype = 0, .offset = offsetof(RoutingPolicyRule, iif), },
[ROUTING_POLICY_RULE_OIF] = { .parser = config_parse_ifname, .ltype = 0, .offset = offsetof(RoutingPolicyRule, oif), },
[ROUTING_POLICY_RULE_FAMILY] = { .parser = config_parse_routing_policy_rule_family, .ltype = 0, .offset = offsetof(RoutingPolicyRule, address_family), },
+ [ROUTING_POLICY_RULE_FWMARK] = { .parser = config_parse_routing_policy_rule_fwmark, .ltype = 0, .offset = 0, },
+ [ROUTING_POLICY_RULE_GOTO] = { .parser = config_parse_routing_policy_rule_goto, .ltype = 0, .offset = 0, },
[ROUTING_POLICY_RULE_INVERT] = { .parser = config_parse_uint32_flag, .ltype = FIB_RULE_INVERT, .offset = offsetof(RoutingPolicyRule, flags), },
[ROUTING_POLICY_RULE_IP_PROTOCOL] = { .parser = config_parse_ip_protocol, .ltype = 0, .offset = offsetof(RoutingPolicyRule, ipproto), },
[ROUTING_POLICY_RULE_L3MDEV] = { .parser = config_parse_bool, .ltype = 0, .offset = offsetof(RoutingPolicyRule, l3mdev), },
+ [ROUTING_POLICY_RULE_SPORT] = { .parser = config_parse_routing_policy_rule_port_range, .ltype = 0, .offset = offsetof(RoutingPolicyRule, sport), },
+ [ROUTING_POLICY_RULE_DPORT] = { .parser = config_parse_routing_policy_rule_port_range, .ltype = 0, .offset = offsetof(RoutingPolicyRule, dport), },
+ [ROUTING_POLICY_RULE_PREFIX] = { .parser = config_parse_routing_policy_rule_prefix, .ltype = 0, .offset = 0, },
+ [ROUTING_POLICY_RULE_PRIORITY] = { .parser = config_parse_routing_policy_rule_priority, .ltype = 0, .offset = 0, },
+ [ROUTING_POLICY_RULE_SUPPRESS_IFGROUP] = { .parser = config_parse_routing_policy_rule_suppress, .ltype = INT32_MAX, .offset = offsetof(RoutingPolicyRule, suppress_ifgroup), },
+ [ROUTING_POLICY_RULE_SUPPRESS_PREFIXLEN] = { .parser = config_parse_routing_policy_rule_suppress, .ltype = 128, .offset = offsetof(RoutingPolicyRule, suppress_prefixlen), },
+ [ROUTING_POLICY_RULE_TABLE] = { .parser = config_parse_routing_policy_rule_table, .ltype = 0, .offset = offsetof(RoutingPolicyRule, table), },
[ROUTING_POLICY_RULE_TOS] = { .parser = config_parse_uint8, .ltype = 0, .offset = offsetof(RoutingPolicyRule, tos), },
+ [ROUTING_POLICY_RULE_TYPE] = { .parser = config_parse_routing_policy_rule_type, .ltype = 0, .offset = offsetof(RoutingPolicyRule, type), },
+ [ROUTING_POLICY_RULE_UID_RANGE] = { .parser = config_parse_routing_policy_rule_uid_range, .ltype = 0, .offset = offsetof(RoutingPolicyRule, uid_range), },
};
int config_parse_routing_policy_rule(