1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-06 08:26:52 +03:00

network: refuse the case To= and From= are in different address family

This commit is contained in:
Yu Watanabe 2019-08-02 05:07:40 +09:00
parent 3a2acd9ee0
commit 0aabccc87d
3 changed files with 16 additions and 3 deletions

View File

@ -281,7 +281,7 @@ int network_verify(Network *network) {
prefix_free(prefix);
LIST_FOREACH_SAFE(rules, rule, rule_next, network->rules)
if (section_is_invalid(rule->section))
if (routing_policy_rule_section_verify(rule) < 0)
routing_policy_rule_free(rule);
return 0;

View File

@ -23,7 +23,6 @@ int routing_policy_rule_new(RoutingPolicyRule **ret) {
return -ENOMEM;
*rule = (RoutingPolicyRule) {
.family = AF_INET,
.table = RT_TABLE_MAIN,
};
@ -555,6 +554,16 @@ int routing_policy_rule_configure(RoutingPolicyRule *rule, Link *link, link_netl
return 1;
}
int routing_policy_rule_section_verify(RoutingPolicyRule *rule) {
if (section_is_invalid(rule->section))
return -EINVAL;
if (rule->family == AF_UNSPEC)
rule->family = AF_INET;
return 0;
}
static int parse_fwmark_fwmask(const char *s, uint32_t *fwmark, uint32_t *fwmask) {
_cleanup_free_ char *f = NULL;
char *p;
@ -767,7 +776,10 @@ int config_parse_routing_policy_rule_prefix(
prefixlen = &n->from_prefixlen;
}
if (n->family == AF_UNSPEC)
r = in_addr_prefix_from_string_auto(rvalue, &n->family, buffer, prefixlen);
else
r = in_addr_prefix_from_string(rvalue, n->family, buffer, prefixlen);
if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "RPDB rule prefix is invalid, ignoring assignment: %s", rvalue);
return 0;

View File

@ -56,6 +56,7 @@ int routing_policy_rule_new(RoutingPolicyRule **ret);
void routing_policy_rule_free(RoutingPolicyRule *rule);
DEFINE_NETWORK_SECTION_FUNCTIONS(RoutingPolicyRule, routing_policy_rule_free);
int routing_policy_rule_section_verify(RoutingPolicyRule *rule);
int routing_policy_rule_configure(RoutingPolicyRule *address, Link *link, link_netlink_message_handler_t callback);
int routing_policy_rule_remove(RoutingPolicyRule *routing_policy_rule, Link *link, link_netlink_message_handler_t callback);