--- a/nhrpd/nhrp_route.c
+++ b/nhrpd/nhrp_route.c
@@ -231,6 +231,8 @@
 	union sockunion nexthop_addr;
 	char buf[PREFIX_STRLEN];
 	int added;
+	int i;
+	int blackhole = 0;
 
 	if (zapi_route_decode(zclient->ibuf, &api) < 0)
 		return -1;
@@ -245,26 +247,39 @@
 
 	sockunion_family(&nexthop_addr) = AF_UNSPEC;
 	if (CHECK_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP)) {
-		api_nh = &api.nexthops[0];
+		added = (cmd == ZEBRA_REDISTRIBUTE_ROUTE_ADD);
 
-		nexthop_addr.sa.sa_family = api.prefix.family;
-		switch (nexthop_addr.sa.sa_family) {
-		case AF_INET:
-			nexthop_addr.sin.sin_addr = api_nh->gate.ipv4;
-			break;
-		case AF_INET6:
-			nexthop_addr.sin6.sin6_addr = api_nh->gate.ipv6;
+		for (i = 0; i < api.nexthop_num; i++) {
+			api_nh = &api.nexthops[i];
+			nexthop_addr.sa.sa_family = api.prefix.family;
+			switch (nexthop_addr.sa.sa_family) {
+			case AF_INET:
+				nexthop_addr.sin.sin_addr = api_nh->gate.ipv4;
+				break;
+			case AF_INET6:
+				nexthop_addr.sin6.sin6_addr = api_nh->gate.ipv6;
+				break;
+			}
+
+			if (api_nh->ifindex != IFINDEX_INTERNAL)
+				ifp = if_lookup_by_index(api_nh->ifindex, VRF_DEFAULT);
+
+			if (CHECK_FLAG(api_nh->flags, ZAPI_NEXTHOP_FLAG_RECURSIVE))
+				continue;
+
+			if (api.nexthops[i].type == NEXTHOP_TYPE_BLACKHOLE) {
+				added = 0;
+				blackhole = 1;
+			}
 			break;
 		}
+	} else 
+		return 0;
 
-		if (api_nh->ifindex != IFINDEX_INTERNAL)
-			ifp = if_lookup_by_index(api_nh->ifindex, VRF_DEFAULT);
-	}
-
-	added = (cmd == ZEBRA_REDISTRIBUTE_ROUTE_ADD);
 	debugf(NHRP_DEBUG_ROUTE, "if-route-%s: %pFX via %s dev %s",
 	       added ? "add" : "del", &api.prefix,
-	       sockunion2str(&nexthop_addr, buf, sizeof(buf)),
+	       blackhole ? "blackhole" : sockunion2str(&nexthop_addr,
+		       buf, sizeof(buf)),
 	       ifp ? ifp->name : "(none)");
 
 	nhrp_route_update_zebra(&api.prefix, &nexthop_addr, added ? ifp : NULL);
@@ -555,6 +570,7 @@
 	zebra_rib[AFI_IP6] = route_table_init();
 
 	zclient = zclient_new(master, &zclient_options_default);
+	zclient->flags |= ZAPI_CLIENT_FLAGS_NH_RECURSIVE;
 	zclient->zebra_connected = nhrp_zebra_connected;
 	zclient->interface_address_add = nhrp_interface_address_add;
 	zclient->interface_address_delete = nhrp_interface_address_delete;
--- a/zebra/zapi_msg.c
+++ b/zebra/zapi_msg.c
@@ -588,8 +588,9 @@
 		memcpy(&api.src_prefix, src_p, sizeof(api.src_prefix));
 	}
 
-	for (nexthop = re->nhe->nhg.nexthop;
-	     nexthop; nexthop = nexthop->next) {
+	for (nexthop = re->nhe->nhg.nexthop; nexthop;
+	     nexthop = (CHECK_FLAG(client->flags, ZAPI_CLIENT_FLAGS_NH_RECURSIVE)) ?
+		     nexthop_next(nexthop) : nexthop->next) {
 		if (!CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_ACTIVE))
 			continue;
 
@@ -597,6 +598,11 @@
 		api_nh->vrf_id = nexthop->vrf_id;
 		api_nh->type = nexthop->type;
 		api_nh->weight = nexthop->weight;
+		if (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_RECURSIVE))
+			SET_FLAG(api_nh->flags, ZAPI_NEXTHOP_FLAG_RECURSIVE);
+		if (nexthop->rparent)
+			SET_FLAG(api_nh->flags, ZAPI_NEXTHOP_FLAG_RESOLVED);
+
 		switch (nexthop->type) {
 		case NEXTHOP_TYPE_BLACKHOLE:
 			api_nh->bh_type = nexthop->bh_type;
@@ -2163,6 +2169,43 @@
 	return;
 }
 
