mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-12-25 23:21:33 +03:00
networkd: unbork rule serialization
We'd write something like RULE=from=250.250.240.0/24 to=(null)/0 tos=0 fwmark=0/0 table=12 RULE=from=250.250.250.0/24 to=(null)/0 tos=0 fwmark=0/0 table=11
This commit is contained in:
parent
401e33ed56
commit
cfc4529b01
@ -1005,7 +1005,6 @@ static void print_string_set(FILE *f, const char *field, OrderedSet *s) {
|
||||
static int manager_save(Manager *m) {
|
||||
_cleanup_ordered_set_free_free_ OrderedSet *dns = NULL, *ntp = NULL, *search_domains = NULL, *route_domains = NULL;
|
||||
RoutingPolicyRule *rule = NULL;
|
||||
bool space = false;
|
||||
Link *link;
|
||||
Iterator i;
|
||||
_cleanup_free_ char *temp_path = NULL;
|
||||
@ -1132,28 +1131,48 @@ static int manager_save(Manager *m) {
|
||||
|
||||
SET_FOREACH(rule, m->rules, i) {
|
||||
_cleanup_free_ char *from_str = NULL, *to_str = NULL;
|
||||
bool space = false;
|
||||
|
||||
fputs("RULE=", f);
|
||||
|
||||
if (!in_addr_is_null(rule->family, &rule->from)) {
|
||||
r = in_addr_to_string(rule->family, &rule->from, &from_str);
|
||||
if (r < 0)
|
||||
goto fail;
|
||||
|
||||
fprintf(f, "from=%s/%hhu",
|
||||
from_str, rule->from_prefixlen);
|
||||
space = true;
|
||||
}
|
||||
|
||||
if (!in_addr_is_null(rule->family, &rule->to)) {
|
||||
r = in_addr_to_string(rule->family, &rule->to, &to_str);
|
||||
if (r < 0)
|
||||
goto fail;
|
||||
|
||||
fprintf(f, "%sto=%s/%hhu",
|
||||
space ? " " : "",
|
||||
to_str, rule->to_prefixlen);
|
||||
space = true;
|
||||
}
|
||||
|
||||
fprintf(f, "from=%s%s/%hhu to=%s%s/%hhu tos=%hhu fwmark=%"PRIu32"/%"PRIu32" table=%"PRIu32,
|
||||
space ? " " : "", from_str, rule->from_prefixlen,
|
||||
space ? " " : "", to_str, rule->to_prefixlen,
|
||||
rule->tos,
|
||||
rule->fwmark, rule->fwmask,
|
||||
rule->table);
|
||||
if (rule->tos != 0) {
|
||||
fprintf(f, "%stos=%hhu",
|
||||
space ? " " : "",
|
||||
rule->tos);
|
||||
space = true;
|
||||
}
|
||||
|
||||
fputc('\n', f);
|
||||
if (rule->fwmark != 0) {
|
||||
fprintf(f, "%sfwmark=%"PRIu32"/%"PRIu32,
|
||||
space ? " " : "",
|
||||
rule->fwmark, rule->fwmask);
|
||||
space = true;
|
||||
}
|
||||
|
||||
fprintf(f, "%stable=%"PRIu32 "\n",
|
||||
space ? " " : "",
|
||||
rule->table);
|
||||
}
|
||||
|
||||
r = fflush_and_check(f);
|
||||
|
@ -885,9 +885,6 @@ int routing_policy_rule_load(Manager *m) {
|
||||
if (!p)
|
||||
continue;
|
||||
|
||||
p = strchr(*i, '=');
|
||||
p++;
|
||||
|
||||
r = routing_policy_rule_new(&rule);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
Loading…
Reference in New Issue
Block a user