]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: set RoutingPolicyRule::family based on Family= setting
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 29 Dec 2020 18:07:33 +0000 (03:07 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 29 Dec 2020 18:19:07 +0000 (03:19 +0900)
src/network/networkd-routing-policy-rule.c

index 79c4b9adcd971551b272888f47f18531dc98f7e1..0012a4bfa94cb6e33e7e60ee3734410c41d7157b 100644 (file)
@@ -1553,8 +1553,13 @@ static int routing_policy_rule_section_verify(RoutingPolicyRule *rule) {
                                 "specified by To= or From=. Ignoring [RoutingPolicyRule] section from line %u.",
                                 rule->section->filename, rule->section->line);
 
-        if (rule->family == AF_UNSPEC && rule->address_family == ADDRESS_FAMILY_NO)
-                rule->family = AF_INET;
+        if (rule->family == AF_UNSPEC) {
+                if (IN_SET(rule->address_family, ADDRESS_FAMILY_IPV4, ADDRESS_FAMILY_NO))
+                        rule->family = AF_INET;
+                else if (rule->address_family == ADDRESS_FAMILY_IPV6)
+                        rule->family = AF_INET6;
+                /* rule->family can be AF_UNSPEC only when Family=both. */
+        }
 
         /* Currently, [RoutingPolicyRule] does not have a setting to set FRA_L3MDEV flag. Please also
          * update routing_policy_rule_is_created_by_kernel() when a new setting which sets the flag is