summaryrefslogtreecommitdiffstats
path: root/zebra/connected.c
diff options
context:
space:
mode:
Diffstat (limited to 'zebra/connected.c')
-rw-r--r--zebra/connected.c47
1 files changed, 42 insertions, 5 deletions
diff --git a/zebra/connected.c b/zebra/connected.c
index 95399fa1..bf5715e4 100644
--- a/zebra/connected.c
+++ b/zebra/connected.c
@@ -112,6 +112,30 @@ connected_check (struct interface *ifp, struct prefix *p)
return NULL;
}
+/* same, but with peer address */
+struct connected *
+connected_check_ptp (struct interface *ifp, struct prefix *p, struct prefix *d)
+{
+ struct connected *ifc;
+ struct listnode *node;
+
+ /* ignore broadcast addresses */
+ if (p->prefixlen != IPV4_MAX_PREFIXLEN)
+ d = NULL;
+
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, node, ifc))
+ {
+ if (!prefix_same (ifc->address, p))
+ continue;
+ if (!CONNECTED_PEER(ifc) && !d)
+ return ifc;
+ if (CONNECTED_PEER(ifc) && d && prefix_same (ifc->destination, d))
+ return ifc;
+ }
+
+ return NULL;
+}
+
/* Check if two ifc's describe the same address */
static int
connected_same (struct connected *ifc1, struct connected *ifc2)
@@ -148,7 +172,7 @@ connected_implicit_withdraw (struct interface *ifp, struct connected *ifc)
struct connected *current;
/* Check same connected route. */
- if ((current = connected_check (ifp, (struct prefix *) ifc->address)))
+ if ((current = connected_check_ptp (ifp, ifc->address, ifc->destination)))
{
if (CHECK_FLAG(current->conf, ZEBRA_IFC_CONFIGURED))
SET_FLAG(ifc->conf, ZEBRA_IFC_CONFIGURED);
@@ -212,7 +236,8 @@ connected_add_ipv4 (struct interface *ifp, int flags, struct in_addr *addr,
p = prefix_ipv4_new ();
p->family = AF_INET;
p->prefix = *addr;
- p->prefixlen = prefixlen;
+ p->prefixlen = CHECK_FLAG(flags, ZEBRA_IFA_PEER)
+ ? IPV4_MAX_PREFIXLEN : prefixlen;
ifc->address = (struct prefix *) p;
/* If there is broadcast or peer address. */
@@ -305,15 +330,27 @@ void
connected_delete_ipv4 (struct interface *ifp, int flags, struct in_addr *addr,
u_char prefixlen, struct in_addr *broad)
{
- struct prefix_ipv4 p;
+ struct prefix_ipv4 p, d;
struct connected *ifc;
memset (&p, 0, sizeof (struct prefix_ipv4));
p.family = AF_INET;
p.prefix = *addr;
- p.prefixlen = prefixlen;
+ p.prefixlen = CHECK_FLAG(flags, ZEBRA_IFA_PEER)
+ ? IPV4_MAX_PREFIXLEN : prefixlen;
+
+ if (broad)
+ {
+ memset (&d, 0, sizeof (struct prefix_ipv4));
+ d.family = AF_INET;
+ d.prefix = *broad;
+ d.prefixlen = prefixlen;
+ ifc = connected_check_ptp (ifp, (struct prefix *) &p,
+ (struct prefix *) &d);
+ }
+ else
+ ifc = connected_check_ptp (ifp, (struct prefix *) &p, NULL);
- ifc = connected_check (ifp, (struct prefix *) &p);
if (! ifc)
return;