Part of the hash input for nat_range_hash() was accidently truncated, so recover it here. Also update the local variable name to better reflect the intention and add missing comments.
Signed-off-by: Darrell Ball <[email protected]> --- lib/conntrack.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/conntrack.c b/lib/conntrack.c index 44a6bc4..aceaf74 100644 --- a/lib/conntrack.c +++ b/lib/conntrack.c @@ -1617,7 +1617,7 @@ nat_range_hash(const struct conn *conn, uint32_t basis) { uint32_t hash = basis; int i; - uint16_t port; + uint32_t ports; for (i = 0; i < sizeof(conn->nat_info->min_addr) / sizeof(uint32_t); @@ -1626,18 +1626,22 @@ nat_range_hash(const struct conn *conn, uint32_t basis) hash = hash_add(hash, ((uint32_t *) &conn->nat_info->max_addr)[i]); } - memcpy(&port, &conn->nat_info->min_port, sizeof port); - hash = hash_add(hash, port); + + /* Fold in the 4 bytes starting at the address of min_port. */ + memcpy(&ports, &conn->nat_info->min_port, sizeof ports); + hash = hash_add(hash, ports); for (i = 0; i < sizeof(conn->key.src.addr) / sizeof(uint32_t); i++) { hash = hash_add(hash, ((uint32_t *) &conn->key.src)[i]); hash = hash_add(hash, ((uint32_t *) &conn->key.dst)[i]); } - memcpy(&port, &conn->key.src.port, sizeof port); - hash = hash_add(hash, port); - memcpy(&port, &conn->key.dst.port, sizeof port); - hash = hash_add(hash, port); + /* Fold in the 4 bytes starting at the address of src.port. */ + memcpy(&ports, &conn->key.src.port, sizeof ports); + hash = hash_add(hash, ports); + /* Fold in the 4 bytes starting at the address of dst.port. */ + memcpy(&ports, &conn->key.dst.port, sizeof ports); + hash = hash_add(hash, ports); hash = hash_add(hash, (OVS_FORCE uint32_t) conn->key.dl_type); hash = hash_add(hash, conn->key.nw_proto); -- 1.9.1 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
