]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib: optimize vrf_id_to_name(VRF_DEFAULT) case
authorChristophe Gouault <christophe.gouault@6wind.com>
Wed, 26 Aug 2020 14:26:49 +0000 (16:26 +0200)
committerIgor Ryzhov <iryzhov@nfware.com>
Tue, 6 Oct 2020 12:54:25 +0000 (15:54 +0300)
vrf_id_to_name() looks up in a RB_TREE to find the VRF entry, then
reads the name.

Avoid it for VRF_DEFAULT, which always exists and for which the
translation is straightforward.

Signed-off-by: Christophe Gouault <christophe.gouault@6wind.com>
lib/vrf.c

index cc7445558c6f91eadc1e9de25f61a54051a17387..a7e9b256f2cf034af47298c544f677e7454c85e4 100644 (file)
--- a/lib/vrf.c
+++ b/lib/vrf.c
@@ -331,6 +331,9 @@ const char *vrf_id_to_name(vrf_id_t vrf_id)
 {
        struct vrf *vrf;
 
+       if (vrf_id == VRF_DEFAULT)
+               return VRF_DEFAULT_NAME;
+
        vrf = vrf_lookup_by_id(vrf_id);
        return VRF_LOGNAME(vrf);
 }