]>
git.proxmox.com Git - mirror_frr.git/blob - pimd/pim_bfd.c
2 * pim_bfd.c: PIM BFD handling routines
4 * Copyright (C) 2017 Cumulus Networks, Inc.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; see the file COPYING; if not, write to the
19 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
30 #include "pim_instance.h"
31 #include "pim_neighbor.h"
33 #include "pim_iface.h"
37 #include "pim_zebra.h"
40 * pim_bfd_write_config - Write the interface BFD configuration.
42 void pim_bfd_write_config(struct vty
*vty
, struct interface
*ifp
)
44 struct pim_interface
*pim_ifp
= ifp
->info
;
46 if (!pim_ifp
|| !pim_ifp
->bfd_config
.enabled
)
50 if (pim_ifp
->bfd_config
.detection_multiplier
!= BFD_DEF_DETECT_MULT
51 || pim_ifp
->bfd_config
.min_rx
!= BFD_DEF_MIN_RX
52 || pim_ifp
->bfd_config
.min_tx
!= BFD_DEF_MIN_TX
)
53 vty_out(vty
, " ip pim bfd %d %d %d\n",
54 pim_ifp
->bfd_config
.detection_multiplier
,
55 pim_ifp
->bfd_config
.min_rx
, pim_ifp
->bfd_config
.min_tx
);
57 #endif /* ! HAVE_BFDD */
58 vty_out(vty
, " ip pim bfd\n");
60 if (pim_ifp
->bfd_config
.profile
)
61 vty_out(vty
, " ip pim bfd profile %s\n",
62 pim_ifp
->bfd_config
.profile
);
65 static void pim_neighbor_bfd_cb(struct bfd_session_params
*bsp
,
66 const struct bfd_session_status
*bss
, void *arg
)
68 struct pim_neighbor
*nbr
= arg
;
70 if (PIM_DEBUG_PIM_TRACE
) {
71 zlog_debug("%s: status %s old_status %s", __func__
,
72 bfd_get_status_str(bss
->state
),
73 bfd_get_status_str(bss
->previous_state
));
76 if (bss
->state
== BFD_STATUS_DOWN
77 && bss
->previous_state
== BFD_STATUS_UP
)
78 pim_neighbor_delete(nbr
->interface
, nbr
, "BFD Session Expired");
82 * pim_bfd_info_nbr_create - Create/update BFD information for a neighbor.
84 void pim_bfd_info_nbr_create(struct pim_interface
*pim_ifp
,
85 struct pim_neighbor
*neigh
)
87 /* Check if Pim Interface BFD is enabled */
88 if (!pim_ifp
|| !pim_ifp
->bfd_config
.enabled
)
91 if (neigh
->bfd_session
== NULL
)
92 neigh
->bfd_session
= bfd_sess_new(pim_neighbor_bfd_cb
, neigh
);
95 neigh
->bfd_session
, pim_ifp
->bfd_config
.detection_multiplier
,
96 pim_ifp
->bfd_config
.min_rx
, pim_ifp
->bfd_config
.min_tx
);
97 bfd_sess_set_ipv4_addrs(neigh
->bfd_session
, NULL
, &neigh
->source_addr
);
98 bfd_sess_set_interface(neigh
->bfd_session
, neigh
->interface
->name
);
99 bfd_sess_set_vrf(neigh
->bfd_session
, neigh
->interface
->vrf
->vrf_id
);
100 bfd_sess_set_profile(neigh
->bfd_session
, pim_ifp
->bfd_config
.profile
);
101 bfd_sess_install(neigh
->bfd_session
);
105 * pim_bfd_reg_dereg_all_nbr - Register/Deregister all neighbors associated
106 * with a interface with BFD through
107 * zebra for starting/stopping the monitoring of
108 * the neighbor rechahability.
110 void pim_bfd_reg_dereg_all_nbr(struct interface
*ifp
)
112 struct pim_interface
*pim_ifp
= NULL
;
113 struct listnode
*node
= NULL
;
114 struct pim_neighbor
*neigh
= NULL
;
120 for (ALL_LIST_ELEMENTS_RO(pim_ifp
->pim_neighbor_list
, node
, neigh
)) {
121 if (pim_ifp
->bfd_config
.enabled
)
122 pim_bfd_info_nbr_create(pim_ifp
, neigh
);
124 bfd_sess_free(&neigh
->bfd_session
);
128 void pim_bfd_init(void)
130 bfd_protocol_integration_init(pim_zebra_zclient_get(), router
->master
);