diff options
author | Donald Sharp <sharpd@cumulusnetworks.com> | 2016-08-19 19:25:20 +0200 |
---|---|---|
committer | Donald Sharp <sharpd@cumulusnetworks.com> | 2016-12-22 02:26:07 +0100 |
commit | f24405b1e81bf5a269936fc03187c20853e6056d (patch) | |
tree | d3718d2c18c0873c5c18dafb31db583e5f229c3d | |
parent | pimd: When deleting upstream double ensure route is removed (diff) | |
download | frr-f24405b1e81bf5a269936fc03187c20853e6056d.tar.xz frr-f24405b1e81bf5a269936fc03187c20853e6056d.zip |
pimd - Fix rpf lookup to what it was originally
I tried to be smart and skirt around rpf lookup if I knew
the incoming interface. This turns out to be not necessarily
a good thing because we can easily have asymetrical routing.
This fix removes the attempt to cache the ifp we received
the incoming packet on and just lets the lookup work like
it should.
Additionally it removes the weird hardcoding of the rpf
interface from the register stuff.
Ticket: CM-12530
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
reb
-rw-r--r-- | pimd/pim_cmd.c | 2 | ||||
-rw-r--r-- | pimd/pim_mroute.c | 2 | ||||
-rw-r--r-- | pimd/pim_register.c | 4 | ||||
-rw-r--r-- | pimd/pim_rp.c | 4 | ||||
-rw-r--r-- | pimd/pim_rpf.c | 82 | ||||
-rw-r--r-- | pimd/pim_rpf.h | 7 | ||||
-rw-r--r-- | pimd/pim_upstream.c | 4 | ||||
-rw-r--r-- | pimd/pim_zebra.c | 2 |
8 files changed, 45 insertions, 62 deletions
diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c index ba2d4a063..bd3a85abb 100644 --- a/pimd/pim_cmd.c +++ b/pimd/pim_cmd.c @@ -2347,7 +2347,7 @@ DEFUN (show_ip_rib, return CMD_WARNING; } - if (pim_nexthop_lookup(&nexthop, addr, NULL)) { + if (pim_nexthop_lookup(&nexthop, addr)) { vty_out(vty, "Failure querying RIB nexthop for unicast address %s%s", addr_str, VTY_NEWLINE); return CMD_WARNING; diff --git a/pimd/pim_mroute.c b/pimd/pim_mroute.c index e678b87cc..a17a8b100 100644 --- a/pimd/pim_mroute.c +++ b/pimd/pim_mroute.c @@ -358,7 +358,7 @@ pim_mroute_msg_wrvifwhole (int fd, struct interface *ifp, const char *buf) { struct pim_nexthop source; //No if channel, but upstream we are at the RP. - pim_nexthop_lookup (&source, up->upstream_register, NULL); + pim_nexthop_lookup (&source, up->upstream_register); pim_register_stop_send(source.interface, &sg, up->upstream_register); //Send S bit down the join. up->sptbit = PIM_UPSTREAM_SPTBIT_TRUE; diff --git a/pimd/pim_register.c b/pimd/pim_register.c index 439bb577c..4cc4a2703 100644 --- a/pimd/pim_register.c +++ b/pimd/pim_register.c @@ -326,12 +326,10 @@ pim_register_recv (struct interface *ifp, upstream->upstream_register = src_addr; pim_rp_set_upstream_addr (&upstream->upstream_addr, sg.src, sg.grp); pim_nexthop_lookup (&upstream->rpf.source_nexthop, - upstream->upstream_addr, NULL); - upstream->rpf.source_nexthop.interface = ifp; + upstream->upstream_addr); upstream->sg.src = sg.src; upstream->rpf.rpf_addr = upstream->rpf.source_nexthop.mrib_nexthop_addr; - //pim_upstream_switch (upstream, PIM_UPSTREAM_PRUNE); upstream->join_state = PIM_UPSTREAM_PRUNE; } diff --git a/pimd/pim_rp.c b/pimd/pim_rp.c index 0af7a991e..84de87076 100644 --- a/pimd/pim_rp.c +++ b/pimd/pim_rp.c @@ -262,7 +262,7 @@ pim_rp_setup (void) for (ALL_LIST_ELEMENTS_RO (qpim_rp_list, node, rp_info)) { - if (pim_nexthop_lookup (&rp_info->rp.source_nexthop, rp_info->rp.rpf_addr, NULL) != 0) + if (pim_nexthop_lookup (&rp_info->rp.source_nexthop, rp_info->rp.rpf_addr) != 0) { zlog_err ("Unable to lookup nexthop for rp specified"); ret++; @@ -358,7 +358,7 @@ pim_rp_g (struct in_addr group) if (rp_info) { - pim_nexthop_lookup(&rp_info->rp.source_nexthop, rp_info->rp.rpf_addr, NULL); + pim_nexthop_lookup(&rp_info->rp.source_nexthop, rp_info->rp.rpf_addr); return (&rp_info->rp); } diff --git a/pimd/pim_rpf.c b/pimd/pim_rpf.c index 15b00d8d0..e81e262cd 100644 --- a/pimd/pim_rpf.c +++ b/pimd/pim_rpf.c @@ -37,8 +37,7 @@ static struct in_addr pim_rpf_find_rpf_addr(struct pim_upstream *up); -int pim_nexthop_lookup(struct pim_nexthop *nexthop, - struct in_addr addr, struct interface *incoming) +int pim_nexthop_lookup(struct pim_nexthop *nexthop, struct in_addr addr) { struct pim_zlookup_nexthop nexthop_tab[PIM_NEXTHOP_IFINDEX_TAB_SIZE]; int num_ifindex; @@ -47,46 +46,38 @@ int pim_nexthop_lookup(struct pim_nexthop *nexthop, memset (nexthop_tab, 0, sizeof (struct pim_zlookup_nexthop) * PIM_NEXTHOP_IFINDEX_TAB_SIZE); - if (!incoming) - { - num_ifindex = zclient_lookup_nexthop(nexthop_tab, - PIM_NEXTHOP_IFINDEX_TAB_SIZE, - addr, PIM_NEXTHOP_LOOKUP_MAX); - if (num_ifindex < 1) { - char addr_str[100]; - pim_inet4_dump("<addr?>", addr, addr_str, sizeof(addr_str)); - zlog_warn("%s %s: could not find nexthop ifindex for address %s", - __FILE__, __PRETTY_FUNCTION__, - addr_str); - return -1; - } - - first_ifindex = nexthop_tab[0].ifindex; - - if (num_ifindex > 1) { - char addr_str[100]; - pim_inet4_dump("<addr?>", addr, addr_str, sizeof(addr_str)); - zlog_info("%s %s: FIXME ignoring multiple nexthop ifindex'es num_ifindex=%d for address %s (using only ifindex=%d)", - __FILE__, __PRETTY_FUNCTION__, - num_ifindex, addr_str, first_ifindex); - /* debug warning only, do not return */ - } - - ifp = if_lookup_by_index(first_ifindex); - if (!ifp) { - char addr_str[100]; - pim_inet4_dump("<addr?>", addr, addr_str, sizeof(addr_str)); - zlog_warn("%s %s: could not find interface for ifindex %d (address %s)", - __FILE__, __PRETTY_FUNCTION__, - first_ifindex, addr_str); - return -2; - } - } - else - { - ifp = incoming; - first_ifindex = ifp->ifindex; - } + num_ifindex = zclient_lookup_nexthop(nexthop_tab, + PIM_NEXTHOP_IFINDEX_TAB_SIZE, + addr, PIM_NEXTHOP_LOOKUP_MAX); + if (num_ifindex < 1) { + char addr_str[100]; + pim_inet4_dump("<addr?>", addr, addr_str, sizeof(addr_str)); + zlog_warn("%s %s: could not find nexthop ifindex for address %s", + __FILE__, __PRETTY_FUNCTION__, + addr_str); + return -1; + } + + first_ifindex = nexthop_tab[0].ifindex; + + if (num_ifindex > 1) { + char addr_str[100]; + pim_inet4_dump("<addr?>", addr, addr_str, sizeof(addr_str)); + zlog_info("%s %s: FIXME ignoring multiple nexthop ifindex'es num_ifindex=%d for address %s (using only ifindex=%d)", + __FILE__, __PRETTY_FUNCTION__, + num_ifindex, addr_str, first_ifindex); + /* debug warning only, do not return */ + } + + ifp = if_lookup_by_index(first_ifindex); + if (!ifp) { + char addr_str[100]; + pim_inet4_dump("<addr?>", addr, addr_str, sizeof(addr_str)); + zlog_warn("%s %s: could not find interface for ifindex %d (address %s)", + __FILE__, __PRETTY_FUNCTION__, + first_ifindex, addr_str); + return -2; + } if (!ifp->info) { char addr_str[100]; @@ -131,9 +122,7 @@ 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, - struct interface *incoming) +enum pim_rpf_result pim_rpf_update(struct pim_upstream *up, struct in_addr *old_rpf_addr) { struct in_addr save_rpf_addr; struct pim_nexthop save_nexthop; @@ -142,8 +131,7 @@ enum pim_rpf_result pim_rpf_update(struct pim_upstream *up, save_nexthop = rpf->source_nexthop; /* detect change in pim_nexthop */ save_rpf_addr = rpf->rpf_addr; /* detect change in RPF'(S,G) */ - if (pim_nexthop_lookup(&rpf->source_nexthop, - up->upstream_addr, incoming)) { + if (pim_nexthop_lookup(&rpf->source_nexthop, up->upstream_addr)) { return PIM_RPF_FAILURE; } diff --git a/pimd/pim_rpf.h b/pimd/pim_rpf.h index 86c33c2e4..ab16039a2 100644 --- a/pimd/pim_rpf.h +++ b/pimd/pim_rpf.h @@ -27,10 +27,7 @@ #include "pim_upstream.h" #include "pim_neighbor.h" -int pim_nexthop_lookup(struct pim_nexthop *nexthop, - struct in_addr addr, struct interface *incoming); -enum pim_rpf_result pim_rpf_update(struct pim_upstream *up, - struct in_addr *old_rpf_addr, - struct interface *incoming); +int pim_nexthop_lookup(struct pim_nexthop *nexthop, struct in_addr addr); +enum pim_rpf_result pim_rpf_update(struct pim_upstream *up, struct in_addr *old_rpf_addr); #endif /* PIM_RPF_H */ diff --git a/pimd/pim_upstream.c b/pimd/pim_upstream.c index bd6677d47..37b900688 100644 --- a/pimd/pim_upstream.c +++ b/pimd/pim_upstream.c @@ -463,13 +463,13 @@ static struct pim_upstream *pim_upstream_new(struct prefix_sg *sg, up->channel_oil = NULL; up->sptbit = PIM_UPSTREAM_SPTBIT_FALSE; - up->rpf.source_nexthop.interface = 0; + up->rpf.source_nexthop.interface = NULL; up->rpf.source_nexthop.mrib_nexthop_addr.s_addr = PIM_NET_INADDR_ANY; up->rpf.source_nexthop.mrib_metric_preference = qpim_infinite_assert_metric.metric_preference; up->rpf.source_nexthop.mrib_route_metric = qpim_infinite_assert_metric.route_metric; up->rpf.rpf_addr.s_addr = PIM_NET_INADDR_ANY; - rpf_result = pim_rpf_update(up, 0, incoming); + rpf_result = pim_rpf_update(up, 0); if (rpf_result == PIM_RPF_FAILURE) { XFREE(MTYPE_PIM_UPSTREAM, up); return NULL; diff --git a/pimd/pim_zebra.c b/pimd/pim_zebra.c index f710fc20c..94cd65893 100644 --- a/pimd/pim_zebra.c +++ b/pimd/pim_zebra.c @@ -333,7 +333,7 @@ static void scan_upstream_rpf_cache() struct in_addr old_rpf_addr; enum pim_rpf_result rpf_result; - rpf_result = pim_rpf_update(up, &old_rpf_addr, NULL); + rpf_result = pim_rpf_update(up, &old_rpf_addr); if (rpf_result == PIM_RPF_FAILURE) continue; |