diff --git a/bgpd/bgp_fsm.c b/bgpd/bgp_fsm.c
index 4f1838a..d84a865 100644
--- a/bgpd/bgp_fsm.c
+++ b/bgpd/bgp_fsm.c
@@ -42,6 +42,7 @@
 #include "bgpd/bgp_route.h"
 #include "bgpd/bgp_dump.h"
 #include "bgpd/bgp_open.h"
+#include "bgpd/bgp_nht.h"
 #ifdef HAVE_SNMP
 #include "bgpd/bgp_snmp.h"
 #endif /* HAVE_SNMP */
@@ -675,6 +676,7 @@
 bgp_start (struct peer *peer)
 {
   int status;
+  int connected = 0;
 
   if (BGP_PEER_START_SUPPRESSED (peer))
     {
@@ -713,6 +715,12 @@
       return 0;
     }
 
+  /* Register to be notified on peer up */
+  if ((peer->ttl == 1) || (peer->gtsm_hops == 1))
+    connected = 1;
+
+  bgp_find_or_add_nexthop(family2afi(peer->su.sa.sa_family), NULL, peer,
+			  connected);
   status = bgp_connect (peer);
 
   switch (status)
@@ -939,6 +947,45 @@
   return 0;
 }
 
+void
+bgp_fsm_nht_update(struct peer *peer, int valid)
+{
+  int ret = 0;
+
+  if (!peer)
+    return;
+
+  switch (peer->status)
+    {
+    case Idle:
+      if (valid)
+	BGP_EVENT_ADD(peer, BGP_Start);
+      break;
+    case Connect:
+      ret = bgp_connect_check(peer, 0);
+      if (!ret && valid)
+	{
+	  BGP_TIMER_OFF(peer->t_connect);
+	  BGP_EVENT_ADD(peer, ConnectRetry_timer_expired);
+	}
+      break;
+    case Active:
+      if (valid)
+	{
+	  BGP_TIMER_OFF(peer->t_connect);
+	  BGP_EVENT_ADD(peer, ConnectRetry_timer_expired);
+	}
+    case OpenSent:
+    case OpenConfirm:
+    case Established:
+    case Clearing:
+    case Deleted:
+    default:
+      break;
+    }
+}
+
+
 /* Finite State Machine structure */
 static const struct {
   int (*func) (struct peer *);
diff --git a/bgpd/bgp_fsm.h b/bgpd/bgp_fsm.h
index 752d6e2..b38e64c 100644
--- a/bgpd/bgp_fsm.h
+++ b/bgpd/bgp_fsm.h
@@ -72,6 +72,7 @@
   } while (0)
 
 /* Prototypes. */
+extern void bgp_fsm_nht_update(struct peer *, int valid);
 extern int bgp_event (struct thread *);
 extern int bgp_stop (struct peer *peer);
 extern void bgp_timer_set (struct peer *);
diff --git a/bgpd/bgp_main.c b/bgpd/bgp_main.c
index eb0fe17..af9c030 100644
--- a/bgpd/bgp_main.c
+++ b/bgpd/bgp_main.c
@@ -230,7 +230,6 @@
   struct listnode *node, *nnode;
   int *socket;
   struct interface *ifp;
-  extern struct zclient *zlookup;
 
   /* it only makes sense for this to be called on a clean exit */
   assert (status == 0);
@@ -292,9 +291,6 @@
   /* reverse bgp_route_map_init/route_map_init */
   route_map_finish ();
 
-  /* reverse bgp_scan_init */
-  bgp_scan_finish ();
-
   /* reverse access_list_init */
   access_list_add_hook (NULL);
   access_list_delete_hook (NULL);
@@ -319,13 +315,14 @@
   bgp_address_destroy();
   bgp_scan_destroy();
   bgp_zebra_destroy();
-  if (zlookup)
-    zclient_free (zlookup);
   if (bgp_nexthop_buf)
     stream_free (bgp_nexthop_buf);
   if (bgp_ifindices_buf)
     stream_free (bgp_ifindices_buf);
 
+  /* reverse bgp_scan_init */
+  bgp_scan_finish ();
+
   /* reverse bgp_master_init */
   if (bm->master)
     thread_master_free (bm->master);
diff --git a/bgpd/bgp_nexthop.c b/bgpd/bgp_nexthop.c
index 434b2cd..429c638 100644
--- a/bgpd/bgp_nexthop.c
+++ b/bgpd/bgp_nexthop.c
@@ -44,34 +44,14 @@
 #include "zebra/rib.h"
 #include "zebra/zserv.h"	/* For ZEBRA_SERV_PATH. */
 
-extern struct zclient *zclient;
-
-struct bgp_nexthop_cache *zlookup_query (struct in_addr);
-struct bgp_nexthop_cache *zlookup_query_ipv6 (struct in6_addr *);
-
-/* Only one BGP scan thread are activated at the same time. */
-static struct thread *bgp_scan_thread = NULL;
-
-/* BGP import thread */
-static struct thread *bgp_import_thread = NULL;
-
-/* BGP scan interval. */
-static int bgp_scan_interval;
-
-/* BGP import interval. */
-static int bgp_import_interval;
 
 /* Route table for next-hop lookup cache. */
 struct bgp_table *bgp_nexthop_cache_table[AFI_MAX];
 static struct bgp_table *cache1_table[AFI_MAX];
-static struct bgp_table *cache2_table[AFI_MAX];
 
 /* Route table for connected route. */
 static struct bgp_table *bgp_connected_table[AFI_MAX];
 
-/* BGP nexthop lookup query client. */
-struct zclient *zlookup = NULL;
-
 char *
 bnc_str (struct bgp_nexthop_cache *bnc, char *buf, int size)
 {
@@ -79,21 +59,6 @@
   return buf;
 }
 
-/* Add nexthop to the end of the list.  */
-static void
-bnc_nexthop_add (struct bgp_nexthop_cache *bnc, struct nexthop *nexthop)
-{
-  struct nexthop *last;
-
-  for (last = bnc->nexthop; last && last->next; last = last->next)
-    ;
-  if (last)
-    last->next = nexthop;
-  else
-    bnc->nexthop = nexthop;
-  nexthop->prev = last;
-}
-
 void
 bnc_nexthop_free (struct bgp_nexthop_cache *bnc)
 {
@@ -124,40 +89,12 @@
   XFREE (MTYPE_BGP_NEXTHOP_CACHE, bnc);
 }
 
