struct interface *if_lookup_by_ipv4(struct in_addr *addr, vrf_id_t vrf_id)
{
- struct listnode *ifnode;
+ struct vrf *vrf;
struct listnode *cnode;
struct interface *ifp;
struct connected *connected;
struct prefix_ipv4 p;
struct prefix *cp;
+ vrf = vrf_lookup_by_id(vrf_id);
+ if (!vrf)
+ return NULL;
+
p.family = AF_INET;
p.prefix = *addr;
p.prefixlen = IPV4_MAX_BITLEN;
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(vrf_id), ifnode, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
for (ALL_LIST_ELEMENTS_RO(ifp->connected, cnode, connected)) {
cp = connected->address;
struct interface *if_lookup_by_ipv4_exact(struct in_addr *addr, vrf_id_t vrf_id)
{
- struct listnode *ifnode;
+ struct vrf *vrf;
struct listnode *cnode;
struct interface *ifp;
struct connected *connected;
struct prefix *cp;
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(vrf_id), ifnode, ifp)) {
+ vrf = vrf_lookup_by_id(vrf_id);
+ if (!vrf)
+ return NULL;
+
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
for (ALL_LIST_ELEMENTS_RO(ifp->connected, cnode, connected)) {
cp = connected->address;
struct interface *if_lookup_by_ipv6(struct in6_addr *addr, ifindex_t ifindex,
vrf_id_t vrf_id)
{
- struct listnode *ifnode;
+ struct vrf *vrf;
struct listnode *cnode;
struct interface *ifp;
struct connected *connected;
struct prefix_ipv6 p;
struct prefix *cp;
+ vrf = vrf_lookup_by_id(vrf_id);
+ if (!vrf)
+ return NULL;
+
p.family = AF_INET6;
p.prefix = *addr;
p.prefixlen = IPV6_MAX_BITLEN;
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(vrf_id), ifnode, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
for (ALL_LIST_ELEMENTS_RO(ifp->connected, cnode, connected)) {
cp = connected->address;
struct interface *if_lookup_by_ipv6_exact(struct in6_addr *addr,
ifindex_t ifindex, vrf_id_t vrf_id)
{
- struct listnode *ifnode;
+ struct vrf *vrf;
struct listnode *cnode;
struct interface *ifp;
struct connected *connected;
struct prefix *cp;
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(vrf_id), ifnode, ifp)) {
+ vrf = vrf_lookup_by_id(vrf_id);
+ if (!vrf)
+ return NULL;
+
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
for (ALL_LIST_ELEMENTS_RO(ifp->connected, cnode, connected)) {
cp = connected->address;