summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorChristophe Gouault <christophe.gouault@6wind.com>2020-08-26 16:26:49 +0200
committerChristophe Gouault <christophe.gouault@6wind.com>2020-09-21 10:07:56 +0200
commit7c1119cb7a1c66028d5487ff66682383244f987d (patch)
treeb41faebe98e5456ba6a1cf4c19594d9aa0c95773 /lib
parentzebra: fix show ip route output (diff)
downloadfrr-7c1119cb7a1c66028d5487ff66682383244f987d.tar.xz
frr-7c1119cb7a1c66028d5487ff66682383244f987d.zip
lib: optimize vrf_id_to_name(VRF_DEFAULT) case
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>
Diffstat (limited to 'lib')
-rw-r--r--lib/vrf.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/vrf.c b/lib/vrf.c
index cc7445558..a7e9b256f 100644
--- 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);
}