+static int zsend_client_flags(struct zserv *client, struct zebra_vrf *zvrf)
+{
+	struct stream *s = stream_new(ZEBRA_MAX_PACKET_SIZ);
+	int i;
+	char *fp = (char *)&(client->flags);
+
+	zclient_create_header(s, ZEBRA_CLIENT_FLAGS, zvrf->vrf->vrf_id);
+	for(i = 0; i < (int) sizeof(client->flags); i++)
+	       stream_putc(s, *(fp+i));
+	stream_putw_at(s, 0, stream_get_endp(s));
+	return zserv_send_message(client, s);
+}
+
+static void zread_client_flags(ZAPI_HANDLER_ARGS)
+{
+	struct stream *s;
+	uint32_t flags;
+	char *fp = (char *)&flags;
+	int i;
+
+	s = msg;
+
+	if ((sizeof(flags) * 2) == hdr->length) {
+		for (flags = 0, i = 0; i < (int) sizeof(flags); i++)
+			STREAM_GETC(s, *(fp+i));
+		client->flags |= flags;
+		for (flags = 0, i = 0; i < (int) sizeof(flags); i++)
+			STREAM_GETC(s, *(fp+i));
+		client->flags &= ~(flags);
+	} else
+		for(i=0; i < hdr->length; i++)
+			STREAM_GETC(s, *(fp));
+	zsend_client_flags(client, zvrf);
+stream_failure:
+	return;
+}
+
 static void zsend_capabilities(struct zserv *client, struct zebra_vrf *zvrf)
 {
 	struct stream *s = stream_new(ZEBRA_MAX_PACKET_SIZ);
@@ -3323,6 +3366,7 @@
 	[ZEBRA_NHG_ADD] = zread_nhg_add,
 	[ZEBRA_NHG_DEL] = zread_nhg_del,
 	[ZEBRA_ROUTE_NOTIFY_REQUEST] = zread_route_notify_request,
+	[ZEBRA_CLIENT_FLAGS] = zread_client_flags,
 };
 
 /*
--- a/lib/zclient.h
+++ b/lib/zclient.h
@@ -221,6 +221,7 @@
 	ZEBRA_NEIGH_DISCOVER,
 	ZEBRA_ROUTE_NOTIFY_REQUEST,
 	ZEBRA_CLIENT_CLOSE_NOTIFY,
+	ZEBRA_CLIENT_FLAGS
 } zebra_message_types_t;
 
 enum zebra_error_types {
@@ -307,6 +308,9 @@
 	/* Thread to write buffered data to zebra. */
 	struct thread *t_write;
 
+	/* flags */
+	uint32_t flags;
+
 	/* Redistribute information. */
 	uint8_t redist_default; /* clients protocol */
 	unsigned short instance;
@@ -391,6 +395,10 @@
 /* Backup nexthops are present */
 #define ZAPI_MESSAGE_BACKUP_NEXTHOPS 0x40
 #define ZAPI_MESSAGE_NHG 0x80
+
+/* Zebra API Client Option flags */
+#define ZAPI_CLIENT_FLAGS_NH_RECURSIVE	(1<<0)
+
 /*
  * This should only be used by a DAEMON that needs to communicate
  * the table being used is not in the VRF.  You must pass the
@@ -453,6 +461,8 @@
 #define ZAPI_NEXTHOP_FLAG_LABEL		0x02
 #define ZAPI_NEXTHOP_FLAG_WEIGHT	0x04
 #define ZAPI_NEXTHOP_FLAG_HAS_BACKUP	0x08 /* Nexthop has a backup */
