int manager_rtnl_process_rule(sd_netlink *rtnl, sd_netlink_message *message, void *userdata) {
uint8_t tos = 0, to_prefixlen = 0, from_prefixlen = 0;
+ union in_addr_union to = {}, from = {};
RoutingPolicyRule *rule = NULL;
- union in_addr_union to, from;
uint32_t fwmark = 0, table = 0;
+ char *iif = NULL, *oif = NULL;
Manager *m = userdata;
- char *iif, *oif;
uint16_t type;
int family;
int r;
network_config_section_free(rule->section);
}
- if (rule->network->manager) {
- set_remove(rule->network->manager->rules, rule);
- set_remove(rule->network->manager->rules_foreign, rule);
- }
+ }
+
+ if (rule->m) {
+ set_remove(rule->m->rules, rule);
+ set_remove(rule->m->rules_foreign, rule);
}
free(rule->iif);
return -ENOENT;
}
-static int routing_policy_rule_add_internal(Set **rules,
+static int routing_policy_rule_add_internal(Manager *m,
+ Set **rules,
int family,
const union in_addr_union *from,
uint8_t from_prefixlen,
if (r < 0)
return r;
+ rule->m = m;
rule->family = family;
rule->from = *from;
rule->from_prefixlen = from_prefixlen;
char *oif,
RoutingPolicyRule **ret) {
- return routing_policy_rule_add_internal(&m->rules, family, from, from_prefixlen, to, to_prefixlen, tos, fwmark, table, iif, oif, ret);
+ return routing_policy_rule_add_internal(m, &m->rules, family, from, from_prefixlen, to, to_prefixlen, tos, fwmark, table, iif, oif, ret);
}
int routing_policy_rule_add_foreign(Manager *m,
char *iif,
char *oif,
RoutingPolicyRule **ret) {
- return routing_policy_rule_add_internal(&m->rules_foreign, family, from, from_prefixlen, to, to_prefixlen, tos, fwmark, table, iif, oif, ret);
+ return routing_policy_rule_add_internal(m, &m->rules_foreign, family, from, from_prefixlen, to, to_prefixlen, tos, fwmark, table, iif, oif, ret);
}
static int routing_policy_rule_remove_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata) {