isisd: unexpected kernel routing table (BZ#544)

Fix bug 544: isisd produces an unexpected routing table for wide-metric.

* isis_spf.c: Accept VTYPE_PSEUDO_TE_IS and VTYPE_NONPSEUDO_TE_IS
  vertex types for SPF calculation
* isis_pdu.c: Change order of TLVs to match Cisco to make bitwise
  comparison easier for Wireshark
* isis_tlv.c: EXTREME_TLV_DEBUG for TLV debugging instead of
  EXTREME_DEBUG
diff --git a/isisd/isis_pdu.c b/isisd/isis_pdu.c
index e55d336..dfc613c 100644
--- a/isisd/isis_pdu.c
+++ b/isisd/isis_pdu.c
@@ -1992,12 +1992,34 @@
     if (tlv_add_authinfo (circuit->passwd.type, circuit->passwd.len,
 			  circuit->passwd.passwd, circuit->snd_stream))
       return ISIS_WARNING;
+
+  /* Protocols Supported TLV */
+  if (circuit->nlpids.count > 0)
+    if (tlv_add_nlpid (&circuit->nlpids, circuit->snd_stream))
+      return ISIS_WARNING;
+
   /*  Area Addresses TLV */
   assert (circuit->area);
   if (circuit->area->area_addrs && circuit->area->area_addrs->count > 0)
     if (tlv_add_area_addrs (circuit->area->area_addrs, circuit->snd_stream))
       return ISIS_WARNING;
 
+  /* IP interface Address TLV */
+  if (circuit->ip_router && circuit->ip_addrs && circuit->ip_addrs->count > 0)
+    if (tlv_add_ip_addrs (circuit->ip_addrs, circuit->snd_stream))
+      return ISIS_WARNING;
+
+#ifdef HAVE_IPV6
+  /* IPv6 Interface Address TLV */
+  if (circuit->ipv6_router && circuit->ipv6_link &&
+      circuit->ipv6_link->count > 0)
+    if (tlv_add_ipv6_addrs (circuit->ipv6_link, circuit->snd_stream))
+      return ISIS_WARNING;
+#endif /* HAVE_IPV6 */
+
+  /* Restart signaling, vendor C sends it too */
+  retval = add_tlv (211, 3, 0, circuit->snd_stream);
+
   /*  LAN Neighbors TLV */
   if (circuit->circ_type == CIRCUIT_T_BROADCAST)
     {
@@ -2011,23 +2033,6 @@
 	  return ISIS_WARNING;
     }
 
-  /* Protocols Supported TLV */
-  if (circuit->nlpids.count > 0)
-    if (tlv_add_nlpid (&circuit->nlpids, circuit->snd_stream))
-      return ISIS_WARNING;
-  /* IP interface Address TLV */
-  if (circuit->ip_router && circuit->ip_addrs && circuit->ip_addrs->count > 0)
-    if (tlv_add_ip_addrs (circuit->ip_addrs, circuit->snd_stream))
-      return ISIS_WARNING;
-
-#ifdef HAVE_IPV6
-  /* IPv6 Interface Address TLV */
-  if (circuit->ipv6_router && circuit->ipv6_link &&
-      circuit->ipv6_link->count > 0)
-    if (tlv_add_ipv6_addrs (circuit->ipv6_link, circuit->snd_stream))
-      return ISIS_WARNING;
-#endif /* HAVE_IPV6 */
-
   if (circuit->u.bc.pad_hellos)
     if (tlv_add_padding (circuit->snd_stream))
       return ISIS_WARNING;
@@ -2284,9 +2289,7 @@
   circuit->t_send_csnp[0] = NULL;
 
   if (circuit->circ_type == CIRCUIT_T_BROADCAST && circuit->u.bc.is_dr[0])
-    {
       send_csnp (circuit, 1);
-    }
   /* set next timer thread */
   THREAD_TIMER_ON (master, circuit->t_send_csnp[0], send_l1_csnp, circuit,
 		   isis_jitter (circuit->csnp_interval[0], CSNP_JITTER));
@@ -2306,9 +2309,7 @@
   circuit->t_send_csnp[1] = NULL;
 
   if (circuit->circ_type == CIRCUIT_T_BROADCAST && circuit->u.bc.is_dr[1])
-    {
       send_csnp (circuit, 2);
-    }
   /* set next timer thread */
   THREAD_TIMER_ON (master, circuit->t_send_csnp[1], send_l2_csnp, circuit,
 		   isis_jitter (circuit->csnp_interval[1], CSNP_JITTER));
diff --git a/isisd/isis_spf.c b/isisd/isis_spf.c
index b6178e3..5d0b161 100644
--- a/isisd/isis_spf.c
+++ b/isisd/isis_spf.c
@@ -1030,15 +1030,22 @@
 
   while (listcount (spftree->tents) > 0)
     {
+      /* C.2.7 a) 1) */
       node = listhead (spftree->tents);
       vertex = listgetdata (node);
-      /* Remove from tent list */
+
+      /* C.2.7 a) 2) */
       list_delete_node (spftree->tents, node);
+
+      /* C.2.7 a) 3) */
       if (isis_find_vertex (spftree->paths, vertex->N.id, vertex->type))
 	continue;
       add_to_paths (spftree, vertex, area, level);
+
       if (vertex->type == VTYPE_PSEUDO_IS ||
-	  vertex->type == VTYPE_NONPSEUDO_IS)
+	  vertex->type == VTYPE_NONPSEUDO_IS ||
+	  vertex->type == VTYPE_PSEUDO_TE_IS ||
+	  vertex->type == VTYPE_NONPSEUDO_TE_IS )
 	{
 	  if (listcount(vertex->Adj_N) == 0) {
 	    continue;
@@ -1054,7 +1061,6 @@
 		{
 		  isis_spf_process_pseudo_lsp (spftree, lsp, vertex->d_N,
 					       vertex->depth, family, adj);
-
 		}
 	      else
 		{
diff --git a/isisd/isis_tlv.c b/isisd/isis_tlv.c
index 94fa65e..9fffef5 100644
--- a/isisd/isis_tlv.c
+++ b/isisd/isis_tlv.c
@@ -741,7 +741,7 @@
   stream_putc (stream, len);	/* LENGTH */
   stream_put (stream, value, (int) len);	/* VALUE */
 
-#ifdef EXTREME_DEBUG
+#ifdef EXTREME_TLV_DEBUG
   zlog_debug ("Added TLV %d len %d", tag, len);
 #endif /* EXTREME DEBUG */
   return ISIS_OK;