summaryrefslogtreecommitdiff
path: root/lib/zclient.c
diff options
context:
space:
mode:
authorDonald Sharp <donaldsharp72@gmail.com>2025-02-05 09:14:58 -0500
committerGitHub <noreply@github.com>2025-02-05 09:14:58 -0500
commit0b42b4ce6d7ccb43931c391e916ac6bf0a0aadf2 (patch)
tree80dbbf17651c54797287b8aca095de15e325ef92 /lib/zclient.c
parent3fabd4f4f97630ef911a83712eef4ac515a76a42 (diff)
parent001fcfa1dd9f7dc2639b4f5c7a52ab59cc425452 (diff)
Merge pull request #17901 from opensourcerouting/nexthop_hashing
lib: actually hash all 16 bytes of IPv6 addresses, not just 4
Diffstat (limited to 'lib/zclient.c')
-rw-r--r--lib/zclient.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/lib/zclient.c b/lib/zclient.c
index d8c75c9029..5deea8f0cf 100644
--- a/lib/zclient.c
+++ b/lib/zclient.c
@@ -2300,7 +2300,27 @@ struct nexthop *nexthop_from_zapi_nexthop(const struct zapi_nexthop *znh)
n->type = znh->type;
n->vrf_id = znh->vrf_id;
n->ifindex = znh->ifindex;
- n->gate = znh->gate;
+
+ /* only copy values that have meaning - make sure "spare bytes" are
+ * left zeroed for hashing (look at _nexthop_hash_bytes)
+ */
+ switch (znh->type) {
+ case NEXTHOP_TYPE_BLACKHOLE:
+ n->bh_type = znh->bh_type;
+ break;
+ case NEXTHOP_TYPE_IPV4:
+ case NEXTHOP_TYPE_IPV4_IFINDEX:
+ n->gate.ipv4 = znh->gate.ipv4;
+ break;
+ case NEXTHOP_TYPE_IPV6:
+ case NEXTHOP_TYPE_IPV6_IFINDEX:
+ n->gate.ipv6 = znh->gate.ipv6;
+ break;
+ case NEXTHOP_TYPE_IFINDEX:
+ /* nothing, ifindex is always copied */
+ break;
+ }
+
n->srte_color = znh->srte_color;
n->weight = znh->weight;