]> git.proxmox.com Git - mirror_frr.git/blobdiff - bfdd/bfd.c
Merge pull request #5810 from donaldsharp/fix_yang_routemap
[mirror_frr.git] / bfdd / bfd.c
index cc171f2ebfd405d6cb4711258565ef78debf6960..222bf32c94eb21252a18f938f504239f500b4afb 100644 (file)
@@ -403,10 +403,21 @@ struct bfd_session *ptm_bfd_sess_find(struct bfd_pkt *cp,
        if (cp->discrs.remote_discr)
                return bfd_find_disc(peer, ntohl(cp->discrs.remote_discr));
 
-       /* Search for session without using discriminator. */
-       ifp = if_lookup_by_index(ifindex, vrfid);
-
-       vrf = vrf_lookup_by_id(vrfid);
+       /*
+        * Search for session without using discriminator.
+        *
+        * XXX: we can't trust `vrfid` because the VRF handling is not
+        * properly implemented. Meanwhile we should use the interface
+        * VRF to find out which one it belongs.
+        */
+       ifp = if_lookup_by_index_all_vrf(ifindex);
+       if (ifp == NULL) {
+               if (vrfid != VRF_DEFAULT)
+                       vrf = vrf_lookup_by_id(vrfid);
+               else
+                       vrf = NULL;
+       } else
+               vrf = vrf_lookup_by_id(ifp->vrf_id);
 
        gen_bfd_key(&key, peer, local, is_mhop, ifp ? ifp->name : NULL,
                    vrf ? vrf->name : VRF_DEFAULT_NAME);
@@ -1852,3 +1863,8 @@ void bfd_session_update_vrf_name(struct bfd_session *bs, struct vrf *vrf)
        strlcpy(bs->key.vrfname, vrf->name, sizeof(bs->key.vrfname));
        hash_get(bfd_key_hash, bs, hash_alloc_intern);
 }
+
+unsigned long bfd_get_session_count(void)
+{
+       return bfd_key_hash->count;
+}