diff options
Diffstat (limited to 'nest/neighbor.c')
-rw-r--r-- | nest/neighbor.c | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/nest/neighbor.c b/nest/neighbor.c index 87253857..78337b47 100644 --- a/nest/neighbor.c +++ b/nest/neighbor.c @@ -72,28 +72,38 @@ if_connected(ip_addr a, struct iface *i, struct ifa **ap, uint flags) struct ifa *b; /* Handle iface pseudo-neighbors */ - if (flags & NEF_IFACE) + if (flags & NEF_IFACE) { + debug("pseudo-neighbor\n"); return *ap = NULL, (i->flags & IF_UP) ? SCOPE_HOST : -1; + } /* Host addresses match even if iface is down */ WALK_LIST(b, i->addrs) - if (ipa_equal(a, b->ip)) + if (ipa_equal(a, b->ip)) { + debug("host addresses\n"); return *ap = b, SCOPE_HOST; + } /* Rest do not match if iface is down */ - if (!(i->flags & IF_UP)) + if (!(i->flags & IF_UP)) { + debug("iface not up %s\n", i->name); return *ap = NULL, -1; + } + + debug("regular neighbor %I %s\n", a, i->name); /* Regular neighbors */ WALK_LIST(b, i->addrs) { if (b->flags & IA_PEER) { + debug("Peer: %N\n", &b->prefix); if (ipa_equal(a, b->opposite)) return *ap = b, b->scope; } else { + debug("Test prefix: %N\n", &b->prefix); if (ipa_in_netX(a, &b->prefix)) { /* Do not allow IPv4 network and broadcast addresses */ @@ -101,7 +111,10 @@ if_connected(ip_addr a, struct iface *i, struct ifa **ap, uint flags) (net_pxlen(&b->prefix) < (IP4_MAX_PREFIX_LENGTH - 1)) && (ipa_equal(a, net_prefix(&b->prefix)) || /* Network address */ ipa_equal(a, b->brd))) /* Broadcast */ + { + debug("Do not allow IPv4 network and broadcast addresses\n"); return *ap = NULL, -1; + } return *ap = b, b->scope; } @@ -112,6 +125,8 @@ if_connected(ip_addr a, struct iface *i, struct ifa **ap, uint flags) if (flags & NEF_ONLINK) return *ap = NULL, ipa_classify(a) & IADDR_SCOPE_MASK; + debug("regular neighbor not found\n"); + return *ap = NULL, -1; } @@ -133,8 +148,10 @@ if_connected_any(ip_addr a, struct iface *vrf, struct iface **iface, struct ifa *iface = i; *addr = b; scope = s; + debug("iface found scope %s %x\n", i->name, scope); } + debug("found scope %x\n", scope); return scope; } @@ -175,12 +192,14 @@ neigh_find(struct proto *p, ip_addr a, struct iface *iface, uint flags) else { class = ipa_classify(a); + debug("find class 0x%x\n", class); if (class < 0) /* Invalid address */ return NULL; - if (((class & IADDR_SCOPE_MASK) == SCOPE_HOST) || +/* if (((class & IADDR_SCOPE_MASK) == SCOPE_HOST) || (((class & IADDR_SCOPE_MASK) == SCOPE_LINK) && !iface) || !(class & IADDR_HOST)) - return NULL; /* Bad scope or a somecast */ + return NULL;*/ /* Bad scope or a somecast */ + } if ((flags & NEF_ONLINK) && !iface) |