summaryrefslogtreecommitdiff
path: root/lib/if.c
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2015-05-19 17:58:13 -0700
committerDonald Sharp <sharpd@cumulusnetworks.com>2015-05-19 17:58:13 -0700
commit525c183906c47c491611f294db218d53a561a3b9 (patch)
treebe3eae87696fd7713622a0df97a591d37686282d /lib/if.c
parentc8a1cb5c9db0490cd6d426999f3d1cb2df143e45 (diff)
Unnumbered interface support.
Diffstat (limited to 'lib/if.c')
-rw-r--r--lib/if.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/if.c b/lib/if.c
index b3decf3be9..4800105dc0 100644
--- a/lib/if.c
+++ b/lib/if.c
@@ -315,6 +315,36 @@ if_lookup_address (struct in_addr src)
return match;
}
+/* Lookup anchor interface by IPv4 address. */
+struct connected *
+if_anchor_lookup_by_address (struct in_addr src)
+{
+ struct listnode *node;
+ struct listnode *cnode;
+ struct interface *ifp;
+ struct prefix *p;
+ struct connected *c;
+
+ for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
+ {
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, cnode, c))
+ {
+ if (CHECK_FLAG(c->flags, ZEBRA_IFA_UNNUMBERED) ||
+ !CHECK_FLAG(c->conf, ZEBRA_IFC_REAL))
+ continue;
+
+ p = c->address;
+
+ if (p && p->family == AF_INET)
+ {
+ if (IPV4_ADDR_SAME (&p->u.prefix4, &src))
+ return c;
+ }
+ }
+ }
+ return NULL;
+}
+
/* Lookup interface by prefix */
struct interface *
if_lookup_prefix (struct prefix *prefix)