summaryrefslogtreecommitdiffstats
path: root/proto/ospf/neighbor.c
diff options
context:
space:
mode:
Diffstat (limited to 'proto/ospf/neighbor.c')
-rw-r--r--proto/ospf/neighbor.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/proto/ospf/neighbor.c b/proto/ospf/neighbor.c
index d22a60e..ca92e9d 100644
--- a/proto/ospf/neighbor.c
+++ b/proto/ospf/neighbor.c
@@ -432,16 +432,25 @@ find_neigh(struct ospf_iface *ifa, u32 rid)
return NULL;
}
+
+/* Find a closest neighbor which is at leas 2-Way */
struct ospf_neighbor *
find_neigh_noifa(struct proto_ospf *po, u32 rid)
{
- struct ospf_neighbor *n;
+ struct ospf_neighbor *n=NULL,*m;
struct ospf_iface *ifa;
WALK_LIST (ifa, po->iface_list)
- if((n=find_neigh(ifa, rid))!=NULL)
- return n;
- return NULL;
+ if((m=find_neigh(ifa, rid))!=NULL)
+ {
+ if(m->state>=NEIGHBOR_2WAY)
+ {
+ if(n==NULL) n=m;
+ else
+ if(m->ifa->cost < n->ifa->cost) n=m;
+ }
+ }
+ return n;
}
struct ospf_area *