network: make routing_policy_rule_new() static
This commit is contained in:
parent
51a0dc4a15
commit
f1828a222a
|
@ -19,7 +19,32 @@
|
|||
#include "strv.h"
|
||||
#include "user-util.h"
|
||||
|
||||
int routing_policy_rule_new(RoutingPolicyRule **ret) {
|
||||
RoutingPolicyRule *routing_policy_rule_free(RoutingPolicyRule *rule) {
|
||||
if (!rule)
|
||||
return NULL;
|
||||
|
||||
if (rule->network) {
|
||||
assert(rule->section);
|
||||
hashmap_remove(rule->network->rules_by_section, rule->section);
|
||||
}
|
||||
|
||||
if (rule->manager) {
|
||||
if (set_get(rule->manager->rules, rule) == rule)
|
||||
set_remove(rule->manager->rules, rule);
|
||||
if (set_get(rule->manager->rules_foreign, rule) == rule)
|
||||
set_remove(rule->manager->rules_foreign, rule);
|
||||
}
|
||||
|
||||
network_config_section_free(rule->section);
|
||||
free(rule->iif);
|
||||
free(rule->oif);
|
||||
|
||||
return mfree(rule);
|
||||
}
|
||||
|
||||
DEFINE_NETWORK_SECTION_FUNCTIONS(RoutingPolicyRule, routing_policy_rule_free);
|
||||
|
||||
static int routing_policy_rule_new(RoutingPolicyRule **ret) {
|
||||
RoutingPolicyRule *rule;
|
||||
|
||||
rule = new(RoutingPolicyRule, 1);
|
||||
|
@ -76,29 +101,6 @@ static int routing_policy_rule_new_static(Network *network, const char *filename
|
|||
return 0;
|
||||
}
|
||||
|
||||
RoutingPolicyRule *routing_policy_rule_free(RoutingPolicyRule *rule) {
|
||||
if (!rule)
|
||||
return NULL;
|
||||
|
||||
if (rule->network) {
|
||||
assert(rule->section);
|
||||
hashmap_remove(rule->network->rules_by_section, rule->section);
|
||||
}
|
||||
|
||||
if (rule->manager) {
|
||||
if (set_get(rule->manager->rules, rule) == rule)
|
||||
set_remove(rule->manager->rules, rule);
|
||||
if (set_get(rule->manager->rules_foreign, rule) == rule)
|
||||
set_remove(rule->manager->rules_foreign, rule);
|
||||
}
|
||||
|
||||
network_config_section_free(rule->section);
|
||||
free(rule->iif);
|
||||
free(rule->oif);
|
||||
|
||||
return mfree(rule);
|
||||
}
|
||||
|
||||
static int routing_policy_rule_copy(RoutingPolicyRule *dest, RoutingPolicyRule *src) {
|
||||
_cleanup_free_ char *iif = NULL, *oif = NULL;
|
||||
|
||||
|
|
|
@ -49,10 +49,7 @@ typedef struct RoutingPolicyRule {
|
|||
int suppress_prefixlen;
|
||||
} RoutingPolicyRule;
|
||||
|
||||
int routing_policy_rule_new(RoutingPolicyRule **ret);
|
||||
RoutingPolicyRule *routing_policy_rule_free(RoutingPolicyRule *rule);
|
||||
|
||||
DEFINE_NETWORK_SECTION_FUNCTIONS(RoutingPolicyRule, routing_policy_rule_free);
|
||||
int routing_policy_rule_section_verify(RoutingPolicyRule *rule);
|
||||
|
||||
int link_set_routing_policy_rules(Link *link);
|
||||
|
|
Loading…
Reference in a new issue