]>
git.proxmox.com Git - mirror_frr.git/blob - pimd/pim_bfd.c
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * pim_bfd.c: PIM BFD handling routines
5 * Copyright (C) 2017 Cumulus Networks, Inc.
16 #include "pim_instance.h"
17 #include "pim_neighbor.h"
19 #include "pim_iface.h"
23 #include "pim_zebra.h"
26 * pim_bfd_write_config - Write the interface BFD configuration.
28 void pim_bfd_write_config(struct vty
*vty
, struct interface
*ifp
)
30 struct pim_interface
*pim_ifp
= ifp
->info
;
32 if (!pim_ifp
|| !pim_ifp
->bfd_config
.enabled
)
36 if (pim_ifp
->bfd_config
.detection_multiplier
!= BFD_DEF_DETECT_MULT
37 || pim_ifp
->bfd_config
.min_rx
!= BFD_DEF_MIN_RX
38 || pim_ifp
->bfd_config
.min_tx
!= BFD_DEF_MIN_TX
)
39 vty_out(vty
, " " PIM_AF_NAME
" pim bfd %d %d %d\n",
40 pim_ifp
->bfd_config
.detection_multiplier
,
41 pim_ifp
->bfd_config
.min_rx
, pim_ifp
->bfd_config
.min_tx
);
43 #endif /* ! HAVE_BFDD */
44 vty_out(vty
, " " PIM_AF_NAME
" pim bfd\n");
46 if (pim_ifp
->bfd_config
.profile
)
47 vty_out(vty
, " " PIM_AF_NAME
" pim bfd profile %s\n",
48 pim_ifp
->bfd_config
.profile
);
51 static void pim_neighbor_bfd_cb(struct bfd_session_params
*bsp
,
52 const struct bfd_session_status
*bss
, void *arg
)
54 struct pim_neighbor
*nbr
= arg
;
56 if (PIM_DEBUG_PIM_TRACE
) {
57 zlog_debug("%s: status %s old_status %s", __func__
,
58 bfd_get_status_str(bss
->state
),
59 bfd_get_status_str(bss
->previous_state
));
62 if (bss
->state
== BFD_STATUS_DOWN
63 && bss
->previous_state
== BFD_STATUS_UP
)
64 pim_neighbor_delete(nbr
->interface
, nbr
, "BFD Session Expired");
68 * pim_bfd_info_nbr_create - Create/update BFD information for a neighbor.
70 void pim_bfd_info_nbr_create(struct pim_interface
*pim_ifp
,
71 struct pim_neighbor
*neigh
)
73 /* Check if Pim Interface BFD is enabled */
74 if (!pim_ifp
|| !pim_ifp
->bfd_config
.enabled
)
77 if (neigh
->bfd_session
== NULL
)
78 neigh
->bfd_session
= bfd_sess_new(pim_neighbor_bfd_cb
, neigh
);
81 neigh
->bfd_session
, pim_ifp
->bfd_config
.detection_multiplier
,
82 pim_ifp
->bfd_config
.min_rx
, pim_ifp
->bfd_config
.min_tx
);
84 bfd_sess_set_ipv4_addrs(neigh
->bfd_session
, NULL
, &neigh
->source_addr
);
86 bfd_sess_set_ipv6_addrs(neigh
->bfd_session
, NULL
, &neigh
->source_addr
);
88 bfd_sess_set_interface(neigh
->bfd_session
, neigh
->interface
->name
);
89 bfd_sess_set_vrf(neigh
->bfd_session
, neigh
->interface
->vrf
->vrf_id
);
90 bfd_sess_set_profile(neigh
->bfd_session
, pim_ifp
->bfd_config
.profile
);
91 bfd_sess_install(neigh
->bfd_session
);
95 * pim_bfd_reg_dereg_all_nbr - Register/Deregister all neighbors associated
96 * with a interface with BFD through
97 * zebra for starting/stopping the monitoring of
98 * the neighbor rechahability.
100 void pim_bfd_reg_dereg_all_nbr(struct interface
*ifp
)
102 struct pim_interface
*pim_ifp
= NULL
;
103 struct listnode
*node
= NULL
;
104 struct pim_neighbor
*neigh
= NULL
;
110 for (ALL_LIST_ELEMENTS_RO(pim_ifp
->pim_neighbor_list
, node
, neigh
)) {
111 if (pim_ifp
->bfd_config
.enabled
)
112 pim_bfd_info_nbr_create(pim_ifp
, neigh
);
114 bfd_sess_free(&neigh
->bfd_session
);
118 void pim_bfd_init(void)
120 bfd_protocol_integration_init(pim_zebra_zclient_get(), router
->master
);