-static int
-bgp_nexthop_cache_different (struct bgp_nexthop_cache *bnc1,
-			   struct bgp_nexthop_cache *bnc2)
-{
-  int i;
-  struct nexthop *next1, *next2;
-
-  if (bnc1->nexthop_num != bnc2->nexthop_num)
-    return 1;
-
-  next1 = bnc1->nexthop;
-  next2 = bnc2->nexthop;
-
-  for (i = 0; i < bnc1->nexthop_num; i++)
-    {
-      if (! nexthop_same_no_recurse (next1, next2))
-	return 1;
-
-      next1 = next1->next;
-      next2 = next2->next;
-    }
-  return 0;
-}
-
 /* If nexthop exists on connected network return 1. */
 int
 bgp_nexthop_onlink (afi_t afi, struct attr *attr)
 {
   struct bgp_node *rn;
   
-  /* If zebra is not enabled return */
-  if (zlookup->sock < 0)
-    return 1;
-  
   /* Lookup the address is onlink or not. */
   if (afi == AFI_IP)
     {
@@ -189,333 +126,6 @@
   return 0;
 }
 
-/* Check specified next-hop is reachable or not. */
-static int
-bgp_nexthop_lookup_ipv6 (struct peer *peer, struct bgp_info *ri, int *changed,
-			 int *metricchanged)
-{
-  struct bgp_node *rn;
-  struct prefix p;
-  struct bgp_nexthop_cache *bnc;
-  struct attr *attr;
-  
-  /* If lookup is not enabled, return valid. */
-  if (zlookup->sock < 0)
-    {
-      if (ri->extra)
-        ri->extra->igpmetric = 0;
-      return 1;
-    }
-  
-  /* Only check IPv6 global address only nexthop. */
-  attr = ri->attr;
-
-  if (attr->extra->mp_nexthop_len != 16 
-      || IN6_IS_ADDR_LINKLOCAL (&attr->extra->mp_nexthop_global))
-    return 1;
-
-  memset (&p, 0, sizeof (struct prefix));
-  p.family = AF_INET6;
-  p.prefixlen = IPV6_MAX_BITLEN;
-  p.u.prefix6 = attr->extra->mp_nexthop_global;
-
-  /* IBGP or ebgp-multihop */
-  rn = bgp_node_get (bgp_nexthop_cache_table[AFI_IP6], &p);
-
-  if (rn->info)
-    {
-      bnc = rn->info;
-      bgp_unlock_node (rn);
-    }
-  else
-    {
-      if (NULL == (bnc = zlookup_query_ipv6 (&attr->extra->mp_nexthop_global)))
-	bnc = bnc_new ();
-      else
-	{
-	  if (changed)
-	    {
-	      struct bgp_table *old;
-	      struct bgp_node *oldrn;
-
-	      if (bgp_nexthop_cache_table[AFI_IP6] == cache1_table[AFI_IP6])
-		old = cache2_table[AFI_IP6];
-	      else
-		old = cache1_table[AFI_IP6];
-
-	      oldrn = bgp_node_lookup (old, &p);
-	      if (oldrn)
-		{
-		  struct bgp_nexthop_cache *oldbnc = oldrn->info;
-
-		  bnc->changed = bgp_nexthop_cache_different (bnc, oldbnc);
-
-		  if (bnc->metric != oldbnc->metric)
-		    bnc->metricchanged = 1;
-
-                  bgp_unlock_node (oldrn);
-		}
-	    }
-	}
-      rn->info = bnc;
-    }
-
-  if (changed)
-    *changed = bnc->changed;
-
-  if (metricchanged)
-    *metricchanged = bnc->metricchanged;
-
-  if (bnc->valid && bnc->metric)
-    (bgp_info_extra_get (ri))->igpmetric = bnc->metric;
-  else if (ri->extra)
-    ri->extra->igpmetric = 0;
-
-  return bnc->valid;
-}
-
-/* Check specified next-hop is reachable or not. */
-int
-bgp_nexthop_lookup (afi_t afi, struct peer *peer, struct bgp_info *ri,
-		    int *changed, int *metricchanged)
-{
-  struct bgp_node *rn;
-  struct prefix p;
-  struct bgp_nexthop_cache *bnc;
-  struct in_addr addr;
-  
-  /* If lookup is not enabled, return valid. */
-  if (zlookup->sock < 0)
-    {
-      if (ri->extra)
-        ri->extra->igpmetric = 0;
-      return 1;
-    }
-  
-  if (afi == AFI_IP6)
-    return bgp_nexthop_lookup_ipv6 (peer, ri, changed, metricchanged);
-
-  addr = ri->attr->nexthop;
-
-  memset (&p, 0, sizeof (struct prefix));
-  p.family = AF_INET;
-  p.prefixlen = IPV4_MAX_BITLEN;
-  p.u.prefix4 = addr;
-
-  /* IBGP or ebgp-multihop */
-  rn = bgp_node_get (bgp_nexthop_cache_table[AFI_IP], &p);
-
-  if (rn->info)
-    {
-      bnc = rn->info;
-      bgp_unlock_node (rn);
-    }
-  else
-    {
-      if (NULL == (bnc = zlookup_query (addr)))
-	bnc = bnc_new ();
-      else
-	{
-	  if (changed)
-	    {
-	      struct bgp_table *old;
-	      struct bgp_node *oldrn;
-
-	      if (bgp_nexthop_cache_table[AFI_IP] == cache1_table[AFI_IP])
-		old = cache2_table[AFI_IP];
-	      else
-		old = cache1_table[AFI_IP];
-
-	      oldrn = bgp_node_lookup (old, &p);
-	      if (oldrn)
-		{
-		  struct bgp_nexthop_cache *oldbnc = oldrn->info;
-
-		  bnc->changed = bgp_nexthop_cache_different (bnc, oldbnc);
-
-		  if (bnc->metric != oldbnc->metric)
-		    bnc->metricchanged = 1;
-
-                  bgp_unlock_node (oldrn);
-		}
-	    }
-	}
-      rn->info = bnc;
-    }
-
-  if (changed)
-    *changed = bnc->changed;
-
-  if (metricchanged)
-    *metricchanged = bnc->metricchanged;
-
-  if (bnc->valid && bnc->metric)
-    (bgp_info_extra_get(ri))->igpmetric = bnc->metric;
-  else if (ri->extra)
-    ri->extra->igpmetric = 0;
-
-  return bnc->valid;
-}
-
-#if BGP_SCAN_NEXTHOP
-/* Reset and free all BGP nexthop cache. */
-static void
-bgp_nexthop_cache_reset (struct bgp_table *table)
-{
-  struct bgp_node *rn;
-  struct bgp_nexthop_cache *bnc;
-
-  for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
-    if ((bnc = rn->info) != NULL)
-      {
-	bnc_free (bnc);
-	rn->info = NULL;
-	bgp_unlock_node (rn);
-      }
-}
-#endif
-
-static void
-bgp_scan (afi_t afi, safi_t safi)
-{
-  struct bgp_node *rn;
-  struct bgp *bgp;
-  struct bgp_info *bi;
-  struct bgp_info *next;
-  struct peer *peer;
-  struct listnode *node, *nnode;
-#if BGP_SCAN_NEXTHOP
-  int valid;
-  int current;
-  int changed;
-  int metricchanged;
-
-  /* Change cache. */
-  if (bgp_nexthop_cache_table[afi] == cache1_table[afi])
-    bgp_nexthop_cache_table[afi] = cache2_table[afi];
-  else
-    bgp_nexthop_cache_table[afi] = cache1_table[afi];
-#endif
-
-  /* Get default bgp. */
-  bgp = bgp_get_default ();
-  if (bgp == NULL)
-    return;
-
-  /* Maximum prefix check */
-  for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
-    {
-      if (peer->status != Established)
-	continue;
-
-      if (peer->afc[afi][SAFI_UNICAST])
-	bgp_maximum_prefix_overflow (peer, afi, SAFI_UNICAST, 1);
-      if (peer->afc[afi][SAFI_MULTICAST])
-	bgp_maximum_prefix_overflow (peer, afi, SAFI_MULTICAST, 1);
-      if (peer->afc[afi][SAFI_MPLS_VPN])
-	bgp_maximum_prefix_overflow (peer, afi, SAFI_MPLS_VPN, 1);
-    }
-
-  for (rn = bgp_table_top (bgp->rib[afi][SAFI_UNICAST]); rn;
-       rn = bgp_route_next (rn))
-    {
-      for (bi = rn->info; bi; bi = next)
-	{
-	  next = bi->next;
-
-	  if (bi->type == ZEBRA_ROUTE_BGP && bi->sub_type == BGP_ROUTE_NORMAL)
-	    {
-#if BGP_SCAN_NEXTHOP
-	      changed = 0;
-	      metricchanged = 0;
-
-	      if (bi->peer->sort == BGP_PEER_EBGP && bi->peer->ttl == 1
-		  && !CHECK_FLAG(bi->peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))
-		valid = bgp_nexthop_onlink (afi, bi->attr);
-	      else
-		valid = bgp_nexthop_lookup (afi, bi->peer, bi,
-					    &changed, &metricchanged);
-
-	      current = CHECK_FLAG (bi->flags, BGP_INFO_VALID) ? 1 : 0;
-
-	      if (changed)
-		SET_FLAG (bi->flags, BGP_INFO_IGP_CHANGED);
-	      else
-		UNSET_FLAG (bi->flags, BGP_INFO_IGP_CHANGED);
-
-	      if (valid != current)
-		{
-		  if (CHECK_FLAG (bi->flags, BGP_INFO_VALID))
-		    {
-		      bgp_aggregate_decrement (bgp, &rn->p, bi,
-					       afi, SAFI_UNICAST);
-		      bgp_info_unset_flag (rn, bi, BGP_INFO_VALID);
-		    }
-		  else
-		    {
-		      bgp_info_set_flag (rn, bi, BGP_INFO_VALID);
-		      bgp_aggregate_increment (bgp, &rn->p, bi,
-					       afi, SAFI_UNICAST);
-		    }
-		}
-#endif
-
-              if (CHECK_FLAG (bgp->af_flags[afi][SAFI_UNICAST],
-		  BGP_CONFIG_DAMPENING)
-                  &&  bi->extra && bi->extra->damp_info )
-                if (bgp_damp_scan (bi, afi, SAFI_UNICAST))
-		  bgp_aggregate_increment (bgp, &rn->p, bi,
-					   afi, SAFI_UNICAST);
-	    }
-	}
-      if (rn->info)
-        bgp_process (bgp, rn, afi, SAFI_UNICAST);
-    }
-
-#if BGP_SCAN_NEXTHOP
-  /* Flash old cache. */
-  if (bgp_nexthop_cache_table[afi] == cache1_table[afi])
-    bgp_nexthop_cache_reset (cache2_table[afi]);
-  else
-    bgp_nexthop_cache_reset (cache1_table[afi]);
-#endif
-
-  if (BGP_DEBUG (events, EVENTS))
-    {
-      if (afi == AFI_IP)
-	zlog_debug ("scanning IPv4 Unicast routing tables");
-      else if (afi == AFI_IP6)
-	zlog_debug ("scanning IPv6 Unicast routing tables");
-    }
-
-  /* Reevaluate default-originate route-maps and announce/withdraw
-   * default route if neccesary. */
-  for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
-    {
-      if (peer->status == Established
-	  && CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE)
-	  && peer->default_rmap[afi][safi].name)
-	bgp_default_originate (peer, afi, safi, 0);
-    }
-}
-
-/* BGP scan thread.  This thread check nexthop reachability. */
-static int
-bgp_scan_timer (struct thread *t)
-{
-  bgp_scan_thread =
-    thread_add_timer (bm->master, bgp_scan_timer, NULL, bgp_scan_interval);
-
-  if (BGP_DEBUG (events, EVENTS))
-    zlog_debug ("Performing BGP general scanning");
-
-  bgp_scan (AFI_IP, SAFI_UNICAST);
-
-  bgp_scan (AFI_IP6, SAFI_UNICAST);
-
-  return 0;
-}
-
 /* BGP own address structure */
 struct bgp_addr
 {
@@ -763,585 +373,39 @@
   return 0;
 }
 
