]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Fix #7704 and #7708. (#7712)
authorSusant Sahani <145210+ssahani@users.noreply.github.com>
Thu, 21 Dec 2017 12:27:45 +0000 (17:57 +0530)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 21 Dec 2017 12:27:45 +0000 (21:27 +0900)
Init rule variable iif oif and to, from

While foreign rules are added the network part is not attached.
attach manager to rules and use it in routing_policy_rule_free.

src/network/networkd-manager.c
src/network/networkd-route.h
src/network/networkd-routing-policy-rule.c
src/network/networkd-routing-policy-rule.h

index cc17af9391be6f950aadb0121bc51dd9ae8c5c70..186f9ce33ea253c48f81947be505ac08654f3198 100644 (file)
@@ -726,11 +726,11 @@ static int manager_rtnl_process_link(sd_netlink *rtnl, sd_netlink_message *messa
 
 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;
index cfb85cbd6d3712f48e176fbb6ccfb4426e931b77..cde31c96633b9640defe5c8b7929bd20499d1468 100644 (file)
@@ -26,6 +26,7 @@ typedef struct NetworkConfigSection NetworkConfigSection;
 #include "networkd-network.h"
 
 struct Route {
+        Manager *m;
         Network *network;
         NetworkConfigSection *section;
 
index 1314564c1107a61e6d49b5c12738bb00046e3fc6..1019b3980779457a59962648da8d19bee3959c7e 100644 (file)
@@ -60,10 +60,11 @@ void routing_policy_rule_free(RoutingPolicyRule *rule) {
                         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);
@@ -236,7 +237,8 @@ int routing_policy_rule_make_local(Manager *m, RoutingPolicyRule *rule) {
         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,
@@ -258,6 +260,7 @@ static int routing_policy_rule_add_internal(Set **rules,
         if (r < 0)
                 return r;
 
+        rule->m = m;
         rule->family = family;
         rule->from = *from;
         rule->from_prefixlen = from_prefixlen;
@@ -298,7 +301,7 @@ int routing_policy_rule_add(Manager *m,
                             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,
@@ -313,7 +316,7 @@ 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) {
index 70a861723bb9bf17b9e1e0f683b67fcc9db90dbd..a56a2a52ef4514fdd5cb346bcf29fb806810fd13 100644 (file)
@@ -33,8 +33,10 @@ typedef struct RoutingPolicyRule RoutingPolicyRule;
 typedef struct Network Network;
 typedef struct Link Link;
 typedef struct NetworkConfigSection NetworkConfigSection;
+typedef struct Manager Manager;
 
 struct RoutingPolicyRule {
+        Manager *m;
         Network *network;
         Link *link;
         NetworkConfigSection *section;