diff --git a/lib/if.c b/lib/if.c index 6f567861d19c..30618c53b965 100644 --- a/lib/if.c +++ b/lib/if.c @@ -322,8 +322,8 @@ struct interface *if_vrf_lookup_by_index_next(ifindex_t ifindex, if (ifindex == 0) { tmp_ifp = RB_MIN(if_index_head, &vrf->ifaces_by_index); - /* skip the vrf interface */ - if (tmp_ifp && if_is_vrf(tmp_ifp)) + /* skip the vrf interface or the lo interface */ + if (tmp_ifp && if_is_loopback(tmp_ifp)) ifindex = tmp_ifp->ifindex; else return tmp_ifp; @@ -331,8 +331,8 @@ struct interface *if_vrf_lookup_by_index_next(ifindex_t ifindex, RB_FOREACH (tmp_ifp, if_index_head, &vrf->ifaces_by_index) { if (found) { - /* skip the vrf interface */ - if (tmp_ifp && if_is_vrf(tmp_ifp)) + /* skip the vrf interface or the lo interface */ + if (tmp_ifp && if_is_loopback(tmp_ifp)) continue; else return tmp_ifp; diff --git a/lib/vrf.h b/lib/vrf.h index 956730bac6ad..433de553e5f5 100644 --- a/lib/vrf.h +++ b/lib/vrf.h @@ -149,6 +149,9 @@ static inline uint32_t vrf_interface_count(struct vrf *vrf) struct interface *ifp; RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) { + /* skip the lo interface */ + if (if_is_loopback_exact(ifp)) + continue; /* skip the l3mdev */ if (strncmp(ifp->name, vrf->name, VRF_NAMSIZ) == 0) continue;