-static struct bgp_nexthop_cache *
-zlookup_read (void)
-{
-  struct stream *s;
-  uint16_t length;
-  u_char marker;
-  u_char version;
-  uint16_t vrf_id;
-  uint16_t command;
-  int err;
-  struct in_addr raddr __attribute__((unused));
-  uint32_t metric;
-  int i;
-  u_char nexthop_num;
-  struct nexthop *nexthop;
-  struct bgp_nexthop_cache *bnc;
-
-  s = zlookup->ibuf;
-  stream_reset (s);
-
-  err = zclient_read_header (s, zlookup->sock, &length, &marker, &version,
-                             &vrf_id, &command);
-  if (err < 0)
-    {
-      zlog_err("%s: zserv_read_header() failed", __func__);
-      return NULL;
-    }
-
-  /* XXX: not doing anything with raddr */
-  raddr.s_addr = stream_get_ipv4 (s);
-  metric = stream_getl (s);
-  nexthop_num = stream_getc (s);
-
-  if (nexthop_num)
-    {
-      bnc = bnc_new ();
-      bnc->valid = 1;
-      bnc->metric = metric;
-      bnc->nexthop_num = nexthop_num;
-
-      for (i = 0; i < nexthop_num; i++)
-	{
-	  nexthop = XCALLOC (MTYPE_NEXTHOP, sizeof (struct nexthop));
-	  nexthop->type = stream_getc (s);
-	  switch (nexthop->type)
-	    {
-	    case ZEBRA_NEXTHOP_IPV4:
-	      nexthop->gate.ipv4.s_addr = stream_get_ipv4 (s);
-	      break;
-	    case ZEBRA_NEXTHOP_IPV4_IFINDEX:
-	      nexthop->gate.ipv4.s_addr = stream_get_ipv4 (s);
-	      nexthop->ifindex = stream_getl (s);
-	      break;
-	    case ZEBRA_NEXTHOP_IFINDEX:
-	    case ZEBRA_NEXTHOP_IFNAME:
-	      nexthop->ifindex = stream_getl (s);
-	      break;
-            default:
-              /* do nothing */
-              break;
-	    }
-	  bnc_nexthop_add (bnc, nexthop);
-	}
-    }
-  else
-    return NULL;
-
-  return bnc;
-}
-
-struct bgp_nexthop_cache *
-zlookup_query (struct in_addr addr)
-{
-  int ret;
-  struct stream *s;
-
-  /* Check socket. */
-  if (zlookup->sock < 0)
-    return NULL;
-
-  s = zlookup->obuf;
-  stream_reset (s);
-  zclient_create_header (s, ZEBRA_IPV4_NEXTHOP_LOOKUP, VRF_DEFAULT);
-  stream_put_in_addr (s, &addr);
-  
-  stream_putw_at (s, 0, stream_get_endp (s));
-  
-  ret = writen (zlookup->sock, s->data, stream_get_endp (s));
-  if (ret < 0)
-    {
-      zlog_err ("can't write to zlookup->sock");
-      close (zlookup->sock);
-      zlookup->sock = -1;
-      return NULL;
-    }
-  if (ret == 0)
-    {
-      zlog_err ("zlookup->sock connection closed");
-      close (zlookup->sock);
-      zlookup->sock = -1;
-      return NULL;
-    }
-
-  return zlookup_read ();
-}
-
-static struct bgp_nexthop_cache *
-zlookup_read_ipv6 (void)
-{
-  struct stream *s;
-  uint16_t length, vrf_id, cmd;
-  u_char version, marker;
-  struct in6_addr raddr;
-  uint32_t metric;
-  int i, err;
-  u_char nexthop_num;
-  struct nexthop *nexthop;
-  struct bgp_nexthop_cache *bnc;
-
-  s = zlookup->ibuf;
-  stream_reset (s);
-
-  err = zclient_read_header (s, zlookup->sock, &length, &marker, &version,
-                             &vrf_id, &cmd);
-  if (err < 0)
-    {
-      zlog_err("%s: zserv_read_header() failed", __func__);
-      return NULL;
-    }
-
-  /* XXX: not actually doing anything with raddr */
-  stream_get (&raddr, s, 16);
-
-  metric = stream_getl (s);
-  nexthop_num = stream_getc (s);
-
-  if (nexthop_num)
-    {
-      bnc = bnc_new ();
-      bnc->valid = 1;
-      bnc->metric = metric;
-      bnc->nexthop_num = nexthop_num;
-
-      for (i = 0; i < nexthop_num; i++)
-	{
-	  nexthop = XCALLOC (MTYPE_NEXTHOP, sizeof (struct nexthop));
-	  nexthop->type = stream_getc (s);
-	  switch (nexthop->type)
-	    {
-	    case ZEBRA_NEXTHOP_IPV6:
-	      stream_get (&nexthop->gate.ipv6, s, 16);
-	      break;
-	    case ZEBRA_NEXTHOP_IPV6_IFINDEX:
-	    case ZEBRA_NEXTHOP_IPV6_IFNAME:
-	      stream_get (&nexthop->gate.ipv6, s, 16);
-	      nexthop->ifindex = stream_getl (s);
-	      break;
-	    case ZEBRA_NEXTHOP_IFINDEX:
-	    case ZEBRA_NEXTHOP_IFNAME:
-	      nexthop->ifindex = stream_getl (s);
-	      break;
-	    default:
-	      /* do nothing */
-	      break;
-	    }
-	  bnc_nexthop_add (bnc, nexthop);
-	}
-    }
-  else
-    return NULL;
-
-  return bnc;
-}
-
-struct bgp_nexthop_cache *
-zlookup_query_ipv6 (struct in6_addr *addr)
-{
-  int ret;
-  struct stream *s;
-
-  /* Check socket. */
-  if (zlookup->sock < 0)
-    return NULL;
-
-  s = zlookup->obuf;
-  stream_reset (s);
-  zclient_create_header (s, ZEBRA_IPV6_NEXTHOP_LOOKUP, VRF_DEFAULT);
-  stream_put (s, addr, 16);
-  stream_putw_at (s, 0, stream_get_endp (s));
-  
-  ret = writen (zlookup->sock, s->data, stream_get_endp (s));
-  if (ret < 0)
-    {
-      zlog_err ("can't write to zlookup->sock");
-      close (zlookup->sock);
-      zlookup->sock = -1;
-      return NULL;
-    }
-  if (ret == 0)
-    {
-      zlog_err ("zlookup->sock connection closed");
-      close (zlookup->sock);
-      zlookup->sock = -1;
-      return NULL;
-    }
-
-  return zlookup_read_ipv6 ();
-}
-
-static int
-bgp_import_check (struct prefix *p, u_int32_t *igpmetric,
-                  struct in_addr *igpnexthop)
-{
-  struct stream *s;
-  int ret;
-  u_int16_t length, vrf_id, command;
-  u_char version, marker;
-  struct in_addr addr __attribute__((unused));
-  struct in_addr nexthop;
-  u_int32_t metric = 0;
-  u_char nexthop_num;
-  u_char nexthop_type;
-
-  /* If lookup connection is not available return valid. */
-  if (zlookup->sock < 0)
-    {
-      if (igpmetric)
-	*igpmetric = 0;
-      return 1;
-    }
-
-  /* Send query to the lookup connection */
-  s = zlookup->obuf;
-  stream_reset (s);
-  zclient_create_header (s, ZEBRA_IPV4_IMPORT_LOOKUP, VRF_DEFAULT);
-  
-  stream_putc (s, p->prefixlen);
-  stream_put_in_addr (s, &p->u.prefix4);
-  
-  stream_putw_at (s, 0, stream_get_endp (s));
-  
-  /* Write the packet. */
-  ret = writen (zlookup->sock, s->data, stream_get_endp (s));
-
-  if (ret < 0)
-    {
-      zlog_err ("can't write to zlookup->sock");
-      close (zlookup->sock);
-      zlookup->sock = -1;
-      return 1;
-    }
-  if (ret == 0)
-    {
-      zlog_err ("zlookup->sock connection closed");
-      close (zlookup->sock);
-      zlookup->sock = -1;
-      return 1;
-    }
-
-  /* Get result. */
-  stream_reset (s);
-
-  ret = zclient_read_header (s, zlookup->sock, &length, &marker, &version,
-                             &vrf_id, &command);
-  if (ret < 0)
-    {
-      zlog_err("%s: zserv_read_header() failed", __func__);
-      return 0;
-    }
-
-  /* XXX: not using addr */
-  addr.s_addr = stream_get_ipv4 (s);
-  metric = stream_getl (s);
-  nexthop_num = stream_getc (s);
-
-  /* Set IGP metric value. */
-  if (igpmetric)
-    *igpmetric = metric;
-
-  /* If there is nexthop then this is active route. */
-  if (nexthop_num)
-    {
-      nexthop.s_addr = 0;
-      nexthop_type = stream_getc (s);
-      switch (nexthop_type)
-	{
-	case ZEBRA_NEXTHOP_IPV4:
-	  nexthop.s_addr = stream_get_ipv4 (s);
-	  break;
-	case ZEBRA_NEXTHOP_IPV4_IFINDEX:
-	  nexthop.s_addr = stream_get_ipv4 (s);
-	  /* ifindex */ (void)stream_getl (s);
-	  break;
-	default:
-	  /* do nothing */
-	  break;
-	}
-      *igpnexthop = nexthop;
-
-      return 1;
-    }
-  else
-    return 0;
-}
-
-/* Scan all configured BGP route then check the route exists in IGP or
-   not. */
-static int
-bgp_import (struct thread *t)
-{
-  struct bgp *bgp;
-  struct bgp_node *rn;
-  struct bgp_static *bgp_static;
-  struct listnode *node, *nnode;
-  int valid;
-  u_int32_t metric;
-  struct in_addr nexthop;
-  afi_t afi;
-  safi_t safi;
-
-  bgp_import_thread = 
-    thread_add_timer (bm->master, bgp_import, NULL, bgp_import_interval);
-
-  if (BGP_DEBUG (events, EVENTS))
-    zlog_debug ("Import timer expired.");
-
-  for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
-    {
-      for (afi = AFI_IP; afi < AFI_MAX; afi++)
-	for (safi = SAFI_UNICAST; safi < SAFI_MPLS_VPN; safi++)
-	  for (rn = bgp_table_top (bgp->route[afi][safi]); rn;
-	       rn = bgp_route_next (rn))
-	    if ((bgp_static = rn->info) != NULL)
-	      {
-		if (bgp_static->backdoor)
-		  continue;
-
-		valid = bgp_static->valid;
-		metric = bgp_static->igpmetric;
-		nexthop = bgp_static->igpnexthop;
-
-		if (bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK)
-		    && afi == AFI_IP && safi == SAFI_UNICAST)
-		  bgp_static->valid = bgp_import_check (&rn->p, &bgp_static->igpmetric,
-						        &bgp_static->igpnexthop);
-		else
-		  {
-		    bgp_static->valid = 1;
-		    bgp_static->igpmetric = 0;
-		    bgp_static->igpnexthop.s_addr = 0;
-		  }
-
-		if (bgp_static->valid != valid)
-		  {
-		    if (bgp_static->valid)
-		      bgp_static_update (bgp, &rn->p, bgp_static, afi, safi);
-		    else
-		      bgp_static_withdraw (bgp, &rn->p, afi, safi);
-		  }
-		else if (bgp_static->valid)
-		  {
-		    if (bgp_static->igpmetric != metric
-			|| bgp_static->igpnexthop.s_addr != nexthop.s_addr
-			|| bgp_static->rmap.name)
-		      bgp_static_update (bgp, &rn->p, bgp_static, afi, safi);
-		  }
-	      }
-    }
-  return 0;
-}
-
-/* Connect to zebra for nexthop lookup. */
-static int
-zlookup_connect (struct thread *t)
-{
-  struct zclient *zlookup;
-
-  zlookup = THREAD_ARG (t);
-  zlookup->t_connect = NULL;
-
-  if (zlookup->sock != -1)
-    return 0;
-
-  if (zclient_socket_connect (zlookup) < 0)
-    return -1;
-
-  return 0;
-}
-
-/* Check specified multiaccess next-hop. */
 int
