From fa81d14420f2fb582d9d42c16098b511a1c91f23 Mon Sep 17 00:00:00 2001 From: Xiaodong Xu Date: Tue, 6 Jun 2017 16:47:35 -0700 Subject: [PATCH] Fix an issue on RP hash calculations. As per RFC4601, all multicast routers in a domain should use the same algorithm for RP elections, and all the IP addresses including the mask address used in the algorithm should be in host byte order. The change fixes the problem about RP hash calculation so that the results will be consistent across different routers. Signed-off-by: Xiaodong Xu --- src/rp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/rp.c b/src/rp.c index dbf24d23..4e009c90 100644 --- a/src/rp.c +++ b/src/rp.c @@ -783,6 +783,7 @@ rp_grp_entry_t *rp_grp_match(uint32_t group) uint32_t curr_hash_value = 0; uint32_t curr_address_h = 0; uint32_t group_h = ntohl(group); + uint32_t curr_hash_mask_h = 0; if (grp_mask_list == NULL) return NULL; @@ -793,12 +794,13 @@ rp_grp_entry_t *rp_grp_match(uint32_t group) != ntohl(mask_ptr->group_mask & mask_ptr->group_addr)) continue; + curr_hash_mask_h = ntohl(mask_ptr->hash_mask); for (entry_ptr = mask_ptr->grp_rp_next; entry_ptr; entry_ptr = entry_ptr->grp_rp_next) { if (best_priority < entry_ptr->priority) break; - curr_hash_value = RP_HASH_VALUE(group_h, mask_ptr->hash_mask, curr_address_h); curr_address_h = ntohl(entry_ptr->rp->rpentry->address); + curr_hash_value = RP_HASH_VALUE(group_h, curr_hash_mask_h, curr_address_h); if (best_priority == entry_ptr->priority) { /* Compare the hash_value and then the addresses */