+#define ZAPI_NEXTHOP_FLAG_RECURSIVE	0x10
+#define ZAPI_NEXTHOP_FLAG_RESOLVED	0x20
 
 /*
  * ZAPI Nexthop Group. For use with protocol creation of nexthop groups.
@@ -811,6 +821,8 @@
 extern struct zclient *zclient_new(struct thread_master *m,
 				   struct zclient_options *opt);
 
+extern uint32_t zclient_flags(struct zclient *, uint32_t newflags, uint32_t delflags);
+
 extern void zclient_init(struct zclient *, int, unsigned short,
 			 struct zebra_privs_t *privs);
 extern int zclient_start(struct zclient *);
--- a/ldpd/ldp_zebra.c
+++ b/ldpd/ldp_zebra.c
@@ -562,6 +562,8 @@
 	/* loop through all the nexthops */
 	for (i = 0; i < api.nexthop_num; i++) {
 		api_nh = &api.nexthops[i];
+		if (CHECK_FLAG(api_nh->flags, ZAPI_NEXTHOP_FLAG_RESOLVED))
+			continue;
 		switch (api_nh->type) {
 		case NEXTHOP_TYPE_IPV4:
 			if (kr.af != AF_INET)
--- a/zebra/zserv.h
+++ b/zebra/zserv.h
@@ -147,6 +147,9 @@
 	uint16_t instance;
 	uint32_t session_id;
 
+	/* client's flags */
+	uint32_t flags;
+
 	/*
 	 * Interested for MLAG Updates, and also stores the client
 	 * interested message mask
--- a/lib/zclient.c
+++ b/lib/zclient.c
@@ -673,6 +673,10 @@
 	if (zclient->zebra_connected)
 		(*zclient->zebra_connected)(zclient);
 
+	if (zclient->flags)
+		if (zclient_flags(zclient, zclient->flags, 0) != zclient->flags)
+			if (zclient_debug)
+				zlog_debug("zclient flags are not synchronized");
 	return 0;
 }
 
@@ -3323,6 +3327,54 @@
 	return;
 }
 
+static void zclient_read_flags(struct zclient *client, uint32_t length)
+{
+	struct stream *s = client->ibuf;
+	typeof(client->flags) i, flags = 0;
+	char * fp = (char *) &flags;
+	char c;
+
+	for(i=0; i < sizeof(client->flags) && i < length; i++)
+		STREAM_GETC(s, *fp++);
+	if (zclient_debug)
+		zlog_debug(
+			"zclient read flags %lx.",
+				(unsigned long) flags);
+	if (client->flags != flags)
+		client->flags = flags;
+
+	while (i++ < length)
+		STREAM_GETC(s, c);
+
+stream_failure:
+	return;
+}
+
+enum zclient_send_status
+zclient_encode_flags(struct zclient *client, uint32_t addflags, uint32_t delflags)
+{
+	struct stream *s = client->obuf;
+	int i = 0;
+	char *p = (char *) &addflags;
+
+	stream_reset(s);
+
+	zclient_create_header(s, ZEBRA_CLIENT_FLAGS, VRF_DEFAULT);
+
+	for(i=0; i < (int) sizeof(client->flags); i++)
+		stream_putc(s, *(p+i));
+
+	p = (char *)&delflags;
+	for(i=0; i < (int) sizeof(client->flags); i++)
+		stream_putc(s, *(p+i));
+	stream_putw_at(s, 0, stream_get_endp(s));
+	if (zclient_send_message(client) > -1)
+		stream_reset(s);
+	else
+		return -1;
+	return 0;
+}
+
 enum zclient_send_status zclient_send_mlag_register(struct zclient *client,
 						    uint32_t bit_map)
 {
@@ -3669,6 +3721,9 @@
 	case ZEBRA_CAPABILITIES:
 		zclient_capability_decode(command, zclient, length, vrf_id);
 		break;
+	case ZEBRA_CLIENT_FLAGS:
+		zclient_read_flags(zclient, length);
+		break;
 	case ZEBRA_ROUTER_ID_UPDATE:
 		if (zclient->router_id_update)
 			(*zclient->router_id_update)(command, zclient, length,
@@ -4176,3 +4231,16 @@
 
 	return buf;
 }
+
+
+/* process client flags */
+
+uint32_t zclient_flags(struct zclient *client, uint32_t addflags, uint32_t delflags)
+{
+	uint32_t oldflags = client->flags;
+
+	if (!zclient_encode_flags(client, client->flags | addflags, delflags))
+		if (zclient_debug)
+			zlog_debug("zclient_encode_flags returned nonzero");
+	return oldflags;
+}
--- a/lib/log.c
+++ b/lib/log.c
@@ -462,7 +462,8 @@
 	DESC_ENTRY(ZEBRA_NHG_DEL),
 	DESC_ENTRY(ZEBRA_NHG_NOTIFY_OWNER),
 	DESC_ENTRY(ZEBRA_ROUTE_NOTIFY_REQUEST),
-	DESC_ENTRY(ZEBRA_CLIENT_CLOSE_NOTIFY)};
+	DESC_ENTRY(ZEBRA_CLIENT_CLOSE_NOTIFY),
+	DESC_ENTRY(ZEBRA_CLIENT_FLAGS)};
 #undef DESC_ENTRY
 
 static const struct zebra_desc_table unknown = {0, "unknown", '?'};