-bgp_multiaccess_check_v4 (struct in_addr nexthop, char *peer)
+bgp_multiaccess_check_v4 (struct in_addr nexthop, struct peer *peer)
 {
   struct bgp_node *rn1;
   struct bgp_node *rn2;
-  struct prefix p1;
-  struct prefix p2;
-  struct in_addr addr;
+  struct prefix p;
   int ret;
 
-  ret = inet_aton (peer, &addr);
-  if (! ret)
+  p.family = AF_INET;
+  p.prefixlen = IPV4_MAX_BITLEN;
+  p.u.prefix4 = nexthop;
+
+  rn1 = bgp_node_match (bgp_connected_table[AFI_IP], &p);
+  if (!rn1)
     return 0;
 
-  memset (&p1, 0, sizeof (struct prefix));
-  p1.family = AF_INET;
-  p1.prefixlen = IPV4_MAX_BITLEN;
-  p1.u.prefix4 = nexthop;
-  memset (&p2, 0, sizeof (struct prefix));
-  p2.family = AF_INET;
-  p2.prefixlen = IPV4_MAX_BITLEN;
-  p2.u.prefix4 = addr;
+  p.family = AF_INET;
+  p.prefixlen = IPV4_MAX_BITLEN;
+  p.u.prefix4 = peer->su.sin.sin_addr;
 
-  /* If bgp scan is not enabled, return invalid. */
-  if (zlookup->sock < 0)
-    return 0;
-
-  rn1 = bgp_node_match (bgp_connected_table[AFI_IP], &p1);
-  if (! rn1)
-    return 0;
-  bgp_unlock_node (rn1);
-  
-  rn2 = bgp_node_match (bgp_connected_table[AFI_IP], &p2);
-  if (! rn2)
-    return 0;
-  bgp_unlock_node (rn2);
-
-  /* This is safe, even with above unlocks, since we are just
-     comparing pointers to the objects, not the objects themselves. */
-  if (rn1 == rn2)
-    return 1;
-
-  return 0;
-}
-
-DEFUN (bgp_scan_time,
-       bgp_scan_time_cmd,
-       "bgp scan-time <5-60>",
-       "BGP specific commands\n"
-       "Configure background scanner interval\n"
-       "Scanner interval (seconds)\n")
-{
-  bgp_scan_interval = atoi (argv[0]);
-
-  if (bgp_scan_thread)
+  rn2 = bgp_node_match (bgp_connected_table[AFI_IP], &p);
+  if (!rn2)
     {
-      thread_cancel (bgp_scan_thread);
-      bgp_scan_thread = 
-	thread_add_timer (bm->master, bgp_scan_timer, NULL, bgp_scan_interval);
+      bgp_unlock_node(rn1);
+      return 0;
     }
 
-  return CMD_SUCCESS;
-}
+  ret = (rn1 == rn2) ? 1 : 0;
 
-DEFUN (no_bgp_scan_time,
-       no_bgp_scan_time_cmd,
-       "no bgp scan-time",
-       NO_STR
-       "BGP specific commands\n"
-       "Configure background scanner interval\n")
-{
-  bgp_scan_interval = BGP_SCAN_INTERVAL_DEFAULT;
+  bgp_unlock_node(rn1);
+  bgp_unlock_node(rn2);
 
-  if (bgp_scan_thread)
-    {
-      thread_cancel (bgp_scan_thread);
-      bgp_scan_thread = 
-	thread_add_timer (bm->master, bgp_scan_timer, NULL, bgp_scan_interval);
-    }
-
-  return CMD_SUCCESS;
-}
-
-ALIAS (no_bgp_scan_time,
-       no_bgp_scan_time_val_cmd,
-       "no bgp scan-time <5-60>",
-       NO_STR
-       "BGP specific commands\n"
-       "Configure background scanner interval\n"
-       "Scanner interval (seconds)\n")
-
-static int
-show_ip_bgp_scan_tables (struct vty *vty, const char detail)
-{
-  struct bgp_node *rn;
-  char buf[INET6_ADDRSTRLEN];
-
-  if (bgp_scan_thread)
-    vty_out (vty, "BGP scan is running%s", VTY_NEWLINE);
-  else
-    vty_out (vty, "BGP scan is not running%s", VTY_NEWLINE);
-  vty_out (vty, "BGP scan interval is %d%s", bgp_scan_interval, VTY_NEWLINE);
-
-#if BGP_SCAN_NEXTHOP
-  vty_out (vty, "Current BGP nexthop cache:%s", VTY_NEWLINE);
-  for (rn = bgp_table_top (bgp_nexthop_cache_table[AFI_IP]); rn; rn = bgp_route_next (rn))
-    if ((bnc = rn->info) != NULL)
-      {
-	if (bnc->valid)
-	{
-	  vty_out (vty, " %s valid [IGP metric %d]%s",
-		   inet_ntop (AF_INET, &rn->p.u.prefix4, buf, INET6_ADDRSTRLEN), bnc->metric, VTY_NEWLINE);
-	  if (detail)
-	    for (nexthop = bnc->nexthop; nexthop; nexthop = nexthop->next)
-	      switch (nexthop->type)
-	      {
-	      case NEXTHOP_TYPE_IPV4:
-		vty_out (vty, "  gate %s%s", inet_ntop (AF_INET, &nexthop->gate.ipv4, buf, INET6_ADDRSTRLEN), VTY_NEWLINE);
-		break;
-	      case NEXTHOP_TYPE_IPV4_IFINDEX:
-		vty_out (vty, "  gate %s", inet_ntop (AF_INET, &nexthop->gate.ipv4, buf, INET6_ADDRSTRLEN));
-		vty_out (vty, " ifidx %u%s", nexthop->ifindex, VTY_NEWLINE);
-		break;
-	      case NEXTHOP_TYPE_IFINDEX:
-		vty_out (vty, "  ifidx %u%s", nexthop->ifindex, VTY_NEWLINE);
-		break;
-	      default:
-		vty_out (vty, "  invalid nexthop type %u%s", nexthop->type, VTY_NEWLINE);
-	      }
-	}
-	else
-	  vty_out (vty, " %s invalid%s",
-		   inet_ntop (AF_INET, &rn->p.u.prefix4, buf, INET6_ADDRSTRLEN), VTY_NEWLINE);
-      }
-
-  {
-    for (rn = bgp_table_top (bgp_nexthop_cache_table[AFI_IP6]); 
-         rn; 
-         rn = bgp_route_next (rn))
-      if ((bnc = rn->info) != NULL)
-	{
-	  if (bnc->valid)
-	  {
-	    vty_out (vty, " %s valid [IGP metric %d]%s",
-		     inet_ntop (AF_INET6, &rn->p.u.prefix6, buf, INET6_ADDRSTRLEN),
-		     bnc->metric, VTY_NEWLINE);
-	    if (detail)
-	      for (nexthop = bnc->nexthop; nexthop; nexthop = nexthop->next)
-		switch (nexthop->type)
-		{
-		case NEXTHOP_TYPE_IPV6:
-		  vty_out (vty, "  gate %s%s", inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, INET6_ADDRSTRLEN), VTY_NEWLINE);
-		  break;
-		case NEXTHOP_TYPE_IFINDEX:
-		  vty_out (vty, "  ifidx %u%s", nexthop->ifindex, VTY_NEWLINE);
-		  break;
-		default:
-		  vty_out (vty, "  invalid nexthop type %u%s", nexthop->type, VTY_NEWLINE);
-		}
-	  }
-	  else
-	    vty_out (vty, " %s invalid%s",
-		     inet_ntop (AF_INET6, &rn->p.u.prefix6, buf, INET6_ADDRSTRLEN),
-		     VTY_NEWLINE);
-	}
-  }
-#else
-  vty_out (vty, "BGP next-hop tracking is on%s", VTY_NEWLINE);
-#endif
-  vty_out (vty, "BGP connected route:%s", VTY_NEWLINE);
-  for (rn = bgp_table_top (bgp_connected_table[AFI_IP]); 
-       rn; 
-       rn = bgp_route_next (rn))
-    if (rn->info != NULL)
-      vty_out (vty, " %s/%d%s", inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
-	       VTY_NEWLINE);
-
-  {
-    for (rn = bgp_table_top (bgp_connected_table[AFI_IP6]); 
-         rn; 
-         rn = bgp_route_next (rn))
-      if (rn->info != NULL)
-	vty_out (vty, " %s/%d%s",
-		 inet_ntop (AF_INET6, &rn->p.u.prefix6, buf, INET6_ADDRSTRLEN),
-		 rn->p.prefixlen,
-		 VTY_NEWLINE);
-  }
-
-  return CMD_SUCCESS;
+  return (ret);
 }
 
 static int
