Add back support for null0 interface blackhole routes.
diff --git a/configure.ac b/configure.ac
index 62f43f5..fba397e 100755
--- a/configure.ac
+++ b/configure.ac
@@ -160,7 +160,7 @@
 dnl Check header files.
 dnl -------------------
 AC_STDC_HEADERS
-AC_CHECK_HEADERS(string.h stropts.h sys/conf.h sys/ksym.h sys/time.h sys/times.h sys/select.h sys/sysctl.h sys/sockio.h sys/types.h net/if_dl.h net/if_var.h linux/version.h kvm.h netdb.h netinet/in.h net/netopt.h netinet/in_var.h netinet/in6_var.h netinet6/in6_var.h netinet/in6.h netinet6/in6.h inet/nd.h asm/types.h netinet/icmp6.h netinet6/nd6.h libutil.h)
+AC_CHECK_HEADERS(string.h stropts.h sys/conf.h sys/ksym.h sys/time.h sys/times.h sys/select.h sys/sysctl.h sys/sockio.h sys/types.h net/if_dl.h net/if_var.h linux/version.h kvm.h netdb.h netinet/in.h net/netopt.h netinet/in_var.h netinet/in6_var.h netinet6/in6_var.h netinet/in6.h inet/nd.h asm/types.h netinet/icmp6.h netinet6/nd6.h libutil.h)
 
 dnl check some types
 AC_C_CONST
diff --git a/configure.in b/configure.in
index 62f43f5..fba397e 100755
--- a/configure.in
+++ b/configure.in
@@ -160,7 +160,7 @@
 dnl Check header files.
 dnl -------------------
 AC_STDC_HEADERS
-AC_CHECK_HEADERS(string.h stropts.h sys/conf.h sys/ksym.h sys/time.h sys/times.h sys/select.h sys/sysctl.h sys/sockio.h sys/types.h net/if_dl.h net/if_var.h linux/version.h kvm.h netdb.h netinet/in.h net/netopt.h netinet/in_var.h netinet/in6_var.h netinet6/in6_var.h netinet/in6.h netinet6/in6.h inet/nd.h asm/types.h netinet/icmp6.h netinet6/nd6.h libutil.h)
+AC_CHECK_HEADERS(string.h stropts.h sys/conf.h sys/ksym.h sys/time.h sys/times.h sys/select.h sys/sysctl.h sys/sockio.h sys/types.h net/if_dl.h net/if_var.h linux/version.h kvm.h netdb.h netinet/in.h net/netopt.h netinet/in_var.h netinet/in6_var.h netinet6/in6_var.h netinet/in6.h inet/nd.h asm/types.h netinet/icmp6.h netinet6/nd6.h libutil.h)
 
 dnl check some types
 AC_C_CONST
diff --git a/lib/zclient.c b/lib/zclient.c
index ebf685a..bb7747f 100644
--- a/lib/zclient.c
+++ b/lib/zclient.c
@@ -317,18 +317,24 @@
   /* Nexthop, ifindex, distance and metric information. */
   if (CHECK_FLAG (api->message, ZAPI_MESSAGE_NEXTHOP))
     {
-	stream_putc (s, api->nexthop_num + api->ifindex_num);
-
+      if (CHECK_FLAG (api->flags, ZEBRA_FLAG_BLACKHOLE))
+        {
+          stream_putc (s, 1);
+          stream_putc (s, ZEBRA_NEXTHOP_BLACKHOLE);
+        }
+      else
+        stream_putc (s, api->nexthop_num + api->ifindex_num);
+        
       for (i = 0; i < api->nexthop_num; i++)
-	{
-	  stream_putc (s, ZEBRA_NEXTHOP_IPV4);
-	  stream_put_in_addr (s, api->nexthop[i]);
-	}
+        {
+          stream_putc (s, ZEBRA_NEXTHOP_IPV4);
+          stream_put_in_addr (s, api->nexthop[i]);
+        }
       for (i = 0; i < api->ifindex_num; i++)
-	{
-	  stream_putc (s, ZEBRA_NEXTHOP_IFINDEX);
-	  stream_putl (s, api->ifindex[i]);
-	}
+        {
+          stream_putc (s, ZEBRA_NEXTHOP_IFINDEX);
+          stream_putl (s, api->ifindex[i]);
+        }
     }
 
   if (CHECK_FLAG (api->message, ZAPI_MESSAGE_DISTANCE))
