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:
parent
3a2acd9ee0
commit
0aabccc87d
@ -281,7 +281,7 @@ int network_verify(Network *network) {
|
|||||||
prefix_free(prefix);
|
prefix_free(prefix);
|
||||||
|
|
||||||
LIST_FOREACH_SAFE(rules, rule, rule_next, network->rules)
|
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);
|
routing_policy_rule_free(rule);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -23,7 +23,6 @@ int routing_policy_rule_new(RoutingPolicyRule **ret) {
|
|||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
*rule = (RoutingPolicyRule) {
|
*rule = (RoutingPolicyRule) {
|
||||||
.family = AF_INET,
|
|
||||||
.table = RT_TABLE_MAIN,
|
.table = RT_TABLE_MAIN,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -555,6 +554,16 @@ int routing_policy_rule_configure(RoutingPolicyRule *rule, Link *link, link_netl
|
|||||||
return 1;
|
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) {
|
static int parse_fwmark_fwmask(const char *s, uint32_t *fwmark, uint32_t *fwmask) {
|
||||||
_cleanup_free_ char *f = NULL;
|
_cleanup_free_ char *f = NULL;
|
||||||
char *p;
|
char *p;
|
||||||
@ -767,7 +776,10 @@ int config_parse_routing_policy_rule_prefix(
|
|||||||
prefixlen = &n->from_prefixlen;
|
prefixlen = &n->from_prefixlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (n->family == AF_UNSPEC)
|
||||||
r = in_addr_prefix_from_string_auto(rvalue, &n->family, buffer, prefixlen);
|
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) {
|
if (r < 0) {
|
||||||
log_syntax(unit, LOG_ERR, filename, line, r, "RPDB rule prefix is invalid, ignoring assignment: %s", rvalue);
|
log_syntax(unit, LOG_ERR, filename, line, r, "RPDB rule prefix is invalid, ignoring assignment: %s", rvalue);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -56,6 +56,7 @@ int routing_policy_rule_new(RoutingPolicyRule **ret);
|
|||||||
void routing_policy_rule_free(RoutingPolicyRule *rule);
|
void routing_policy_rule_free(RoutingPolicyRule *rule);
|
||||||
|
|
||||||
DEFINE_NETWORK_SECTION_FUNCTIONS(RoutingPolicyRule, routing_policy_rule_free);
|
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_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);
|
int routing_policy_rule_remove(RoutingPolicyRule *routing_policy_rule, Link *link, link_netlink_message_handler_t callback);
|
||||||
|
Loading…
Reference in New Issue
Block a user