@@ -1418,29 +482,6 @@
   return CMD_SUCCESS;
 }
 
-DEFUN (show_ip_bgp_scan,
-       show_ip_bgp_scan_cmd,
-       "show ip bgp scan",
-       SHOW_STR
-       IP_STR
-       BGP_STR
-       "BGP scan status\n")
-{
-  return show_ip_bgp_scan_tables (vty, 0);
-}
-
-DEFUN (show_ip_bgp_scan_detail,
-       show_ip_bgp_scan_detail_cmd,
-       "show ip bgp scan detail",
-       SHOW_STR
-       IP_STR
-       BGP_STR
-       "BGP scan status\n"
-       "More detailed output\n")
-{
-  return show_ip_bgp_scan_tables (vty, 1);
-}
-
 DEFUN (show_ip_bgp_nexthop,
        show_ip_bgp_nexthop_cmd,
        "show ip bgp nexthop",
@@ -1463,49 +504,25 @@
   return show_ip_bgp_nexthop_table (vty, 1);
 }
 
-int
-bgp_config_write_scan_time (struct vty *vty)
-{
-  if (bgp_scan_interval != BGP_SCAN_INTERVAL_DEFAULT)
-    vty_out (vty, " bgp scan-time %d%s", bgp_scan_interval, VTY_NEWLINE);
-  return CMD_SUCCESS;
-}
-
 void
 bgp_scan_init (void)
 {
-  zlookup = zclient_new (bm->master);
-  zlookup->sock = -1;
-  zlookup->t_connect = thread_add_event (bm->master, zlookup_connect, zlookup, 0);
-
-  bgp_scan_interval = BGP_SCAN_INTERVAL_DEFAULT;
-  bgp_import_interval = BGP_IMPORT_INTERVAL_DEFAULT;
-
   cache1_table[AFI_IP] = bgp_table_init (AFI_IP, SAFI_UNICAST);
-  cache2_table[AFI_IP] = bgp_table_init (AFI_IP, SAFI_UNICAST);
   bgp_nexthop_cache_table[AFI_IP] = cache1_table[AFI_IP];
 
   bgp_connected_table[AFI_IP] = bgp_table_init (AFI_IP, SAFI_UNICAST);
 
   cache1_table[AFI_IP6] = bgp_table_init (AFI_IP6, SAFI_UNICAST);
-  cache2_table[AFI_IP6] = bgp_table_init (AFI_IP6, SAFI_UNICAST);
   bgp_nexthop_cache_table[AFI_IP6] = cache1_table[AFI_IP6];
   bgp_connected_table[AFI_IP6] = bgp_table_init (AFI_IP6, SAFI_UNICAST);
 
-  /* Make BGP scan thread. */
-  bgp_scan_thread = thread_add_timer (bm->master, bgp_scan_timer, 
-                                      NULL, bgp_scan_interval);
-  /* Make BGP import there. */
-  bgp_import_thread = thread_add_timer (bm->master, bgp_import, NULL, 0);
+}
 
-  install_element (BGP_NODE, &bgp_scan_time_cmd);
-  install_element (BGP_NODE, &no_bgp_scan_time_cmd);
-  install_element (BGP_NODE, &no_bgp_scan_time_val_cmd);
-  install_element (VIEW_NODE, &show_ip_bgp_scan_cmd);
-  install_element (VIEW_NODE, &show_ip_bgp_scan_detail_cmd);
+void
+bgp_scan_vty_init()
+{
   install_element (VIEW_NODE, &show_ip_bgp_nexthop_cmd);
   install_element (VIEW_NODE, &show_ip_bgp_nexthop_detail_cmd);
-  install_element (RESTRICTED_NODE, &show_ip_bgp_scan_cmd);
 }
 
 void
@@ -1515,10 +532,6 @@
     bgp_table_unlock (cache1_table[AFI_IP]);
   cache1_table[AFI_IP] = NULL;
 
-  if (cache2_table[AFI_IP])
-    bgp_table_unlock (cache2_table[AFI_IP]);
-  cache2_table[AFI_IP] = NULL;
-  
   if (bgp_connected_table[AFI_IP])
     bgp_table_unlock (bgp_connected_table[AFI_IP]);
   bgp_connected_table[AFI_IP] = NULL;
@@ -1527,10 +540,6 @@
     bgp_table_unlock (cache1_table[AFI_IP6]);
   cache1_table[AFI_IP6] = NULL;
 
-  if (cache2_table[AFI_IP6])
-    bgp_table_unlock (cache2_table[AFI_IP6]);
-  cache2_table[AFI_IP6] = NULL;
-
   if (bgp_connected_table[AFI_IP6])
     bgp_table_unlock (bgp_connected_table[AFI_IP6]);
   bgp_connected_table[AFI_IP6] = NULL;
@@ -1539,12 +548,5 @@
 void
 bgp_scan_destroy (void)
 {
-  if (zlookup == NULL)
-    return;
-  THREAD_OFF(bgp_import_thread);
-  THREAD_OFF(bgp_scan_thread);
-  THREAD_OFF(zlookup->t_connect);
   bgp_scan_finish();
-  zclient_free (zlookup);
-  zlookup = NULL;
 }
diff --git a/bgpd/bgp_nexthop.h b/bgpd/bgp_nexthop.h
index a239ca0..fe4f5ad 100644
--- a/bgpd/bgp_nexthop.h
+++ b/bgpd/bgp_nexthop.h
@@ -25,9 +25,6 @@
 #include "queue.h"
 #include "prefix.h"
 
-#define BGP_SCAN_INTERVAL_DEFAULT   60
-#define BGP_IMPORT_INTERVAL_DEFAULT 15
-
 #define NEXTHOP_FAMILY(nexthop_len) ( \
   ((nexthop_len) ==  4 ||             \
    (nexthop_len) == 12 ? AF_INET :    \
@@ -40,15 +37,6 @@
 /* BGP nexthop cache value structure. */
 struct bgp_nexthop_cache
 {
-  /* This nexthop exists in IGP. */
-  u_char valid;
-
-  /* Nexthop is changed. */
-  u_char changed;
-
-  /* Nexthop is changed. */
-  u_char metricchanged;
-
   /* IGP route's metric. */
   u_int32_t metric;
 
@@ -58,26 +46,28 @@
   time_t last_update;
   u_int16_t flags;
 
-#define BGP_NEXTHOP_VALID (1 << 0)
-#define BGP_NEXTHOP_REGISTERED (1 << 1)
+#define BGP_NEXTHOP_VALID             (1 << 0)
+#define BGP_NEXTHOP_REGISTERED        (1 << 1)
+#define BGP_NEXTHOP_CONNECTED         (1 << 2)
+#define BGP_NEXTHOP_PEER_NOTIFIED     (1 << 3)
 
   u_int16_t change_flags;
 
-#define BGP_NEXTHOP_CHANGED (1 << 0)
-#define BGP_NEXTHOP_METRIC_CHANGED (1 << 1)
+#define BGP_NEXTHOP_CHANGED           (1 << 0)
+#define BGP_NEXTHOP_METRIC_CHANGED    (1 << 1)
+#define BGP_NEXTHOP_CONNECTED_CHANGED (1 << 2)
 
   struct bgp_node *node;
+  void *nht_info;		/* In BGP, peer session */
   LIST_HEAD(path_list, bgp_info) paths;
   unsigned int path_count;
 };
 
-extern void bgp_scan_init (void);
-extern void bgp_scan_finish (void);
 extern int bgp_nexthop_lookup (afi_t, struct peer *peer, struct bgp_info *,
 			int *, int *);
 extern void bgp_connected_add (struct connected *c);
 extern void bgp_connected_delete (struct connected *c);
-extern int bgp_multiaccess_check_v4 (struct in_addr, char *);
+extern int bgp_multiaccess_check_v4 (struct in_addr, struct peer *);
 extern int bgp_config_write_scan_time (struct vty *);
 extern int bgp_nexthop_onlink (afi_t, struct attr *);
 extern int bgp_nexthop_self (struct attr *);
@@ -89,4 +79,6 @@
 extern void bnc_nexthop_free(struct bgp_nexthop_cache *bnc);
 extern char *bnc_str(struct bgp_nexthop_cache *bnc, char *buf, int size);
 
+extern void bgp_scan_init (void);
+extern void bgp_scan_vty_init (void);
 #endif /* _QUAGGA_BGP_NEXTHOP_H */
diff --git a/bgpd/bgp_nht.c b/bgpd/bgp_nht.c
index 21e1411..34b5fd1 100644
--- a/bgpd/bgp_nht.c
+++ b/bgpd/bgp_nht.c
@@ -39,6 +39,7 @@
 #include "bgpd/bgp_nexthop.h"
 #include "bgpd/bgp_debug.h"
 #include "bgpd/bgp_nht.h"
+#include "bgpd/bgp_fsm.h"
 
 extern struct zclient *zclient;
 extern struct bgp_table *bgp_nexthop_cache_table[AFI_MAX];
@@ -51,19 +52,15 @@
 			int keep);
 
 int
