]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network/routing-policy-rule: fix compare func
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 5 Feb 2025 00:14:51 +0000 (09:14 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 5 Feb 2025 00:14:54 +0000 (09:14 +0900)
Previously, when comparing an existing and requested routing policy
rules, `all` flag was unset, thus the from and to addresses in the two
rules were not compared. Hence, a new request with from and/or to
addresses might be considered as it already exists even the addresses of
existing one were different from the newly requested one.

All existing rules have valid family, i.e. AF_INET or AF_INET6. And,
all requesting rules with from and/or to addresses also have a valid
family. Hence, even `all` flag is unset, the addresses can be and must
be compared in that case.

Fixes a regression caused by fc58350aa464cd2414b6fe9fec089412120c7d52 (v257).
Fixes #35874.

src/network/networkd-routing-policy-rule.c

index 87dcaa4fc44b7896a9f67868c1718ef7d0ce9376..0c95b7d34fdfbb9fcebfe84b60ff906ad1206aa4 100644 (file)
@@ -318,7 +318,7 @@ static int routing_policy_rule_compare_func_full(const RoutingPolicyRule *a, con
         if (r != 0)
                 return r;
 
-        if (all) {
+        if (a->family == b->family && a->family != AF_UNSPEC) {
                 r = memcmp(&a->from.address, &b->from.address, FAMILY_ADDRESS_SIZE(a->family));
                 if (r != 0)
                         return r;