* bgp_nexthop.c: Improve debug.
        * bgpd.[ch], bgp_nexthop.c, bgp_snmp.c: Remove useless bgp_get_master()
          function.
        * bgp_packet.c: MP AFI_IP update and withdraw parsing.
        * bgp_fsm.c: Reset peer synctime in bgp_stop(). bgp_fsm_change_status()
          is better place to log about peer status change than bgp_event().
          Log in bgp_connect_success().
        * bgp_vty.c: Fix typo in comment.
        * bgp_attr.c: Better log about unknown attribute.

	[merge from GNU Zebra]
diff --git a/bgpd/ChangeLog b/bgpd/ChangeLog
index 6bee4de..269c552 100644
--- a/bgpd/ChangeLog
+++ b/bgpd/ChangeLog
@@ -1,3 +1,15 @@
+2005-02-01 Akihiro Mizutani <mizutani@net-chef.net>
+
+	* bgp_nexthop.c: Improve debug.
+	* bgpd.[ch], bgp_nexthop.c, bgp_snmp.c: Remove useless bgp_get_master()
+	  function.
+	* bgp_packet.c: MP AFI_IP update and withdraw parsing.
+	* bgp_fsm.c: Reset peer synctime in bgp_stop(). bgp_fsm_change_status()
+	  is better place to log about peer status change than bgp_event().
+	  Log in bgp_connect_success().
+	* bgp_vty.c: Fix typo in comment.
+	* bgp_attr.c: Better log about unknown attribute.
+
 2005-01-29 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
 
 	* bgp_filter.c: (ip_as_path,no_ip_as_path) Use argv_concat instead
diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c
index 8ffcfdd..cad9168 100644
--- a/bgpd/bgp_attr.c
+++ b/bgpd/bgp_attr.c
@@ -1084,6 +1084,10 @@
   bgp_size_t total;
   struct transit *transit;
 
+  if (BGP_DEBUG (normal, NORMAL))
+  zlog_debug ("%s Unknown attribute is received (type %d, length %d)",
+	      peer->host, type, length);
+  
   if (BGP_DEBUG (events, EVENTS))
     zlog (peer->log, LOG_DEBUG, 
 	  "Unknown attribute type %d length %d is received", type, length);
diff --git a/bgpd/bgp_fsm.c b/bgpd/bgp_fsm.c
index 8919586..7327db0 100644
--- a/bgpd/bgp_fsm.c
+++ b/bgpd/bgp_fsm.c
@@ -367,6 +367,9 @@
 
       /* Need of clear of peer. */
       bgp_clear_route_all (peer);
+
+      /* Reset peer synctime */
+      peer->synctime = 0;
     }
 
   /* Stop read and write threads when exists. */
@@ -491,6 +494,8 @@
 int
 bgp_connect_success (struct peer *peer)
 {
+  char buf1[BUFSIZ];
+
   if (peer->fd < 0)
     {
       zlog_err ("bgp_connect_success peer's fd is negative value %d",
@@ -499,7 +504,17 @@
     }
   BGP_READ_ON (peer->t_read, bgp_read, peer->fd);
 
-  /* bgp_getsockname (peer); */
+  if (! CHECK_FLAG (peer->sflags, PEER_STATUS_ACCEPT_PEER))
+    bgp_getsockname (peer);
+
+  if (BGP_DEBUG (normal, NORMAL))
+    {
+      if (! CHECK_FLAG (peer->sflags, PEER_STATUS_ACCEPT_PEER))
+	zlog_debug ("%s open active, local address %s", peer->host,
+		    sockunion2str (peer->su_local, buf1, SU_ADDRSTRLEN));
+      else
+	zlog_debug ("%s passive open", peer->host);
+    }
 
   if (! CHECK_FLAG (peer->sflags, PEER_STATUS_ACCEPT_PEER))
     bgp_open_send (peer);
@@ -594,6 +609,12 @@
   /* Preserve old status and change into new status. */
   peer->ostatus = peer->status;
   peer->status = status;
+
+  if (BGP_DEBUG (normal, NORMAL))
+    zlog_debug ("%s went from %s to %s",
+		peer->host,
+		LOOKUP (bgp_status_msg, peer->ostatus),
+		LOOKUP (bgp_status_msg, peer->status));
 }
 
 /* Keepalive send to peer. */
@@ -866,12 +887,6 @@
 	       bgp_event_str[event],
 	       LOOKUP (bgp_status_msg, peer->status),
 	       LOOKUP (bgp_status_msg, next));
-  if (BGP_DEBUG (normal, NORMAL)
-      && strcmp (LOOKUP (bgp_status_msg, peer->status), LOOKUP (bgp_status_msg, next)))
-    zlog_debug ("%s went from %s to %s",
-	       peer->host,
-	       LOOKUP (bgp_status_msg, peer->status),
-	       LOOKUP (bgp_status_msg, next));
 
   /* Call function. */
   ret = (*(FSM [peer->status - 1][event - 1].func))(peer);