-bgp_find_nexthop (struct bgp_info *path, int *changed, int *metricchanged)
+bgp_find_nexthop (struct bgp_info *path, int connected)
 {
   struct bgp_nexthop_cache *bnc = path->nexthop;
 
   if (!bnc)
     return 0;
 
-  if (changed)
-    *changed = CHECK_FLAG(bnc->change_flags, BGP_NEXTHOP_CHANGED);
-
-  if (metricchanged)
-    *metricchanged = CHECK_FLAG(bnc->change_flags,
-				BGP_NEXTHOP_METRIC_CHANGED);
+  if (connected && !(CHECK_FLAG(bnc->flags, BGP_NEXTHOP_CONNECTED)))
+    return 0;
 
   return (CHECK_FLAG(bnc->flags, BGP_NEXTHOP_VALID));
 }
@@ -78,7 +75,7 @@
 
   path_nh_map(path, NULL, 0);
 
-  if (LIST_EMPTY(&(bnc->paths)))
+  if (LIST_EMPTY(&(bnc->paths)) && !bnc->nht_info)
     {
       if (BGP_DEBUG(nht, NHT))
 	{
@@ -94,15 +91,34 @@
 }
 
 int
-bgp_find_or_add_nexthop (afi_t afi, struct bgp_info *ri, int *changed,
-			 int *metricchanged)
+bgp_find_or_add_nexthop (afi_t afi, struct bgp_info *ri, struct peer *peer,
+			 int connected)
 {
   struct bgp_node *rn;
   struct bgp_nexthop_cache *bnc;
   struct prefix p;
 
-  if (make_prefix(afi, ri, &p) < 0)
-    return 1;
+  if (ri)
+    {
+      if (make_prefix(afi, ri, &p) < 0)
+	return 1;
+    }
+  else if (peer)
+    {
+      if (afi == AFI_IP)
+	{
+	  p.family = AF_INET;
+	  p.prefixlen = IPV4_MAX_BITLEN;
+	  p.u.prefix4 = peer->su.sin.sin_addr;
+	}
+      else if (afi == AFI_IP6)
+	{
+	  p.family = AF_INET6;
+	  p.prefixlen = IPV6_MAX_BITLEN;
+	  p.u.prefix6 = peer->su.sin6.sin6_addr;
+	}
+    }
+
   rn = bgp_node_get (bgp_nexthop_cache_table[afi], &p);
 
   if (!rn->info)
@@ -111,23 +127,27 @@
       rn->info = bnc;
       bnc->node = rn;
       bgp_lock_node(rn);
-      register_nexthop(bnc);
+      if (connected)
+	SET_FLAG(bnc->flags, BGP_NEXTHOP_CONNECTED);
     }
+
   bnc = rn->info;
   bgp_unlock_node (rn);
-  path_nh_map(ri, bnc, 1);
 
-  if (changed)
-    *changed = CHECK_FLAG(bnc->change_flags, BGP_NEXTHOP_CHANGED);
+  if (!CHECK_FLAG(bnc->flags, BGP_NEXTHOP_REGISTERED))
+    register_nexthop(bnc);
 
-  if (metricchanged)
-    *metricchanged = CHECK_FLAG(bnc->change_flags,
-				BGP_NEXTHOP_METRIC_CHANGED);
+  if (ri)
+    {
+      path_nh_map(ri, bnc, 1);
 
-  if (CHECK_FLAG(bnc->flags, BGP_NEXTHOP_VALID) && bnc->metric)
-    (bgp_info_extra_get(ri))->igpmetric = bnc->metric;
-  else if (ri->extra)
-    ri->extra->igpmetric = 0;
+      if (CHECK_FLAG(bnc->flags, BGP_NEXTHOP_VALID) && bnc->metric)
+	(bgp_info_extra_get(ri))->igpmetric = bnc->metric;
+      else if (ri->extra)
+	ri->extra->igpmetric = 0;
+    }
+  else if (peer)
+    bnc->nht_info = (void *)peer;
 
   return (CHECK_FLAG(bnc->flags, BGP_NEXTHOP_VALID));
 }
@@ -269,6 +289,7 @@
   else
     {
       bnc->flags &= ~BGP_NEXTHOP_VALID;
+      UNSET_FLAG(bnc->flags, BGP_NEXTHOP_PEER_NOTIFIED);
       bnc_nexthop_free(bnc);
       bnc->nexthop = NULL;
     }
@@ -326,12 +347,21 @@
 
   /* Check socket. */
   if (!zclient || zclient->sock < 0)
-    return;
+    {
+      zlog_debug("%s: Can't send NH register, Zebra client not established",
+		 __FUNCTION__);
+      return;
+    }
 
   p = &(bnc->node->p);
   s = zclient->obuf;
   stream_reset (s);
   zclient_create_header (s, command, VRF_DEFAULT);
+  if (CHECK_FLAG(bnc->flags, BGP_NEXTHOP_CONNECTED))
+    stream_putc(s, 1);
+  else
+    stream_putc(s, 0);
+
   stream_putw(s, PREFIX_FAMILY(p));
   stream_putc(s, p->prefixlen);
   switch (PREFIX_FAMILY(p))
@@ -339,11 +369,9 @@
     case AF_INET:
       stream_put_in_addr (s, &p->u.prefix4);
       break;
-#ifdef HAVE_IPV6
     case AF_INET6:
       stream_put(s, &(p->u.prefix6), 16);
       break;
-#endif
     default:
       break;
     }
@@ -353,6 +381,11 @@
   /* TBD: handle the failure */
   if (ret < 0)
     zlog_warn("sendmsg_nexthop: zclient_send_message() failed");
+
+  if (command == ZEBRA_NEXTHOP_REGISTER)
+    SET_FLAG(bnc->flags, BGP_NEXTHOP_REGISTERED);
+  else if (command == ZEBRA_NEXTHOP_UNREGISTER)
+    UNSET_FLAG(bnc->flags, BGP_NEXTHOP_REGISTERED);
   return;
 }
 
@@ -371,7 +404,6 @@
   if (bnc->flags & BGP_NEXTHOP_REGISTERED)
     return;
   sendmsg_nexthop(bnc, ZEBRA_NEXTHOP_REGISTER);
-  SET_FLAG(bnc->flags, BGP_NEXTHOP_REGISTERED);
 }
 
 /**
@@ -389,7 +421,6 @@
     return;
 
   sendmsg_nexthop(bnc, ZEBRA_NEXTHOP_UNREGISTER);
-  UNSET_FLAG(bnc->flags, BGP_NEXTHOP_REGISTERED);
 }
 
 /**
@@ -406,6 +437,7 @@
   struct bgp_info *path;
   struct bgp *bgp = bgp_get_default();
   int afi;
+  struct peer *peer = (struct peer *)bnc->nht_info;
 
   LIST_FOREACH(path, &(bnc->paths), nh_thread)
     {
@@ -448,6 +480,15 @@
 
       bgp_process(bgp, rn, afi, SAFI_UNICAST);
     }
+
+  if (peer && !CHECK_FLAG(bnc->flags, BGP_NEXTHOP_PEER_NOTIFIED))
+    {
+      if (BGP_DEBUG(nht, NHT))
+	zlog_debug("%s: Updating peer (%s) status with NHT", __FUNCTION__, peer->host);
+      bgp_fsm_nht_update(peer, CHECK_FLAG(bnc->flags, BGP_NEXTHOP_VALID));
+      SET_FLAG(bnc->flags, BGP_NEXTHOP_PEER_NOTIFIED);
+    }
+
   RESET_FLAG(bnc->change_flags);
 }
 
diff --git a/bgpd/bgp_nht.h b/bgpd/bgp_nht.h
index 41c2b85..2bced7f 100644
--- a/bgpd/bgp_nht.h
+++ b/bgpd/bgp_nht.h
@@ -31,12 +31,9 @@
  * bgp_find_nexthop() - lookup the nexthop cache table for the bnc object
  * ARGUMENTS:
  *   p - path for which the nexthop object is being looked up
- *   c - output variable that stores whether the nexthop object has changed
- *        since last time.
- *   m - output variable that stores whether the nexthop metric has changed
- *        since last time.
+ *   connected - True if NH MUST be a connected route
  */
-extern int bgp_find_nexthop(struct bgp_info *p, int *c, int *m);
+extern int bgp_find_nexthop(struct bgp_info *p, int connected);
 
 /**
  * bgp_find_or_add_nexthop() - lookup the nexthop cache table for the bnc
@@ -45,12 +42,11 @@
  * ARGUMENTS:
  *   a - afi: AFI_IP or AF_IP6
  *   p - path for which the nexthop object is being looked up
- *   c - output variable that stores whether the nexthop object has changed
- *        since last time.
- *   m - output variable that stores whether the nexthop metric has changed
- *        since last time.
+ *   peer - The BGP peer associated with this NHT
+ *   connected - True if NH MUST be a connected route
  */
-extern int bgp_find_or_add_nexthop(afi_t a, struct bgp_info *p, int *c, int *m);
+extern int bgp_find_or_add_nexthop(afi_t a, struct bgp_info *p,
+				   struct peer *peer, int connected);
 
 /**
  * bgp_unlink_nexthop() - Unlink the nexthop object from the path structure.
diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c
index f42e544..2ec595f 100644
--- a/bgpd/bgp_packet.c
+++ b/bgpd/bgp_packet.c
@@ -103,8 +103,8 @@
 }
 
 /* Check file descriptor whether connect is established. */
