]> git.proxmox.com Git - mirror_frr.git/commitdiff
bfdd: enable bfd session if vrf interface available
authorPhilippe Guibert <philippe.guibert@6wind.com>
Fri, 8 Jan 2021 09:34:20 +0000 (09:34 +0000)
committerPhilippe Guibert <philippe.guibert@6wind.com>
Sat, 9 Jan 2021 13:29:42 +0000 (13:29 +0000)
The vrf interface notification and interface notifications are separated
on zapi interface between the system (zebra daemon) and other daemons
(bfd for instance). In the case of bfd, the initial code was waiting for
vrf notification to create the socket. Actually, in vrf-lite world, we
need to wait the vrf interface to be present, in order to create the
socket and bind to the vrf interface (this is the usual way to work with
vrf-lite).
On bfd, the changes consist in delaying the socket creation first, then
when interface is created, check the interface name presence instead of
checking the interface configuration.

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

index 9667ba8708bbc74ed0c36f7a3e25bbce49519aad..622b6ef396975e9f5816a664e3bda7f34d538518 100644 (file)
@@ -313,6 +313,13 @@ int bfd_session_enable(struct bfd_session *bs)
                }
        }
 
+       if (!vrf_is_backend_netns() && vrf && vrf->vrf_id != VRF_DEFAULT
+           && !if_lookup_by_name(vrf->name, vrf->vrf_id)) {
+               zlog_err("session-enable: vrf interface %s not available yet",
+                        vrf->name);
+               return 0;
+       }
+
        if (bs->key.ifname[0]) {
                if (vrf)
                        ifp = if_lookup_by_name(bs->key.ifname, vrf->vrf_id);
index 44519c47b5e95055e3b1dd1397f03d4a31ae3f3d..26ff7bd188796d569e2bc0dee8ba8c67ce7c5a4d 100644 (file)
@@ -669,17 +669,24 @@ static void bfdd_sessions_enable_interface(struct interface *ifp)
        struct bfd_session *bs;
        struct vrf *vrf;
 
+       vrf = vrf_lookup_by_id(ifp->vrf_id);
+       if (!vrf)
+               return;
+
        TAILQ_FOREACH(bso, &bglobal.bg_obslist, bso_entry) {
                bs = bso->bso_bs;
-               /* Interface name mismatch. */
-               if (strcmp(ifp->name, bs->key.ifname))
-                       continue;
-               vrf = vrf_lookup_by_id(ifp->vrf_id);
-               if (!vrf)
-                       continue;
+               /* check vrf name */
                if (bs->key.vrfname[0] &&
                    strcmp(vrf->name, bs->key.vrfname))
                        continue;
+
+               /* If Interface matches vrfname, then bypass iface check */
+               if (vrf_is_backend_netns() || strcmp(ifp->name, vrf->name)) {
+                       /* Interface name mismatch. */
+                       if (strcmp(ifp->name, bs->key.ifname))
+                               continue;
+               }
+
                /* Skip enabled sessions. */
                if (bs->sock != -1)
                        continue;