mirror of
https://github.com/systemd/systemd.git
synced 2025-03-31 14:50:15 +03:00
networkd: use same order in _hash_func() and _compare_func()
This makes it easier to see that the same data is handled in both cases. No functional change.
This commit is contained in:
parent
24be91817f
commit
67e05dd8cd
@ -157,11 +157,14 @@ static void route_hash_func(const Route *route, struct siphash *state) {
|
||||
switch (route->family) {
|
||||
case AF_INET:
|
||||
case AF_INET6:
|
||||
siphash24_compress(&route->gw, FAMILY_ADDRESS_SIZE(route->family), state);
|
||||
siphash24_compress(&route->dst, FAMILY_ADDRESS_SIZE(route->family), state);
|
||||
siphash24_compress(&route->dst_prefixlen, sizeof(route->dst_prefixlen), state);
|
||||
siphash24_compress(&route->src, FAMILY_ADDRESS_SIZE(route->family), state);
|
||||
siphash24_compress(&route->dst, FAMILY_ADDRESS_SIZE(route->family), state);
|
||||
|
||||
siphash24_compress(&route->src_prefixlen, sizeof(route->src_prefixlen), state);
|
||||
siphash24_compress(&route->src, FAMILY_ADDRESS_SIZE(route->family), state);
|
||||
|
||||
siphash24_compress(&route->gw, FAMILY_ADDRESS_SIZE(route->family), state);
|
||||
|
||||
siphash24_compress(&route->prefsrc, FAMILY_ADDRESS_SIZE(route->family), state);
|
||||
|
||||
siphash24_compress(&route->tos, sizeof(route->tos), state);
|
||||
@ -170,6 +173,7 @@ static void route_hash_func(const Route *route, struct siphash *state) {
|
||||
siphash24_compress(&route->protocol, sizeof(route->protocol), state);
|
||||
siphash24_compress(&route->scope, sizeof(route->scope), state);
|
||||
siphash24_compress(&route->type, sizeof(route->type), state);
|
||||
|
||||
siphash24_compress(&route->initcwnd, sizeof(route->initcwnd), state);
|
||||
siphash24_compress(&route->initrwnd, sizeof(route->initrwnd), state);
|
||||
|
||||
@ -194,10 +198,26 @@ static int route_compare_func(const Route *a, const Route *b) {
|
||||
if (r != 0)
|
||||
return r;
|
||||
|
||||
r = memcmp(&a->dst, &b->dst, FAMILY_ADDRESS_SIZE(a->family));
|
||||
if (r != 0)
|
||||
return r;
|
||||
|
||||
r = CMP(a->src_prefixlen, b->src_prefixlen);
|
||||
if (r != 0)
|
||||
return r;
|
||||
|
||||
r = memcmp(&a->src, &b->src, FAMILY_ADDRESS_SIZE(a->family));
|
||||
if (r != 0)
|
||||
return r;
|
||||
|
||||
r = memcmp(&a->gw, &b->gw, FAMILY_ADDRESS_SIZE(a->family));
|
||||
if (r != 0)
|
||||
return r;
|
||||
|
||||
r = memcmp(&a->prefsrc, &b->prefsrc, FAMILY_ADDRESS_SIZE(a->family));
|
||||
if (r != 0)
|
||||
return r;
|
||||
|
||||
r = CMP(a->tos, b->tos);
|
||||
if (r != 0)
|
||||
return r;
|
||||
@ -230,19 +250,7 @@ static int route_compare_func(const Route *a, const Route *b) {
|
||||
if (r != 0)
|
||||
return r;
|
||||
|
||||
r = memcmp(&a->gw, &b->gw, FAMILY_ADDRESS_SIZE(a->family));
|
||||
if (r != 0)
|
||||
return r;
|
||||
|
||||
r = memcmp(&a->dst, &b->dst, FAMILY_ADDRESS_SIZE(a->family));
|
||||
if (r != 0)
|
||||
return r;
|
||||
|
||||
r = memcmp(&a->src, &b->src, FAMILY_ADDRESS_SIZE(a->family));
|
||||
if (r != 0)
|
||||
return r;
|
||||
|
||||
return memcmp(&a->prefsrc, &b->prefsrc, FAMILY_ADDRESS_SIZE(a->family));
|
||||
return 0;
|
||||
default:
|
||||
/* treat any other address family as AF_UNSPEC */
|
||||
return 0;
|
||||
|
@ -105,7 +105,6 @@ static void routing_policy_rule_hash_func(const RoutingPolicyRule *rule, struct
|
||||
switch (rule->family) {
|
||||
case AF_INET:
|
||||
case AF_INET6:
|
||||
|
||||
siphash24_compress(&rule->from, FAMILY_ADDRESS_SIZE(rule->family), state);
|
||||
siphash24_compress(&rule->from_prefixlen, sizeof(rule->from_prefixlen), state);
|
||||
|
||||
@ -151,10 +150,18 @@ static int routing_policy_rule_compare_func(const RoutingPolicyRule *a, const Ro
|
||||
if (r != 0)
|
||||
return r;
|
||||
|
||||
r = memcmp(&a->from, &b->from, FAMILY_ADDRESS_SIZE(a->family));
|
||||
if (r != 0)
|
||||
return r;
|
||||
|
||||
r = CMP(a->to_prefixlen, b->to_prefixlen);
|
||||
if (r != 0)
|
||||
return r;
|
||||
|
||||
r = memcmp(&a->to, &b->to, FAMILY_ADDRESS_SIZE(a->family));
|
||||
if (r != 0)
|
||||
return r;
|
||||
|
||||
r = CMP(a->invert_rule, b->invert_rule);
|
||||
if (r != 0)
|
||||
return r;
|
||||
@ -179,14 +186,6 @@ static int routing_policy_rule_compare_func(const RoutingPolicyRule *a, const Ro
|
||||
if (r != 0)
|
||||
return r;
|
||||
|
||||
r = strcmp_ptr(a->iif, b->iif);
|
||||
if (!r)
|
||||
return r;
|
||||
|
||||
r = strcmp_ptr(a->oif, b->oif);
|
||||
if (!r)
|
||||
return r;
|
||||
|
||||
r = CMP(a->protocol, b->protocol);
|
||||
if (r != 0)
|
||||
return r;
|
||||
@ -199,12 +198,15 @@ static int routing_policy_rule_compare_func(const RoutingPolicyRule *a, const Ro
|
||||
if (r != 0)
|
||||
return r;
|
||||
|
||||
r = memcmp(&a->from, &b->from, FAMILY_ADDRESS_SIZE(a->family));
|
||||
if (r != 0)
|
||||
r = strcmp_ptr(a->iif, b->iif);
|
||||
if (!r)
|
||||
return r;
|
||||
|
||||
return memcmp(&a->to, &b->to, FAMILY_ADDRESS_SIZE(a->family));
|
||||
r = strcmp_ptr(a->oif, b->oif);
|
||||
if (!r)
|
||||
return r;
|
||||
|
||||
return 0;
|
||||
default:
|
||||
/* treat any other address family as AF_UNSPEC */
|
||||
return 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user