]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/network/networkd-network.c
networkd: add support to configure IP Rule (#5725)
[thirdparty/systemd.git] / src / network / networkd-network.c
index 3b52a8a5b96f97d19d03f3f1e7bbcb855181cd4c..1694b1e5eb53f7444ec140cf58affe6ca1930ae9 100644 (file)
@@ -77,7 +77,7 @@ int network_config_section_new(const char *filename, unsigned line, NetworkConfi
 }
 
 void network_config_section_free(NetworkConfigSection *cs) {
-          free(cs);
+        free(cs);
 }
 
 /* Set defaults following RFC7844 */
@@ -157,6 +157,7 @@ static int network_load_one(Manager *manager, const char *filename) {
         LIST_HEAD_INIT(network->ipv6_proxy_ndp_addresses);
         LIST_HEAD_INIT(network->address_labels);
         LIST_HEAD_INIT(network->static_prefixes);
+        LIST_HEAD_INIT(network->rules);
 
         network->stacked_netdevs = hashmap_new(&string_hash_ops);
         if (!network->stacked_netdevs)
@@ -182,6 +183,10 @@ static int network_load_one(Manager *manager, const char *filename) {
         if (!network->prefixes_by_section)
                 return log_oom();
 
+        network->rules_by_section = hashmap_new(&network_config_hash_ops);
+        if (!network->rules_by_section)
+                return log_oom();
+
         network->filename = strdup(filename);
         if (!network->filename)
                 return log_oom();
@@ -258,6 +263,7 @@ static int network_load_one(Manager *manager, const char *filename) {
                               "Network\0"
                               "Address\0"
                               "IPv6AddressLabel\0"
+                              "RoutingPolicyRule\0"
                               "Route\0"
                               "DHCP\0"
                               "DHCPv4\0" /* compat */
@@ -336,13 +342,14 @@ int network_load(Manager *manager) {
 }
 
 void network_free(Network *network) {
-        NetDev *netdev;
-        Route *route;
-        Address *address;
-        FdbEntry *fdb_entry;
         IPv6ProxyNDPAddress *ipv6_proxy_ndp_address;
+        RoutingPolicyRule *rule;
+        FdbEntry *fdb_entry;
         AddressLabel *label;
         Prefix *prefix;
+        Address *address;
+        NetDev *netdev;
+        Route *route;
         Iterator i;
 
         if (!network)
@@ -396,11 +403,15 @@ void network_free(Network *network) {
         while ((prefix = network->static_prefixes))
                 prefix_free(prefix);
 
+        while ((rule = network->rules))
+                routing_policy_rule_free(rule);
+
         hashmap_free(network->addresses_by_section);
         hashmap_free(network->routes_by_section);
         hashmap_free(network->fdb_entries_by_section);
         hashmap_free(network->address_labels_by_section);
         hashmap_free(network->prefixes_by_section);
+        hashmap_free(network->rules_by_section);
 
         if (network->manager) {
                 if (network->manager->networks)
@@ -746,7 +757,7 @@ int config_parse_tunnel(const char *unit,
             netdev->kind != NETDEV_KIND_VTI &&
             netdev->kind != NETDEV_KIND_VTI6 &&
             netdev->kind != NETDEV_KIND_IP6TNL
-            ) {
+        ) {
                 log_syntax(unit, LOG_ERR, filename, line, 0,
                            "NetDev is not a tunnel, ignoring assignment: %s", rvalue);
                 return 0;