]> git.puffer.fish Git - mirror/frr.git/commitdiff
lib: remove enabled flag for bfd sessions 8536/head
authorIgor Ryzhov <iryzhov@nfware.com>
Thu, 22 Apr 2021 12:24:49 +0000 (15:24 +0300)
committerIgor Ryzhov <iryzhov@nfware.com>
Thu, 22 Apr 2021 13:39:29 +0000 (16:39 +0300)
Currently this flag is only helpful in an extremely rare situation when
the BFD session registration was unsuccessful and after that zebra is
restarted. Let's remove this flag to simplify the API. If we ever want
to solve the problem of unsuccessful registration/deregistration, this
can be done using internal flags, without API modification.

Also add the error log to help user understand why the BFD session is
not working.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
bgpd/bgp_bfd.c
lib/bfd.c
lib/bfd.h
ospfd/ospf_bfd.c

index 958d7cf0ed68d37ca02b5c449fcf636af8fd7315..6004070e68b4224726c43b60b460d026da7598c4 100644 (file)
@@ -308,8 +308,6 @@ void bgp_peer_configure_bfd(struct peer *p, bool manual)
        if (p->nexthop.ifp)
                bfd_sess_set_interface(p->bfd_config->session,
                                       p->nexthop.ifp->name);
-
-       bfd_sess_enable(p->bfd_config->session, true);
 }
 
 static void bgp_peer_remove_bfd(struct peer *p)
index d22a9150d19fc80967b8b66f897c6797ab8547cf..bf3eaa32db792cbb294c18d399bdc26c586cecd7 100644 (file)
--- a/lib/bfd.c
+++ b/lib/bfd.c
@@ -619,8 +619,6 @@ struct bfd_session_params {
 
        /** BFD session installation state. */
        bool installed;
-       /** BFD session enabled. */
-       bool enabled;
 
        /** Global BFD paramaters list. */
        TAILQ_ENTRY(bfd_session_params) entry;
@@ -748,6 +746,21 @@ static int _bfd_sess_send(struct thread *t)
                        bsp->installed = false;
                else if (bsp->args.command == ZEBRA_BFD_DEST_REGISTER)
                        bsp->installed = true;
+       } else {
+               struct ipaddr src, dst;
+
+               src.ipa_type = bsp->args.family;
+               src.ipaddr_v6 = bsp->args.src;
+               dst.ipa_type = bsp->args.family;
+               dst.ipaddr_v6 = bsp->args.dst;
+
+               zlog_err(
+                       "%s: BFD session %pIA -> %pIA interface %s VRF %s(%u) was not %s",
+                       __func__, &src, &dst,
+                       bsp->args.ifnamelen ? bsp->args.ifname : "*",
+                       vrf_id_to_name(bsp->args.vrf_id), bsp->args.vrf_id,
+                       bsp->lastev == BSE_INSTALL ? "installed"
+                                                  : "uninstalled");
        }
 
        return 0;
@@ -782,15 +795,6 @@ void bfd_sess_free(struct bfd_session_params **bsp)
        XFREE(MTYPE_BFD_INFO, (*bsp));
 }
 
-void bfd_sess_enable(struct bfd_session_params *bsp, bool enable)
-{
-       /* Remove the session when disabling. */
-       if (!enable)
-               _bfd_sess_remove(bsp);
-
-       bsp->enabled = enable;
-}
-
 void bfd_sess_set_ipv4_addrs(struct bfd_session_params *bsp,
                             struct in_addr *src, struct in_addr *dst)
 {
@@ -909,10 +913,6 @@ void bfd_sess_set_timers(struct bfd_session_params *bsp,
 
 void bfd_sess_install(struct bfd_session_params *bsp)
 {
-       /* Don't attempt to install/update when disabled. */
-       if (!bsp->enabled)
-               return;
-
        bsp->lastev = BSE_INSTALL;
        thread_add_event(bsglobal.tm, _bfd_sess_send, bsp, 0, &bsp->installev);
 }
@@ -1060,8 +1060,8 @@ static int zclient_bfd_session_reply(ZAPI_CALLBACK_ARGS)
 
        /* Replay all activated peers. */
        TAILQ_FOREACH (bsp, &bsglobal.bsplist, entry) {
-               /* Skip disabled sessions. */
-               if (!bsp->enabled)
+               /* Skip not installed sessions. */
+               if (!bsp->installed)
                        continue;
 
                /* We are reconnecting, so we must send installation. */
@@ -1138,8 +1138,8 @@ static int zclient_bfd_session_update(ZAPI_CALLBACK_ARGS)
 
        /* Notify all matching sessions about update. */
        TAILQ_FOREACH (bsp, &bsglobal.bsplist, entry) {
-               /* Skip disabled or not installed entries. */
-               if (!bsp->enabled || !bsp->installed)
+               /* Skip not installed entries. */
+               if (!bsp->installed)
                        continue;
                /* Skip different VRFs. */
                if (bsp->args.vrf_id != vrf_id)
index 1325f86a303a928bff1fb821376b1370b305ceae..230fde5e1fe5f4467f692ce3537063390d8d8f8b 100644 (file)
--- a/lib/bfd.h
+++ b/lib/bfd.h
@@ -184,14 +184,6 @@ struct bfd_session_params *bfd_sess_new(bsp_status_update updatecb, void *args);
  */
 void bfd_sess_free(struct bfd_session_params **bsp);
 
-/**
- * Enable/disable session installation.
- *
- * \param bsp session parameters.
- * \param enable knob variable.
- */
-void bfd_sess_enable(struct bfd_session_params *bsp, bool enable);
-
 /**
  * Set the local and peer address of the BFD session.
  *
index 2ab7db68bdca0174efb31b44f599d1d48129168a..56116cd28d1988d4f3e5c9134135ae126278323f 100644 (file)
@@ -99,7 +99,6 @@ 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. */