-static void
-bgp_connect_check (struct peer *peer)
+int
+bgp_connect_check (struct peer *peer, int change_state)
 {
   int status;
   socklen_t slen;
@@ -123,20 +123,23 @@
     {
       zlog (peer->log, LOG_INFO, "can't get sockopt for nonblocking connect");
       BGP_EVENT_ADD (peer, TCP_fatal_error);
-      return;
+      return -1;
     }      
 
   /* When status is 0 then TCP connection is established. */
   if (status == 0)
     {
       BGP_EVENT_ADD (peer, TCP_connection_open);
+      return 1;
     }
   else
     {
       if (BGP_DEBUG (events, EVENTS))
 	  plog_debug (peer->log, "%s [Event] Connect failed (%s)",
 		     peer->host, safe_strerror (errno));
-      BGP_EVENT_ADD (peer, TCP_connection_open_failed);
+      if (change_state)
+	BGP_EVENT_ADD (peer, TCP_connection_open_failed);
+      return 0;
     }
 }
 
@@ -715,7 +718,7 @@
   /* For non-blocking IO check. */
   if (peer->status == Connect)
     {
-      bgp_connect_check (peer);
+      bgp_connect_check (peer, 1);
       return 0;
     }
 
@@ -2492,7 +2495,7 @@
   /* For non-blocking IO check. */
   if (peer->status == Connect)
     {
-      bgp_connect_check (peer);
+      bgp_connect_check (peer, 1);
       goto done;
     }
   else
diff --git a/bgpd/bgp_packet.h b/bgpd/bgp_packet.h
index 6b0b7f4..74c62c0 100644
--- a/bgpd/bgp_packet.h
+++ b/bgpd/bgp_packet.h
@@ -40,6 +40,7 @@
 /* Packet send and receive function prototypes. */
 extern int bgp_read (struct thread *);
 extern int bgp_write (struct thread *);
+extern int bgp_connect_check (struct peer *, int change_state);
 
 extern void bgp_keepalive_send (struct peer *);
 extern void bgp_open_send (struct peer *);
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index 066637b..a88a022 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -55,7 +55,7 @@
 #include "bgpd/bgp_zebra.h"
 #include "bgpd/bgp_vty.h"
 #include "bgpd/bgp_mpath.h"
-#include "bgpd/bgp_nht.c"
+#include "bgpd/bgp_nht.h"
 
 /* Extern from bgp_dump.c */
 extern const char *bgp_origin_str[];
@@ -998,7 +998,7 @@
 	   || (NEXTHOP_IS_V6 &&
                IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global))
 	   || (peer->sort == BGP_PEER_EBGP
-	       && bgp_multiaccess_check_v4 (attr->nexthop, peer->host) == 0))
+               && (bgp_multiaccess_check_v4 (attr->nexthop, peer) == 0)))
     {
       /* Set IPv4 nexthop. */
       if (NEXTHOP_IS_V4)
@@ -2129,6 +2129,7 @@
   struct bgp_info *new;
   const char *reason;
   char buf[SU_ADDRSTRLEN];
+  int connected = 0;
 
   memset (&new_attr, 0, sizeof(struct attr));
   memset (&new_extra, 0, sizeof(struct attr_extra));
@@ -2209,17 +2210,6 @@
   /* IPv4 unicast next hop check.  */
   if (afi == AFI_IP && safi == SAFI_UNICAST)
     {
-      /* If the peer is EBGP and nexthop is not on connected route,
-	 discard it.  */
-      if (peer->sort == BGP_PEER_EBGP && peer->ttl == 1
-	  && ! bgp_nexthop_onlink (afi, &new_attr)
-	  && ! CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))
-	{
-	  reason = "non-connected next-hop;";
-	  bgp_attr_flush (&new_attr);
-	  goto filtered;
-	}
-
       /* Next hop must not be 0.0.0.0 nor Class D/E address. Next hop
 	 must not be my own address.  */
       if (new_attr.nexthop.s_addr == 0
@@ -2347,20 +2337,29 @@
 	}
 
       /* Nexthop reachability check. */
-      if ((afi == AFI_IP || afi == AFI_IP6)
-	  && safi == SAFI_UNICAST 
-	  && (peer->sort == BGP_PEER_IBGP
-              || peer->sort == BGP_PEER_CONFED
-	      || (peer->sort == BGP_PEER_EBGP && peer->ttl != 1)
-	      || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK)))
+      if ((afi == AFI_IP || afi == AFI_IP6) && safi == SAFI_UNICAST)
 	{
-	  if (bgp_find_or_add_nexthop (afi, ri, NULL, NULL))
+	  if (peer->sort == BGP_PEER_EBGP && peer->ttl == 1 &&
+	      ! CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))
+	    connected = 1;
+	  else
+	    connected = 0;
+
+	  if (bgp_find_or_add_nexthop (afi, ri, NULL, connected))
 	    bgp_info_set_flag (rn, ri, BGP_INFO_VALID);
 	  else
-	    bgp_info_unset_flag (rn, ri, BGP_INFO_VALID);
+	    {
+	      if (BGP_DEBUG(nht, NHT))
+		{
+		  char buf1[INET6_ADDRSTRLEN];
+		  inet_ntop(AF_INET, (const void *)&attr_new->nexthop, buf1, INET6_ADDRSTRLEN);
+		  zlog_debug("%s(%s): NH unresolved", __FUNCTION__, buf1);
+		}
+	      bgp_info_unset_flag (rn, ri, BGP_INFO_VALID);
+	    }
 	}
       else
-        bgp_info_set_flag (rn, ri, BGP_INFO_VALID);
+	bgp_info_set_flag (rn, ri, BGP_INFO_VALID);
 
       bgp_attr_flush (&new_attr);
 
@@ -2390,17 +2389,26 @@
     memcpy ((bgp_info_extra_get (new))->tag, tag, 3);
 
   /* Nexthop reachability check. */
-  if ((afi == AFI_IP || afi == AFI_IP6)
-      && safi == SAFI_UNICAST
-      && (peer->sort == BGP_PEER_IBGP
-          || peer->sort == BGP_PEER_CONFED
-	  || (peer->sort == BGP_PEER_EBGP && peer->ttl != 1)
-	  || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK)))
+  if ((afi == AFI_IP || afi == AFI_IP6) && safi == SAFI_UNICAST)
     {
-      if (bgp_find_or_add_nexthop (afi, new, NULL, NULL))
+      if (peer->sort == BGP_PEER_EBGP && peer->ttl == 1 &&
+	  ! CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))
+	connected = 1;
+      else
+	connected = 0;
+
+      if (bgp_find_or_add_nexthop (afi, new, NULL, connected))
 	bgp_info_set_flag (rn, new, BGP_INFO_VALID);
       else
-        bgp_info_unset_flag (rn, new, BGP_INFO_VALID);
+	{
+	  if (BGP_DEBUG(nht, NHT))
+	    {
+	      char buf1[INET6_ADDRSTRLEN];
+	      inet_ntop(AF_INET, (const void *)&attr_new->nexthop, buf1, INET6_ADDRSTRLEN);
+	      zlog_debug("%s(%s): NH unresolved", __FUNCTION__, buf1);
+	    }
+	  bgp_info_unset_flag (rn, new, BGP_INFO_VALID);
+	}
     }
   else
     bgp_info_set_flag (rn, new, BGP_INFO_VALID);
@@ -3532,6 +3540,23 @@
           ri->attr = attr_new;
           ri->uptime = bgp_clock ();
 
+	  /* Nexthop reachability check. */
+	  if (bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK))
+	    {
+	      if (bgp_find_or_add_nexthop (afi, ri, NULL, 0))
+		bgp_info_set_flag (rn, ri, BGP_INFO_VALID);
+	      else
+		{
+		  if (BGP_DEBUG(nht, NHT))
+		    {
+		      char buf1[INET6_ADDRSTRLEN];
+		      inet_ntop(AF_INET, (const void *)&attr_new->nexthop,
+				buf1, INET6_ADDRSTRLEN);
+		      zlog_debug("%s(%s): NH unresolved", __FUNCTION__, buf1);
+		    }
+		  bgp_info_unset_flag (rn, ri, BGP_INFO_VALID);
+		}
+	    }
           /* Process change. */
           bgp_process (bgp, rn, afi, safi);
           bgp_unlock_node (rn);
@@ -3544,7 +3569,25 @@
   /* Make new BGP info. */
   new = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_STATIC, bgp->peer_self,
 		  attr_new, rn);
-  SET_FLAG (new->flags, BGP_INFO_VALID);
+  /* Nexthop reachability check. */
+  if (bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK))
+    {
+      if (bgp_find_or_add_nexthop (afi, new, NULL, 0))
+	bgp_info_set_flag (rn, new, BGP_INFO_VALID);
+      else
+	{
+	  if (BGP_DEBUG(nht, NHT))
+	    {
+	      char buf1[INET6_ADDRSTRLEN];
+	      inet_ntop(AF_INET, (const void *)&attr_new->nexthop,
+			buf1, INET6_ADDRSTRLEN);
+	      zlog_debug("%s(%s): NH unresolved", __FUNCTION__, buf1);
+	    }
+	  bgp_info_unset_flag (rn, new, BGP_INFO_VALID);
+	}
+    }
+  else
+    bgp_info_set_flag (rn, new, BGP_INFO_VALID);
 
   /* Register new BGP information. */
   bgp_info_add (rn, new);
@@ -3562,7 +3605,7 @@
 
 static void
 bgp_static_update_main (struct bgp *bgp, struct prefix *p,
-		   struct bgp_static *bgp_static, afi_t afi, safi_t safi)
+			struct bgp_static *bgp_static, afi_t afi, safi_t safi)
 {
   struct bgp_node *rn;
   struct bgp_info *ri;
@@ -3646,6 +3689,23 @@
 	  ri->attr = attr_new;
 	  ri->uptime = bgp_clock ();
 
+	  /* Nexthop reachability check. */
+	  if (bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK))
+	    {
+	      if (bgp_find_or_add_nexthop (afi, ri, NULL, 0))
+		bgp_info_set_flag (rn, ri, BGP_INFO_VALID);
+	      else
+		{
+		  if (BGP_DEBUG(nht, NHT))
+		    {
+		      char buf1[INET6_ADDRSTRLEN];
+		      inet_ntop(AF_INET, (const void *)&attr_new->nexthop,
+				buf1, INET6_ADDRSTRLEN);
+		      zlog_debug("%s(%s): NH unresolved", __FUNCTION__, buf1);
+		    }
+		  bgp_info_unset_flag (rn, ri, BGP_INFO_VALID);
+		}
+	    }
 	  /* Process change. */
 	  bgp_aggregate_increment (bgp, p, ri, afi, safi);
 	  bgp_process (bgp, rn, afi, safi);
