2023-02-08 13:17:09 +01:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
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
|
|
|
|
*/
|
2015-02-04 07:01:14 +01:00
|
|
|
|
|
|
|
#include <zebra.h>
|
|
|
|
|
|
|
|
#include "if.h"
|
|
|
|
#include "log.h"
|
|
|
|
#include "prefix.h"
|
|
|
|
#include "zclient.h"
|
|
|
|
#include "stream.h"
|
|
|
|
#include "network.h"
|
2016-09-13 21:41:33 +02:00
|
|
|
#include "vty.h"
|
|
|
|
#include "plist.h"
|
2017-04-11 03:01:53 +02:00
|
|
|
#include "lib/bfd.h"
|
2015-02-04 07:01:14 +01:00
|
|
|
|
|
|
|
#include "pimd.h"
|
|
|
|
#include "pim_pim.h"
|
|
|
|
#include "pim_zebra.h"
|
|
|
|
#include "pim_iface.h"
|
|
|
|
#include "pim_str.h"
|
|
|
|
#include "pim_oil.h"
|
|
|
|
#include "pim_rpf.h"
|
|
|
|
#include "pim_time.h"
|
|
|
|
#include "pim_join.h"
|
|
|
|
#include "pim_zlookup.h"
|
|
|
|
#include "pim_ifchannel.h"
|
2015-09-30 14:41:18 +02:00
|
|
|
#include "pim_rp.h"
|
2016-07-11 22:22:14 +02:00
|
|
|
#include "pim_igmpv3.h"
|
2017-02-15 03:32:16 +01:00
|
|
|
#include "pim_jp_agg.h"
|
2017-02-22 16:28:36 +01:00
|
|
|
#include "pim_nht.h"
|
2017-03-17 19:51:13 +01:00
|
|
|
#include "pim_ssm.h"
|
2019-03-21 16:49:09 +01:00
|
|
|
#include "pim_vxlan.h"
|
2019-11-12 09:17:13 +01:00
|
|
|
#include "pim_mlag.h"
|
2015-02-04 07:01:14 +01:00
|
|
|
|
|
|
|
#undef PIM_DEBUG_IFADDR_DUMP
|
|
|
|
#define PIM_DEBUG_IFADDR_DUMP
|
|
|
|
|
2019-11-12 07:36:17 +01:00
|
|
|
struct zclient *zclient;
|
2016-12-09 17:08:45 +01:00
|
|
|
|
2015-02-04 07:01:14 +01:00
|
|
|
|
|
|
|
/* Router-id update message from zebra. */
|
2019-05-03 21:42:59 +02:00
|
|
|
static int pim_router_id_update_zebra(ZAPI_CALLBACK_ARGS)
|
2015-02-04 07:01:14 +01:00
|
|
|
{
|
|
|
|
struct prefix router_id;
|
|
|
|
|
|
|
|
zebra_router_id_update_read(zclient->ibuf, &router_id);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-05-03 21:42:59 +02:00
|
|
|
static int pim_zebra_interface_vrf_update(ZAPI_CALLBACK_ARGS)
|
2019-02-02 21:52:14 +01:00
|
|
|
{
|
|
|
|
struct interface *ifp;
|
|
|
|
vrf_id_t new_vrf_id;
|
|
|
|
|
|
|
|
ifp = zebra_interface_vrf_update_read(zclient->ibuf, vrf_id,
|
|
|
|
&new_vrf_id);
|
|
|
|
if (!ifp)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (PIM_DEBUG_ZEBRA)
|
2020-03-05 19:17:54 +01:00
|
|
|
zlog_debug("%s: %s updating from %u to %u", __func__, ifp->name,
|
|
|
|
vrf_id, new_vrf_id);
|
2019-02-02 21:52:14 +01:00
|
|
|
|
2019-06-24 01:46:39 +02:00
|
|
|
if_update_to_new_vrf(ifp, new_vrf_id);
|
2019-02-02 21:52:14 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-02-04 07:01:14 +01:00
|
|
|
#ifdef PIM_DEBUG_IFADDR_DUMP
|
|
|
|
static void dump_if_address(struct interface *ifp)
|
|
|
|
{
|
|
|
|
struct connected *ifc;
|
|
|
|
struct listnode *node;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2020-03-06 15:23:22 +01:00
|
|
|
zlog_debug("%s %s: interface %s addresses:", __FILE__, __func__,
|
|
|
|
ifp->name);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2015-02-04 07:01:14 +01:00
|
|
|
for (ALL_LIST_ELEMENTS_RO(ifp->connected, node, ifc)) {
|
|
|
|
struct prefix *p = ifc->address;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2015-02-04 07:01:14 +01:00
|
|
|
if (p->family != AF_INET)
|
|
|
|
continue;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2020-10-22 16:01:20 +02:00
|
|
|
zlog_debug("%s %s: interface %s address %pI4 %s", __FILE__,
|
|
|
|
__func__, ifp->name, &p->u.prefix4,
|
2015-02-04 07:01:14 +01:00
|
|
|
CHECK_FLAG(ifc->flags, ZEBRA_IFA_SECONDARY)
|
|
|
|
? "secondary"
|
|
|
|
: "primary");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2019-05-03 21:42:59 +02:00
|
|
|
static int pim_zebra_if_address_add(ZAPI_CALLBACK_ARGS)
|
2015-02-04 07:01:14 +01:00
|
|
|
{
|
|
|
|
struct connected *c;
|
|
|
|
struct prefix *p;
|
2016-11-18 18:12:27 +01:00
|
|
|
struct pim_interface *pim_ifp;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2015-02-04 07:01:14 +01:00
|
|
|
/*
|
|
|
|
zebra api notifies address adds/dels events by using the same call
|
|
|
|
interface_add_read below, see comments in lib/zclient.c
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2015-02-04 07:01:14 +01:00
|
|
|
zebra_interface_address_read(ZEBRA_INTERFACE_ADDRESS_ADD, ...)
|
|
|
|
will add address to interface list by calling
|
|
|
|
connected_add_by_prefix()
|
|
|
|
*/
|
2019-05-03 21:42:59 +02:00
|
|
|
c = zebra_interface_address_read(cmd, zclient->ibuf, vrf_id);
|
2015-02-04 07:01:14 +01:00
|
|
|
if (!c)
|
|
|
|
return 0;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2016-11-18 18:12:27 +01:00
|
|
|
pim_ifp = c->ifp->info;
|
2015-02-04 07:01:14 +01:00
|
|
|
p = c->address;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2015-02-04 07:01:14 +01:00
|
|
|
if (PIM_DEBUG_ZEBRA) {
|
2020-10-18 13:33:54 +02:00
|
|
|
zlog_debug("%s: %s(%u) connected IP address %pFX flags %u %s",
|
|
|
|
__func__, c->ifp->name, vrf_id, p, c->flags,
|
2017-06-13 14:59:32 +02:00
|
|
|
CHECK_FLAG(c->flags, ZEBRA_IFA_SECONDARY)
|
|
|
|
? "secondary"
|
|
|
|
: "primary");
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2015-02-04 07:01:14 +01:00
|
|
|
#ifdef PIM_DEBUG_IFADDR_DUMP
|
|
|
|
dump_if_address(c->ifp);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2022-01-21 16:42:03 +01:00
|
|
|
#if PIM_IPV == 4
|
2022-01-14 17:52:36 +01:00
|
|
|
if (p->family != PIM_AF)
|
|
|
|
SET_FLAG(c->flags, ZEBRA_IFA_SECONDARY);
|
|
|
|
else if (!CHECK_FLAG(c->flags, ZEBRA_IFA_SECONDARY)) {
|
|
|
|
/* trying to add primary address? */
|
|
|
|
pim_addr primary_addr = pim_find_primary_addr(c->ifp);
|
|
|
|
pim_addr addr = pim_addr_from_prefix(p);
|
|
|
|
|
|
|
|
if (pim_addr_cmp(primary_addr, addr)) {
|
2020-10-18 13:33:54 +02:00
|
|
|
if (PIM_DEBUG_ZEBRA)
|
2016-11-18 18:12:27 +01:00
|
|
|
zlog_warn(
|
2020-10-18 13:33:54 +02:00
|
|
|
"%s: %s : forcing secondary flag on %pFX",
|
|
|
|
__func__, c->ifp->name, p);
|
2015-02-04 07:01:14 +01:00
|
|
|
SET_FLAG(c->flags, ZEBRA_IFA_SECONDARY);
|
|
|
|
}
|
|
|
|
}
|
2022-03-10 13:10:37 +01:00
|
|
|
#else /* PIM_IPV != 4 */
|
|
|
|
if (p->family != PIM_AF)
|
|
|
|
return 0;
|
|
|
|
#endif
|
2015-02-04 07:01:14 +01:00
|
|
|
|
|
|
|
pim_if_addr_add(c);
|
2018-05-11 21:04:10 +02:00
|
|
|
if (pim_ifp) {
|
2022-01-21 16:42:03 +01:00
|
|
|
struct pim_instance *pim;
|
|
|
|
|
2018-05-11 21:04:10 +02:00
|
|
|
pim = pim_get_pim_instance(vrf_id);
|
2022-04-04 12:54:42 +02:00
|
|
|
if (!pim) {
|
|
|
|
if (PIM_DEBUG_ZEBRA)
|
|
|
|
zlog_debug("%s: Unable to find pim instance",
|
|
|
|
__func__);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-05-11 21:04:10 +02:00
|
|
|
pim_ifp->pim = pim;
|
|
|
|
|
2016-11-18 18:12:27 +01:00
|
|
|
pim_rp_check_on_if_add(pim_ifp);
|
2018-05-11 21:04:10 +02:00
|
|
|
}
|
2015-02-04 07:01:14 +01:00
|
|
|
|
2016-09-07 15:06:47 +02:00
|
|
|
if (if_is_loopback(c->ifp)) {
|
2021-11-16 16:09:09 +01:00
|
|
|
struct vrf *vrf = vrf_lookup_by_id(vrf_id);
|
2016-09-07 15:06:47 +02:00
|
|
|
struct interface *ifp;
|
|
|
|
|
2017-10-06 20:25:58 +02:00
|
|
|
FOR_ALL_INTERFACES (vrf, ifp) {
|
2016-09-07 15:06:47 +02:00
|
|
|
if (!if_is_loopback(ifp) && if_is_operative(ifp))
|
|
|
|
pim_if_addr_add_all(ifp);
|
|
|
|
}
|
|
|
|
}
|
2015-02-04 07:01:14 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-05-03 21:42:59 +02:00
|
|
|
static int pim_zebra_if_address_del(ZAPI_CALLBACK_ARGS)
|
2015-02-04 07:01:14 +01:00
|
|
|
{
|
|
|
|
struct connected *c;
|
|
|
|
struct prefix *p;
|
2017-05-19 22:41:25 +02:00
|
|
|
struct vrf *vrf = vrf_lookup_by_id(vrf_id);
|
2017-10-25 19:30:45 +02:00
|
|
|
|
|
|
|
if (!vrf)
|
|
|
|
return 0;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2015-02-04 07:01:14 +01:00
|
|
|
/*
|
|
|
|
zebra api notifies address adds/dels events by using the same call
|
|
|
|
interface_add_read below, see comments in lib/zclient.c
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2015-02-04 07:01:14 +01:00
|
|
|
zebra_interface_address_read(ZEBRA_INTERFACE_ADDRESS_DELETE, ...)
|
|
|
|
will remove address from interface list by calling
|
|
|
|
connected_delete_by_prefix()
|
|
|
|
*/
|
2019-05-03 21:42:59 +02:00
|
|
|
c = zebra_interface_address_read(cmd, zclient->ibuf, vrf_id);
|
2015-02-04 07:01:14 +01:00
|
|
|
if (!c)
|
|
|
|
return 0;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2015-02-04 07:01:14 +01:00
|
|
|
p = c->address;
|
2017-03-17 01:07:08 +01:00
|
|
|
|
2022-01-21 16:42:03 +01:00
|
|
|
if (PIM_DEBUG_ZEBRA) {
|
|
|
|
zlog_debug(
|
|
|
|
"%s: %s(%u) disconnected IP address %pFX flags %u %s",
|
|
|
|
__func__, c->ifp->name, vrf_id, p, c->flags,
|
|
|
|
CHECK_FLAG(c->flags, ZEBRA_IFA_SECONDARY)
|
|
|
|
? "secondary"
|
|
|
|
: "primary");
|
2015-02-04 07:01:14 +01:00
|
|
|
#ifdef PIM_DEBUG_IFADDR_DUMP
|
2022-01-21 16:42:03 +01:00
|
|
|
dump_if_address(c->ifp);
|
2015-02-04 07:01:14 +01:00
|
|
|
#endif
|
2022-01-21 16:42:03 +01:00
|
|
|
}
|
2015-02-04 07:01:14 +01:00
|
|
|
|
2022-03-10 13:10:37 +01:00
|
|
|
if (p->family == PIM_AF) {
|
2022-01-21 16:42:03 +01:00
|
|
|
struct pim_instance *pim;
|
2015-02-04 07:01:14 +01:00
|
|
|
|
2022-01-21 16:42:03 +01:00
|
|
|
pim = vrf->info;
|
2017-03-17 01:07:08 +01:00
|
|
|
pim_if_addr_del(c, 0);
|
2017-05-19 22:41:25 +02:00
|
|
|
pim_rp_setup(pim);
|
|
|
|
pim_i_am_rp_re_evaluate(pim);
|
2017-03-17 01:07:08 +01:00
|
|
|
}
|
|
|
|
|
2019-10-30 01:16:28 +01:00
|
|
|
connected_free(&c);
|
2015-02-04 07:01:14 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-07-31 23:40:37 +02:00
|
|
|
void pim_zebra_update_all_interfaces(struct pim_instance *pim)
|
|
|
|
{
|
|
|
|
struct interface *ifp;
|
|
|
|
|
|
|
|
FOR_ALL_INTERFACES (pim->vrf, ifp) {
|
|
|
|
struct pim_interface *pim_ifp = ifp->info;
|
|
|
|
struct pim_iface_upstream_switch *us;
|
|
|
|
struct listnode *node;
|
|
|
|
|
|
|
|
if (!pim_ifp)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
for (ALL_LIST_ELEMENTS_RO(pim_ifp->upstream_switch_list, node,
|
|
|
|
us)) {
|
|
|
|
struct pim_rpf rpf;
|
|
|
|
|
|
|
|
rpf.source_nexthop.interface = ifp;
|
2022-04-27 10:22:21 +02:00
|
|
|
rpf.rpf_addr = us->address;
|
2018-07-31 23:40:37 +02:00
|
|
|
pim_joinprune_send(&rpf, us->us);
|
|
|
|
pim_jp_agg_clear_group(us->us);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-01 00:27:54 +02:00
|
|
|
void pim_zebra_upstream_rpf_changed(struct pim_instance *pim,
|
|
|
|
struct pim_upstream *up,
|
|
|
|
struct pim_rpf *old)
|
|
|
|
{
|
2019-02-22 16:29:24 +01:00
|
|
|
if (old->source_nexthop.interface) {
|
|
|
|
struct pim_neighbor *nbr;
|
2018-08-01 00:27:54 +02:00
|
|
|
|
2022-04-27 10:22:21 +02:00
|
|
|
nbr = pim_neighbor_find(old->source_nexthop.interface,
|
2022-10-19 02:32:11 +02:00
|
|
|
old->rpf_addr, true);
|
|
|
|
|
2019-02-22 16:29:24 +01:00
|
|
|
if (nbr)
|
2019-11-15 21:08:18 +01:00
|
|
|
pim_jp_agg_remove_group(nbr->upstream_jp_agg, up, nbr);
|
2018-08-01 00:27:54 +02:00
|
|
|
|
|
|
|
/*
|
2019-02-22 16:29:24 +01:00
|
|
|
* We have detected a case where we might need
|
|
|
|
* to rescan the inherited o_list so do it.
|
2018-08-01 00:27:54 +02:00
|
|
|
*/
|
2019-02-22 16:29:24 +01:00
|
|
|
if (up->channel_oil->oil_inherited_rescan) {
|
|
|
|
pim_upstream_inherited_olist_decide(pim, up);
|
|
|
|
up->channel_oil->oil_inherited_rescan = 0;
|
|
|
|
}
|
2018-08-01 00:27:54 +02:00
|
|
|
|
2019-02-22 16:29:24 +01:00
|
|
|
if (up->join_state == PIM_UPSTREAM_JOINED) {
|
|
|
|
/*
|
|
|
|
* If we come up real fast we can be here
|
|
|
|
* where the mroute has not been installed
|
|
|
|
* so install it.
|
|
|
|
*/
|
|
|
|
if (!up->channel_oil->installed)
|
2019-11-15 19:40:00 +01:00
|
|
|
pim_upstream_mroute_add(up->channel_oil,
|
2020-03-05 19:17:54 +01:00
|
|
|
__func__);
|
2019-02-22 16:29:24 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* RFC 4601: 4.5.7. Sending (S,G)
|
|
|
|
* Join/Prune Messages
|
|
|
|
*
|
|
|
|
* Transitions from Joined State
|
|
|
|
*
|
|
|
|
* RPF'(S,G) changes not due to an Assert
|
|
|
|
*
|
|
|
|
* The upstream (S,G) state machine remains
|
|
|
|
* in Joined state. Send Join(S,G) to the new
|
|
|
|
* upstream neighbor, which is the new value
|
|
|
|
* of RPF'(S,G). Send Prune(S,G) to the old
|
|
|
|
* upstream neighbor, which is the old value
|
|
|
|
* of RPF'(S,G). Set the Join Timer (JT) to
|
|
|
|
* expire after t_periodic seconds.
|
|
|
|
*/
|
|
|
|
pim_jp_agg_switch_interface(old, &up->rpf, up);
|
|
|
|
|
|
|
|
pim_upstream_join_timer_restart(up, old);
|
|
|
|
} /* up->join_state == PIM_UPSTREAM_JOINED */
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
2018-08-01 00:27:54 +02:00
|
|
|
/*
|
2019-02-22 16:29:24 +01:00
|
|
|
* We have detected a case where we might need
|
|
|
|
* to rescan the inherited o_list so do it.
|
2018-08-01 00:27:54 +02:00
|
|
|
*/
|
2019-02-22 16:29:24 +01:00
|
|
|
if (up->channel_oil->oil_inherited_rescan) {
|
|
|
|
pim_upstream_inherited_olist_decide(pim, up);
|
|
|
|
up->channel_oil->oil_inherited_rescan = 0;
|
|
|
|
}
|
2018-08-01 00:27:54 +02:00
|
|
|
|
2019-11-15 20:41:49 +01:00
|
|
|
if (up->join_state == PIM_UPSTREAM_JOINED)
|
|
|
|
pim_jp_agg_switch_interface(old, &up->rpf, up);
|
|
|
|
|
2019-02-22 16:29:24 +01:00
|
|
|
if (!up->channel_oil->installed)
|
2020-03-05 19:17:54 +01:00
|
|
|
pim_upstream_mroute_add(up->channel_oil, __func__);
|
2019-02-22 16:29:24 +01:00
|
|
|
}
|
2018-08-01 00:27:54 +02:00
|
|
|
|
2019-02-22 16:29:24 +01:00
|
|
|
/* FIXME can join_desired actually be changed by pim_rpf_update()
|
|
|
|
* returning PIM_RPF_CHANGED ?
|
|
|
|
*/
|
2018-08-01 00:27:54 +02:00
|
|
|
pim_upstream_update_join_desired(pim, up);
|
|
|
|
}
|
|
|
|
|
2022-01-21 16:42:03 +01:00
|
|
|
__attribute__((unused))
|
2019-05-03 21:42:59 +02:00
|
|
|
static int pim_zebra_vxlan_sg_proc(ZAPI_CALLBACK_ARGS)
|
2019-03-21 16:49:09 +01:00
|
|
|
{
|
|
|
|
struct stream *s;
|
|
|
|
struct pim_instance *pim;
|
2022-01-04 17:54:44 +01:00
|
|
|
pim_sgaddr sg;
|
|
|
|
size_t prefixlen;
|
2019-03-21 16:49:09 +01:00
|
|
|
|
|
|
|
pim = pim_get_pim_instance(vrf_id);
|
|
|
|
if (!pim)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
s = zclient->ibuf;
|
|
|
|
|
2022-01-04 17:54:44 +01:00
|
|
|
prefixlen = stream_getl(s);
|
2022-01-14 16:55:12 +01:00
|
|
|
stream_get(&sg.src, s, prefixlen);
|
|
|
|
stream_get(&sg.grp, s, prefixlen);
|
2019-03-21 16:49:09 +01:00
|
|
|
|
2022-01-04 21:10:37 +01:00
|
|
|
if (PIM_DEBUG_ZEBRA)
|
|
|
|
zlog_debug("%u:recv SG %s %pSG", vrf_id,
|
|
|
|
(cmd == ZEBRA_VXLAN_SG_ADD) ? "add" : "del", &sg);
|
2019-03-21 16:49:09 +01:00
|
|
|
|
2019-05-03 21:42:59 +02:00
|
|
|
if (cmd == ZEBRA_VXLAN_SG_ADD)
|
2019-03-21 16:49:09 +01:00
|
|
|
pim_vxlan_sg_add(pim, &sg);
|
|
|
|
else
|
|
|
|
pim_vxlan_sg_del(pim, &sg);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-01-21 16:42:03 +01:00
|
|
|
__attribute__((unused))
|
2019-07-02 20:20:34 +02:00
|
|
|
static void pim_zebra_vxlan_replay(void)
|
|
|
|
{
|
|
|
|
struct stream *s = NULL;
|
|
|
|
|
|
|
|
/* Check socket. */
|
|
|
|
if (!zclient || zclient->sock < 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
s = zclient->obuf;
|
|
|
|
stream_reset(s);
|
|
|
|
|
|
|
|
zclient_create_header(s, ZEBRA_VXLAN_SG_REPLAY, VRF_DEFAULT);
|
|
|
|
stream_putw_at(s, 0, stream_get_endp(s));
|
|
|
|
|
|
|
|
zclient_send_message(zclient);
|
|
|
|
}
|
|
|
|
|
2018-03-18 02:13:09 +01:00
|
|
|
void pim_scan_oil(struct pim_instance *pim)
|
2016-06-27 21:06:46 +02:00
|
|
|
{
|
|
|
|
struct channel_oil *c_oil;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2018-03-18 02:34:55 +01:00
|
|
|
pim->scan_oil_last = pim_time_monotonic_sec();
|
|
|
|
++pim->scan_oil_events;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2019-12-21 04:12:19 +01:00
|
|
|
frr_each (rb_pim_oil, &pim->channel_oil_head, c_oil)
|
2019-11-15 20:09:13 +01:00
|
|
|
pim_upstream_mroute_iif_update(c_oil, __func__);
|
2015-02-04 07:01:14 +01:00
|
|
|
}
|
|
|
|
|
2022-02-23 01:04:25 +01:00
|
|
|
static void on_rpf_cache_refresh(struct thread *t)
|
2015-02-04 07:01:14 +01:00
|
|
|
{
|
2018-03-18 02:13:09 +01:00
|
|
|
struct pim_instance *pim = THREAD_ARG(t);
|
|
|
|
|
2015-02-04 07:01:14 +01:00
|
|
|
/* update kernel multicast forwarding cache (MFC) */
|
2018-03-18 02:13:09 +01:00
|
|
|
pim_scan_oil(pim);
|
2015-02-04 07:01:14 +01:00
|
|
|
|
2018-03-18 02:34:55 +01:00
|
|
|
pim->rpf_cache_refresh_last = pim_time_monotonic_sec();
|
|
|
|
++pim->rpf_cache_refresh_events;
|
2015-02-04 07:01:14 +01: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>
2017-04-05 22:14:12 +02:00
|
|
|
// It is called as part of pim_neighbor_add
|
|
|
|
// pim_rp_setup ();
|
2015-02-04 07:01:14 +01:00
|
|
|
}
|
|
|
|
|
2018-03-18 02:13:09 +01:00
|
|
|
void sched_rpf_cache_refresh(struct pim_instance *pim)
|
2015-02-04 07:01:14 +01:00
|
|
|
{
|
2018-03-18 02:34:55 +01:00
|
|
|
++pim->rpf_cache_refresh_requests;
|
2015-02-04 07:01:14 +01:00
|
|
|
|
2018-03-18 02:34:55 +01:00
|
|
|
pim_rpf_set_refresh_time(pim);
|
2016-10-27 17:54:55 +02:00
|
|
|
|
2018-03-18 02:13:09 +01:00
|
|
|
if (pim->rpf_cache_refresher) {
|
2015-02-04 07:01:14 +01:00
|
|
|
/* Refresh timer is already running */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Start refresh timer */
|
|
|
|
|
|
|
|
if (PIM_DEBUG_ZEBRA) {
|
2020-03-05 19:17:54 +01:00
|
|
|
zlog_debug("%s: triggering %ld msec timer", __func__,
|
2018-12-21 14:50:34 +01:00
|
|
|
router->rpf_cache_refresh_delay_msec);
|
2015-02-04 07:01:14 +01:00
|
|
|
}
|
|
|
|
|
2018-12-20 16:34:04 +01:00
|
|
|
thread_add_timer_msec(router->master, on_rpf_cache_refresh, pim,
|
2018-12-21 14:50:34 +01:00
|
|
|
router->rpf_cache_refresh_delay_msec,
|
2018-03-18 02:13:09 +01:00
|
|
|
&pim->rpf_cache_refresher);
|
2015-02-04 07:01:14 +01:00
|
|
|
}
|
|
|
|
|
2016-05-26 03:24:01 +02:00
|
|
|
static void pim_zebra_connected(struct zclient *zclient)
|
|
|
|
{
|
2022-01-21 16:42:03 +01:00
|
|
|
#if PIM_IPV == 4
|
2017-04-11 03:01:53 +02:00
|
|
|
/* Send the client registration */
|
2019-03-26 14:29:13 +01:00
|
|
|
bfd_client_sendmsg(zclient, ZEBRA_BFD_CLIENT_REGISTER, router->vrf_id);
|
2022-01-21 16:42:03 +01:00
|
|
|
#endif
|
2017-04-11 03:01:53 +02:00
|
|
|
|
2018-12-21 15:23:36 +01:00
|
|
|
zclient_send_reg_requests(zclient, router->vrf_id);
|
2019-07-02 20:20:34 +02:00
|
|
|
|
2022-01-21 16:42:03 +01:00
|
|
|
#if PIM_IPV == 4
|
2019-07-02 20:20:34 +02:00
|
|
|
/* request for VxLAN BUM group addresses */
|
|
|
|
pim_zebra_vxlan_replay();
|
2022-01-21 16:42:03 +01:00
|
|
|
#endif
|
2016-05-26 03:24:01 +02:00
|
|
|
}
|
2016-11-03 23:55:35 +01:00
|
|
|
|
2018-12-18 14:13:25 +01:00
|
|
|
static void pim_zebra_capabilities(struct zclient_capabilities *cap)
|
|
|
|
{
|
2020-02-06 18:30:36 +01:00
|
|
|
router->mlag_role = cap->role;
|
2022-06-22 14:12:04 +02:00
|
|
|
router->multipath = cap->ecmp;
|
2018-12-18 14:13:25 +01:00
|
|
|
}
|
|
|
|
|
2021-10-20 13:07:47 +02:00
|
|
|
static zclient_handler *const pim_handlers[] = {
|
|
|
|
[ZEBRA_INTERFACE_ADDRESS_ADD] = pim_zebra_if_address_add,
|
|
|
|
[ZEBRA_INTERFACE_ADDRESS_DELETE] = pim_zebra_if_address_del,
|
2022-03-01 10:57:42 +01:00
|
|
|
|
|
|
|
[ZEBRA_NEXTHOP_UPDATE] = pim_parse_nexthop_update,
|
2022-01-21 16:42:03 +01:00
|
|
|
[ZEBRA_ROUTER_ID_UPDATE] = pim_router_id_update_zebra,
|
2021-10-20 13:07:47 +02:00
|
|
|
[ZEBRA_INTERFACE_VRF_UPDATE] = pim_zebra_interface_vrf_update,
|
|
|
|
|
2022-03-10 13:10:37 +01:00
|
|
|
#if PIM_IPV == 4
|
2021-10-20 13:07:47 +02:00
|
|
|
[ZEBRA_VXLAN_SG_ADD] = pim_zebra_vxlan_sg_proc,
|
|
|
|
[ZEBRA_VXLAN_SG_DEL] = pim_zebra_vxlan_sg_proc,
|
|
|
|
|
|
|
|
[ZEBRA_MLAG_PROCESS_UP] = pim_zebra_mlag_process_up,
|
|
|
|
[ZEBRA_MLAG_PROCESS_DOWN] = pim_zebra_mlag_process_down,
|
|
|
|
[ZEBRA_MLAG_FORWARD_MSG] = pim_zebra_mlag_handle_msg,
|
2022-01-21 16:42:03 +01:00
|
|
|
#endif
|
2021-10-20 13:07:47 +02:00
|
|
|
};
|
|
|
|
|
2016-11-13 09:48:56 +01:00
|
|
|
void pim_zebra_init(void)
|
2015-02-04 07:01:14 +01:00
|
|
|
{
|
|
|
|
/* Socket for receiving updates from Zebra daemon */
|
2021-10-20 13:07:47 +02:00
|
|
|
zclient = zclient_new(router->master, &zclient_options_default,
|
|
|
|
pim_handlers, array_size(pim_handlers));
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2018-12-18 14:13:25 +01:00
|
|
|
zclient->zebra_capabilities = pim_zebra_capabilities;
|
2016-12-09 17:08:45 +01:00
|
|
|
zclient->zebra_connected = pim_zebra_connected;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2017-10-11 16:37:20 +02:00
|
|
|
zclient_init(zclient, ZEBRA_ROUTE_PIM, 0, &pimd_privs);
|
2015-02-04 07:01:14 +01:00
|
|
|
if (PIM_DEBUG_PIM_TRACE) {
|
2020-03-05 19:17:54 +01:00
|
|
|
zlog_notice("%s: zclient socket initialized", __func__);
|
2015-02-04 07:01:14 +01:00
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2016-08-09 21:04:23 +02:00
|
|
|
zclient_lookup_new();
|
2015-02-04 07:01:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void pim_forward_start(struct pim_ifchannel *ch)
|
|
|
|
{
|
|
|
|
struct pim_upstream *up = ch->upstream;
|
pimd: fix OIL not removed after IGMP prune
Issue: Client1------LHR-----(int-1)RP(int-2)------client2
Client2 send IGMP join for group G.
Client1 send IGMP join for group G.
verify show ip mroute in RP, will have 2 OIL.
Client2 send IGMP leave.
Verify show ip mroute in RP, will still have 2.
Root cause: When RP receives IGMP join from client2, it creates
a (s,g) channel oil and add the interface int-2 into oil list and
set the flag PIM_OIF_FLAG_PROTO_IGMP to int-2
Client1 send IGMP join, LHR will send a (*,G) join to RP. RP will
add the interface int-1 into the oil list of (s,g) channel_oil and
will set the flag PIM_OIF_FLAG_PROTO_IGMP and PIM_OIF_FLAG_PROTO_PIM
to the int-1 and set PIM_OIF_FLAG_PROTO_PIM to int-2 as well. It is
happening because of the pim_upstream_inherited_olist_decide() and
forward_on() get all the oil and update the flag wrongly.
So now when client 2 sends IGMP prune, RP will not remove the int-2
from oil list since both PIM_OIF_FLAG_PROTO_PIM & PIM_OIF_FLAG_PROTO_IGMP
are set, it just unset the flag PIM_OIF_FLAG_PROTO_IGMP.
Fix: Introduced new flags in if_channel, PIM_IF_FLAG_MASK_PROTO_PIM
& PIM_IF_FLAG_MASK_PROTO_IGMP. If a if_channel is created because of
pim join or pim (s,g,rpt) prune received, then set the flag
PIM_IF_FLAG_MASK_PROTO_PIM. If a if_channel is created becuase of IGMP
join received, then set the flag PIM_IF_FLAG_MASK_PROTO_IGMP.
When an interface needs to be added into the oil list check if
PIM_IF_FLAG_MASK_PROTO_PIM or PIM_IF_FLAG_MASK_PROTO_IGMP is set, then
update oil flag accordingly.
Signed-off-by: Sarita Patra <saritap@vmware.com>
2020-03-02 09:55:22 +01:00
|
|
|
uint32_t mask = 0;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2022-01-05 19:12:12 +01:00
|
|
|
if (PIM_DEBUG_PIM_TRACE)
|
2022-03-11 12:13:41 +01:00
|
|
|
zlog_debug("%s: (S,G)=%pSG oif=%s (%pPA)", __func__, &ch->sg,
|
2022-01-05 19:12:12 +01:00
|
|
|
ch->interface->name, &up->upstream_addr);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
pimd: fix OIL not removed after IGMP prune
Issue: Client1------LHR-----(int-1)RP(int-2)------client2
Client2 send IGMP join for group G.
Client1 send IGMP join for group G.
verify show ip mroute in RP, will have 2 OIL.
Client2 send IGMP leave.
Verify show ip mroute in RP, will still have 2.
Root cause: When RP receives IGMP join from client2, it creates
a (s,g) channel oil and add the interface int-2 into oil list and
set the flag PIM_OIF_FLAG_PROTO_IGMP to int-2
Client1 send IGMP join, LHR will send a (*,G) join to RP. RP will
add the interface int-1 into the oil list of (s,g) channel_oil and
will set the flag PIM_OIF_FLAG_PROTO_IGMP and PIM_OIF_FLAG_PROTO_PIM
to the int-1 and set PIM_OIF_FLAG_PROTO_PIM to int-2 as well. It is
happening because of the pim_upstream_inherited_olist_decide() and
forward_on() get all the oil and update the flag wrongly.
So now when client 2 sends IGMP prune, RP will not remove the int-2
from oil list since both PIM_OIF_FLAG_PROTO_PIM & PIM_OIF_FLAG_PROTO_IGMP
are set, it just unset the flag PIM_OIF_FLAG_PROTO_IGMP.
Fix: Introduced new flags in if_channel, PIM_IF_FLAG_MASK_PROTO_PIM
& PIM_IF_FLAG_MASK_PROTO_IGMP. If a if_channel is created because of
pim join or pim (s,g,rpt) prune received, then set the flag
PIM_IF_FLAG_MASK_PROTO_PIM. If a if_channel is created becuase of IGMP
join received, then set the flag PIM_IF_FLAG_MASK_PROTO_IGMP.
When an interface needs to be added into the oil list check if
PIM_IF_FLAG_MASK_PROTO_PIM or PIM_IF_FLAG_MASK_PROTO_IGMP is set, then
update oil flag accordingly.
Signed-off-by: Sarita Patra <saritap@vmware.com>
2020-03-02 09:55:22 +01:00
|
|
|
if (PIM_IF_FLAG_TEST_PROTO_IGMP(ch->flags))
|
2022-04-13 10:00:50 +02:00
|
|
|
mask = PIM_OIF_FLAG_PROTO_GM;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
pimd: fix OIL not removed after IGMP prune
Issue: Client1------LHR-----(int-1)RP(int-2)------client2
Client2 send IGMP join for group G.
Client1 send IGMP join for group G.
verify show ip mroute in RP, will have 2 OIL.
Client2 send IGMP leave.
Verify show ip mroute in RP, will still have 2.
Root cause: When RP receives IGMP join from client2, it creates
a (s,g) channel oil and add the interface int-2 into oil list and
set the flag PIM_OIF_FLAG_PROTO_IGMP to int-2
Client1 send IGMP join, LHR will send a (*,G) join to RP. RP will
add the interface int-1 into the oil list of (s,g) channel_oil and
will set the flag PIM_OIF_FLAG_PROTO_IGMP and PIM_OIF_FLAG_PROTO_PIM
to the int-1 and set PIM_OIF_FLAG_PROTO_PIM to int-2 as well. It is
happening because of the pim_upstream_inherited_olist_decide() and
forward_on() get all the oil and update the flag wrongly.
So now when client 2 sends IGMP prune, RP will not remove the int-2
from oil list since both PIM_OIF_FLAG_PROTO_PIM & PIM_OIF_FLAG_PROTO_IGMP
are set, it just unset the flag PIM_OIF_FLAG_PROTO_IGMP.
Fix: Introduced new flags in if_channel, PIM_IF_FLAG_MASK_PROTO_PIM
& PIM_IF_FLAG_MASK_PROTO_IGMP. If a if_channel is created because of
pim join or pim (s,g,rpt) prune received, then set the flag
PIM_IF_FLAG_MASK_PROTO_PIM. If a if_channel is created becuase of IGMP
join received, then set the flag PIM_IF_FLAG_MASK_PROTO_IGMP.
When an interface needs to be added into the oil list check if
PIM_IF_FLAG_MASK_PROTO_PIM or PIM_IF_FLAG_MASK_PROTO_IGMP is set, then
update oil flag accordingly.
Signed-off-by: Sarita Patra <saritap@vmware.com>
2020-03-02 09:55:22 +01:00
|
|
|
if (PIM_IF_FLAG_TEST_PROTO_PIM(ch->flags))
|
|
|
|
mask |= PIM_OIF_FLAG_PROTO_PIM;
|
|
|
|
|
2019-11-15 17:47:33 +01:00
|
|
|
pim_channel_add_oif(up->channel_oil, ch->interface,
|
|
|
|
mask, __func__);
|
2015-02-04 07:01:14 +01:00
|
|
|
}
|
|
|
|
|
2021-10-24 13:45:18 +02:00
|
|
|
void pim_forward_stop(struct pim_ifchannel *ch)
|
2015-02-04 07:01:14 +01:00
|
|
|
{
|
|
|
|
struct pim_upstream *up = ch->upstream;
|
|
|
|
|
|
|
|
if (PIM_DEBUG_PIM_TRACE) {
|
2021-10-24 13:45:18 +02:00
|
|
|
zlog_debug("%s: (S,G)=%s oif=%s installed: %d",
|
2020-03-05 19:17:54 +01:00
|
|
|
__func__, ch->sg_str, ch->interface->name,
|
2021-10-24 13:45:18 +02:00
|
|
|
up->channel_oil->installed);
|
2015-02-04 07:01:14 +01:00
|
|
|
}
|
|
|
|
|
2019-04-24 10:33:37 +02:00
|
|
|
/*
|
|
|
|
* If a channel is being removed, check to see if we still need
|
|
|
|
* to inherit the interface. If so make sure it is added in
|
|
|
|
*/
|
|
|
|
if (pim_upstream_evaluate_join_desired_interface(up, ch, ch->parent))
|
|
|
|
pim_channel_add_oif(up->channel_oil, ch->interface,
|
2019-11-15 17:47:33 +01:00
|
|
|
PIM_OIF_FLAG_PROTO_PIM, __func__);
|
2019-04-24 10:33:37 +02:00
|
|
|
else
|
|
|
|
pim_channel_del_oif(up->channel_oil, ch->interface,
|
2019-11-15 17:47:33 +01:00
|
|
|
PIM_OIF_FLAG_PROTO_PIM, __func__);
|
2015-02-04 07:01:14 +01:00
|
|
|
}
|
2016-12-09 17:05:08 +01:00
|
|
|
|
|
|
|
void pim_zebra_zclient_update(struct vty *vty)
|
|
|
|
{
|
|
|
|
vty_out(vty, "Zclient update socket: ");
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2016-12-09 17:08:45 +01:00
|
|
|
if (zclient) {
|
2017-07-13 17:49:13 +02:00
|
|
|
vty_out(vty, "%d failures=%d\n", zclient->sock, zclient->fail);
|
2016-12-09 17:05:08 +01:00
|
|
|
} else {
|
2017-07-13 17:49:13 +02:00
|
|
|
vty_out(vty, "<null zclient>\n");
|
2016-12-09 17:05:08 +01:00
|
|
|
}
|
|
|
|
}
|
2017-02-22 16:28:36 +01:00
|
|
|
|
|
|
|
struct zclient *pim_zebra_zclient_get(void)
|
|
|
|
{
|
|
|
|
if (zclient)
|
|
|
|
return zclient;
|
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
}
|
2019-09-19 05:07:44 +02:00
|
|
|
|
|
|
|
void pim_zebra_interface_set_master(struct interface *vrf,
|
|
|
|
struct interface *ifp)
|
|
|
|
{
|
|
|
|
zclient_interface_set_master(zclient, vrf, ifp);
|
|
|
|
}
|