network/nexthop: do not add NextHop object to Link on requesting

Then, all nexthops managed by networkd really exist (unless the kernel
silently removes a nexthop).

This is the same for nexthop already done by
3c283289ae and
0a0c2672db (for address), and
5d098f5d36 (for neighbor).
This commit is contained in:
Yu Watanabe
2023-12-14 18:58:26 +09:00
parent 352eba2e49
commit cdf3bee6a2
2 changed files with 206 additions and 144 deletions
+18 -14
View File
@@ -58,12 +58,14 @@ static void request_hash_func(const Request *req, struct siphash *state) {
assert(req);
assert(state);
siphash24_compress_boolean(req->link, state);
if (req->link)
siphash24_compress(&req->link->ifindex, sizeof(req->link->ifindex), state);
siphash24_compress(&req->type, sizeof(req->type), state);
if (req->type != REQUEST_TYPE_NEXTHOP) {
siphash24_compress_boolean(req->link, state);
if (req->link)
siphash24_compress(&req->link->ifindex, sizeof(req->link->ifindex), state);
}
siphash24_compress(&req->hash_func, sizeof(req->hash_func), state);
siphash24_compress(&req->compare_func, sizeof(req->compare_func), state);
@@ -77,20 +79,22 @@ static int request_compare_func(const struct Request *a, const struct Request *b
assert(a);
assert(b);
r = CMP(!!a->link, !!b->link);
if (r != 0)
return r;
if (a->link) {
r = CMP(a->link->ifindex, b->link->ifindex);
if (r != 0)
return r;
}
r = CMP(a->type, b->type);
if (r != 0)
return r;
if (a->type != REQUEST_TYPE_NEXTHOP) {
r = CMP(!!a->link, !!b->link);
if (r != 0)
return r;
if (a->link) {
r = CMP(a->link->ifindex, b->link->ifindex);
if (r != 0)
return r;
}
}
r = CMP(PTR_TO_UINT64(a->hash_func), PTR_TO_UINT64(b->hash_func));
if (r != 0)
return r;