@@ -3659,7 +3719,25 @@
   /* Make new BGP info. */
   new = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_STATIC, bgp->peer_self, attr_new,
 		  rn);
-  SET_FLAG (new->flags, BGP_INFO_VALID);
+  /* Nexthop reachability check. */
+  if (bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK))
+    {
+      if (bgp_find_or_add_nexthop (afi, new, NULL, 0))
+	bgp_info_set_flag (rn, new, BGP_INFO_VALID);
+      else
+	{
+	  if (BGP_DEBUG(nht, NHT))
+	    {
+	      char buf1[INET6_ADDRSTRLEN];
+	      inet_ntop(AF_INET, (const void *)&attr_new->nexthop, buf1,
+			INET6_ADDRSTRLEN);
+	      zlog_debug("%s(%s): NH unresolved", __FUNCTION__, buf1);
+	    }
+	  bgp_info_unset_flag (rn, new, BGP_INFO_VALID);
+	}
+    }
+  else
+    bgp_info_set_flag (rn, new, BGP_INFO_VALID);
 
   /* Aggregate address increment. */
   bgp_aggregate_increment (bgp, p, new, afi, safi);
@@ -3720,6 +3798,7 @@
   if (ri)
     {
       bgp_aggregate_decrement (bgp, p, ri, afi, safi);
+      bgp_unlink_nexthop(ri);
       bgp_info_delete (rn, ri);
       bgp_process (bgp, rn, afi, safi);
     }
@@ -3978,17 +4057,12 @@
       rn->info = bgp_static;
     }
 
-  /* If BGP scan is not enabled, we should install this route here.  */
-  if (! bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK))
-    {
-      bgp_static->valid = 1;
+  bgp_static->valid = 1;
+  if (need_update)
+    bgp_static_withdraw (bgp, &p, afi, safi);
 
-      if (need_update)
-	bgp_static_withdraw (bgp, &p, afi, safi);
-
-      if (! bgp_static->backdoor)
-	bgp_static_update (bgp, &p, bgp_static, afi, safi);
-    }
+  if (! bgp_static->backdoor)
+    bgp_static_update (bgp, &p, bgp_static, afi, safi);
 
   return CMD_SUCCESS;
 }
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c
index 010e224..eacf804 100644
--- a/bgpd/bgpd.c
+++ b/bgpd/bgpd.c
@@ -61,6 +61,7 @@
 #include "bgpd/bgp_network.h"
 #include "bgpd/bgp_vty.h"
 #include "bgpd/bgp_mpath.h"
+#include "bgpd/bgp_nht.h"
 #ifdef HAVE_SNMP
 #include "bgpd/bgp_snmp.h"
 #endif /* HAVE_SNMP */
@@ -4564,24 +4565,33 @@
   else
     UNSET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING);
 
-  if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
-    return 0;
-
-  group = peer->group;
-  for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
+  if (CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
     {
-      if (! peer->af_group[afi][safi])
-	continue;
+      group = peer->group;
+      for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
+	{
+	  if (! peer->af_group[afi][safi])
+	    continue;
 
-      SET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX);
-      peer->pmax[afi][safi] = max;
-      peer->pmax_threshold[afi][safi] = threshold;
-      peer->pmax_restart[afi][safi] = restart;
-      if (warning)
-	SET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING);
-      else
-	UNSET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING);
+	  SET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX);
+	  peer->pmax[afi][safi] = max;
+	  peer->pmax_threshold[afi][safi] = threshold;
+	  peer->pmax_restart[afi][safi] = restart;
+	  if (warning)
+	    SET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING);
+	  else
+	    UNSET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING);
+
+	  if ((peer->status == Established) && (peer->afc[afi][safi]))
+	    bgp_maximum_prefix_overflow (peer, afi, safi, 1);
+	}
     }
+  else
+    {
+      if ((peer->status == Established) && (peer->afc[afi][safi]))
+	bgp_maximum_prefix_overflow (peer, afi, safi, 1);
+    }
+
   return 0;
 }
 
@@ -5572,9 +5582,6 @@
       if (bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK))
 	vty_out (vty, " bgp network import-check%s", VTY_NEWLINE);
 
-      /* BGP scan interval. */
-      bgp_config_write_scan_time (vty);
-
       /* BGP flag dampening. */
       if (CHECK_FLAG (bgp->af_flags[AFI_IP][SAFI_UNICAST],
 	  BGP_CONFIG_DAMPENING))
@@ -5660,12 +5667,16 @@
 void
 bgp_init (void)
 {
-  /* BGP VTY commands installation.  */
-  bgp_vty_init ();
+
+  /* allocates some vital data structures used by peer commands in vty_init */
+  bgp_scan_init ();
 
   /* Init zebra. */
   bgp_zebra_init (bm->master);
 
+  /* BGP VTY commands installation.  */
+  bgp_vty_init ();
+
   /* BGP inits. */
   bgp_attr_init ();
   bgp_debug_init ();
@@ -5673,7 +5684,7 @@
   bgp_route_init ();
   bgp_route_map_init ();
   bgp_address_init ();
-  bgp_scan_init ();
+  bgp_scan_vty_init();
   bgp_mplsvpn_init ();
   bgp_encap_init ();
 
diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h
index 40da02e..87d2fff 100644
--- a/bgpd/bgpd.h
+++ b/bgpd/bgpd.h
@@ -997,4 +997,5 @@
 extern int peer_ttl_security_hops_set (struct peer *, int);
 extern int peer_ttl_security_hops_unset (struct peer *);
 
+extern void bgp_scan_finish (void);
 #endif /* _QUAGGA_BGPD_H */
diff --git a/zebra/zebra_rnh.c b/zebra/zebra_rnh.c
index 02a1468..7b6d0f8 100644
--- a/zebra/zebra_rnh.c
+++ b/zebra/zebra_rnh.c
@@ -212,7 +212,8 @@
     {
       if (!nrn->info)
 	  continue;
-
+      
+      rnh = nrn->info;
       prn = route_node_match(ptable, &nrn->p);
       if (!prn)
 	rib = NULL;
@@ -223,11 +224,18 @@
 	      if (CHECK_FLAG (rib->status, RIB_ENTRY_REMOVED))
 		continue;
 	      if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED))
-		break;
+		{
+		  if (CHECK_FLAG(rnh->flags, ZEBRA_NHT_CONNECTED))
+		    {
+		      if (rib->type == ZEBRA_ROUTE_CONNECT)
+			break;
+		    }
+		  else
+		    break;
+		}
 	    }
 	}
 
-      rnh = nrn->info;
       if (compare_state(rib, rnh->state))
 	{
 	  if (IS_ZEBRA_DEBUG_NHT)
@@ -598,7 +606,9 @@
 	print_nh(nexthop, vty);
     }
   else
-    vty_out(vty, " unresolved%s", VTY_NEWLINE);
+    vty_out(vty, " unresolved%s%s",
+	    CHECK_FLAG(rnh->flags, ZEBRA_NHT_CONNECTED) ? "(Connected)" : "",
+	    VTY_NEWLINE);
 
   vty_out(vty, " Client list:");
   for (ALL_LIST_ELEMENTS_RO(rnh->client_list, node, client))
diff --git a/zebra/zebra_rnh.h b/zebra/zebra_rnh.h
index 97dbba7..574c95f 100644
--- a/zebra/zebra_rnh.h
+++ b/zebra/zebra_rnh.h
@@ -30,6 +30,7 @@
 struct rnh
 {
   u_char flags;
+#define ZEBRA_NHT_CONNECTED  	0x1
   struct rib *state;
   struct list *client_list;
   struct route_node *node;
diff --git a/zebra/zserv.c b/zebra/zserv.c
index 4a8b55f..f0e8d12 100644
--- a/zebra/zserv.c
+++ b/zebra/zserv.c
@@ -748,6 +748,7 @@
   struct stream *s;
   struct prefix p;
   u_short l = 0;
+  u_char connected;
 
   if (IS_ZEBRA_DEBUG_NHT)
     zlog_debug("nexthop_register msg from client %s: length=%d\n",
@@ -757,14 +758,19 @@
 
   while (l < length)
     {
+      connected = stream_getc(s);
       p.family = stream_getw(s);
       p.prefixlen = stream_getc(s);
-      l += 3;
+      l += 4;
       stream_get(&p.u.prefix, s, PSIZE(p.prefixlen));
       l += PSIZE(p.prefixlen);
       rnh = zebra_add_rnh(&p, 0);
 
       client->nh_reg_time = quagga_time(NULL);
+      
+      if (connected)
+	SET_FLAG(rnh->flags, ZEBRA_NHT_CONNECTED);
+
       zebra_add_rnh_client(rnh, client, vrf_id);
     }
   zebra_evaluate_rnh_table(0, AF_INET);
@@ -789,9 +795,10 @@
 
   while (l < length)
     {
+      (void)stream_getc(s);
       p.family = stream_getw(s);
       p.prefixlen = stream_getc(s);
-      l += 3;
+      l += 4;
       stream_get(&p.u.prefix, s, PSIZE(p.prefixlen));
       l += PSIZE(p.prefixlen);
       rnh = zebra_lookup_rnh(&p, 0);
