]> git.puffer.fish Git - mirror/frr.git/commitdiff
bfdd: upon vrf enable/disable, update bs and obs list
authorPhilippe Guibert <philippe.guibert@6wind.com>
Tue, 26 Mar 2019 13:48:13 +0000 (14:48 +0100)
committerPhilippe Guibert <philippe.guibert@6wind.com>
Tue, 7 May 2019 13:54:30 +0000 (15:54 +0200)
parse observer list, and update bs context if vrf pointer is not yet populated.
this is helpful for validation, but also will permit bfd to send
notification to remote daemon.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
bfdd/bfd.c
bfdd/bfd.h
bfdd/ptm_adapter.c

index 8acf7796604527458c1266876dbd4a6fe7124d4d..06ab5ea409dfb51935caac44f58c6ec93debcf6d 100644 (file)
@@ -1503,8 +1503,10 @@ static int bfd_vrf_enable(struct vrf *vrf)
                thread_add_read(master, bfd_recv_cb, bvrf, bvrf->bg_echov6,
                                &bvrf->bg_ev[5]);
 
-       if (vrf->vrf_id != VRF_DEFAULT)
+       if (vrf->vrf_id != VRF_DEFAULT) {
                bfdd_zclient_register(vrf->vrf_id);
+               bfdd_sessions_enable_vrf(vrf);
+       }
        return 0;
 }
 
@@ -1516,8 +1518,10 @@ static int bfd_vrf_disable(struct vrf *vrf)
                return 0;
        bvrf = vrf->info;
 
-       if (vrf->vrf_id != VRF_DEFAULT)
+       if (vrf->vrf_id != VRF_DEFAULT) {
+               bfdd_sessions_disable_vrf(vrf);
                bfdd_zclient_unregister(vrf->vrf_id);
+       }
 
        log_debug("VRF disable %s id %d", vrf->name, vrf->vrf_id);
        /* Close all descriptors. */
index c94b9a637188893a73bf61e9994ac9f004441dad..2bfdcc4055404edaf6e5e2a95d323b249ccb842c 100644 (file)
@@ -588,6 +588,8 @@ void bfdd_zclient_init(struct zebra_privs_t *bfdd_priv);
 void bfdd_zclient_stop(void);
 void bfdd_zclient_unregister(vrf_id_t vrf_id);
 void bfdd_zclient_register(vrf_id_t vrf_id);
+void bfdd_sessions_enable_vrf(struct vrf *vrf);
+void bfdd_sessions_disable_vrf(struct vrf *vrf);
 
 int ptm_bfd_notify(struct bfd_session *bs);
 
index a98d19aa2f595c2a067c7c6dfbf2ca8699f09270..abfb4e4a267f704511be02b04ebb843892176bcb 100644 (file)
@@ -605,6 +605,52 @@ static void bfdd_sessions_disable_interface(struct interface *ifp)
        }
 }
 
+void bfdd_sessions_enable_vrf(struct vrf *vrf)
+{
+       struct bfd_session_observer *bso;
+       struct bfd_session *bs;
+
+       /* it may affect configs without interfaces */
+       TAILQ_FOREACH(bso, &bglobal.bg_obslist, bso_entry) {
+               bs = bso->bso_bs;
+               if (bs->vrf)
+                       continue;
+               if (bs->key.vrfname[0] &&
+                   strcmp(vrf->name, bs->key.vrfname))
+                       continue;
+               /* need to update the vrf information on
+                * bs so that callbacks are handled
+                */
+               bs->vrf = vrf;
+               /* Skip enabled sessions. */
+               if (bs->sock != -1)
+                       continue;
+               /* Try to enable it. */
+               bfd_session_enable(bs);
+       }
+}
+
+void bfdd_sessions_disable_vrf(struct vrf *vrf)
+{
+       struct bfd_session_observer *bso;
+       struct bfd_session *bs;
+
+       TAILQ_FOREACH(bso, &bglobal.bg_obslist, bso_entry) {
+               if (bso->bso_isinterface)
+                       continue;
+               bs = bso->bso_bs;
+               if (bs->key.vrfname[0] &&
+                   strcmp(vrf->name, bs->key.vrfname))
+                       continue;
+               /* Skip disabled sessions. */
+               if (bs->sock == -1)
+                       continue;
+
+               /* Try to enable it. */
+               bfd_session_disable(bs);
+       }
+}
+
 static int bfdd_interface_update(ZAPI_CALLBACK_ARGS)
 {
        struct interface *ifp;