From e55a43d491c8423feceb6c37b8d42d8b1637a0e5 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Mon, 30 Apr 2018 07:56:24 -0400 Subject: [PATCH] pimd: Remove expensive lookup for if a device is a vrf device Interfaces know if they are a vrf device or not and this data is passed up to the protocol. Signed-off-by: Donald Sharp --- pimd/pim_iface.c | 12 ++++-------- pimd/pim_iface.h | 2 +- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/pimd/pim_iface.c b/pimd/pim_iface.c index e58d81591d..5996a3ac96 100644 --- a/pimd/pim_iface.c +++ b/pimd/pim_iface.c @@ -1555,16 +1555,12 @@ bool pim_if_is_loopback(struct interface *ifp) return false; } -int pim_if_is_vrf_device(struct interface *ifp) +bool pim_if_is_vrf_device(struct interface *ifp) { - struct vrf *vrf; - - RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) { - if (strncmp(ifp->name, vrf->name, strlen(ifp->name)) == 0) - return 1; - } + if (if_is_vrf(ifp)) + return true; - return 0; + return false; } int pim_if_ifchannel_count(struct pim_interface *pim_ifp) diff --git a/pimd/pim_iface.h b/pimd/pim_iface.h index 12098fde29..cf025cbd4a 100644 --- a/pimd/pim_iface.h +++ b/pimd/pim_iface.h @@ -209,7 +209,7 @@ int pim_update_source_set(struct interface *ifp, struct in_addr source); bool pim_if_is_loopback(struct interface *ifp); -int pim_if_is_vrf_device(struct interface *ifp); +bool pim_if_is_vrf_device(struct interface *ifp); int pim_if_ifchannel_count(struct pim_interface *pim_ifp); #endif /* PIM_IFACE_H */ -- 2.39.5