XFREE(MTYPE_BFD_INFO, (*bsp));
}
+static bool bfd_sess_address_changed(const struct bfd_session_params *bsp,
+ uint32_t family,
+ const struct in6_addr *src,
+ const struct in6_addr *dst)
+{
+ size_t addrlen;
+
+ if (bsp->args.family != family)
+ return true;
+
+ addrlen = (family == AF_INET) ? sizeof(struct in_addr)
+ : sizeof(struct in6_addr);
+ if ((src == NULL && memcmp(&bsp->args.src, &i6a_zero, addrlen))
+ || (src && memcmp(src, &bsp->args.src, addrlen))
+ || memcmp(dst, &bsp->args.dst, addrlen))
+ return true;
+
+ return false;
+}
+
void bfd_sess_set_ipv4_addrs(struct bfd_session_params *bsp,
struct in_addr *src, struct in_addr *dst)
{
+ if (!bfd_sess_address_changed(bsp, AF_INET, (struct in6_addr *)src,
+ (struct in6_addr *)dst))
+ return;
+
/* If already installed, remove the old setting. */
_bfd_sess_remove(bsp);
void bfd_sess_set_ipv6_addrs(struct bfd_session_params *bsp,
struct in6_addr *src, struct in6_addr *dst)
{
+ if (!bfd_sess_address_changed(bsp, AF_INET, (struct in6_addr *)src,
+ (struct in6_addr *)dst))
+ return;
+
/* If already installed, remove the old setting. */
_bfd_sess_remove(bsp);
void bfd_sess_set_interface(struct bfd_session_params *bsp, const char *ifname)
{
+ if ((ifname == NULL && bsp->args.ifnamelen == 0)
+ || (ifname && strcmp(bsp->args.ifname, ifname) == 0))
+ return;
+
/* If already installed, remove the old setting. */
_bfd_sess_remove(bsp);
void bfd_sess_set_vrf(struct bfd_session_params *bsp, vrf_id_t vrf_id)
{
+ if (bsp->args.vrf_id == vrf_id)
+ return;
+
/* If already installed, remove the old setting. */
_bfd_sess_remove(bsp);
{
assert(min_ttl != 0);
+ if (bsp->args.ttl == ((BFD_SINGLE_HOP_TTL + 1) - min_ttl))
+ return;
+
/* If already installed, remove the old setting. */
_bfd_sess_remove(bsp);
void bfd_sess_set_hop_count(struct bfd_session_params *bsp, uint8_t min_ttl)
{
+ if (bsp->args.ttl == min_ttl)
+ return;
+
/* If already installed, remove the old setting. */
_bfd_sess_remove(bsp);
/**
* Allocates and initializes the session parameters.
*
- * \param updatedb status update notification callback.
+ * \param updatecb status update notification callback.
* \param args application independent data.
*
* \returns pointer to configuration storage.
/**
* Set the local and peer address of the BFD session.
*
+ * NOTE:
+ * If the address changed the session is removed and must be installed again
+ * with `bfd_sess_install`.
+ *
* \param bsp BFD session parameters.
* \param src local address (optional, can be `NULL`).
* \param dst remote address (mandatory).
/**
* Set the local and peer address of the BFD session.
*
+ * NOTE:
+ * If the address changed the session is removed and must be installed again
+ * with `bfd_sess_install`.
+ *
* \param bsp BFD session parameters.
* \param src local address (optional, can be `NULL`).
* \param dst remote address (mandatory).
/**
* Configure the BFD session interface.
*
+ * NOTE:
+ * If the interface changed the session is removed and must be installed again
+ * with `bfd_sess_install`.
+ *
* \param bsp BFD session parameters.
* \param ifname interface name (or `NULL` to remove it).
*/
/**
* Configure the BFD session profile name.
*
+ * NOTE:
+ * Session profile will only change after a `bfd_sess_install`.
+ *
* \param bsp BFD session parameters.
* \param profile profile name (or `NULL` to remove it).
*/
/**
* Configure the BFD session VRF.
*
+ * NOTE:
+ * If the VRF changed the session is removed and must be installed again
+ * with `bfd_sess_install`.
+ *
* \param bsp BFD session parameters.
* \param vrf_id the VRF identification number.
*/
/**
* Configure the BFD session single/multi hop setting.
*
+ * NOTE:
+ * If the TTL changed the session is removed and must be installed again
+ * with `bfd_sess_install`.
+ *
* \param bsp BFD session parameters.
* \param min_ttl minimum TTL value expected (255 for single hop, 254 for
* multi hop with single hop, 253 for multi hop with two hops
* Instead of receiving the minimum expected TTL, it receives the amount of
* hops the protocol will jump.
*
+ * NOTE:
+ * If the TTL changed the session is removed and must be installed again
+ * with `bfd_sess_install`.
+ *
* \param bsp BFD session parameters.
* \param min_ttl minimum amount of hops expected (1 for single hop, 2 or
* more for multi hop).
/**
* Configure the BFD session to set the Control Plane Independent bit.
*
+ * NOTE:
+ * Session CPI bit will only change after a `bfd_sess_install`.
+ *
* \param bsp BFD session parameters.
* \param enable BFD Control Plane Independent state.
*/
* Configures the BFD session timers to use. This is specially useful with
* `ptm-bfd` which does not support timers.
*
+ * NOTE:
+ * Session timers will only apply if the session has not been created yet.
+ * If the session is already installed you must uninstall and install again
+ * to take effect.
+ *
* \param bsp BFD session parameters.
* \param detection_multiplier the detection multiplier value.
* \param min_rx minimum required receive period.
/**
* Installs or updates the BFD session based on the saved session arguments.
*
+ * NOTE:
+ * This function has a delayed effect: it will only install/update after
+ * all northbound/CLI command batch finishes.
+ *
* \param bsp session parameters.
*/
void bfd_sess_install(struct bfd_session_params *bsp);
/**
* Uninstall the BFD session based on the saved session arguments.
*
+ * NOTE:
+ * This function uninstalls the session immediately (if installed) and cancels
+ * any previous `bfd_sess_install` calls.
+ *
* \param bsp session parameters.
*/
void bfd_sess_uninstall(struct bfd_session_params *bsp);