When we are searching for a RP to use, amongst
many RP's and separate prefix-lists, Match on
the longest prefix specified to choose the
correct RP.
Example:
ip pim rp 4.3.2.1 prefix-list A
ip pim rp 4.3.2.2 prefix-list B
ip pim rp 4.3.2.3 prefix-list C
ip prefix-list A seq 5 permit 225.0.0.0/8
ip prefix-list B seq 5 permit 225.1.0.0/16
ip prefix-list C seq 5 permit 225.1.1.0/24
Old behavior: Group 225.1.1.14 comes in and
we need to find the RP to use, we would match
on the first prefix-list A( since we are searching
based on a sorted link list of RP address ) and
select 4.3.2.1 as our RP
New behavior: Group 225.1.1.14 comes in and
we need to find theRP to use, we now will
match on C( longest prefix match ) and select
4.3.2.3 as our RP.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
struct prefix *group)
{
struct listnode *node;
+ struct rp_info *best = NULL;
struct rp_info *rp_info;
struct prefix_list *plist;
+ struct prefix *p, *bp;
for (ALL_LIST_ELEMENTS_RO(pim->rp_list, node, rp_info)) {
if (rp_info->plist) {
plist = prefix_list_lookup(AFI_IP, rp_info->plist);
- if (plist
- && prefix_list_apply(plist, group) == PREFIX_PERMIT)
- return rp_info;
+ if (prefix_list_apply_which_prefix(plist, &p, group) == PREFIX_DENY)
+ continue;
+
+ if (!best) {
+ best = rp_info;
+ bp = p;
+ continue;
+ }
+
+ if (bp->prefixlen < p->prefixlen) {
+ best = rp_info;
+ bp = p;
+ }
} else {
if (prefix_match(&rp_info->group, group))
return rp_info;
}
}
- return NULL;
+ return best;
}
/*