diff --git a/bgpd/bgp_nexthop.c b/bgpd/bgp_nexthop.c
index c368eba..76c1c2a 100644
--- a/bgpd/bgp_nexthop.c
+++ b/bgpd/bgp_nexthop.c
@@ -507,6 +507,14 @@
     bgp_nexthop_cache_reset (cache2_table[afi]);
   else
     bgp_nexthop_cache_reset (cache1_table[afi]);
+
+  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");
+    }
 }
 
 /* BGP scan thread.  This thread check nexthop reachability. */
@@ -516,7 +524,7 @@
   bgp_scan_thread =
     thread_add_timer (master, bgp_scan_timer, NULL, bgp_scan_interval);
 
-  if (BGP_DEBUG (normal, NORMAL))
+  if (BGP_DEBUG (events, EVENTS))
     zlog_debug ("Performing BGP general scanning");
 
   bgp_scan (AFI_IP, SAFI_UNICAST);
@@ -1022,7 +1030,6 @@
 int
 bgp_import (struct thread *t)
 {
-  struct bgp_master *bm;
   struct bgp *bgp;
   struct bgp_node *rn;
   struct bgp_static *bgp_static;
@@ -1036,9 +1043,8 @@
   bgp_import_thread = 
     thread_add_timer (master, bgp_import, NULL, bgp_import_interval);
 
-  bm = bgp_get_master ();
-  if (! bm)
-    return 0;
+  if (BGP_DEBUG (events, EVENTS))
+    zlog_debug ("Import timer expired.");
 
   LIST_LOOP (bm->bgp, bgp, nn)
     {
diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c
index 5640e2b..04e5bd3 100644
--- a/bgpd/bgp_packet.c
+++ b/bgpd/bgp_packet.c
@@ -1527,6 +1527,16 @@
 	  bgp_nlri_parse (peer, &attr, &update);
 	}
 
+      if (mp_update.length
+	  && mp_update.afi == AFI_IP 
+	  && mp_update.safi == SAFI_UNICAST)
+	bgp_nlri_parse (peer, &attr, &mp_update);
+
+      if (mp_withdraw.length
+	  && mp_withdraw.afi == AFI_IP 
+	  && mp_withdraw.safi == SAFI_UNICAST)
+	bgp_nlri_parse (peer, NULL, &mp_withdraw);
+
       if (! attribute_len && ! withdraw_len)
 	{
 	  /* End-of-RIB received */
diff --git a/bgpd/bgp_snmp.c b/bgpd/bgp_snmp.c
index 6ffadf9..228060a 100644
--- a/bgpd/bgp_snmp.c
+++ b/bgpd/bgp_snmp.c
@@ -870,11 +870,6 @@
 void
 bgp_snmp_init ()
 {
-  struct bgp_master *bm;
-  
-  if ( !(bm = bgp_get_master ()) )
-    return;
-    
   smux_init (bm->master);
   REGISTER_MIB("mibII/bgp", bgp_variables, variable, bgp_oid);
 }
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c
index 5968f68..b94e66b 100644
--- a/bgpd/bgp_vty.c
+++ b/bgpd/bgp_vty.c
@@ -2770,7 +2770,7 @@
   return CMD_SUCCESS;
 }
 
-/* Set specified peer's BGP version.  */
+/* Set specified peer's BGP port.  */
 DEFUN (neighbor_port,
        neighbor_port_cmd,
        NEIGHBOR_CMD "port <0-65535>",
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c
index bd2f998..cb760d9 100644
--- a/bgpd/bgpd.c
+++ b/bgpd/bgpd.c
@@ -1780,15 +1780,6 @@
   return bgp;
 }
 
-/* Return master of BGP. */
-struct bgp_master *
-bgp_get_master ()
-{
-  if (bm)
-    return bm;
-  return NULL;
-}
-
 /* Return first entry of BGP. */
 struct bgp *
 bgp_get_default ()
@@ -4870,14 +4861,11 @@
 void
 bgp_terminate ()
 {
-  struct bgp_master *bm;
   struct bgp *bgp;
   struct peer *peer;
   struct listnode *nn;
   struct listnode *mm;
 
-  bm = bgp_get_master ();
-
   LIST_LOOP (bm->bgp, bgp, nn)
     LIST_LOOP (bgp->peer, peer, mm)
       if (peer->status == Established)
diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h
index 4137baf..42c3cea 100644
--- a/bgpd/bgpd.h
+++ b/bgpd/bgpd.h
@@ -764,7 +764,6 @@
 void bgp_zclient_reset ();
 int bgp_nexthop_set (union sockunion *, union sockunion *, 
 		     struct bgp_nexthop *, struct peer *);
-struct bgp_master *bgp_get_master ();
 struct bgp *bgp_get_default ();
 struct bgp *bgp_lookup (as_t, const char *);
 struct bgp *bgp_lookup_by_name (const char *);