@@ -371,18 +377,24 @@
   /* Nexthop, ifindex, distance and metric information. */
   if (CHECK_FLAG (api->message, ZAPI_MESSAGE_NEXTHOP))
     {
-	stream_putc (s, api->nexthop_num + api->ifindex_num);
+      if (CHECK_FLAG (api->flags, ZEBRA_FLAG_BLACKHOLE))
+        {
+          stream_putc (s, 1);
+          stream_putc (s, ZEBRA_NEXTHOP_BLACKHOLE);
+        }
+      else
+        stream_putc (s, api->nexthop_num + api->ifindex_num);
 
       for (i = 0; i < api->nexthop_num; i++)
-	{
-	  stream_putc (s, ZEBRA_NEXTHOP_IPV4);
-	  stream_put_in_addr (s, api->nexthop[i]);
-	}
+        {
+          stream_putc (s, ZEBRA_NEXTHOP_IPV4);
+          stream_put_in_addr (s, api->nexthop[i]);
+        }
       for (i = 0; i < api->ifindex_num; i++)
-	{
-	  stream_putc (s, ZEBRA_NEXTHOP_IFINDEX);
-	  stream_putl (s, api->ifindex[i]);
-	}
+        {
+          stream_putc (s, ZEBRA_NEXTHOP_IFINDEX);
+          stream_putl (s, api->ifindex[i]);
+        }
     }
 
   if (CHECK_FLAG (api->message, ZAPI_MESSAGE_DISTANCE))
diff --git a/lib/zebra.h b/lib/zebra.h
index baad6d6..7b1e801 100644
--- a/lib/zebra.h
+++ b/lib/zebra.h
@@ -271,6 +271,7 @@
 #define ZEBRA_NEXTHOP_IPV6               6
 #define ZEBRA_NEXTHOP_IPV6_IFINDEX       7
 #define ZEBRA_NEXTHOP_IPV6_IFNAME        8
+#define ZEBRA_NEXTHOP_BLACKHOLE          9
 
 #ifndef INADDR_LOOPBACK
 #define	INADDR_LOOPBACK	0x7f000001	/* Internet address 127.0.0.1.  */
diff --git a/zebra/rib.h b/zebra/rib.h
index d416c15..5b0dcfe 100644
--- a/zebra/rib.h
+++ b/zebra/rib.h
@@ -76,6 +76,7 @@
   u_char type;
 #define STATIC_IPV4_GATEWAY     1
 #define STATIC_IPV4_IFNAME      2
+#define STATIC_IPV4_BLACKHOLE   3
 
   /* Nexthop value. */
   union 
@@ -137,6 +138,7 @@
 #define NEXTHOP_TYPE_IPV6           6 /* IPv6 nexthop.  */
 #define NEXTHOP_TYPE_IPV6_IFINDEX   7 /* IPv6 nexthop with ifindex.  */
 #define NEXTHOP_TYPE_IPV6_IFNAME    8 /* IPv6 nexthop with ifname.  */
+#define NEXTHOP_TYPE_BLACKHOLE      9 /* Null0 nexthop.  */
 
   u_char flags;
 #define NEXTHOP_FLAG_ACTIVE     (1 << 0) /* This nexthop is alive. */
@@ -194,6 +196,7 @@
 
 struct nexthop *nexthop_ifindex_add (struct rib *, unsigned int);
 struct nexthop *nexthop_ifname_add (struct rib *, char *);
+struct nexthop *nexthop_blackhole_add (struct rib *);
 struct nexthop *nexthop_ipv4_add (struct rib *, struct in_addr *);
 #ifdef HAVE_IPV6
 struct nexthop *nexthop_ipv6_add (struct rib *, struct in6_addr *);
diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c
index 60043c9..87062dc 100644
--- a/zebra/rt_netlink.c
+++ b/zebra/rt_netlink.c
@@ -1174,14 +1174,16 @@
       req.r.rtm_protocol = RTPROT_ZEBRA;
       req.r.rtm_scope = RT_SCOPE_UNIVERSE;
 
-      if (discard) {
-       if (zebra_flags & ZEBRA_FLAG_BLACKHOLE)
-         req.r.rtm_type = RTN_BLACKHOLE;
-       else if (zebra_flags & ZEBRA_FLAG_REJECT)
-         req.r.rtm_type = RTN_UNREACHABLE;
-       else assert(RTN_BLACKHOLE != RTN_UNREACHABLE); /* false */
-      } else
-	req.r.rtm_type = RTN_UNICAST;
+      if (discard) 
+        {
+          if (zebra_flags & ZEBRA_FLAG_BLACKHOLE)
+            req.r.rtm_type = RTN_BLACKHOLE;
+          else if (zebra_flags & ZEBRA_FLAG_REJECT)
+            req.r.rtm_type = RTN_UNREACHABLE;
+          else assert(RTN_BLACKHOLE != RTN_UNREACHABLE); /* false */
+        } 
+      else
+	      req.r.rtm_type = RTN_UNICAST;
     }
 
   if (dest)
