2017-04-11 03:01:53 +02:00
|
|
|
/*
|
|
|
|
* pim_bfd.c: PIM BFD handling routines
|
|
|
|
*
|
|
|
|
* Copyright (C) 2017 Cumulus Networks, Inc.
|
|
|
|
* Chirag Shah
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <zebra.h>
|
|
|
|
|
|
|
|
#include "lib/json.h"
|
|
|
|
#include "command.h"
|
|
|
|
#include "vty.h"
|
|
|
|
#include "zclient.h"
|
|
|
|
|
2017-05-20 01:36:53 +02:00
|
|
|
#include "pim_instance.h"
|
2021-08-19 11:36:16 +02:00
|
|
|
#include "pim_neighbor.h"
|
2017-04-11 03:01:53 +02:00
|
|
|
#include "pim_cmd.h"
|
|
|
|
#include "pim_vty.h"
|
|
|
|
#include "pim_iface.h"
|
|
|
|
#include "pim_bfd.h"
|
|
|
|
#include "bfd.h"
|
|
|
|
#include "pimd.h"
|
|
|
|
#include "pim_zebra.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* pim_bfd_write_config - Write the interface BFD configuration.
|
|
|
|
*/
|
|
|
|
void pim_bfd_write_config(struct vty *vty, struct interface *ifp)
|
|
|
|
{
|
|
|
|
struct pim_interface *pim_ifp = ifp->info;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2021-04-12 18:48:21 +02:00
|
|
|
if (!pim_ifp || !pim_ifp->bfd_config.enabled)
|
2017-06-02 02:11:19 +02:00
|
|
|
return;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2018-06-27 18:46:08 +02:00
|
|
|
#if HAVE_BFDD == 0
|
2021-04-12 18:48:21 +02:00
|
|
|
if (pim_ifp->bfd_config.detection_multiplier != BFD_DEF_DETECT_MULT
|
|
|
|
|| pim_ifp->bfd_config.min_rx != BFD_DEF_MIN_RX
|
|
|
|
|| pim_ifp->bfd_config.min_tx != BFD_DEF_MIN_TX)
|
|
|
|
vty_out(vty, " ip pim bfd %d %d %d\n",
|
|
|
|
pim_ifp->bfd_config.detection_multiplier,
|
|
|
|
pim_ifp->bfd_config.min_rx, pim_ifp->bfd_config.min_tx);
|
2017-04-11 03:01:53 +02:00
|
|
|
else
|
2018-06-27 18:46:08 +02:00
|
|
|
#endif /* ! HAVE_BFDD */
|
2017-07-13 17:49:13 +02:00
|
|
|
vty_out(vty, " ip pim bfd\n");
|
2021-04-13 16:07:01 +02:00
|
|
|
|
|
|
|
if (pim_ifp->bfd_config.profile)
|
|
|
|
vty_out(vty, " ip pim bfd profile %s\n",
|
|
|
|
pim_ifp->bfd_config.profile);
|
2017-04-11 03:01:53 +02:00
|
|
|
}
|
|
|
|
|
2021-04-12 18:48:21 +02:00
|
|
|
static void pim_neighbor_bfd_cb(struct bfd_session_params *bsp,
|
|
|
|
const struct bfd_session_status *bss, void *arg)
|
2017-04-11 03:01:53 +02:00
|
|
|
{
|
2021-04-12 18:48:21 +02:00
|
|
|
struct pim_neighbor *nbr = arg;
|
|
|
|
|
|
|
|
if (PIM_DEBUG_PIM_TRACE) {
|
|
|
|
zlog_debug("%s: status %s old_status %s", __func__,
|
|
|
|
bfd_get_status_str(bss->state),
|
|
|
|
bfd_get_status_str(bss->previous_state));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bss->state == BFD_STATUS_DOWN
|
|
|
|
&& bss->previous_state == BFD_STATUS_UP)
|
|
|
|
pim_neighbor_delete(nbr->interface, nbr, "BFD Session Expired");
|
2017-04-11 03:01:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* pim_bfd_info_nbr_create - Create/update BFD information for a neighbor.
|
|
|
|
*/
|
|
|
|
void pim_bfd_info_nbr_create(struct pim_interface *pim_ifp,
|
|
|
|
struct pim_neighbor *neigh)
|
|
|
|
{
|
|
|
|
/* Check if Pim Interface BFD is enabled */
|
2021-04-12 18:48:21 +02:00
|
|
|
if (!pim_ifp || !pim_ifp->bfd_config.enabled)
|
2017-04-11 03:01:53 +02:00
|
|
|
return;
|
bfdd, lib, bgpd: add bfd cbit usage
bfd cbit is a value carried out in bfd messages, that permit to keep or
not, the independence between control plane and dataplane. In other
words, while most of the cases plan to flush entries, when bfd goes
down, there are some cases where that bfd event should be ignored. this
is the case with non stop forwarding mechanisms where entries may be
kept. this is the case for BGP, when graceful restart capability is
used. If BFD event down happens, and bgp is in graceful restart mode, it
is wished to ignore the BFD event while waiting for the remote router to
restart.
The changes take into account the following:
- add a config flag across zebra layer so that daemon can set or not the
cbit capability.
- ability for daemons to read the remote bfd capability associated to a bfd
notification.
- in bfdd, according to the value, the cbit value is set
- in bfdd, the received value is retrived and stored in the bfd session
context.
- by default, the local cbit announced to remote is set to 1 while
preservation of the local path is not set.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-04-15 17:20:25 +02:00
|
|
|
|
2021-04-12 18:48:21 +02:00
|
|
|
if (neigh->bfd_session == NULL)
|
|
|
|
neigh->bfd_session = bfd_sess_new(pim_neighbor_bfd_cb, neigh);
|
bfdd, lib, bgpd: add bfd cbit usage
bfd cbit is a value carried out in bfd messages, that permit to keep or
not, the independence between control plane and dataplane. In other
words, while most of the cases plan to flush entries, when bfd goes
down, there are some cases where that bfd event should be ignored. this
is the case with non stop forwarding mechanisms where entries may be
kept. this is the case for BGP, when graceful restart capability is
used. If BFD event down happens, and bgp is in graceful restart mode, it
is wished to ignore the BFD event while waiting for the remote router to
restart.
The changes take into account the following:
- add a config flag across zebra layer so that daemon can set or not the
cbit capability.
- ability for daemons to read the remote bfd capability associated to a bfd
notification.
- in bfdd, according to the value, the cbit value is set
- in bfdd, the received value is retrived and stored in the bfd session
context.
- by default, the local cbit announced to remote is set to 1 while
preservation of the local path is not set.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-04-15 17:20:25 +02:00
|
|
|
|
2021-04-12 18:48:21 +02:00
|
|
|
bfd_sess_set_timers(
|
|
|
|
neigh->bfd_session, pim_ifp->bfd_config.detection_multiplier,
|
|
|
|
pim_ifp->bfd_config.min_rx, pim_ifp->bfd_config.min_tx);
|
|
|
|
bfd_sess_set_ipv4_addrs(neigh->bfd_session, NULL, &neigh->source_addr);
|
|
|
|
bfd_sess_set_interface(neigh->bfd_session, neigh->interface->name);
|
2021-05-31 12:57:55 +02:00
|
|
|
bfd_sess_set_vrf(neigh->bfd_session, neigh->interface->vrf_id);
|
2021-04-13 16:07:01 +02:00
|
|
|
bfd_sess_set_profile(neigh->bfd_session, pim_ifp->bfd_config.profile);
|
2021-04-12 18:48:21 +02:00
|
|
|
bfd_sess_install(neigh->bfd_session);
|
2017-04-11 03:01:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* pim_bfd_reg_dereg_all_nbr - Register/Deregister all neighbors associated
|
|
|
|
* with a interface with BFD through
|
|
|
|
* zebra for starting/stopping the monitoring of
|
|
|
|
* the neighbor rechahability.
|
|
|
|
*/
|
2021-04-12 18:48:21 +02:00
|
|
|
void pim_bfd_reg_dereg_all_nbr(struct interface *ifp)
|
2017-04-11 03:01:53 +02:00
|
|
|
{
|
|
|
|
struct pim_interface *pim_ifp = NULL;
|
|
|
|
struct listnode *node = NULL;
|
|
|
|
struct pim_neighbor *neigh = NULL;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2017-04-11 03:01:53 +02:00
|
|
|
pim_ifp = ifp->info;
|
|
|
|
if (!pim_ifp)
|
2021-04-12 18:48:21 +02:00
|
|
|
return;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2017-04-11 03:01:53 +02:00
|
|
|
for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_neighbor_list, node, neigh)) {
|
2021-04-12 18:48:21 +02:00
|
|
|
if (pim_ifp->bfd_config.enabled)
|
2017-04-11 03:01:53 +02:00
|
|
|
pim_bfd_info_nbr_create(pim_ifp, neigh);
|
|
|
|
else
|
2021-04-12 18:48:21 +02:00
|
|
|
bfd_sess_free(&neigh->bfd_session);
|
2017-04-11 03:01:53 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void pim_bfd_init(void)
|
|
|
|
{
|
2021-04-12 18:48:21 +02:00
|
|
|
bfd_protocol_integration_init(pim_zebra_zclient_get(), router->master);
|
2017-04-11 03:01:53 +02:00
|
|
|
}
|