From: Yu Watanabe Date: Tue, 20 Oct 2020 06:32:36 +0000 (+0900) Subject: network: also compare and hash weight of the gateway X-Git-Tag: v247-rc1~29^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=40075951dc437b3f7ea9a56085e7efa78598e33f;p=thirdparty%2Fsystemd.git network: also compare and hash weight of the gateway --- diff --git a/src/network/networkd-route.c b/src/network/networkd-route.c index 34ede604056..85d540c32ab 100644 --- a/src/network/networkd-route.c +++ b/src/network/networkd-route.c @@ -299,9 +299,10 @@ void route_hash_func(const Route *route, struct siphash *state) { siphash24_compress(&route->src, FAMILY_ADDRESS_SIZE(route->family), state); siphash24_compress(&route->gw_family, sizeof(route->gw_family), state); - if (IN_SET(route->gw_family, AF_INET, AF_INET6)) + if (IN_SET(route->gw_family, AF_INET, AF_INET6)) { siphash24_compress(&route->gw, FAMILY_ADDRESS_SIZE(route->gw_family), state); - + siphash24_compress(&route->gw_weight, sizeof(route->gw_weight), state); + } siphash24_compress(&route->prefsrc, FAMILY_ADDRESS_SIZE(route->family), state); @@ -356,6 +357,10 @@ int route_compare_func(const Route *a, const Route *b) { r = memcmp(&a->gw, &b->gw, FAMILY_ADDRESS_SIZE(a->family)); if (r != 0) return r; + + r = CMP(a->gw_weight, b->gw_weight); + if (r != 0) + return r; } r = memcmp(&a->prefsrc, &b->prefsrc, FAMILY_ADDRESS_SIZE(a->family)); @@ -484,6 +489,7 @@ static void route_copy(Route *dest, const Route *src, const MultipathRoute *m) { } else { dest->gw_family = src->gw_family; dest->gw = src->gw; + dest->gw_weight = src->gw_weight; } }