Skip to content

Commit

Permalink
Fix an issue on RP hash calculations.
Browse files Browse the repository at this point in the history
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 <stid.smth@gmail.com>
  • Loading branch information
xdxu committed Jun 7, 2017
1 parent 4a49a32 commit fa81d14
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/rp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 */
Expand Down

0 comments on commit fa81d14

Please sign in to comment.