@@ -1252,14 +1254,16 @@
       req.r.rtm_protocol = RTPROT_ZEBRA;
       req.r.rtm_scope = RT_SCOPE_UNIVERSE;
 
-      if (discard) {
-       if (rib->flags & ZEBRA_FLAG_BLACKHOLE)
-         req.r.rtm_type = RTN_BLACKHOLE;
-       else if (rib->flags & ZEBRA_FLAG_REJECT)
-         req.r.rtm_type = RTN_UNREACHABLE;
-       else assert(RTN_BLACKHOLE != RTN_UNREACHABLE); /* false */
-      } else
-	req.r.rtm_type = RTN_UNICAST;
+      if (discard) 
+        {
+          if (rib->flags & ZEBRA_FLAG_BLACKHOLE)
+            req.r.rtm_type = RTN_BLACKHOLE;
+          else if (rib->flags & ZEBRA_FLAG_REJECT)
+            req.r.rtm_type = RTN_UNREACHABLE;
+          else assert(RTN_BLACKHOLE != RTN_UNREACHABLE); /* false */
+        } 
+      else
+	      req.r.rtm_type = RTN_UNICAST;
     }
 
   addattr_l (&req.n, sizeof req, RTA_DST, &p->u.prefix, bytelen);
diff --git a/zebra/rt_socket.c b/zebra/rt_socket.c
index cd2f26c..19b2fc2 100644
--- a/zebra/rt_socket.c
+++ b/zebra/rt_socket.c
@@ -129,7 +129,14 @@
 		  || nexthop->type == NEXTHOP_TYPE_IFNAME
 		  || nexthop->type == NEXTHOP_TYPE_IPV4_IFINDEX)
 		ifindex = nexthop->ifindex;
-	    }
+	  if (nexthop->type == NEXTHOP_TYPE_BLACKHOLE)
+      {
+        struct in_addr loopback;
+        loopback.s_addr = htonl (INADDR_LOOPBACK);
+        sin_gate.sin_addr = loopback;
+        gate = 1;
+      }
+	  }
 
 	  if (cmd == RTM_ADD)
 	    SET_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB);
diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c
index d7f8bda..fe29e81 100644
--- a/zebra/zebra_rib.c
+++ b/zebra/zebra_rib.c
@@ -305,6 +305,21 @@
 }
 #endif /* HAVE_IPV6 */
 
+struct nexthop *
+nexthop_blackhole_add (struct rib *rib)
+{
+  struct nexthop *nexthop;
+
+  nexthop = XMALLOC (MTYPE_NEXTHOP, sizeof (struct nexthop));
+  memset (nexthop, 0, sizeof (struct nexthop));
+  nexthop->type = NEXTHOP_TYPE_BLACKHOLE;
+  SET_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE);
+
+  nexthop_add (rib, nexthop);
+
+  return nexthop;
+}
+
 /* If force flag is not set, do not modify falgs at all for uninstall
    the route from FIB. */
 int
@@ -723,6 +738,9 @@
 	}
       break;
 #endif /* HAVE_IPV6 */
+    case NEXTHOP_TYPE_BLACKHOLE:
+      SET_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE);
+      break;
     default:
       break;
     }
@@ -1270,6 +1288,9 @@
 	case STATIC_IPV4_IFNAME:
 	  nexthop_ifname_add (rib, si->gate.ifname);
 	  break;
+  case STATIC_IPV4_BLACKHOLE:
+    nexthop_blackhole_add (rib);
+    break;
 	}
       rib_process (rn, NULL);
     }
@@ -1292,6 +1313,9 @@
 	case STATIC_IPV4_IFNAME:
 	  nexthop_ifname_add (rib, si->gate.ifname);
 	  break;
+  case STATIC_IPV4_BLACKHOLE:
+    nexthop_blackhole_add (rib);
+    break;
 	}
 
       /* Save the flags of this static routes (reject, blackhole) */
@@ -1316,6 +1340,9 @@
       && si->type == STATIC_IPV4_IFNAME
       && strcmp (nexthop->ifname, si->gate.ifname) == 0)
     return 1;
+  if (nexthop->type == NEXTHOP_TYPE_BLACKHOLE
+      && si->type == STATIC_IPV4_BLACKHOLE)
+    return 1;
   return 0;;
 }
 
@@ -1406,6 +1433,8 @@
     type = STATIC_IPV4_GATEWAY;
   if (ifname)
     type = STATIC_IPV4_IFNAME;
