diff options
author | Donald Sharp <sharpd@cumulusnetworks.com> | 2017-02-14 16:41:28 +0100 |
---|---|---|
committer | Donald Sharp <sharpd@cumulusnetworks.com> | 2017-02-24 16:03:41 +0100 |
commit | 42a0111b64018c15b2d3bf71faf384d29113e31a (patch) | |
tree | d2a9245fefb001752af24e19dcff441a5aeebe93 | |
parent | pimd: Refactor functions (diff) | |
download | frr-42a0111b64018c15b2d3bf71faf384d29113e31a.tar.xz frr-42a0111b64018c15b2d3bf71faf384d29113e31a.zip |
pimd: Refactor pim_rpf_update to take a 'struct pim_rpf'
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
-rw-r--r-- | pimd/pim_rpf.c | 27 | ||||
-rw-r--r-- | pimd/pim_rpf.h | 2 | ||||
-rw-r--r-- | pimd/pim_zebra.c | 9 |
3 files changed, 19 insertions, 19 deletions
diff --git a/pimd/pim_rpf.c b/pimd/pim_rpf.c index ae00e347b..40e035c3f 100644 --- a/pimd/pim_rpf.c +++ b/pimd/pim_rpf.c @@ -184,14 +184,13 @@ static int nexthop_mismatch(const struct pim_nexthop *nh1, (nh1->mrib_route_metric != nh2->mrib_route_metric); } -enum pim_rpf_result pim_rpf_update(struct pim_upstream *up, struct in_addr *old_rpf_addr) +enum pim_rpf_result pim_rpf_update(struct pim_upstream *up, struct pim_rpf *old) { - struct prefix save_rpf_addr; - struct pim_nexthop save_nexthop; struct pim_rpf *rpf = &up->rpf; + struct pim_rpf saved; - save_nexthop = rpf->source_nexthop; /* detect change in pim_nexthop */ - save_rpf_addr = rpf->rpf_addr; /* detect change in RPF'(S,G) */ + saved.source_nexthop = rpf->source_nexthop; + saved.rpf_addr = rpf->rpf_addr; if (pim_nexthop_lookup(&rpf->source_nexthop, up->upstream_addr, @@ -211,7 +210,7 @@ enum pim_rpf_result pim_rpf_update(struct pim_upstream *up, struct in_addr *old_ } /* detect change in pim_nexthop */ - if (nexthop_mismatch(&rpf->source_nexthop, &save_nexthop)) { + if (nexthop_mismatch(&rpf->source_nexthop, &saved.source_nexthop)) { if (PIM_DEBUG_ZEBRA) { char nhaddr_str[PREFIX_STRLEN]; @@ -231,27 +230,29 @@ enum pim_rpf_result pim_rpf_update(struct pim_upstream *up, struct in_addr *old_ } /* detect change in RPF_interface(S) */ - if (save_nexthop.interface != rpf->source_nexthop.interface) { + if (saved.source_nexthop.interface != rpf->source_nexthop.interface) { if (PIM_DEBUG_ZEBRA) { zlog_debug("%s %s: (S,G)=%s RPF_interface(S) changed from %s to %s", __FILE__, __PRETTY_FUNCTION__, up->sg_str, - save_nexthop.interface ? save_nexthop.interface->name : "<oldif?>", + saved.source_nexthop.interface ? saved.source_nexthop.interface->name : "<oldif?>", rpf->source_nexthop.interface ? rpf->source_nexthop.interface->name : "<newif?>"); /* warning only */ } - pim_upstream_rpf_interface_changed(up, save_nexthop.interface); + pim_upstream_rpf_interface_changed(up, saved.source_nexthop.interface); } /* detect change in RPF'(S,G) */ - if (save_rpf_addr.u.prefix4.s_addr != rpf->rpf_addr.u.prefix4.s_addr) { + if (saved.rpf_addr.u.prefix4.s_addr != rpf->rpf_addr.u.prefix4.s_addr) { /* return old rpf to caller ? */ - if (old_rpf_addr) - *old_rpf_addr = save_rpf_addr.u.prefix4; - + if (old) + { + old->source_nexthop = saved.source_nexthop; + old->rpf_addr = saved.rpf_addr; + } return PIM_RPF_CHANGED; } diff --git a/pimd/pim_rpf.h b/pimd/pim_rpf.h index bb7777532..51e84b459 100644 --- a/pimd/pim_rpf.h +++ b/pimd/pim_rpf.h @@ -63,7 +63,7 @@ struct pim_upstream; extern long long nexthop_lookups_avoided; int pim_nexthop_lookup(struct pim_nexthop *nexthop, struct in_addr addr, int neighbor_needed); -enum pim_rpf_result pim_rpf_update(struct pim_upstream *up, struct in_addr *old_rpf_addr); +enum pim_rpf_result pim_rpf_update(struct pim_upstream *up, struct pim_rpf *old); int pim_rpf_addr_is_inaddr_none (struct pim_rpf *rpf); int pim_rpf_addr_is_inaddr_any (struct pim_rpf *rpf); diff --git a/pimd/pim_zebra.c b/pimd/pim_zebra.c index 1bb4852c6..b96d812a6 100644 --- a/pimd/pim_zebra.c +++ b/pimd/pim_zebra.c @@ -366,12 +366,11 @@ static void scan_upstream_rpf_cache() struct pim_upstream *up; for (ALL_LIST_ELEMENTS(pim_upstream_list, up_node, up_nextnode, up)) { - struct in_addr old_rpf_addr; - struct interface *old_interface; enum pim_rpf_result rpf_result; + struct pim_rpf old; - old_interface = up->rpf.source_nexthop.interface; - rpf_result = pim_rpf_update(up, &old_rpf_addr); + old.source_nexthop.interface = up->rpf.source_nexthop.interface; + rpf_result = pim_rpf_update(up, &old); if (rpf_result == PIM_RPF_FAILURE) continue; @@ -412,7 +411,7 @@ static void scan_upstream_rpf_cache() /* send Prune(S,G) to the old upstream neighbor */ - pim_joinprune_send(old_interface, old_rpf_addr, + pim_joinprune_send(old.source_nexthop.interface, old.rpf_addr.u.prefix4, up, 0 /* prune */); /* send Join(S,G) to the current upstream neighbor */ |