2015-02-04 07:01:14 +01:00
|
|
|
/*
|
2017-05-13 10:25:29 +02:00
|
|
|
* PIM for Quagga
|
|
|
|
* Copyright (C) 2008 Everton da Silva Marques
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; see the file COPYING; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
2015-02-04 07:01:14 +01:00
|
|
|
|
|
|
|
#include <zebra.h>
|
|
|
|
|
2016-06-18 02:43:21 +02:00
|
|
|
#include "if.h"
|
|
|
|
|
2015-02-04 07:01:14 +01:00
|
|
|
#include "log.h"
|
|
|
|
#include "prefix.h"
|
|
|
|
#include "memory.h"
|
2017-05-19 00:51:31 +02:00
|
|
|
#include "jhash.h"
|
2015-02-04 07:01:14 +01:00
|
|
|
|
|
|
|
#include "pimd.h"
|
|
|
|
#include "pim_rpf.h"
|
|
|
|
#include "pim_pim.h"
|
|
|
|
#include "pim_str.h"
|
|
|
|
#include "pim_iface.h"
|
2021-08-19 11:36:16 +02:00
|
|
|
#include "pim_neighbor.h"
|
2015-02-04 07:01:14 +01:00
|
|
|
#include "pim_zlookup.h"
|
|
|
|
#include "pim_ifchannel.h"
|
2016-10-27 17:54:55 +02:00
|
|
|
#include "pim_time.h"
|
2017-02-22 16:28:36 +01:00
|
|
|
#include "pim_nht.h"
|
2017-05-21 15:20:37 +02:00
|
|
|
#include "pim_oil.h"
|
2020-02-06 18:30:43 +01:00
|
|
|
#include "pim_mlag.h"
|
2016-10-27 17:54:55 +02:00
|
|
|
|
2017-02-22 16:28:36 +01:00
|
|
|
static struct in_addr pim_rpf_find_rpf_addr(struct pim_upstream *up);
|
2015-02-04 07:01:14 +01:00
|
|
|
|
2018-03-18 02:34:55 +01:00
|
|
|
void pim_rpf_set_refresh_time(struct pim_instance *pim)
|
2016-10-27 17:54:55 +02:00
|
|
|
{
|
2018-03-18 02:34:55 +01:00
|
|
|
pim->last_route_change_time = pim_time_monotonic_usec();
|
2019-11-12 14:02:06 +01:00
|
|
|
if (PIM_DEBUG_PIM_TRACE)
|
2018-03-18 02:34:55 +01:00
|
|
|
zlog_debug("%s: vrf(%s) New last route change time: %" PRId64,
|
2020-03-05 19:17:54 +01:00
|
|
|
__func__, pim->vrf->name,
|
2018-03-18 02:34:55 +01:00
|
|
|
pim->last_route_change_time);
|
2016-10-27 17:54:55 +02:00
|
|
|
}
|
|
|
|
|
2019-04-01 21:41:32 +02:00
|
|
|
bool pim_nexthop_lookup(struct pim_instance *pim, struct pim_nexthop *nexthop,
|
|
|
|
struct in_addr addr, int neighbor_needed)
|
2015-02-04 07:01:14 +01:00
|
|
|
{
|
2016-09-14 17:24:06 +02:00
|
|
|
struct pim_zlookup_nexthop nexthop_tab[MULTIPATH_NUM];
|
2017-02-15 03:32:16 +01:00
|
|
|
struct pim_neighbor *nbr = NULL;
|
2015-02-04 07:01:14 +01:00
|
|
|
int num_ifindex;
|
2017-01-19 14:49:47 +01:00
|
|
|
struct interface *ifp = NULL;
|
|
|
|
ifindex_t first_ifindex = 0;
|
2016-09-15 16:18:28 +02:00
|
|
|
int found = 0;
|
|
|
|
int i = 0;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2017-08-31 14:49:10 +02:00
|
|
|
/*
|
|
|
|
* We should not attempt to lookup a
|
|
|
|
* 255.255.255.255 address, since
|
|
|
|
* it will never work
|
|
|
|
*/
|
|
|
|
if (addr.s_addr == INADDR_NONE)
|
2019-04-01 21:41:32 +02:00
|
|
|
return false;
|
2017-08-31 14:49:10 +02:00
|
|
|
|
2016-10-27 17:54:55 +02:00
|
|
|
if ((nexthop->last_lookup.s_addr == addr.s_addr)
|
2018-03-18 02:34:55 +01:00
|
|
|
&& (nexthop->last_lookup_time > pim->last_route_change_time)) {
|
2019-11-12 14:02:06 +01:00
|
|
|
if (PIM_DEBUG_PIM_NHT) {
|
2016-10-27 17:54:55 +02:00
|
|
|
char addr_str[INET_ADDRSTRLEN];
|
|
|
|
pim_inet4_dump("<addr?>", addr, addr_str,
|
|
|
|
sizeof(addr_str));
|
pimd: Pim Nexthop Tracking support with ECMP
In this patch, PIM nexthop tracking uses locally populated nexthop cached list
to determine ECMP based nexthop (w/ ECMP knob enabled), otherwise picks
the first nexthop as RPF.
Introduced '[no] ip pim ecmp' command to enable/disable PIM ECMP knob.
By default, PIM ECMP is disabled.
Intorudced '[no] ip pim ecmp rebalance' command to provide existing mcache
entry to switch new path based on hash chosen path.
Introduced, show command to display pim registered addresses and respective nexthops.
Introuduce, show command to find nexthop and out interface for (S,G) or (RP,G).
Re-Register an address with nexthop when Interface UP event received,
to ensure the PIM nexthop cache is updated (being PIM enabled).
During PIM neighbor UP, traverse all RPs and Upstreams nexthop and determine, if
any of nexthop's IPv4 address changes/resolves due to neigbor UP event.
Testing Done: Run various LHR, RP and FHR related cases to resolve RPF using
nexthop cache with ECMP knob disabled, performed interface/PIM neighbor flap events.
Executed pim-smoke with knob disabled.
Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
(cherry picked from commit cba444817883b8b3b22a7ed9958dc9ed77f76230)
2017-04-05 22:14:12 +02:00
|
|
|
char nexthop_str[PREFIX_STRLEN];
|
|
|
|
pim_addr_dump("<nexthop?>", &nexthop->mrib_nexthop_addr,
|
|
|
|
nexthop_str, sizeof(nexthop_str));
|
|
|
|
zlog_debug(
|
2020-03-27 12:51:47 +01:00
|
|
|
"%s: Using last lookup for %s at %lld, %" PRId64" addr %s",
|
2020-03-05 19:17:54 +01:00
|
|
|
__func__, addr_str, nexthop->last_lookup_time,
|
2018-03-18 02:34:55 +01:00
|
|
|
pim->last_route_change_time, nexthop_str);
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
2018-03-18 02:34:55 +01:00
|
|
|
pim->nexthop_lookups_avoided++;
|
2019-04-01 21:41:32 +02:00
|
|
|
return true;
|
2017-07-17 14:03:14 +02:00
|
|
|
} else {
|
2019-11-12 14:02:06 +01:00
|
|
|
if (PIM_DEBUG_PIM_NHT) {
|
2016-10-27 17:54:55 +02:00
|
|
|
char addr_str[INET_ADDRSTRLEN];
|
|
|
|
pim_inet4_dump("<addr?>", addr, addr_str,
|
|
|
|
sizeof(addr_str));
|
2016-09-15 16:18:28 +02:00
|
|
|
zlog_debug(
|
2018-03-18 02:34:55 +01:00
|
|
|
"%s: Looking up: %s, last lookup time: %lld, %" PRId64,
|
2020-03-05 19:17:54 +01:00
|
|
|
__func__, addr_str, nexthop->last_lookup_time,
|
2018-03-18 02:34:55 +01:00
|
|
|
pim->last_route_change_time);
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
2016-10-27 17:54:55 +02:00
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2016-09-14 17:24:06 +02:00
|
|
|
memset(nexthop_tab, 0,
|
2016-10-27 17:54:55 +02:00
|
|
|
sizeof(struct pim_zlookup_nexthop) * MULTIPATH_NUM);
|
2017-05-21 15:03:07 +02:00
|
|
|
num_ifindex = zclient_lookup_nexthop(pim, nexthop_tab, MULTIPATH_NUM,
|
|
|
|
addr, PIM_NEXTHOP_LOOKUP_MAX);
|
2016-10-27 17:54:55 +02:00
|
|
|
if (num_ifindex < 1) {
|
|
|
|
char addr_str[INET_ADDRSTRLEN];
|
|
|
|
pim_inet4_dump("<addr?>", addr, addr_str, sizeof(addr_str));
|
|
|
|
zlog_warn(
|
|
|
|
"%s %s: could not find nexthop ifindex for address %s",
|
2020-03-05 19:17:54 +01:00
|
|
|
__FILE__, __func__, addr_str);
|
2019-04-01 21:41:32 +02:00
|
|
|
return false;
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
|
|
|
|
2016-10-25 16:40:04 +02:00
|
|
|
while (!found && (i < num_ifindex)) {
|
2016-09-15 16:18:28 +02:00
|
|
|
first_ifindex = nexthop_tab[i].ifindex;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2021-05-12 20:31:45 +02:00
|
|
|
ifp = if_lookup_by_index(first_ifindex, pim->vrf->vrf_id);
|
2016-09-15 16:18:28 +02:00
|
|
|
if (!ifp) {
|
|
|
|
if (PIM_DEBUG_ZEBRA) {
|
2016-10-20 16:09:30 +02:00
|
|
|
char addr_str[INET_ADDRSTRLEN];
|
2016-09-15 16:18:28 +02:00
|
|
|
pim_inet4_dump("<addr?>", addr, addr_str,
|
|
|
|
sizeof(addr_str));
|
|
|
|
zlog_debug(
|
2016-10-27 17:54:55 +02:00
|
|
|
"%s %s: could not find interface for ifindex %d (address %s)",
|
2020-03-05 19:17:54 +01:00
|
|
|
__FILE__, __func__, first_ifindex,
|
|
|
|
addr_str);
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
|
|
|
i++;
|
2016-12-13 01:23:29 +01:00
|
|
|
continue;
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
|
|
|
|
2016-10-25 16:40:04 +02:00
|
|
|
if (!ifp->info) {
|
2016-09-15 16:18:28 +02:00
|
|
|
if (PIM_DEBUG_ZEBRA) {
|
2016-10-25 16:40:04 +02:00
|
|
|
char addr_str[INET_ADDRSTRLEN];
|
|
|
|
pim_inet4_dump("<addr?>", addr, addr_str,
|
|
|
|
sizeof(addr_str));
|
|
|
|
zlog_debug(
|
2016-10-27 17:54:55 +02:00
|
|
|
"%s: multicast not enabled on input interface %s (ifindex=%d, RPF for source %s)",
|
2020-03-05 19:17:54 +01:00
|
|
|
__func__, ifp->name, first_ifindex,
|
|
|
|
addr_str);
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
|
|
|
i++;
|
2016-10-25 16:40:04 +02:00
|
|
|
} else if (neighbor_needed
|
|
|
|
&& !pim_if_connected_to_source(ifp, addr)) {
|
2016-09-15 16:18:28 +02:00
|
|
|
nbr = pim_neighbor_find(
|
|
|
|
ifp, nexthop_tab[i].nexthop_addr.u.prefix4);
|
2016-11-29 16:35:43 +01:00
|
|
|
if (PIM_DEBUG_PIM_TRACE_DETAIL)
|
2016-10-27 17:54:55 +02:00
|
|
|
zlog_debug("ifp name: %s, pim nbr: %p",
|
|
|
|
ifp->name, nbr);
|
|
|
|
if (!nbr && !if_is_loopback(ifp))
|
2017-07-17 14:03:14 +02:00
|
|
|
i++;
|
|
|
|
else
|
2016-10-27 17:54:55 +02:00
|
|
|
found = 1;
|
2017-07-17 14:03:14 +02:00
|
|
|
} else
|
2016-09-15 16:18:28 +02:00
|
|
|
found = 1;
|
2016-10-27 17:54:55 +02:00
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2016-08-19 19:25:20 +02:00
|
|
|
if (found) {
|
|
|
|
if (PIM_DEBUG_ZEBRA) {
|
|
|
|
char nexthop_str[PREFIX_STRLEN];
|
2016-10-20 16:09:30 +02:00
|
|
|
char addr_str[INET_ADDRSTRLEN];
|
2016-08-19 19:25:20 +02:00
|
|
|
pim_addr_dump("<nexthop?>",
|
2016-09-15 16:18:28 +02:00
|
|
|
&nexthop_tab[i].nexthop_addr, nexthop_str,
|
|
|
|
sizeof(nexthop_str));
|
|
|
|
pim_inet4_dump("<addr?>", addr, addr_str,
|
|
|
|
sizeof(addr_str));
|
|
|
|
zlog_debug(
|
|
|
|
"%s %s: found nexthop %s for address %s: interface %s ifindex=%d metric=%d pref=%d",
|
2020-03-05 19:17:54 +01:00
|
|
|
__FILE__, __func__, nexthop_str, addr_str,
|
|
|
|
ifp->name, first_ifindex,
|
2016-09-15 16:18:28 +02:00
|
|
|
nexthop_tab[i].route_metric,
|
|
|
|
nexthop_tab[i].protocol_distance);
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
2018-06-05 10:36:30 +02:00
|
|
|
/* update nexthop data */
|
2016-10-20 16:09:30 +02:00
|
|
|
nexthop->interface = ifp;
|
2016-11-23 22:35:45 +01:00
|
|
|
nexthop->mrib_nexthop_addr = nexthop_tab[i].nexthop_addr;
|
2016-09-15 16:18:28 +02:00
|
|
|
nexthop->mrib_metric_preference =
|
2016-11-23 22:35:45 +01:00
|
|
|
nexthop_tab[i].protocol_distance;
|
|
|
|
nexthop->mrib_route_metric = nexthop_tab[i].route_metric;
|
2016-10-27 17:54:55 +02:00
|
|
|
nexthop->last_lookup = addr;
|
|
|
|
nexthop->last_lookup_time = pim_time_monotonic_usec();
|
2017-02-15 03:32:16 +01:00
|
|
|
nexthop->nbr = nbr;
|
2019-04-01 21:41:32 +02:00
|
|
|
return true;
|
2016-09-15 16:18:28 +02:00
|
|
|
} else
|
2019-04-01 21:41:32 +02:00
|
|
|
return false;
|
2015-02-04 07:01:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int nexthop_mismatch(const struct pim_nexthop *nh1,
|
|
|
|
const struct pim_nexthop *nh2)
|
|
|
|
{
|
2016-09-02 18:17:10 +02:00
|
|
|
return (nh1->interface != nh2->interface)
|
|
|
|
|| (nh1->mrib_nexthop_addr.u.prefix4.s_addr
|
|
|
|
!= nh2->mrib_nexthop_addr.u.prefix4.s_addr)
|
|
|
|
|| (nh1->mrib_metric_preference != nh2->mrib_metric_preference)
|
2015-02-04 07:01:14 +01:00
|
|
|
|| (nh1->mrib_route_metric != nh2->mrib_route_metric);
|
|
|
|
}
|
|
|
|
|
2020-02-06 18:30:36 +01:00
|
|
|
static void pim_rpf_cost_change(struct pim_instance *pim,
|
|
|
|
struct pim_upstream *up, uint32_t old_cost)
|
|
|
|
{
|
|
|
|
struct pim_rpf *rpf = &up->rpf;
|
|
|
|
uint32_t new_cost;
|
|
|
|
|
|
|
|
new_cost = pim_up_mlag_local_cost(up);
|
|
|
|
if (PIM_DEBUG_MLAG)
|
|
|
|
zlog_debug(
|
|
|
|
"%s: Cost_to_rp of upstream-%s changed to:%u, from:%u",
|
|
|
|
__func__, up->sg_str, new_cost, old_cost);
|
|
|
|
|
|
|
|
if (old_cost == new_cost)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Cost changed, it might Impact MLAG DF election, update */
|
|
|
|
if (PIM_DEBUG_MLAG)
|
|
|
|
zlog_debug(
|
|
|
|
"%s: Cost_to_rp of upstream-%s changed to:%u",
|
|
|
|
__func__, up->sg_str,
|
|
|
|
rpf->source_nexthop.mrib_route_metric);
|
|
|
|
|
|
|
|
if (pim_up_mlag_is_local(up))
|
|
|
|
pim_mlag_up_local_add(pim, up);
|
|
|
|
}
|
|
|
|
|
2017-05-24 16:37:23 +02:00
|
|
|
enum pim_rpf_result pim_rpf_update(struct pim_instance *pim,
|
2019-11-15 20:37:31 +01:00
|
|
|
struct pim_upstream *up, struct pim_rpf *old,
|
|
|
|
const char *caller)
|
2015-02-04 07:01:14 +01:00
|
|
|
{
|
|
|
|
struct pim_rpf *rpf = &up->rpf;
|
2017-02-14 16:41:28 +01:00
|
|
|
struct pim_rpf saved;
|
2017-02-22 16:28:36 +01:00
|
|
|
struct prefix nht_p;
|
pimd: Pim Nexthop Tracking support with ECMP
In this patch, PIM nexthop tracking uses locally populated nexthop cached list
to determine ECMP based nexthop (w/ ECMP knob enabled), otherwise picks
the first nexthop as RPF.
Introduced '[no] ip pim ecmp' command to enable/disable PIM ECMP knob.
By default, PIM ECMP is disabled.
Intorudced '[no] ip pim ecmp rebalance' command to provide existing mcache
entry to switch new path based on hash chosen path.
Introduced, show command to display pim registered addresses and respective nexthops.
Introuduce, show command to find nexthop and out interface for (S,G) or (RP,G).
Re-Register an address with nexthop when Interface UP event received,
to ensure the PIM nexthop cache is updated (being PIM enabled).
During PIM neighbor UP, traverse all RPs and Upstreams nexthop and determine, if
any of nexthop's IPv4 address changes/resolves due to neigbor UP event.
Testing Done: Run various LHR, RP and FHR related cases to resolve RPF using
nexthop cache with ECMP knob disabled, performed interface/PIM neighbor flap events.
Executed pim-smoke with knob disabled.
Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
(cherry picked from commit cba444817883b8b3b22a7ed9958dc9ed77f76230)
2017-04-05 22:14:12 +02:00
|
|
|
struct prefix src, grp;
|
2018-07-06 14:36:34 +02:00
|
|
|
bool neigh_needed = true;
|
2020-02-06 18:30:36 +01:00
|
|
|
uint32_t saved_mrib_route_metric;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2019-03-26 21:36:43 +01:00
|
|
|
if (PIM_UPSTREAM_FLAG_TEST_STATIC_IIF(up->flags))
|
|
|
|
return PIM_RPF_OK;
|
|
|
|
|
2019-02-22 10:59:07 +01:00
|
|
|
if (up->upstream_addr.s_addr == INADDR_ANY) {
|
2019-11-15 20:37:31 +01:00
|
|
|
zlog_debug("%s(%s): RP is not configured yet for %s",
|
|
|
|
__func__, caller, up->sg_str);
|
2019-02-22 10:59:07 +01:00
|
|
|
return PIM_RPF_OK;
|
|
|
|
}
|
|
|
|
|
2017-02-14 16:41:28 +01:00
|
|
|
saved.source_nexthop = rpf->source_nexthop;
|
|
|
|
saved.rpf_addr = rpf->rpf_addr;
|
2020-02-06 18:30:36 +01:00
|
|
|
saved_mrib_route_metric = pim_up_mlag_local_cost(up);
|
2019-11-15 20:49:59 +01:00
|
|
|
if (old) {
|
|
|
|
old->source_nexthop = saved.source_nexthop;
|
|
|
|
old->rpf_addr = saved.rpf_addr;
|
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
pimd: Pim Nexthop Tracking support with ECMP
In this patch, PIM nexthop tracking uses locally populated nexthop cached list
to determine ECMP based nexthop (w/ ECMP knob enabled), otherwise picks
the first nexthop as RPF.
Introduced '[no] ip pim ecmp' command to enable/disable PIM ECMP knob.
By default, PIM ECMP is disabled.
Intorudced '[no] ip pim ecmp rebalance' command to provide existing mcache
entry to switch new path based on hash chosen path.
Introduced, show command to display pim registered addresses and respective nexthops.
Introuduce, show command to find nexthop and out interface for (S,G) or (RP,G).
Re-Register an address with nexthop when Interface UP event received,
to ensure the PIM nexthop cache is updated (being PIM enabled).
During PIM neighbor UP, traverse all RPs and Upstreams nexthop and determine, if
any of nexthop's IPv4 address changes/resolves due to neigbor UP event.
Testing Done: Run various LHR, RP and FHR related cases to resolve RPF using
nexthop cache with ECMP knob disabled, performed interface/PIM neighbor flap events.
Executed pim-smoke with knob disabled.
Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
(cherry picked from commit cba444817883b8b3b22a7ed9958dc9ed77f76230)
2017-04-05 22:14:12 +02:00
|
|
|
nht_p.family = AF_INET;
|
|
|
|
nht_p.prefixlen = IPV4_MAX_BITLEN;
|
|
|
|
nht_p.u.prefix4.s_addr = up->upstream_addr.s_addr;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
pimd: Pim Nexthop Tracking support with ECMP
In this patch, PIM nexthop tracking uses locally populated nexthop cached list
to determine ECMP based nexthop (w/ ECMP knob enabled), otherwise picks
the first nexthop as RPF.
Introduced '[no] ip pim ecmp' command to enable/disable PIM ECMP knob.
By default, PIM ECMP is disabled.
Intorudced '[no] ip pim ecmp rebalance' command to provide existing mcache
entry to switch new path based on hash chosen path.
Introduced, show command to display pim registered addresses and respective nexthops.
Introuduce, show command to find nexthop and out interface for (S,G) or (RP,G).
Re-Register an address with nexthop when Interface UP event received,
to ensure the PIM nexthop cache is updated (being PIM enabled).
During PIM neighbor UP, traverse all RPs and Upstreams nexthop and determine, if
any of nexthop's IPv4 address changes/resolves due to neigbor UP event.
Testing Done: Run various LHR, RP and FHR related cases to resolve RPF using
nexthop cache with ECMP knob disabled, performed interface/PIM neighbor flap events.
Executed pim-smoke with knob disabled.
Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
(cherry picked from commit cba444817883b8b3b22a7ed9958dc9ed77f76230)
2017-04-05 22:14:12 +02:00
|
|
|
src.family = AF_INET;
|
|
|
|
src.prefixlen = IPV4_MAX_BITLEN;
|
|
|
|
src.u.prefix4 = up->upstream_addr; // RP or Src address
|
|
|
|
grp.family = AF_INET;
|
|
|
|
grp.prefixlen = IPV4_MAX_BITLEN;
|
|
|
|
grp.u.prefix4 = up->sg.grp;
|
2018-07-06 14:36:34 +02:00
|
|
|
|
|
|
|
if ((up->sg.src.s_addr == INADDR_ANY && I_am_RP(pim, up->sg.grp)) ||
|
|
|
|
PIM_UPSTREAM_FLAG_TEST_FHR(up->flags))
|
2019-07-01 19:26:05 +02:00
|
|
|
neigh_needed = false;
|
2021-06-25 10:53:26 +02:00
|
|
|
pim_find_or_track_nexthop(pim, &nht_p, up, NULL, NULL);
|
2019-04-02 15:40:41 +02:00
|
|
|
if (!pim_ecmp_nexthop_lookup(pim, &rpf->source_nexthop, &src, &grp,
|
2020-02-06 18:30:36 +01:00
|
|
|
neigh_needed)) {
|
|
|
|
/* Route is Deleted in Zebra, reset the stored NH data */
|
|
|
|
pim_upstream_rpf_clear(pim, up);
|
|
|
|
pim_rpf_cost_change(pim, up, saved_mrib_route_metric);
|
2019-04-02 15:40:41 +02:00
|
|
|
return PIM_RPF_FAILURE;
|
2020-02-06 18:30:36 +01:00
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2016-09-02 18:17:10 +02:00
|
|
|
rpf->rpf_addr.family = AF_INET;
|
|
|
|
rpf->rpf_addr.u.prefix4 = pim_rpf_find_rpf_addr(up);
|
pimd: Fix to Tx S,G Join when SGRpt->Join state
-Upon Rx (*,G) Join w/o SGRpt at RP, trigger (S,G) Join
towards FHR, unset SGRpt flag from channel,
add (*,G) oif to (S,G) entry.
-Add I am not RP check to triger SGRpt on *,G path otherwise,
send S,G Prune on SPT path from RP to FHR upon receving *,G Prune.
-Upon Rx SGRpt receive, remove OIF(downstream where Prune received) from specific S,G.
Testing Done:
pim-smoke
Ran 95 tests in 11790.552s
FAILED (SKIP=10, failures=4)
Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2017-05-12 21:05:46 +02:00
|
|
|
if (pim_rpf_addr_is_inaddr_any(rpf) && PIM_DEBUG_ZEBRA) {
|
|
|
|
/* RPF'(S,G) not found */
|
2019-11-15 20:37:31 +01:00
|
|
|
zlog_debug("%s(%s): RPF'%s not found: won't send join upstream",
|
|
|
|
__func__, caller, up->sg_str);
|
pimd: Fix to Tx S,G Join when SGRpt->Join state
-Upon Rx (*,G) Join w/o SGRpt at RP, trigger (S,G) Join
towards FHR, unset SGRpt flag from channel,
add (*,G) oif to (S,G) entry.
-Add I am not RP check to triger SGRpt on *,G path otherwise,
send S,G Prune on SPT path from RP to FHR upon receving *,G Prune.
-Upon Rx SGRpt receive, remove OIF(downstream where Prune received) from specific S,G.
Testing Done:
pim-smoke
Ran 95 tests in 11790.552s
FAILED (SKIP=10, failures=4)
Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2017-05-12 21:05:46 +02:00
|
|
|
/* warning only */
|
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2015-02-04 07:01:14 +01:00
|
|
|
/* detect change in pim_nexthop */
|
2017-02-14 16:41:28 +01:00
|
|
|
if (nexthop_mismatch(&rpf->source_nexthop, &saved.source_nexthop)) {
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2016-08-26 20:09:41 +02:00
|
|
|
if (PIM_DEBUG_ZEBRA) {
|
2016-10-20 16:09:30 +02:00
|
|
|
char nhaddr_str[PREFIX_STRLEN];
|
2016-09-02 18:17:10 +02:00
|
|
|
pim_addr_dump("<addr?>",
|
|
|
|
&rpf->source_nexthop.mrib_nexthop_addr,
|
|
|
|
nhaddr_str, sizeof(nhaddr_str));
|
2019-11-15 20:37:31 +01:00
|
|
|
zlog_debug("%s(%s): (S,G)=%s source nexthop now is: interface=%s address=%s pref=%d metric=%d",
|
|
|
|
__func__, caller,
|
2016-11-17 14:17:25 +01:00
|
|
|
up->sg_str,
|
2015-02-04 07:01:14 +01:00
|
|
|
rpf->source_nexthop.interface ? rpf->source_nexthop.interface->name : "<ifname?>",
|
|
|
|
nhaddr_str,
|
|
|
|
rpf->source_nexthop.mrib_metric_preference,
|
|
|
|
rpf->source_nexthop.mrib_route_metric);
|
|
|
|
}
|
|
|
|
|
2017-05-21 15:20:37 +02:00
|
|
|
pim_upstream_update_join_desired(pim, up);
|
2015-02-04 07:01:14 +01:00
|
|
|
pim_upstream_update_could_assert(up);
|
|
|
|
pim_upstream_update_my_assert_metric(up);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* detect change in RPF_interface(S) */
|
2017-02-14 16:41:28 +01:00
|
|
|
if (saved.source_nexthop.interface != rpf->source_nexthop.interface) {
|
2015-02-04 07:01:14 +01:00
|
|
|
|
2016-08-26 20:09:41 +02:00
|
|
|
if (PIM_DEBUG_ZEBRA) {
|
2019-11-15 20:37:31 +01:00
|
|
|
zlog_debug("%s(%s): (S,G)=%s RPF_interface(S) changed from %s to %s",
|
|
|
|
__func__, caller,
|
2016-11-17 14:17:25 +01:00
|
|
|
up->sg_str,
|
2017-02-14 16:41:28 +01:00
|
|
|
saved.source_nexthop.interface ? saved.source_nexthop.interface->name : "<oldif?>",
|
2015-02-04 07:01:14 +01:00
|
|
|
rpf->source_nexthop.interface ? rpf->source_nexthop.interface->name : "<newif?>");
|
|
|
|
/* warning only */
|
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2017-02-14 16:41:28 +01:00
|
|
|
pim_upstream_rpf_interface_changed(
|
|
|
|
up, saved.source_nexthop.interface);
|
2015-02-04 07:01:14 +01:00
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2015-02-04 07:01:14 +01:00
|
|
|
/* detect change in RPF'(S,G) */
|
2017-03-16 16:15:32 +01:00
|
|
|
if (saved.rpf_addr.u.prefix4.s_addr != rpf->rpf_addr.u.prefix4.s_addr
|
|
|
|
|| saved.source_nexthop
|
|
|
|
.interface != rpf->source_nexthop.interface) {
|
2020-02-06 18:30:36 +01:00
|
|
|
pim_rpf_cost_change(pim, up, saved_mrib_route_metric);
|
2015-02-04 07:01:14 +01:00
|
|
|
return PIM_RPF_CHANGED;
|
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2020-02-06 18:30:36 +01:00
|
|
|
if (PIM_DEBUG_MLAG)
|
|
|
|
zlog_debug(
|
|
|
|
"%s(%s): Cost_to_rp of upstream-%s changed to:%u",
|
|
|
|
__func__, caller, up->sg_str,
|
|
|
|
rpf->source_nexthop.mrib_route_metric);
|
|
|
|
|
|
|
|
pim_rpf_cost_change(pim, up, saved_mrib_route_metric);
|
|
|
|
|
2015-02-04 07:01:14 +01:00
|
|
|
return PIM_RPF_OK;
|
|
|
|
}
|
|
|
|
|
2019-02-22 16:29:24 +01:00
|
|
|
/*
|
|
|
|
* In the case of RP deletion and RP unreachablity,
|
|
|
|
* uninstall the mroute in the kernel and clear the
|
|
|
|
* rpf information in the pim upstream and pim channel
|
|
|
|
* oil data structure.
|
|
|
|
*/
|
|
|
|
void pim_upstream_rpf_clear(struct pim_instance *pim,
|
|
|
|
struct pim_upstream *up)
|
|
|
|
{
|
|
|
|
if (up->rpf.source_nexthop.interface) {
|
2020-08-04 08:24:29 +02:00
|
|
|
pim_upstream_switch(pim, up, PIM_UPSTREAM_NOTJOINED);
|
2019-02-22 16:29:24 +01:00
|
|
|
up->rpf.source_nexthop.interface = NULL;
|
|
|
|
up->rpf.source_nexthop.mrib_nexthop_addr.u.prefix4.s_addr =
|
|
|
|
PIM_NET_INADDR_ANY;
|
|
|
|
up->rpf.source_nexthop.mrib_metric_preference =
|
|
|
|
router->infinite_assert_metric.metric_preference;
|
|
|
|
up->rpf.source_nexthop.mrib_route_metric =
|
|
|
|
router->infinite_assert_metric.route_metric;
|
|
|
|
up->rpf.rpf_addr.u.prefix4.s_addr = PIM_NET_INADDR_ANY;
|
2019-11-15 20:09:13 +01:00
|
|
|
pim_upstream_mroute_iif_update(up->channel_oil, __func__);
|
2019-02-22 16:29:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-04 07:01:14 +01:00
|
|
|
/*
|
|
|
|
RFC 4601: 4.1.6. State Summarization Macros
|
|
|
|
|
|
|
|
neighbor RPF'(S,G) {
|
|
|
|
if ( I_Am_Assert_Loser(S, G, RPF_interface(S) )) {
|
|
|
|
return AssertWinner(S, G, RPF_interface(S) )
|
|
|
|
} else {
|
|
|
|
return NBR( RPF_interface(S), MRIB.next_hop( S ) )
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RPF'(*,G) and RPF'(S,G) indicate the neighbor from which data
|
|
|
|
packets should be coming and to which joins should be sent on the RP
|
|
|
|
tree and SPT, respectively.
|
|
|
|
*/
|
|
|
|
static struct in_addr pim_rpf_find_rpf_addr(struct pim_upstream *up)
|
|
|
|
{
|
|
|
|
struct pim_ifchannel *rpf_ch;
|
|
|
|
struct pim_neighbor *neigh;
|
|
|
|
struct in_addr rpf_addr;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2015-02-04 07:01:14 +01:00
|
|
|
if (!up->rpf.source_nexthop.interface) {
|
2016-07-22 14:57:20 +02:00
|
|
|
zlog_warn("%s: missing RPF interface for upstream (S,G)=%s",
|
2020-03-05 19:17:54 +01:00
|
|
|
__func__, up->sg_str);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2015-02-04 07:01:14 +01:00
|
|
|
rpf_addr.s_addr = PIM_NET_INADDR_ANY;
|
|
|
|
return rpf_addr;
|
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2015-02-04 07:01:14 +01:00
|
|
|
rpf_ch = pim_ifchannel_find(up->rpf.source_nexthop.interface, &up->sg);
|
|
|
|
if (rpf_ch) {
|
|
|
|
if (rpf_ch->ifassert_state == PIM_IFASSERT_I_AM_LOSER) {
|
|
|
|
return rpf_ch->ifassert_winner;
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
2015-02-04 07:01:14 +01:00
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2015-02-04 07:01:14 +01:00
|
|
|
/* return NBR( RPF_interface(S), MRIB.next_hop( S ) ) */
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2015-02-04 07:01:14 +01:00
|
|
|
neigh = pim_if_find_neighbor(
|
|
|
|
up->rpf.source_nexthop.interface,
|
2016-09-02 18:17:10 +02:00
|
|
|
up->rpf.source_nexthop.mrib_nexthop_addr.u.prefix4);
|
2015-02-04 07:01:14 +01:00
|
|
|
if (neigh)
|
|
|
|
rpf_addr = neigh->source_addr;
|
|
|
|
else
|
|
|
|
rpf_addr.s_addr = PIM_NET_INADDR_ANY;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2015-02-04 07:01:14 +01:00
|
|
|
return rpf_addr;
|
|
|
|
}
|
2016-09-02 18:17:10 +02:00
|
|
|
|
|
|
|
int pim_rpf_addr_is_inaddr_none(struct pim_rpf *rpf)
|
|
|
|
{
|
|
|
|
switch (rpf->rpf_addr.family) {
|
2016-09-02 20:34:14 +02:00
|
|
|
case AF_INET:
|
2016-09-02 18:17:10 +02:00
|
|
|
return rpf->rpf_addr.u.prefix4.s_addr == INADDR_NONE;
|
2016-09-02 20:34:14 +02:00
|
|
|
case AF_INET6:
|
2020-03-05 19:17:54 +01:00
|
|
|
zlog_warn("%s: v6 Unimplmeneted", __func__);
|
2016-09-02 18:17:10 +02:00
|
|
|
return 1;
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int pim_rpf_addr_is_inaddr_any(struct pim_rpf *rpf)
|
|
|
|
{
|
|
|
|
switch (rpf->rpf_addr.family) {
|
2016-09-02 20:34:14 +02:00
|
|
|
case AF_INET:
|
2016-09-02 18:17:10 +02:00
|
|
|
return rpf->rpf_addr.u.prefix4.s_addr == INADDR_ANY;
|
2016-09-02 20:34:14 +02:00
|
|
|
case AF_INET6:
|
2020-03-05 19:17:54 +01:00
|
|
|
zlog_warn("%s: v6 Unimplmented", __func__);
|
2016-09-02 18:17:10 +02:00
|
|
|
return 1;
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2016-11-02 15:53:28 +01:00
|
|
|
|
|
|
|
int pim_rpf_is_same(struct pim_rpf *rpf1, struct pim_rpf *rpf2)
|
|
|
|
{
|
|
|
|
if (rpf1->source_nexthop.interface == rpf2->source_nexthop.interface)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2017-05-19 00:51:31 +02:00
|
|
|
|
2019-05-14 22:19:07 +02:00
|
|
|
unsigned int pim_rpf_hash_key(const void *arg)
|
2017-05-19 00:51:31 +02:00
|
|
|
{
|
2019-05-14 22:19:07 +02:00
|
|
|
const struct pim_nexthop_cache *r = arg;
|
2017-05-19 00:51:31 +02:00
|
|
|
|
|
|
|
return jhash_1word(r->rpf.rpf_addr.u.prefix4.s_addr, 0);
|
|
|
|
}
|
|
|
|
|
2018-10-17 21:27:12 +02:00
|
|
|
bool pim_rpf_equal(const void *arg1, const void *arg2)
|
2017-05-19 00:51:31 +02:00
|
|
|
{
|
|
|
|
const struct pim_nexthop_cache *r1 =
|
|
|
|
(const struct pim_nexthop_cache *)arg1;
|
|
|
|
const struct pim_nexthop_cache *r2 =
|
|
|
|
(const struct pim_nexthop_cache *)arg2;
|
|
|
|
|
|
|
|
return prefix_same(&r1->rpf.rpf_addr, &r2->rpf.rpf_addr);
|
|
|
|
}
|