+  else
+    type = STATIC_IPV4_BLACKHOLE;
 
   /* Do nothing if there is a same static route.  */
   for (si = rn->info; si; si = si->next)
@@ -1499,6 +1528,8 @@
     type = STATIC_IPV4_GATEWAY;
   else if (ifname)
     type = STATIC_IPV4_IFNAME;
+  else
+    type = STATIC_IPV4_BLACKHOLE;
 
   /* Find same static route is the tree */
   for (si = rn->info; si; si = si->next)
diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c
index f7037f6..c8168c9 100644
--- a/zebra/zebra_vty.c
+++ b/zebra/zebra_vty.c
@@ -111,16 +111,37 @@
     {
       ret = inet_aton (mask_str, &mask);
       if (ret == 0)
-	{
-	  vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
-	  return CMD_WARNING;
-	}
+        {
+          vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
+          return CMD_WARNING;
+        }
       p.prefixlen = ip_masklen (mask);
     }
 
   /* Apply mask for given prefix. */
   apply_mask (&p);
 
+  /* Administrative distance. */
+  if (distance_str)
+    distance = atoi (distance_str);
+  else
+    distance = ZEBRA_STATIC_DISTANCE_DEFAULT;
+
+  /* Null0 static route.  */
+  if (strncasecmp (gate_str, "Null0", strlen (gate_str)) == 0)
+    {
+      if (flag_str)
+        {
+          vty_out (vty, "%% can not have flag %s with Null0%s", flag_str, VTY_NEWLINE);
+          return CMD_WARNING;
+        }
+      if (add_cmd)
+        static_add_ipv4 (&p, NULL, NULL, 0, distance, 0);
+      else
+        static_delete_ipv4 (&p, NULL, NULL, distance, 0);
+      return CMD_SUCCESS;
+    }
+
   /* Route flags */
   if (flag_str) {
     switch(flag_str[0]) {
@@ -134,16 +155,10 @@
         break;
       default:
         vty_out (vty, "%% Malformed flag %s %s", flag_str, VTY_NEWLINE);
-           break;
+        return CMD_WARNING;
     }
   }
 
-  /* Administrative distance. */
-  if (distance_str)
-    distance = atoi (distance_str);
-  else
-    distance = ZEBRA_STATIC_DISTANCE_DEFAULT;
-
   /* When gateway is A.B.C.D format, gate is treated as nexthop
      address other case gate is treated as interface name. */
   ret = inet_aton (gate_str, &gate);
@@ -163,12 +178,13 @@
 /* Static route configuration.  */
 DEFUN (ip_route, 
        ip_route_cmd,
-       "ip route A.B.C.D/M (A.B.C.D|INTERFACE)",
+       "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0)",
        IP_STR
        "Establish static routes\n"
        "IP destination prefix (e.g. 10.0.0.0/8)\n"
        "IP gateway address\n"
-       "IP gateway interface name\n")
+       "IP gateway interface name\n"
+       "Null interface\n")
 {
   return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], NULL, NULL);
 }
@@ -190,13 +206,14 @@
 /* Mask as A.B.C.D format.  */
 DEFUN (ip_route_mask,
        ip_route_mask_cmd,
-       "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE)",
+       "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0)",
        IP_STR
        "Establish static routes\n"
        "IP destination prefix\n"
        "IP destination prefix mask\n"
        "IP gateway address\n"
-       "IP gateway interface name\n")
+       "IP gateway interface name\n"
+       "Null interface\n")
 {
   return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], NULL, NULL);
 }
@@ -219,12 +236,13 @@
 /* Distance option value.  */
 DEFUN (ip_route_distance,
        ip_route_distance_cmd,
-       "ip route A.B.C.D/M (A.B.C.D|INTERFACE) <1-255>",
+       "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) <1-255>",
        IP_STR
        "Establish static routes\n"
        "IP destination prefix (e.g. 10.0.0.0/8)\n"
        "IP gateway address\n"
        "IP gateway interface name\n"
+       "Null interface\n"
        "Distance value for this route\n")
 {
   return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], NULL, argv[2]);
@@ -247,13 +265,14 @@
 
 DEFUN (ip_route_mask_distance,
        ip_route_mask_distance_cmd,
-       "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) <1-255>",
+       "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) <1-255>",
        IP_STR
        "Establish static routes\n"
        "IP destination prefix\n"
        "IP destination prefix mask\n"
        "IP gateway address\n"
        "IP gateway interface name\n"
+       "Null interface\n"
        "Distance value for this route\n")
 {
   return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], NULL, argv[3]);
