1
0
mirror of https://github.com/systemd/systemd.git synced 2025-03-24 14:50:17 +03:00

networkd: make neighbor_hash_func() handle the same data as neighbor_compare_func()

In practice this probably makes little difference, because we only use AF_INET
and AF_INET6, but it's cleaner to use the same logic in both places.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2019-09-17 19:13:09 +02:00
parent 67e05dd8cd
commit a811fb8b37

View File

@ -209,18 +209,20 @@ static void neighbor_hash_func(const Neighbor *neighbor, struct siphash *state)
assert(neighbor);
siphash24_compress(&neighbor->family, sizeof(neighbor->family), state);
siphash24_compress(&neighbor->lladdr_size, sizeof(neighbor->lladdr_size), state);
switch (neighbor->family) {
case AF_INET:
case AF_INET6:
/* Equality of neighbors are given by the pair (addr,lladdr) */
siphash24_compress(&neighbor->in_addr, FAMILY_ADDRESS_SIZE(neighbor->family), state);
siphash24_compress(&neighbor->lladdr, neighbor->lladdr_size, state);
break;
default:
/* treat any other address family as AF_UNSPEC */
break;
}
siphash24_compress(&neighbor->lladdr, neighbor->lladdr_size, state);
}
static int neighbor_compare_func(const Neighbor *a, const Neighbor *b) {