+// SPDX-License-Identifier: GPL-2.0-or-later
/**
* ospf_bfd.c: OSPF BFD handling routines
*
* @copyright Copyright (C) 2015 Cumulus Networks, Inc.
- *
- * This file is part of GNU Zebra.
- *
- * GNU Zebra 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, or (at your option) any
- * later version.
- *
- * GNU Zebra 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>
DEFINE_MTYPE_STATIC(OSPFD, BFD_CONFIG, "BFD configuration data");
-extern struct zclient *zclient;
-
/*
* ospf_bfd_trigger_event - Neighbor is registered/deregistered with BFD when
* neighbor state is changed to/from 2way.
/* BFD peer went down. */
if (bss->state == BFD_STATUS_DOWN
&& bss->previous_state == BFD_STATUS_UP) {
- if (IS_DEBUG_OSPF(nsm, NSM_EVENTS))
- zlog_debug("NSM[%s:%pI4]: BFD Down", IF_NAME(nbr->oi),
- &nbr->address.u.prefix4);
+ if (IS_DEBUG_OSPF(bfd, BFD_LIB))
+ zlog_debug("%s: NSM[%s:%pI4]: BFD Down", __func__,
+ IF_NAME(nbr->oi), &nbr->address.u.prefix4);
OSPF_NSM_EVENT_SCHEDULE(nbr, NSM_InactivityTimer);
}
/* BFD peer went up. */
if (bss->state == BSS_UP && bss->previous_state == BSS_DOWN)
- if (IS_DEBUG_OSPF(nsm, NSM_EVENTS))
- zlog_debug("NSM[%s:%pI4]: BFD Up", IF_NAME(nbr->oi),
- &nbr->address.u.prefix4);
+ if (IS_DEBUG_OSPF(bfd, BFD_LIB))
+ zlog_debug("%s: NSM[%s:%pI4]: BFD Up", __func__,
+ IF_NAME(nbr->oi), &nbr->address.u.prefix4);
}
void ospf_neighbor_bfd_apply(struct ospf_neighbor *nbr)
bfd_sess_set_ipv4_addrs(nbr->bfd_session, NULL, &nbr->src);
bfd_sess_set_interface(nbr->bfd_session, oi->ifp->name);
bfd_sess_set_vrf(nbr->bfd_session, oi->ospf->vrf_id);
- bfd_sess_enable(nbr->bfd_session, true);
}
/* Set new configuration. */
__attribute__((unused)))
{
#if HAVE_BFDD == 0
- if (CHECK_FLAG(bfd_info->flags, BFD_FLAG_PARAM_CFG))
+ if (params->bfd_config->detection_multiplier != BFD_DEF_DETECT_MULT
+ || params->bfd_config->min_rx != BFD_DEF_MIN_RX
+ || params->bfd_config->min_tx != BFD_DEF_MIN_TX)
vty_out(vty, " ip ospf bfd %d %d %d\n",
params->bfd_config->detection_multiplier,
params->bfd_config->min_rx, params->bfd_config->min_tx);
else
#endif /* ! HAVE_BFDD */
vty_out(vty, " ip ospf bfd\n");
+
+ if (params->bfd_config->profile[0])
+ vty_out(vty, " ip ospf bfd profile %s\n",
+ params->bfd_config->profile);
}
void ospf_interface_bfd_show(struct vty *vty, const struct interface *ifp,
return CMD_SUCCESS;
}
+DEFUN (ip_ospf_bfd_prof,
+ ip_ospf_bfd_prof_cmd,
+ "ip ospf bfd profile BFDPROF",
+ "IP Information\n"
+ "OSPF interface commands\n"
+ "Enables BFD support\n"
+ BFD_PROFILE_STR
+ BFD_PROFILE_NAME_STR)
+{
+ VTY_DECLVAR_CONTEXT(interface, ifp);
+ struct ospf_if_params *params;
+ int idx_prof = 4;
+
+ params = IF_DEF_PARAMS(ifp);
+ if (!params->bfd_config) {
+ vty_out(vty, "ip ospf bfd has not been set\n");
+ return CMD_WARNING;
+ }
+
+ strlcpy(params->bfd_config->profile, argv[idx_prof]->arg,
+ sizeof(params->bfd_config->profile));
+ ospf_interface_bfd_apply(ifp);
+
+ return CMD_SUCCESS;
+}
+
+DEFUN (no_ip_ospf_bfd_prof,
+ no_ip_ospf_bfd_prof_cmd,
+ "no ip ospf bfd profile [BFDPROF]",
+ NO_STR
+ "IP Information\n"
+ "OSPF interface commands\n"
+ "Enables BFD support\n"
+ BFD_PROFILE_STR
+ BFD_PROFILE_NAME_STR)
+{
+ VTY_DECLVAR_CONTEXT(interface, ifp);
+ struct ospf_if_params *params;
+
+ params = IF_DEF_PARAMS(ifp);
+ if (!params->bfd_config)
+ return CMD_SUCCESS;
+
+ params->bfd_config->profile[0] = 0;
+ ospf_interface_bfd_apply(ifp);
+
+ return CMD_SUCCESS;
+}
+
DEFUN (no_ip_ospf_bfd,
no_ip_ospf_bfd_cmd,
#if HAVE_BFDD > 0
/* Install BFD command */
install_element(INTERFACE_NODE, &ip_ospf_bfd_cmd);
install_element(INTERFACE_NODE, &ip_ospf_bfd_param_cmd);
+ install_element(INTERFACE_NODE, &ip_ospf_bfd_prof_cmd);
+ install_element(INTERFACE_NODE, &no_ip_ospf_bfd_prof_cmd);
install_element(INTERFACE_NODE, &no_ip_ospf_bfd_cmd);
}