@@ -277,13 +296,14 @@
 
 DEFUN (no_ip_route, 
        no_ip_route_cmd,
-       "no ip route A.B.C.D/M (A.B.C.D|INTERFACE)",
+       "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0)",
        NO_STR
        IP_STR
        "Establish static routes\n"
        "IP destination prefix (e.g. 10.0.0.0/8)\n"
        "IP gateway address\n"
-       "IP gateway interface name\n")
+       "IP gateway interface name\n"
+       "Null interface\n")
 {
   return zebra_static_ipv4 (vty, 0, argv[0], NULL, argv[1], NULL, NULL);
 }
@@ -302,14 +322,15 @@
 
 DEFUN (no_ip_route_mask,
        no_ip_route_mask_cmd,
-       "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE)",
+       "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0)",
        NO_STR
        IP_STR
        "Establish static routes\n"
        "IP destination prefix\n"
        "IP destination prefix mask\n"
        "IP gateway address\n"
-       "IP gateway interface name\n")
+       "IP gateway interface name\n"
+       "Null interface\n")
 {
   return zebra_static_ipv4 (vty, 0, argv[0], argv[1], argv[2], NULL, NULL);
 }
@@ -329,13 +350,14 @@
 
 DEFUN (no_ip_route_distance,
        no_ip_route_distance_cmd,
-       "no ip route A.B.C.D/M (A.B.C.D|INTERFACE) <1-255>",
+       "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) <1-255>",
        NO_STR
        IP_STR
        "Establish static routes\n"
        "IP destination prefix (e.g. 10.0.0.0/8)\n"
        "IP gateway address\n"
        "IP gateway interface name\n"
+       "Null interface\n"
        "Distance value for this route\n")
 {
   return zebra_static_ipv4 (vty, 0, argv[0], NULL, argv[1], NULL, argv[2]);
@@ -359,7 +381,7 @@
 
 DEFUN (no_ip_route_mask_distance,
        no_ip_route_mask_distance_cmd,
-       "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) <1-255>",
+       "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) <1-255>",
        NO_STR
        IP_STR
        "Establish static routes\n"
@@ -367,6 +389,7 @@
        "IP destination prefix mask\n"
        "IP gateway address\n"
        "IP gateway interface name\n"
+       "Null interface\n"
        "Distance value for this route\n")
 {
   return zebra_static_ipv4 (vty, 0, argv[0], argv[1], argv[2], NULL, argv[3]);
@@ -461,6 +484,9 @@
 	    case NEXTHOP_TYPE_IFNAME:
 	      vty_out (vty, " directly connected, %s", nexthop->ifname);
 	      break;
+      case NEXTHOP_TYPE_BLACKHOLE:
+        vty_out (vty, " directly connected, via Null0");
+        break;
 	    default:
 	      break;
 	    }
@@ -541,6 +567,9 @@
 	case NEXTHOP_TYPE_IFNAME:
 	  vty_out (vty, " is directly connected, %s", nexthop->ifname);
 	  break;
+  case NEXTHOP_TYPE_BLACKHOLE:
+    vty_out (vty, " is directly connected, Null0");
+    break;
 	default:
 	  break;
 	}
@@ -930,6 +959,9 @@
 	  case STATIC_IPV4_IFNAME:
 	    vty_out (vty, " %s", si->gate.ifname);
 	    break;
+    case STATIC_IPV4_BLACKHOLE:
+      vty_out (vty, " Null0");
+      break;
 	  }
 
        if (CHECK_FLAG(si->flags, ZEBRA_FLAG_REJECT))
@@ -985,7 +1017,7 @@
         break;
       default:
         vty_out (vty, "%% Malformed flag %s %s", flag_str, VTY_NEWLINE);
-           break;
+        return CMD_WARNING;
     }
   }
 
@@ -1252,7 +1284,7 @@
   return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], argv[3], argv[4]);
 }
 
-/* New RIB.  Detailed information for IPv4 route. */
+/* New RIB.  Detailed information for IPv6 route. */
 void
 vty_show_ipv6_route_detail (struct vty *vty, struct route_node *rn)
 {
diff --git a/zebra/zserv.c b/zebra/zserv.c
index ae1e044..70e7672 100644
--- a/zebra/zserv.c
+++ b/zebra/zserv.c
@@ -1098,6 +1098,9 @@
 	    case ZEBRA_NEXTHOP_IPV6:
 	      stream_forward (s, IPV6_MAX_BYTELEN);
 	      break;
+      case ZEBRA_NEXTHOP_BLACKHOLE:
+        nexthop_blackhole_add (rib);
+        break;
 	    }
 	}
     }