]> git.puffer.fish Git - mirror/frr.git/commitdiff
Overhual BGP debugs
authorDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 20 May 2015 00:58:12 +0000 (17:58 -0700)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 20 May 2015 00:58:12 +0000 (17:58 -0700)
Summary of changes
- added an option to enable keepalive debugs for a specific peer
- added an option to enable inbound and/or outbound updates debugs for a specific peer
- added an option to enable update debugs for a specific prefix
- added an option to enable zebra debugs for a specific prefix
- combined "deb bgp", "deb bgp events" and "deb bgp fsm" into "deb bgp neighbor-events". "deb bgp neighbor-events" can be enabled for a specific peer.
- merged "deb bgp filters" into "deb bgp update"
- moved the per-peer logging to one central log file. We now have the ability to filter all verbose debugs on a per-peer and per-prefix basis so we no longer need to keep log files per-peer. This simplifies troubleshooting by keeping all BGP logs in one location.  The use
r can then grep for the peer IP they are interested in if they wish to see the logs for a specific peer.
- Changed "show debugging" in isis to "show debugging isis" to be consistent with all other protocols.  This was very confusing for the user because they would type "show debug" and expect to see a list of debugs enabled across all protocols.
- Removed "undebug" from the parser for BGP.  Again this was to be consisten with all other protocols.
- Removed the "all" keyword from the BGP debug parser.  The user can now do "no debug bgp" to disable all BGP debugs, before you had to type "no deb all bgp" which was confusing.

The new parse tree for BGP debugging is:

deb bgp as4
deb bgp as4 segment
deb bgp keepalives [A.B.C.D|WORD|X:X::X:X]
deb bgp neighbor-events [A.B.C.D|WORD|X:X::X:X]
deb bgp nht
deb bgp updates [in|out] [A.B.C.D|WORD|X:X::X:X]
deb bgp updates prefix [A.B.C.D/M|X:X::X:X/M]
deb bgp zebra
deb bgp zebra prefix [A.B.C.D/M|X:X::X:X/M]

22 files changed:
bgpd/bgp_advertise.c
bgpd/bgp_attr.c
bgpd/bgp_debug.c
bgpd/bgp_debug.h
bgpd/bgp_fsm.c
bgpd/bgp_main.c
bgpd/bgp_mpath.c
bgpd/bgp_network.c
bgpd/bgp_open.c
bgpd/bgp_packet.c
bgpd/bgp_route.c
bgpd/bgp_routemap.c
bgpd/bgp_vty.c
bgpd/bgp_zebra.c
bgpd/bgpd.c
bgpd/bgpd.h
isisd/isisd.c
lib/log.c
lib/log.h
lib/memtypes.c
tests/bgp_capability_test.c
tests/bgp_mp_attr_test.c

index c6b4e59201177e7a30229a4eba9ef2efd8605ade..c71e83bc7223924633b304c07b5ec72c8f5001f1 100644 (file)
@@ -281,7 +281,7 @@ bgp_adj_out_set (struct bgp_node *rn, struct peer *peer, struct prefix *p,
     {
       if (!peer->radv_adjusted)
         {
-          if (BGP_DEBUG (events, EVENTS))
+          if (bgp_debug_update(peer, NULL, 0))
             zlog_debug("%s scheduling MRAI timer after adj_out_set", peer->host);
           bgp_adjust_routeadv(peer);
         }
@@ -331,7 +331,7 @@ bgp_adj_out_unset (struct bgp_node *rn, struct peer *peer, struct prefix *p,
         {
           if (!peer->t_write)
             {
-              if (BGP_DEBUG (events, EVENTS))
+              if (bgp_debug_update(peer, NULL, 0))
                 zlog_debug("%s scheduling write thread after adj_out_unset",
                            peer->host);
               BGP_WRITE_ON (peer->t_write, bgp_write, peer->fd);
index 6f911c26e077971d69c71f8b1dad747aadeef59f..8e1a37ab63addfd3e8349067f6c26c2a57a422b8 100644 (file)
@@ -880,19 +880,18 @@ bgp_attr_flags_diagnose (struct bgp_attr_parser_args *args,
       CHECK_FLAG (real_flags,    attr_flag_str[i].key)
     )
     {
-      zlog (args->peer->log, LOG_ERR, "%s attribute must%s be flagged as \"%s\"",
-            LOOKUP (attr_str, attr_code),
-            CHECK_FLAG (desired_flags, attr_flag_str[i].key) ? "" : " not",
-            attr_flag_str[i].str);
+      zlog_err ("%s attribute must%s be flagged as \"%s\"",
+                LOOKUP (attr_str, attr_code),
+                CHECK_FLAG (desired_flags, attr_flag_str[i].key) ? "" : " not",
+                attr_flag_str[i].str);
       seen = 1;
     }
   if (!seen)
     {
-      zlog (args->peer->log, LOG_DEBUG,
-            "Strange, %s called for attr %s, but no problem found with flags"
-            " (real flags 0x%x, desired 0x%x)",
-            __func__, LOOKUP (attr_str, attr_code),
-            real_flags, desired_flags);
+      zlog_debug ("Strange, %s called for attr %s, but no problem found with flags"
+                  " (real flags 0x%x, desired 0x%x)",
+                  __func__, LOOKUP (attr_str, attr_code),
+                  real_flags, desired_flags);
     }
 }
 
@@ -939,9 +938,8 @@ bgp_attr_flag_invalid (struct bgp_attr_parser_args *args)
   if (!CHECK_FLAG (BGP_ATTR_FLAG_OPTIONAL, flags)
       && !CHECK_FLAG (BGP_ATTR_FLAG_TRANS, flags))
     {
-      zlog (peer->log, LOG_ERR,
-            "%s well-known attributes must have transitive flag set (%x)",
-            LOOKUP (attr_str, attr_code), flags);
+      zlog_err ("%s well-known attributes must have transitive flag set (%x)",
+                LOOKUP (attr_str, attr_code), flags);
       return 1;
     }
   
@@ -952,19 +950,17 @@ bgp_attr_flag_invalid (struct bgp_attr_parser_args *args)
     {
       if (!CHECK_FLAG (flags, BGP_ATTR_FLAG_OPTIONAL))
         {
-          zlog (peer->log, LOG_ERR,
-                "%s well-known attribute "
-                "must NOT have the partial flag set (%x)",
-                 LOOKUP (attr_str, attr_code), flags);
+          zlog_err ("%s well-known attribute "
+                    "must NOT have the partial flag set (%x)",
+                    LOOKUP (attr_str, attr_code), flags);
           return 1;
         }
       if (CHECK_FLAG (flags, BGP_ATTR_FLAG_OPTIONAL)
           && !CHECK_FLAG (flags, BGP_ATTR_FLAG_TRANS))
         {
-          zlog (peer->log, LOG_ERR,
-                "%s optional + transitive attribute "
-                "must NOT have the partial flag set (%x)",
-                 LOOKUP (attr_str, attr_code), flags);
+          zlog_err ("%s optional + transitive attribute "
+                    "must NOT have the partial flag set (%x)",
+                    LOOKUP (attr_str, attr_code), flags);
           return 1;
         }
     }
@@ -999,8 +995,7 @@ bgp_attr_origin (struct bgp_attr_parser_args *args)
      value). */
   if (length != 1)
     {
-      zlog (peer->log, LOG_ERR, "Origin attribute length is not one %d",
-           length);
+      zlog_err ("Origin attribute length is not one %d", length);
       return bgp_attr_malformed (args,
                                  BGP_NOTIFY_UPDATE_ATTR_LENG_ERR,
                                  args->total);
@@ -1016,8 +1011,7 @@ bgp_attr_origin (struct bgp_attr_parser_args *args)
       && (attr->origin != BGP_ORIGIN_EGP)
       && (attr->origin != BGP_ORIGIN_INCOMPLETE))
     {
-      zlog (peer->log, LOG_ERR, "Origin attribute value is invalid %d",
-             attr->origin);
+      zlog_err ("Origin attribute value is invalid %d", attr->origin);
       return bgp_attr_malformed (args,
                                  BGP_NOTIFY_UPDATE_INVAL_ORIGIN,
                                  args->total);
@@ -1048,9 +1042,7 @@ bgp_attr_aspath (struct bgp_attr_parser_args *args)
   /* In case of IBGP, length will be zero. */
   if (! attr->aspath)
     {
-      zlog (peer->log, LOG_ERR,
-            "Malformed AS path from %s, length is %d",
-            peer->host, length);
+      zlog_err ("Malformed AS path from %s, length is %d", peer->host, length);
       return bgp_attr_malformed (args, BGP_NOTIFY_UPDATE_MAL_AS_PATH, 0);
     }
 
@@ -1077,7 +1069,7 @@ bgp_attr_aspath_check (struct peer *const peer, struct attr *const attr)
   if ((peer->sort == BGP_PEER_CONFED && ! aspath_left_confed_check (attr->aspath)) ||
      (peer->sort == BGP_PEER_EBGP && aspath_confed_check (attr->aspath)))
     {
-      zlog (peer->log, LOG_ERR, "Malformed AS path from %s", peer->host);
+      zlog_err ("Malformed AS path from %s", peer->host);
       bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR,
                        BGP_NOTIFY_UPDATE_MAL_AS_PATH);
       return BGP_ATTR_PARSE_ERROR;
@@ -1089,8 +1081,7 @@ bgp_attr_aspath_check (struct peer *const peer, struct attr *const attr)
       if (peer->sort == BGP_PEER_EBGP
          && ! aspath_firstas_check (attr->aspath, peer->as))
        {
-         zlog (peer->log, LOG_ERR,
-               "%s incorrect first AS (must be %u)", peer->host, peer->as);
+          zlog_err ("%s incorrect first AS (must be %u)", peer->host, peer->as);
           bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR,
                            BGP_NOTIFY_UPDATE_MAL_AS_PATH);
           return BGP_ATTR_PARSE_ERROR;
@@ -1124,9 +1115,7 @@ bgp_attr_as4_path (struct bgp_attr_parser_args *args, struct aspath **as4_path)
   /* In case of IBGP, length will be zero. */
   if (!*as4_path)
     {
-      zlog (peer->log, LOG_ERR,
-            "Malformed AS4 path from %s, length is %d",
-            peer->host, length);
+      zlog_err ("Malformed AS4 path from %s, length is %d", peer->host, length);
       return bgp_attr_malformed (args,
                                  BGP_NOTIFY_UPDATE_MAL_AS_PATH,
                                  0);
@@ -1152,8 +1141,7 @@ bgp_attr_nexthop (struct bgp_attr_parser_args *args)
   /* Check nexthop attribute length. */
   if (length != 4)
     {
-      zlog (peer->log, LOG_ERR, "Nexthop attribute length isn't four [%d]",
-             length);
+      zlog_err ("Nexthop attribute length isn't four [%d]", length);
 
       return bgp_attr_malformed (args,
                                  BGP_NOTIFY_UPDATE_ATTR_LENG_ERR,
@@ -1171,7 +1159,7 @@ bgp_attr_nexthop (struct bgp_attr_parser_args *args)
     {
       char buf[INET_ADDRSTRLEN];
       inet_ntop (AF_INET, &nexthop_n, buf, INET_ADDRSTRLEN);
-      zlog (peer->log, LOG_ERR, "Martian nexthop %s", buf);
+      zlog_err ("Martian nexthop %s", buf);
       return bgp_attr_malformed (args,
                                  BGP_NOTIFY_UPDATE_INVAL_NEXT_HOP,
                                  args->total);
@@ -1194,8 +1182,7 @@ bgp_attr_med (struct bgp_attr_parser_args *args)
   /* Length check. */
   if (length != 4)
     {
-      zlog (peer->log, LOG_ERR, 
-           "MED attribute length isn't four [%d]", length);
+      zlog_err ("MED attribute length isn't four [%d]", length);
 
       return bgp_attr_malformed (args,
                                  BGP_NOTIFY_UPDATE_ATTR_LENG_ERR,
@@ -1220,8 +1207,7 @@ bgp_attr_local_pref (struct bgp_attr_parser_args *args)
   /* Length check. */
   if (length != 4)
   {
-    zlog (peer->log, LOG_ERR, "LOCAL_PREF attribute length isn't 4 [%u]",
-          length);
+    zlog_err ("LOCAL_PREF attribute length isn't 4 [%u]", length);
     return bgp_attr_malformed (args,
                                BGP_NOTIFY_UPDATE_ATTR_LENG_ERR,
                                args->total);
@@ -1255,8 +1241,7 @@ bgp_attr_atomic (struct bgp_attr_parser_args *args)
   /* Length check. */
   if (length != 0)
     {
-      zlog (peer->log, LOG_ERR, "ATOMIC_AGGREGATE attribute length isn't 0 [%u]",
-            length);
+      zlog_err ("ATOMIC_AGGREGATE attribute length isn't 0 [%u]", length);
       return bgp_attr_malformed (args,
                                  BGP_NOTIFY_UPDATE_ATTR_LENG_ERR,
                                  args->total);
@@ -1285,8 +1270,7 @@ bgp_attr_aggregator (struct bgp_attr_parser_args *args)
   
   if (length != wantedlen)
     {
-      zlog (peer->log, LOG_ERR, "AGGREGATOR attribute length isn't %u [%u]",
-            wantedlen, length);
+      zlog_err ("AGGREGATOR attribute length isn't %u [%u]", wantedlen, length);
       return bgp_attr_malformed (args,
                                  BGP_NOTIFY_UPDATE_ATTR_LENG_ERR,
                                  args->total);
@@ -1316,8 +1300,7 @@ bgp_attr_as4_aggregator (struct bgp_attr_parser_args *args,
       
   if (length != 8)
     {
-      zlog (peer->log, LOG_ERR, "New Aggregator length is not 8 [%d]",
-            length);
+      zlog_err ("New Aggregator length is not 8 [%d]", length);
       return bgp_attr_malformed (args,
                                  BGP_NOTIFY_UPDATE_ATTR_LENG_ERR,
                                  0);
@@ -1473,7 +1456,7 @@ bgp_attr_originator_id (struct bgp_attr_parser_args *args)
   /* Length check. */
   if (length != 4)
     {
-      zlog (peer->log, LOG_ERR, "Bad originator ID length %d", length);
+      zlog_err ("Bad originator ID length %d", length);
 
       return bgp_attr_malformed (args,
                                  BGP_NOTIFY_UPDATE_ATTR_LENG_ERR,
@@ -1499,7 +1482,7 @@ bgp_attr_cluster_list (struct bgp_attr_parser_args *args)
   /* Check length. */
   if (length % 4)
     {
-      zlog (peer->log, LOG_ERR, "Bad cluster list length %d", length);
+      zlog_err ("Bad cluster list length %d", length);
 
       return bgp_attr_malformed (args, BGP_NOTIFY_UPDATE_ATTR_LENG_ERR,
                                  args->total);
@@ -1587,8 +1570,8 @@ bgp_mp_reach_parse (struct bgp_attr_parser_args *args,
          char buf1[INET6_ADDRSTRLEN];
          char buf2[INET6_ADDRSTRLEN];
 
-         if (BGP_DEBUG (update, UPDATE_IN))
-           zlog_debug ("%s got two nexthop %s %s but second one is not a link-local nexthop", peer->host,
+         if (bgp_debug_update(peer, NULL, 1))
+           zlog_debug ("%s sent two nexthops %s %s but second one is not a link-local nexthop", peer->host,
                       inet_ntop (AF_INET6, &attre->mp_nexthop_global,
                                  buf1, INET6_ADDRSTRLEN),
                       inet_ntop (AF_INET6, &attre->mp_nexthop_local,
@@ -1738,15 +1721,10 @@ bgp_attr_unknown (struct bgp_attr_parser_args *args)
   const u_char flag = args->flags;  
   const bgp_size_t length = args->length;
   
-
-  if (BGP_DEBUG (normal, NORMAL))
-  zlog_debug ("%s Unknown attribute is received (type %d, length %d)",
-             peer->host, type, length);
+  if (bgp_debug_update(peer, NULL, 1))
+    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);
-
   /* Forward read pointer of input stream. */
   stream_forward_getp (peer->ibuf, length);
 
@@ -1822,10 +1800,9 @@ bgp_attr_parse (struct peer *peer, struct attr *attr, bgp_size_t size,
       if (endp - BGP_INPUT_PNT (peer) < BGP_ATTR_MIN_LEN)
        {
          /* XXX warning: long int format, int arg (arg 5) */
-         zlog (peer->log, LOG_WARNING, 
-               "%s: error BGP attribute length %lu is smaller than min len",
-               peer->host,
-               (unsigned long) (endp - STREAM_PNT (BGP_INPUT (peer))));
+         zlog_warn ("%s: error BGP attribute length %lu is smaller than min len",
+                     peer->host,
+                    (unsigned long) (endp - STREAM_PNT (BGP_INPUT (peer))));
 
          bgp_notify_send (peer, 
                           BGP_NOTIFY_UPDATE_ERR, 
@@ -1845,10 +1822,9 @@ bgp_attr_parse (struct peer *peer, struct attr *attr, bgp_size_t size,
       if (CHECK_FLAG (flag, BGP_ATTR_FLAG_EXTLEN)
           && ((endp - startp) < (BGP_ATTR_MIN_LEN + 1)))
        {
-         zlog (peer->log, LOG_WARNING, 
-               "%s: Extended length set, but just %lu bytes of attr header",
-               peer->host,
-               (unsigned long) (endp - STREAM_PNT (BGP_INPUT (peer))));
+         zlog_warn ("%s: Extended length set, but just %lu bytes of attr header",
+                    peer->host,
+                    (unsigned long) (endp - STREAM_PNT (BGP_INPUT (peer))));
 
          bgp_notify_send (peer, 
                           BGP_NOTIFY_UPDATE_ERR, 
@@ -1868,9 +1844,8 @@ bgp_attr_parse (struct peer *peer, struct attr *attr, bgp_size_t size,
 
       if (CHECK_BITMAP (seen, type))
        {
-         zlog (peer->log, LOG_WARNING,
-               "%s: error BGP attribute type %d appears twice in a message",
-               peer->host, type);
+         zlog_warn ("%s: error BGP attribute type %d appears twice in a message",
+                    peer->host, type);
 
          bgp_notify_send (peer, 
                           BGP_NOTIFY_UPDATE_ERR, 
@@ -1888,8 +1863,7 @@ bgp_attr_parse (struct peer *peer, struct attr *attr, bgp_size_t size,
 
       if (attr_endp > endp)
        {
-         zlog (peer->log, LOG_WARNING, 
-               "%s: BGP type %d length %d is too large, attribute total length is %d.  attr_endp is %p.  endp is %p", peer->host, type, length, size, attr_endp, endp);
+         zlog_warn ("%s: BGP type %d length %d is too large, attribute total length is %d.  attr_endp is %p.  endp is %p", peer->host, type, length, size, attr_endp, endp);
          bgp_notify_send (peer, 
                           BGP_NOTIFY_UPDATE_ERR, 
                           BGP_NOTIFY_UPDATE_ATTR_LENG_ERR);
@@ -1988,10 +1962,9 @@ bgp_attr_parse (struct peer *peer, struct attr *attr, bgp_size_t size,
       /* If hard error occured immediately return to the caller. */
       if (ret == BGP_ATTR_PARSE_ERROR)
         {
-          zlog (peer->log, LOG_WARNING,
-                "%s: Attribute %s, parse error", 
-                peer->host, 
-                LOOKUP (attr_str, type));
+          zlog_warn ("%s: Attribute %s, parse error", 
+                     peer->host, 
+                     LOOKUP (attr_str, type));
           if (as4_path)
             aspath_unintern (&as4_path);
           return ret;
@@ -1999,10 +1972,9 @@ bgp_attr_parse (struct peer *peer, struct attr *attr, bgp_size_t size,
       if (ret == BGP_ATTR_PARSE_WITHDRAW)
         {
           
-          zlog (peer->log, LOG_WARNING,
-                "%s: Attribute %s, parse error - treating as withdrawal",
-                peer->host,
-                LOOKUP (attr_str, type));
+          zlog_warn ("%s: Attribute %s, parse error - treating as withdrawal",
+                     peer->host,
+                     LOOKUP (attr_str, type));
           if (as4_path)
             aspath_unintern (&as4_path);
           return ret;
@@ -2011,9 +1983,8 @@ bgp_attr_parse (struct peer *peer, struct attr *attr, bgp_size_t size,
       /* Check the fetched length. */
       if (BGP_INPUT_PNT (peer) != attr_endp)
        {
-         zlog (peer->log, LOG_WARNING, 
-               "%s: BGP attribute %s, fetch error", 
-                peer->host, LOOKUP (attr_str, type));
+         zlog_warn ("%s: BGP attribute %s, fetch error",
+                     peer->host, LOOKUP (attr_str, type));
          bgp_notify_send (peer, 
                           BGP_NOTIFY_UPDATE_ERR, 
                           BGP_NOTIFY_UPDATE_ATTR_LENG_ERR);
@@ -2026,9 +1997,8 @@ bgp_attr_parse (struct peer *peer, struct attr *attr, bgp_size_t size,
   /* Check final read pointer is same as end pointer. */
   if (BGP_INPUT_PNT (peer) != endp)
     {
-      zlog (peer->log, LOG_WARNING, 
-           "%s: BGP attribute %s, length mismatch",
-           peer->host, LOOKUP (attr_str, type));
+      zlog_warn ("%s: BGP attribute %s, length mismatch",
+                peer->host, LOOKUP (attr_str, type));
       bgp_notify_send (peer, 
                       BGP_NOTIFY_UPDATE_ERR, 
                       BGP_NOTIFY_UPDATE_ATTR_LENG_ERR);
@@ -2118,9 +2088,7 @@ bgp_attr_check (struct peer *peer, struct attr *attr)
 
   if (type)
     {
-      zlog (peer->log, LOG_WARNING, 
-           "%s Missing well-known attribute %d.",
-           peer->host, type);
+      zlog_warn ("%s Missing well-known attribute %d.", peer->host, type);
       bgp_notify_send_with_data (peer, 
                                 BGP_NOTIFY_UPDATE_ERR, 
                                 BGP_NOTIFY_UPDATE_MISS_ATTR,
index 91e6ad177c19bb18d20f729bad627ebc024b5fda..9033b94df457f9c0bfa7934d52ef33e2cbb509cd 100644 (file)
@@ -28,6 +28,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 #include "str.h"
 #include "log.h"
 #include "sockunion.h"
+#include "memory.h"
 
 #include "bgpd/bgpd.h"
 #include "bgpd/bgp_aspath.h"
@@ -37,27 +38,32 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 #include "bgpd/bgp_community.h"
 
 unsigned long conf_bgp_debug_as4;
-unsigned long conf_bgp_debug_fsm;
+unsigned long conf_bgp_debug_neighbor_events;
 unsigned long conf_bgp_debug_events;
 unsigned long conf_bgp_debug_packet;
 unsigned long conf_bgp_debug_filter;
 unsigned long conf_bgp_debug_keepalive;
 unsigned long conf_bgp_debug_update;
-unsigned long conf_bgp_debug_normal;
 unsigned long conf_bgp_debug_zebra;
 unsigned long conf_bgp_debug_nht;
 
 unsigned long term_bgp_debug_as4;
-unsigned long term_bgp_debug_fsm;
+unsigned long term_bgp_debug_neighbor_events;
 unsigned long term_bgp_debug_events;
 unsigned long term_bgp_debug_packet;
 unsigned long term_bgp_debug_filter;
 unsigned long term_bgp_debug_keepalive;
 unsigned long term_bgp_debug_update;
-unsigned long term_bgp_debug_normal;
 unsigned long term_bgp_debug_zebra;
 unsigned long term_bgp_debug_nht;
 
+struct list *bgp_debug_neighbor_events_peers = NULL;
+struct list *bgp_debug_keepalive_peers = NULL;
+struct list *bgp_debug_update_out_peers = NULL;
+struct list *bgp_debug_update_in_peers = NULL;
+struct list *bgp_debug_update_prefixes = NULL;
+struct list *bgp_debug_zebra_prefixes = NULL;
+
 /* messages for BGP-4 status */
 const struct message bgp_status_msg[] = 
 {
@@ -91,7 +97,7 @@ static const struct message bgp_notify_msg[] =
   { BGP_NOTIFY_OPEN_ERR, "OPEN Message Error"},
   { BGP_NOTIFY_UPDATE_ERR, "UPDATE Message Error"},
   { BGP_NOTIFY_HOLD_ERR, "Hold Timer Expired"},
-  { BGP_NOTIFY_FSM_ERR, "Finite State Machine Error"},
+  { BGP_NOTIFY_FSM_ERR, "Neighbor Events Error"},
   { BGP_NOTIFY_CEASE, "Cease"},
   { BGP_NOTIFY_CAPABILITY_ERR, "CAPABILITY Message Error"},
 };
@@ -162,6 +168,151 @@ static const int bgp_notify_capability_msg_max = BGP_NOTIFY_CAPABILITY_MAX;
 const char *bgp_origin_str[] = {"i","e","?"};
 const char *bgp_origin_long_str[] = {"IGP","EGP","incomplete"};
 
+
+/* Given a string return a pointer the corresponding peer structure */
+static struct peer *
+bgp_find_peer (struct vty *vty, const char *peer_str)
+{
+  int ret;
+  union sockunion su;
+  struct bgp *bgp;
+
+  bgp = vty->index;
+  ret = str2sockunion (peer_str, &su);
+
+  /* 'swpX' string */
+  if (ret < 0)
+    return peer_lookup_by_conf_if (bgp, peer_str);
+  else
+    return peer_lookup (bgp, &su);
+}
+
+static void
+bgp_debug_list_free(struct list *list)
+{
+  struct bgp_debug_filter *filter;
+  struct listnode *node, *nnode;
+
+  if (list)
+    for (ALL_LIST_ELEMENTS (list, node, nnode, filter))
+      {
+        listnode_delete (list, filter);
+
+        if (filter->p)
+          prefix_free(filter->p);
+
+        if (filter->peer)
+          peer_unlock (filter->peer);
+
+        XFREE (MTYPE_BGP_DEBUG_FILTER, filter);
+      }
+}
+
+/* Print the desc along with a list of peers/prefixes this debug is
+ * enabled for */
+static void
+bgp_debug_list_print (struct vty *vty, const char *desc, struct list *list)
+{
+  struct bgp_debug_filter *filter;
+  struct listnode *node, *nnode;
+  char buf[INET6_ADDRSTRLEN];
+
+  vty_out (vty, "%s", desc);
+
+  if (list && !list_isempty(list))
+    {
+      vty_out (vty, " for");
+      for (ALL_LIST_ELEMENTS (list, node, nnode, filter))
+        {
+          if (filter->peer)
+            vty_out (vty, " %s", filter->peer->host);
+
+          if (filter->p)
+            vty_out (vty, " %s/%d",
+                     inet_ntop (filter->p->family, &filter->p->u.prefix, buf, INET6_ADDRSTRLEN),
+                     filter->p->prefixlen);
+        }
+    }
+
+  vty_out (vty, "%s", VTY_NEWLINE);
+}
+
+static void
+bgp_debug_list_add_entry(struct list *list, struct peer *peer, struct prefix *p)
+{
+  struct bgp_debug_filter *filter;
+
+  filter = XCALLOC (MTYPE_BGP_DEBUG_FILTER, sizeof (struct bgp_debug_filter));
+
+  if (peer)
+    {
+      peer_lock (peer);
+      filter->peer = peer;
+      filter->p = NULL;
+    }
+  else if (p)
+    {
+      filter->peer = NULL;
+      filter->p = p;
+    }
+
+  listnode_add(list, filter);
+}
+
+static int
+bgp_debug_list_remove_entry(struct list *list, struct peer *peer, struct prefix *p)
+{
+  struct bgp_debug_filter *filter;
+  struct listnode *node, *nnode;
+
+  for (ALL_LIST_ELEMENTS (list, node, nnode, filter))
+    {
+      if (peer && filter->peer == peer)
+        {
+          listnode_delete (list, filter);
+          peer_unlock (filter->peer);
+          XFREE (MTYPE_BGP_DEBUG_FILTER, filter);
+          return 1;
+        }
+      else if (p && filter->p->prefixlen == p->prefixlen && prefix_match(filter->p, p))
+        {
+          listnode_delete (list, filter);
+          prefix_free (filter->p);
+          XFREE (MTYPE_BGP_DEBUG_FILTER, filter);
+          return 1;
+        }
+    }
+
+  return 0;
+}
+
+static int
+bgp_debug_list_has_entry(struct list *list, struct peer *peer, struct prefix *p)
+{
+  struct bgp_debug_filter *filter;
+  struct listnode *node, *nnode;
+
+  for (ALL_LIST_ELEMENTS (list, node, nnode, filter))
+    {
+      if (peer)
+        {
+          if (filter->peer == peer)
+            {
+              return 1;
+            }
+        }
+      else if (p)
+        {
+          if (filter->p->prefixlen == p->prefixlen && prefix_match(filter->p, p))
+            {
+              return 1;
+            }
+        }
+    }
+
+  return 0;
+}
+
 /* Dump attribute. */
 int
 bgp_dump_attr (struct peer *peer, struct attr *attr, char *buf, size_t size)
@@ -279,18 +430,12 @@ bgp_notify_print(struct peer *peer, struct bgp_notify *bgp_notify,
       break;
     }
 
-  if (bgp_flag_check (peer->bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES))
+  if (BGP_DEBUG (neighbor_events, NEIGHBOR_EVENTS) || bgp_flag_check (peer->bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES))
     zlog_info ("%%NOTIFICATION: %s neighbor %s %d/%d (%s%s) %d bytes %s",
               strcmp (direct, "received") == 0 ? "received from" : "sent to",
               peer->host, bgp_notify->code, bgp_notify->subcode,
               code_str, subcode_str, bgp_notify->length,
               bgp_notify->data ? bgp_notify->data : "");
-  else if (BGP_DEBUG (normal, NORMAL))
-    plog_debug (peer->log, "%s %s NOTIFICATION %d/%d (%s%s) %d bytes %s",
-              peer ? peer->host : "",
-              direct, bgp_notify->code, bgp_notify->subcode,
-              code_str, subcode_str, bgp_notify->length,
-              bgp_notify->data ? bgp_notify->data : "");
 }
 
 /* Debug option setting interface. */
@@ -337,13 +482,6 @@ DEFUN (no_debug_bgp_as4,
   return CMD_SUCCESS;
 }
 
-ALIAS (no_debug_bgp_as4,
-       undebug_bgp_as4_cmd,
-       "undebug bgp as4",
-       UNDEBUG_STR
-       BGP_STR
-       "BGP AS4 actions\n")
-
 DEFUN (debug_bgp_as4_segment,
        debug_bgp_as4_segment_cmd,
        "debug bgp as4 segment",
@@ -381,98 +519,127 @@ DEFUN (no_debug_bgp_as4_segment,
   return CMD_SUCCESS;
 }
 
-ALIAS (no_debug_bgp_as4_segment,
-       undebug_bgp_as4_segment_cmd,
-       "undebug bgp as4 segment",
-       UNDEBUG_STR
-       BGP_STR
-       "BGP AS4 actions\n"
-       "BGP AS4 aspath segment handling\n")
-
-DEFUN (debug_bgp_fsm,
-       debug_bgp_fsm_cmd,
-       "debug bgp fsm",
+/* debug bgp neighbor_events */
+DEFUN (debug_bgp_neighbor_events,
+       debug_bgp_neighbor_events_cmd,
+       "debug bgp neighbor-events",
        DEBUG_STR
        BGP_STR
-       "BGP Finite State Machine\n")
+       "BGP Neighbor Events\n")
 {
   if (vty->node == CONFIG_NODE)
-    DEBUG_ON (fsm, FSM);
+    DEBUG_ON (neighbor_events, NEIGHBOR_EVENTS);
   else
     {
-      TERM_DEBUG_ON (fsm, FSM);
-      vty_out (vty, "BGP fsm debugging is on%s", VTY_NEWLINE);
+      TERM_DEBUG_ON (neighbor_events, NEIGHBOR_EVENTS);
+      vty_out (vty, "BGP neighbor-events debugging is on%s", VTY_NEWLINE);
     }
   return CMD_SUCCESS;
 }
 
-DEFUN (no_debug_bgp_fsm,
-       no_debug_bgp_fsm_cmd,
-       "no debug bgp fsm",
-       NO_STR
+DEFUN (debug_bgp_neighbor_events_peer,
+       debug_bgp_neighbor_events_peer_cmd,
+       "debug bgp neighbor-events (A.B.C.D|X:X::X:X|WORD)",
        DEBUG_STR
        BGP_STR
-       "Finite State Machine\n")
+       "BGP Neighbor Events\n"
+       "BGP neighbor IP address to debug\n"
+       "BGP IPv6 neighbor to debug\n"
+       "BGP neighbor on interface to debug\n")
 {
+  struct peer *peer;
+
+  peer = bgp_find_peer (vty, argv[0]);
+  if (!peer)
+    {
+      vty_out (vty, "%s is not a configured peer%s", argv[0], VTY_NEWLINE);
+      return CMD_WARNING;
+    }
+
+  if (!bgp_debug_neighbor_events_peers)
+    bgp_debug_neighbor_events_peers = list_new ();
+
+  if (bgp_debug_list_has_entry(bgp_debug_neighbor_events_peers, peer, NULL))
+    {
+      vty_out (vty, "BGP neighbor-events debugging is already enabled for %s%s", peer->host, VTY_NEWLINE);
+      return CMD_SUCCESS;
+    }
+
+  bgp_debug_list_add_entry(bgp_debug_neighbor_events_peers, peer, NULL);
+
   if (vty->node == CONFIG_NODE)
-    DEBUG_OFF (fsm, FSM);
+    DEBUG_ON (neighbor_events, NEIGHBOR_EVENTS);
   else
     {
-      TERM_DEBUG_OFF (fsm, FSM);
-      vty_out (vty, "BGP fsm debugging is off%s", VTY_NEWLINE);
+      TERM_DEBUG_ON (neighbor_events, NEIGHBOR_EVENTS);
+      vty_out (vty, "BGP neighbor-events debugging is on for %s%s", argv[0], VTY_NEWLINE);
     }
   return CMD_SUCCESS;
 }
 
-ALIAS (no_debug_bgp_fsm,
-       undebug_bgp_fsm_cmd,
-       "undebug bgp fsm",
-       UNDEBUG_STR
-       BGP_STR
-       "Finite State Machine\n")
-
-DEFUN (debug_bgp_events,
-       debug_bgp_events_cmd,
-       "debug bgp events",
+DEFUN (no_debug_bgp_neighbor_events,
+       no_debug_bgp_neighbor_events_cmd,
+       "no debug bgp neighbor-events",
+       NO_STR
        DEBUG_STR
        BGP_STR
-       "BGP events\n")
+       "Neighbor Events\n")
 {
+  bgp_debug_list_free(bgp_debug_neighbor_events_peers);
+
   if (vty->node == CONFIG_NODE)
-    DEBUG_ON (events, EVENTS);
+    DEBUG_OFF (neighbor_events, NEIGHBOR_EVENTS);
   else
     {
-      TERM_DEBUG_ON (events, EVENTS);
-      vty_out (vty, "BGP events debugging is on%s", VTY_NEWLINE);
+      TERM_DEBUG_OFF (neighbor_events, NEIGHBOR_EVENTS);
+      vty_out (vty, "BGP neighbor-events debugging is off%s", VTY_NEWLINE);
     }
   return CMD_SUCCESS;
 }
 
-DEFUN (no_debug_bgp_events,
-       no_debug_bgp_events_cmd,
-       "no debug bgp events",
+DEFUN (no_debug_bgp_neighbor_events_peer,
+       no_debug_bgp_neighbor_events_peer_cmd,
+       "no debug bgp neighbor-events (A.B.C.D|X:X::X:X|WORD)",
        NO_STR
        DEBUG_STR
        BGP_STR
-       "BGP events\n")
+       "Neighbor Events\n"
+       "BGP neighbor IP address to debug\n"
+       "BGP IPv6 neighbor to debug\n"
+       "BGP neighbor on interface to debug\n")
 {
-  if (vty->node == CONFIG_NODE)
-    DEBUG_OFF (events, EVENTS);
-  else
+  int found_peer = 0;
+  struct peer *peer;
+
+  peer = bgp_find_peer (vty, argv[0]);
+  if (!peer)
+    {
+      vty_out (vty, "%s is not a configured peer%s", argv[0], VTY_NEWLINE);
+      return CMD_WARNING;
+    }
+
+  if (bgp_debug_neighbor_events_peers && !list_isempty(bgp_debug_neighbor_events_peers))
     {
-      TERM_DEBUG_OFF (events, EVENTS);
-      vty_out (vty, "BGP events debugging is off%s", VTY_NEWLINE);
+      found_peer = bgp_debug_list_remove_entry(bgp_debug_neighbor_events_peers, peer, NULL);
+
+      if (list_isempty(bgp_debug_neighbor_events_peers))
+        {
+          if (vty->node == CONFIG_NODE)
+            DEBUG_OFF (neighbor_events, NEIGHBOR_EVENTS);
+          else
+            TERM_DEBUG_OFF (neighbor_events, NEIGHBOR_EVENTS);
+        }
     }
+
+  if (found_peer)
+    vty_out (vty, "BGP neighbor-events debugging is off for %s%s", argv[0], VTY_NEWLINE);
+  else
+    vty_out (vty, "BGP neighbor-events debugging was not enabled for %s%s", argv[0], VTY_NEWLINE);
+
   return CMD_SUCCESS;
 }
 
-ALIAS (no_debug_bgp_events,
-       undebug_bgp_events_cmd,
-       "undebug bgp events",
-       UNDEBUG_STR
-       BGP_STR
-       "BGP events\n")
-
+/* debug bgp nht */
 DEFUN (debug_bgp_nht,
        debug_bgp_nht_cmd,
        "debug bgp nht",
@@ -508,68 +675,60 @@ DEFUN (no_debug_bgp_nht,
   return CMD_SUCCESS;
 }
 
-ALIAS (no_debug_bgp_nht,
-       undebug_bgp_nht_cmd,
-       "undebug bgp nht",
-       UNDEBUG_STR
-       BGP_STR
-       "BGP next-hop tracking updates\n")
-
-DEFUN (debug_bgp_filter,
-       debug_bgp_filter_cmd,
-       "debug bgp filters",
+/* debug bgp keepalives */
+DEFUN (debug_bgp_keepalive,
+       debug_bgp_keepalive_cmd,
+       "debug bgp keepalives",
        DEBUG_STR
        BGP_STR
-       "BGP filters\n")
+       "BGP keepalives\n")
 {
   if (vty->node == CONFIG_NODE)
-    DEBUG_ON (filter, FILTER);
+    DEBUG_ON (keepalive, KEEPALIVE);
   else
     {
-      TERM_DEBUG_ON (filter, FILTER);
-      vty_out (vty, "BGP filters debugging is on%s", VTY_NEWLINE);
+      TERM_DEBUG_ON (keepalive, KEEPALIVE);
+      vty_out (vty, "BGP keepalives debugging is on%s", VTY_NEWLINE);
     }
   return CMD_SUCCESS;
 }
 
-DEFUN (no_debug_bgp_filter,
-       no_debug_bgp_filter_cmd,
-       "no debug bgp filters",
-       NO_STR
+DEFUN (debug_bgp_keepalive_peer,
+       debug_bgp_keepalive_peer_cmd,
+       "debug bgp keepalives (A.B.C.D|X:X::X:X|WORD)",
        DEBUG_STR
        BGP_STR
-       "BGP filters\n")
+       "BGP Neighbor Events\n"
+       "BGP neighbor IP address to debug\n"
+       "BGP IPv6 neighbor to debug\n"
+       "BGP neighbor on interface to debug\n")
 {
-  if (vty->node == CONFIG_NODE)
-    DEBUG_OFF (filter, FILTER);
-  else
+  struct peer *peer;
+
+  peer = bgp_find_peer (vty, argv[0]);
+  if (!peer)
     {
-      TERM_DEBUG_OFF (filter, FILTER);
-      vty_out (vty, "BGP filters debugging is off%s", VTY_NEWLINE);
+      vty_out (vty, "%s is not a configured peer%s", argv[0], VTY_NEWLINE);
+      return CMD_WARNING;
     }
-  return CMD_SUCCESS;
-}
 
-ALIAS (no_debug_bgp_filter,
-       undebug_bgp_filter_cmd,
-       "undebug bgp filters",
-       UNDEBUG_STR
-       BGP_STR
-       "BGP filters\n")
+  if (!bgp_debug_keepalive_peers)
+    bgp_debug_keepalive_peers = list_new ();
+
+  if (bgp_debug_list_has_entry(bgp_debug_keepalive_peers, peer, NULL))
+    {
+      vty_out (vty, "BGP keepalive debugging is already enabled for %s%s", peer->host, VTY_NEWLINE);
+      return CMD_SUCCESS;
+    }
+
+  bgp_debug_list_add_entry(bgp_debug_keepalive_peers, peer, NULL);
 
-DEFUN (debug_bgp_keepalive,
-       debug_bgp_keepalive_cmd,
-       "debug bgp keepalives",
-       DEBUG_STR
-       BGP_STR
-       "BGP keepalives\n")
-{
   if (vty->node == CONFIG_NODE)
     DEBUG_ON (keepalive, KEEPALIVE);
   else
     {
       TERM_DEBUG_ON (keepalive, KEEPALIVE);
-      vty_out (vty, "BGP keepalives debugging is on%s", VTY_NEWLINE);
+      vty_out (vty, "BGP keepalives debugging is on for %s%s", argv[0], VTY_NEWLINE);
     }
   return CMD_SUCCESS;
 }
@@ -582,6 +741,8 @@ DEFUN (no_debug_bgp_keepalive,
        BGP_STR
        "BGP keepalives\n")
 {
+  bgp_debug_list_free(bgp_debug_keepalive_peers);
+
   if (vty->node == CONFIG_NODE)
     DEBUG_OFF (keepalive, KEEPALIVE);
   else
@@ -592,13 +753,49 @@ DEFUN (no_debug_bgp_keepalive,
   return CMD_SUCCESS;
 }
 
-ALIAS (no_debug_bgp_keepalive,
-       undebug_bgp_keepalive_cmd,
-       "undebug bgp keepalives",
-       UNDEBUG_STR
+DEFUN (no_debug_bgp_keepalive_peer,
+       no_debug_bgp_keepalive_peer_cmd,
+       "no debug bgp keepalives (A.B.C.D|X:X::X:X|WORD)",
+       NO_STR
+       DEBUG_STR
        BGP_STR
-       "BGP keepalives\n")
+       "BGP keepalives\n"
+       "BGP neighbor IP address to debug\n"
+       "BGP IPv6 neighbor to debug\n"
+       "BGP neighbor on interface to debug\n")
+{
+  int found_peer = 0;
+  struct peer *peer;
+
+  peer = bgp_find_peer (vty, argv[0]);
+  if (!peer)
+    {
+      vty_out (vty, "%s is not a configured peer%s", argv[0], VTY_NEWLINE);
+      return CMD_WARNING;
+    }
 
+  if (bgp_debug_keepalive_peers && !list_isempty(bgp_debug_keepalive_peers))
+    {
+      found_peer = bgp_debug_list_remove_entry(bgp_debug_keepalive_peers, peer, NULL);
+
+      if (list_isempty(bgp_debug_keepalive_peers))
+        {
+          if (vty->node == CONFIG_NODE)
+            DEBUG_OFF (keepalive, KEEPALIVE);
+          else
+            TERM_DEBUG_OFF (keepalive, KEEPALIVE);
+        }
+    }
+
+  if (found_peer)
+    vty_out (vty, "BGP keepalives debugging is off for %s%s", argv[0], VTY_NEWLINE);
+  else
+    vty_out (vty, "BGP keepalives debugging was not enabled for %s%s", argv[0], VTY_NEWLINE);
+
+  return CMD_SUCCESS;
+}
+
+/* debug bgp updates */
 DEFUN (debug_bgp_update,
        debug_bgp_update_cmd,
        "debug bgp updates",
@@ -660,74 +857,299 @@ DEFUN (debug_bgp_update_direct,
   return CMD_SUCCESS;
 }
 
-DEFUN (no_debug_bgp_update,
-       no_debug_bgp_update_cmd,
-       "no debug bgp updates",
-       NO_STR
+DEFUN (debug_bgp_update_direct_peer,
+       debug_bgp_update_direct_peer_cmd,
+       "debug bgp updates (in|out) (A.B.C.D|X:X::X:X|WORD)",
        DEBUG_STR
        BGP_STR
-       "BGP updates\n")
+       "BGP updates\n"
+       "Inbound updates\n"
+       "Outbound updates\n"
+       "BGP neighbor IP address to debug\n"
+       "BGP IPv6 neighbor to debug\n"
+       "BGP neighbor on interface to debug\n")
 {
+  struct peer *peer;
+  int inbound;
+
+  peer = bgp_find_peer (vty, argv[1]);
+  if (!peer)
+    {
+      vty_out (vty, "%s is not a configured peer%s", argv[1], VTY_NEWLINE);
+      return CMD_WARNING;
+    }
+
+
+  if (!bgp_debug_update_in_peers)
+    bgp_debug_update_in_peers = list_new ();
+
+  if (!bgp_debug_update_out_peers)
+    bgp_debug_update_out_peers = list_new ();
+
+  if (strncmp ("i", argv[0], 1) == 0)
+    inbound = 1;
+  else
+    inbound = 0;
+
+  if (inbound)
+    {
+      if (bgp_debug_list_has_entry(bgp_debug_update_in_peers, peer, NULL))
+        {
+          vty_out (vty, "BGP inbound update debugging is already enabled for %s%s", peer->host, VTY_NEWLINE);
+          return CMD_SUCCESS;
+        }
+    }
+
+  else
+    {
+      if (bgp_debug_list_has_entry(bgp_debug_update_out_peers, peer, NULL))
+        {
+          vty_out (vty, "BGP outbound update debugging is already enabled for %s%s", peer->host, VTY_NEWLINE);
+          return CMD_SUCCESS;
+        }
+    }
+
+  if (inbound)
+    bgp_debug_list_add_entry(bgp_debug_update_in_peers, peer, NULL);
+  else
+    bgp_debug_list_add_entry(bgp_debug_update_out_peers, peer, NULL);
+
   if (vty->node == CONFIG_NODE)
     {
-      DEBUG_OFF (update, UPDATE_IN);
-      DEBUG_OFF (update, UPDATE_OUT);
+      if (inbound)
+       {
+         DEBUG_OFF (update, UPDATE_OUT);
+         DEBUG_ON (update, UPDATE_IN);
+       }
+      else
+       {
+         DEBUG_OFF (update, UPDATE_IN);
+         DEBUG_ON (update, UPDATE_OUT);
+       }
     }
   else
     {
-      TERM_DEBUG_OFF (update, UPDATE_IN);
-      TERM_DEBUG_OFF (update, UPDATE_OUT);
-      vty_out (vty, "BGP updates debugging is off%s", VTY_NEWLINE);
+      if (inbound)
+       {
+         TERM_DEBUG_OFF (update, UPDATE_OUT);
+         TERM_DEBUG_ON (update, UPDATE_IN);
+         vty_out (vty, "BGP updates debugging is on (inbound) for %s%s", argv[1], VTY_NEWLINE);
+       }
+      else
+       {
+         TERM_DEBUG_OFF (update, UPDATE_IN);
+         TERM_DEBUG_ON (update, UPDATE_OUT);
+         vty_out (vty, "BGP updates debugging is on (outbound) for %s%s", argv[1], VTY_NEWLINE);
+       }
     }
   return CMD_SUCCESS;
 }
 
-ALIAS (no_debug_bgp_update,
-       undebug_bgp_update_cmd,
-       "undebug bgp updates",
-       UNDEBUG_STR
+DEFUN (no_debug_bgp_update_direct_peer,
+       no_debug_bgp_update_direct_peer_cmd,
+       "no debug bgp updates (in|out) (A.B.C.D|X:X::X:X|WORD)",
+       NO_STR
+       DEBUG_STR
        BGP_STR
-       "BGP updates\n")
+       "BGP updates\n"
+       "Inbound updates\n"
+       "Outbound updates\n"
+       "BGP neighbor IP address to debug\n"
+       "BGP IPv6 neighbor to debug\n"
+       "BGP neighbor on interface to debug\n")
+{
+  int inbound;
+  int found_peer = 0;
+  struct peer *peer;
+
+  peer = bgp_find_peer (vty, argv[1]);
+  if (!peer)
+    {
+      vty_out (vty, "%s is not a configured peer%s", argv[1], VTY_NEWLINE);
+      return CMD_WARNING;
+    }
 
-DEFUN (debug_bgp_normal,
-       debug_bgp_normal_cmd,
-       "debug bgp",
+  if (strncmp ("i", argv[0], 1) == 0)
+    inbound = 1;
+  else
+    inbound = 0;
+
+  if (inbound && bgp_debug_update_in_peers &&
+      !list_isempty(bgp_debug_update_in_peers))
+    {
+      found_peer = bgp_debug_list_remove_entry(bgp_debug_update_in_peers, peer, NULL);
+
+      if (list_isempty(bgp_debug_update_in_peers))
+        {
+          if (vty->node == CONFIG_NODE)
+            DEBUG_OFF (update, UPDATE_IN);
+          else
+            {
+              TERM_DEBUG_OFF (update, UPDATE_IN);
+              vty_out (vty, "BGP updates debugging (inbound) is off%s", VTY_NEWLINE);
+            }
+        }
+    }
+
+  if (!inbound && bgp_debug_update_out_peers &&
+      !list_isempty(bgp_debug_update_out_peers))
+    {
+      found_peer = bgp_debug_list_remove_entry(bgp_debug_update_out_peers, peer, NULL);
+
+      if (list_isempty(bgp_debug_update_out_peers))
+        {
+          if (vty->node == CONFIG_NODE)
+            DEBUG_OFF (update, UPDATE_OUT);
+          else
+            {
+              TERM_DEBUG_OFF (update, UPDATE_OUT);
+              vty_out (vty, "BGP updates debugging (outbound) is off%s", VTY_NEWLINE);
+            }
+        }
+    }
+
+  if (found_peer)
+    if (inbound)
+      vty_out (vty, "BGP updates debugging (inbound) is off for %s%s", argv[1], VTY_NEWLINE);
+    else
+      vty_out (vty, "BGP updates debugging (outbound) is off for %s%s", argv[1], VTY_NEWLINE);
+  else
+    if (inbound)
+      vty_out (vty, "BGP updates debugging (inbound) was not enabled for %s%s", argv[1], VTY_NEWLINE);
+    else
+      vty_out (vty, "BGP updates debugging (outbound) was not enabled for %s%s", argv[1], VTY_NEWLINE);
+
+  return CMD_SUCCESS;
+}
+
+DEFUN (debug_bgp_update_prefix,
+       debug_bgp_update_prefix_cmd,
+       "debug bgp updates prefix (A.B.C.D/M|X:X::X:X/M)",
        DEBUG_STR
-       BGP_STR)
+       BGP_STR
+       "BGP updates\n"
+       "Specify a prefix to debug\n"
+       "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
+       "IPv6 prefix <network>/<length>\n")
+
 {
+  struct prefix *argv_p;
+  int ret;
+
+  argv_p = prefix_new();
+  ret = str2prefix (argv[0], argv_p);
+  if (!ret)
+    {
+      prefix_free(argv_p);
+      vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
+      return CMD_WARNING;
+    }
+
+
+  if (!bgp_debug_update_prefixes)
+    bgp_debug_update_prefixes = list_new ();
+
+  if (bgp_debug_list_has_entry(bgp_debug_update_prefixes, NULL, argv_p))
+    {
+      vty_out (vty, "BGP updates debugging is already enabled for %s%s", argv[0], VTY_NEWLINE);
+      return CMD_SUCCESS;
+    }
+
+  bgp_debug_list_add_entry(bgp_debug_update_prefixes, NULL, argv_p);
+
   if (vty->node == CONFIG_NODE)
-    DEBUG_ON (normal, NORMAL);
+    {
+      DEBUG_ON (update, UPDATE_PREFIX);
+    }
   else
     {
-      TERM_DEBUG_ON (normal, NORMAL);
-      vty_out (vty, "BGP debugging is on%s", VTY_NEWLINE);
+      TERM_DEBUG_ON (update, UPDATE_PREFIX);
+      vty_out (vty, "BGP updates debugging is on for %s%s", argv[0], VTY_NEWLINE);
     }
+
   return CMD_SUCCESS;
 }
 
-DEFUN (no_debug_bgp_normal,
-       no_debug_bgp_normal_cmd,
-       "no debug bgp",
+DEFUN (no_debug_bgp_update_prefix,
+       no_debug_bgp_update_prefix_cmd,
+       "no debug bgp updates prefix (A.B.C.D/M|X:X::X:X/M)",
        NO_STR
        DEBUG_STR
-       BGP_STR)
+       BGP_STR
+       "BGP updates\n"
+       "Specify a prefix to debug\n"
+       "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
+       "IPv6 prefix <network>/<length>\n")
+
+{
+  struct prefix *argv_p;
+  int found_prefix = 0;
+  int ret;
+
+  argv_p = prefix_new();
+  ret = str2prefix (argv[0], argv_p);
+  if (!ret)
+    {
+      prefix_free(argv_p);
+      vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
+      return CMD_WARNING;
+    }
+
+  if (bgp_debug_update_prefixes && !list_isempty(bgp_debug_update_prefixes))
+    {
+      found_prefix = bgp_debug_list_remove_entry(bgp_debug_update_prefixes, NULL, argv_p);
+
+      if (list_isempty(bgp_debug_update_prefixes))
+        {
+          if (vty->node == CONFIG_NODE)
+            {
+              DEBUG_OFF (update, UPDATE_PREFIX);
+            }
+          else
+            {
+              TERM_DEBUG_OFF (update, UPDATE_PREFIX);
+              vty_out (vty, "BGP updates debugging (per prefix) is off%s", VTY_NEWLINE);
+            }
+        }
+    }
+
+  if (found_prefix)
+    vty_out (vty, "BGP updates debugging is off for %s%s", argv[0], VTY_NEWLINE);
+  else
+    vty_out (vty, "BGP updates debugging was not enabled for %s%s", argv[0], VTY_NEWLINE);
+
+  return CMD_SUCCESS;
+}
+
+DEFUN (no_debug_bgp_update,
+       no_debug_bgp_update_cmd,
+       "no debug bgp updates",
+       NO_STR
+       DEBUG_STR
+       BGP_STR
+       "BGP updates\n")
 {
+  bgp_debug_list_free(bgp_debug_update_in_peers);
+  bgp_debug_list_free(bgp_debug_update_out_peers);
+  bgp_debug_list_free(bgp_debug_update_prefixes);
+
   if (vty->node == CONFIG_NODE)
-    DEBUG_OFF (normal, NORMAL);
+    {
+      DEBUG_OFF (update, UPDATE_IN);
+      DEBUG_OFF (update, UPDATE_OUT);
+      DEBUG_OFF (update, UPDATE_PREFIX);
+    }
   else
     {
-      TERM_DEBUG_OFF (normal, NORMAL);
-      vty_out (vty, "BGP debugging is off%s", VTY_NEWLINE);
+      TERM_DEBUG_OFF (update, UPDATE_IN);
+      TERM_DEBUG_OFF (update, UPDATE_OUT);
+      TERM_DEBUG_OFF (update, UPDATE_PREFIX);
+      vty_out (vty, "BGP updates debugging is off%s", VTY_NEWLINE);
     }
   return CMD_SUCCESS;
 }
 
-ALIAS (no_debug_bgp_normal,
-       undebug_bgp_normal_cmd,
-       "undebug bgp",
-       UNDEBUG_STR
-       BGP_STR)
-
+/* debug bgp zebra */
 DEFUN (debug_bgp_zebra,
        debug_bgp_zebra_cmd,
        "debug bgp zebra",
@@ -745,6 +1167,51 @@ DEFUN (debug_bgp_zebra,
   return CMD_SUCCESS;
 }
 
+DEFUN (debug_bgp_zebra_prefix,
+       debug_bgp_zebra_prefix_cmd,
+       "debug bgp zebra prefix (A.B.C.D/M|X:X::X:X/M)",
+       DEBUG_STR
+       BGP_STR
+       "BGP Zebra messages\n"
+       "Specify a prefix to debug\n"
+       "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
+       "IPv6 prefix <network>/<length>\n")
+
+{
+  struct prefix *argv_p;
+  int ret;
+
+  argv_p = prefix_new();
+  ret = str2prefix (argv[0], argv_p);
+  if (!ret)
+    {
+      prefix_free(argv_p);
+      vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
+      return CMD_WARNING;
+    }
+
+  if (!bgp_debug_zebra_prefixes)
+    bgp_debug_zebra_prefixes = list_new();
+
+  if (bgp_debug_list_has_entry(bgp_debug_zebra_prefixes, NULL, argv_p))
+    {
+      vty_out (vty, "BGP zebra debugging is already enabled for %s%s", argv[0], VTY_NEWLINE);
+      return CMD_SUCCESS;
+    }
+
+  bgp_debug_list_add_entry(bgp_debug_zebra_prefixes, NULL, argv_p);
+
+  if (vty->node == CONFIG_NODE)
+    DEBUG_ON (zebra, ZEBRA);
+  else
+    {
+      TERM_DEBUG_ON (zebra, ZEBRA);
+      vty_out (vty, "BGP zebra debugging is on for %s%s", argv[0], VTY_NEWLINE);
+    }
+
+  return CMD_SUCCESS;
+}
+
 DEFUN (no_debug_bgp_zebra,
        no_debug_bgp_zebra_cmd,
        "no debug bgp zebra",
@@ -753,6 +1220,8 @@ DEFUN (no_debug_bgp_zebra,
        BGP_STR
        "BGP Zebra messages\n")
 {
+  bgp_debug_list_free(bgp_debug_zebra_prefixes);
+
   if (vty->node == CONFIG_NODE)
     DEBUG_OFF (zebra, ZEBRA);
   else
@@ -763,43 +1232,82 @@ DEFUN (no_debug_bgp_zebra,
   return CMD_SUCCESS;
 }
 
-ALIAS (no_debug_bgp_zebra,
-       undebug_bgp_zebra_cmd,
-       "undebug bgp zebra",
-       UNDEBUG_STR
+DEFUN (no_debug_bgp_zebra_prefix,
+       no_debug_bgp_zebra_prefix_cmd,
+       "no debug bgp zebra prefix (A.B.C.D/M|X:X::X:X/M)",
+       NO_STR
+       DEBUG_STR
        BGP_STR
-       "BGP Zebra messages\n")
+       "BGP Zebra messages\n"
+       "Specify a prefix to debug\n"
+       "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
+       "IPv6 prefix <network>/<length>\n")
+
+{
+  struct prefix *argv_p;
+  int found_prefix = 0;
+  int ret;
+
+  argv_p = prefix_new();
+  ret = str2prefix (argv[0], argv_p);
+  if (!ret)
+    {
+      prefix_free(argv_p);
+      vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
+      return CMD_WARNING;
+    }
+
+  if (bgp_debug_zebra_prefixes && !list_isempty(bgp_debug_zebra_prefixes))
+    {
+      found_prefix = bgp_debug_list_remove_entry(bgp_debug_neighbor_events_peers, NULL, argv_p);
+
+      if (list_isempty(bgp_debug_zebra_prefixes))
+        {
+          if (vty->node == CONFIG_NODE)
+            DEBUG_OFF (zebra, ZEBRA);
+          else
+            {
+              TERM_DEBUG_OFF (zebra, ZEBRA);
+              vty_out (vty, "BGP zebra debugging is off%s", VTY_NEWLINE);
+            }
+        }
+    }
 
-DEFUN (no_debug_bgp_all,
-       no_debug_bgp_all_cmd,
-       "no debug all bgp",
+  if (found_prefix)
+    vty_out (vty, "BGP zebra debugging is off for %s%s", argv[0], VTY_NEWLINE);
+  else
+    vty_out (vty, "BGP zebra debugging was not enabled for %s%s", argv[0], VTY_NEWLINE);
+
+  return CMD_SUCCESS;
+}
+
+DEFUN (no_debug_bgp,
+       no_debug_bgp_cmd,
+       "no debug bgp",
        NO_STR
        DEBUG_STR
-       "Enable all debugging\n"
        BGP_STR)
 {
-  TERM_DEBUG_OFF (normal, NORMAL);
-  TERM_DEBUG_OFF (events, EVENTS);
+  bgp_debug_list_free(bgp_debug_neighbor_events_peers);
+  bgp_debug_list_free(bgp_debug_keepalive_peers);
+  bgp_debug_list_free(bgp_debug_update_in_peers);
+  bgp_debug_list_free(bgp_debug_update_out_peers);
+  bgp_debug_list_free(bgp_debug_update_prefixes);
+  bgp_debug_list_free(bgp_debug_zebra_prefixes);
+
   TERM_DEBUG_OFF (keepalive, KEEPALIVE);
   TERM_DEBUG_OFF (update, UPDATE_IN);
   TERM_DEBUG_OFF (update, UPDATE_OUT);
+  TERM_DEBUG_OFF (update, UPDATE_PREFIX);
   TERM_DEBUG_OFF (as4, AS4);
   TERM_DEBUG_OFF (as4, AS4_SEGMENT);
-  TERM_DEBUG_OFF (fsm, FSM);
-  TERM_DEBUG_OFF (filter, FILTER);
+  TERM_DEBUG_OFF (neighbor_events, NEIGHBOR_EVENTS);
   TERM_DEBUG_OFF (zebra, ZEBRA);
   vty_out (vty, "All possible debugging has been turned off%s", VTY_NEWLINE);
       
   return CMD_SUCCESS;
 }
 
-ALIAS (no_debug_bgp_all,
-       undebug_bgp_all_cmd,
-       "undebug all bgp",
-       UNDEBUG_STR
-       "Enable all debugging\n"
-       BGP_STR)
-
 DEFUN (show_debugging_bgp,
        show_debugging_bgp_cmd,
        "show debugging bgp",
@@ -809,30 +1317,39 @@ DEFUN (show_debugging_bgp,
 {
   vty_out (vty, "BGP debugging status:%s", VTY_NEWLINE);
 
-  if (BGP_DEBUG (normal, NORMAL))
-    vty_out (vty, "  BGP debugging is on%s", VTY_NEWLINE);
-  if (BGP_DEBUG (events, EVENTS))
-    vty_out (vty, "  BGP events debugging is on%s", VTY_NEWLINE);
-  if (BGP_DEBUG (keepalive, KEEPALIVE))
-    vty_out (vty, "  BGP keepalives debugging is on%s", VTY_NEWLINE);
-  if (BGP_DEBUG (update, UPDATE_IN) && BGP_DEBUG (update, UPDATE_OUT))
-    vty_out (vty, "  BGP updates debugging is on%s", VTY_NEWLINE);
-  else if (BGP_DEBUG (update, UPDATE_IN))
-    vty_out (vty, "  BGP updates debugging is on (inbound)%s", VTY_NEWLINE);
-  else if (BGP_DEBUG (update, UPDATE_OUT))
-    vty_out (vty, "  BGP updates debugging is on (outbound)%s", VTY_NEWLINE);
-  if (BGP_DEBUG (fsm, FSM))
-    vty_out (vty, "  BGP fsm debugging is on%s", VTY_NEWLINE);
-  if (BGP_DEBUG (filter, FILTER))
-    vty_out (vty, "  BGP filter debugging is on%s", VTY_NEWLINE);
-  if (BGP_DEBUG (zebra, ZEBRA))
-    vty_out (vty, "  BGP zebra debugging is on%s", VTY_NEWLINE);
   if (BGP_DEBUG (as4, AS4))
     vty_out (vty, "  BGP as4 debugging is on%s", VTY_NEWLINE);
+
   if (BGP_DEBUG (as4, AS4_SEGMENT))
     vty_out (vty, "  BGP as4 aspath segment debugging is on%s", VTY_NEWLINE);
+
+  if (BGP_DEBUG (neighbor_events, NEIGHBOR_EVENTS))
+    bgp_debug_list_print (vty, "  BGP neighbor-events debugging is on",
+                          bgp_debug_neighbor_events_peers);
+
+  if (BGP_DEBUG (keepalive, KEEPALIVE))
+    bgp_debug_list_print (vty, "  BGP keepalives debugging is on",
+                          bgp_debug_keepalive_peers);
+
   if (BGP_DEBUG (nht, NHT))
     vty_out (vty, "  BGP next-hop tracking debugging is on%s", VTY_NEWLINE);
+
+  if (BGP_DEBUG (update, UPDATE_PREFIX))
+    bgp_debug_list_print (vty, "  BGP updates debugging is on for",
+                          bgp_debug_update_prefixes);
+
+  if (BGP_DEBUG (update, UPDATE_IN))
+    bgp_debug_list_print (vty, "  BGP updates debugging is on (inbound)",
+                          bgp_debug_update_in_peers);
+
+  if (BGP_DEBUG (update, UPDATE_OUT))
+    bgp_debug_list_print (vty, "  BGP updates debugging is on (outbound)",
+                          bgp_debug_update_out_peers);
+
+  if (BGP_DEBUG (zebra, ZEBRA))
+    bgp_debug_list_print (vty, "  BGP zebra debugging is on",
+                          bgp_debug_zebra_prefixes);
+
   vty_out (vty, "%s", VTY_NEWLINE);
   return CMD_SUCCESS;
 }
@@ -842,12 +1359,6 @@ bgp_config_write_debug (struct vty *vty)
 {
   int write = 0;
 
-  if (CONF_BGP_DEBUG (normal, NORMAL))
-    {
-      vty_out (vty, "debug bgp%s", VTY_NEWLINE);
-      write++;
-    }
-
   if (CONF_BGP_DEBUG (as4, AS4))
     {
       vty_out (vty, "debug bgp as4%s", VTY_NEWLINE);
@@ -860,12 +1371,6 @@ bgp_config_write_debug (struct vty *vty)
       write++;
     }
 
-  if (CONF_BGP_DEBUG (events, EVENTS))
-    {
-      vty_out (vty, "debug bgp events%s", VTY_NEWLINE);
-      write++;
-    }
-
   if (CONF_BGP_DEBUG (keepalive, KEEPALIVE))
     {
       vty_out (vty, "debug bgp keepalives%s", VTY_NEWLINE);
@@ -888,15 +1393,9 @@ bgp_config_write_debug (struct vty *vty)
       write++;
     }
 
-  if (CONF_BGP_DEBUG (fsm, FSM))
+  if (CONF_BGP_DEBUG (neighbor_events, NEIGHBOR_EVENTS))
     {
-      vty_out (vty, "debug bgp fsm%s", VTY_NEWLINE);
-      write++;
-    }
-
-  if (CONF_BGP_DEBUG (filter, FILTER))
-    {
-      vty_out (vty, "debug bgp filters%s", VTY_NEWLINE);
+      vty_out (vty, "debug bgp neighbor-events%s", VTY_NEWLINE);
       write++;
     }
 
@@ -934,56 +1433,189 @@ bgp_debug_init (void)
   install_element (ENABLE_NODE, &debug_bgp_as4_segment_cmd);
   install_element (CONFIG_NODE, &debug_bgp_as4_segment_cmd);
 
-  install_element (ENABLE_NODE, &debug_bgp_fsm_cmd);
-  install_element (CONFIG_NODE, &debug_bgp_fsm_cmd);
-  install_element (ENABLE_NODE, &debug_bgp_events_cmd);
-  install_element (CONFIG_NODE, &debug_bgp_events_cmd);
+  install_element (ENABLE_NODE, &debug_bgp_neighbor_events_cmd);
+  install_element (CONFIG_NODE, &debug_bgp_neighbor_events_cmd);
   install_element (ENABLE_NODE, &debug_bgp_nht_cmd);
   install_element (CONFIG_NODE, &debug_bgp_nht_cmd);
-  install_element (ENABLE_NODE, &debug_bgp_filter_cmd);
-  install_element (CONFIG_NODE, &debug_bgp_filter_cmd);
   install_element (ENABLE_NODE, &debug_bgp_keepalive_cmd);
   install_element (CONFIG_NODE, &debug_bgp_keepalive_cmd);
   install_element (ENABLE_NODE, &debug_bgp_update_cmd);
   install_element (CONFIG_NODE, &debug_bgp_update_cmd);
   install_element (ENABLE_NODE, &debug_bgp_update_direct_cmd);
   install_element (CONFIG_NODE, &debug_bgp_update_direct_cmd);
-  install_element (ENABLE_NODE, &debug_bgp_normal_cmd);
-  install_element (CONFIG_NODE, &debug_bgp_normal_cmd);
   install_element (ENABLE_NODE, &debug_bgp_zebra_cmd);
   install_element (CONFIG_NODE, &debug_bgp_zebra_cmd);
 
+  /* deb bgp updates [in|out] A.B.C.D */
+  install_element (ENABLE_NODE, &debug_bgp_update_direct_peer_cmd);
+  install_element (CONFIG_NODE, &debug_bgp_update_direct_peer_cmd);
+  install_element (ENABLE_NODE, &no_debug_bgp_update_direct_peer_cmd);
+  install_element (CONFIG_NODE, &no_debug_bgp_update_direct_peer_cmd);
+
+  /* deb bgp updates prefix A.B.C.D/M */
+  install_element (ENABLE_NODE, &debug_bgp_update_prefix_cmd);
+  install_element (CONFIG_NODE, &debug_bgp_update_prefix_cmd);
+  install_element (ENABLE_NODE, &no_debug_bgp_update_prefix_cmd);
+  install_element (CONFIG_NODE, &no_debug_bgp_update_prefix_cmd);
+
+  /* deb bgp zebra prefix A.B.C.D/M */
+  install_element (ENABLE_NODE, &debug_bgp_zebra_prefix_cmd);
+  install_element (CONFIG_NODE, &debug_bgp_zebra_prefix_cmd);
+  install_element (ENABLE_NODE, &no_debug_bgp_zebra_prefix_cmd);
+  install_element (CONFIG_NODE, &no_debug_bgp_zebra_prefix_cmd);
+
   install_element (ENABLE_NODE, &no_debug_bgp_as4_cmd);
-  install_element (ENABLE_NODE, &undebug_bgp_as4_cmd);
   install_element (CONFIG_NODE, &no_debug_bgp_as4_cmd);
   install_element (ENABLE_NODE, &no_debug_bgp_as4_segment_cmd);
-  install_element (ENABLE_NODE, &undebug_bgp_as4_segment_cmd);
   install_element (CONFIG_NODE, &no_debug_bgp_as4_segment_cmd);
 
-  install_element (ENABLE_NODE, &no_debug_bgp_fsm_cmd);
-  install_element (ENABLE_NODE, &undebug_bgp_fsm_cmd);
-  install_element (CONFIG_NODE, &no_debug_bgp_fsm_cmd);
-  install_element (ENABLE_NODE, &no_debug_bgp_events_cmd);
-  install_element (ENABLE_NODE, &undebug_bgp_events_cmd);
-  install_element (CONFIG_NODE, &no_debug_bgp_events_cmd);
+  /* deb bgp neighbor-events A.B.C.D */
+  install_element (ENABLE_NODE, &debug_bgp_neighbor_events_peer_cmd);
+  install_element (CONFIG_NODE, &debug_bgp_neighbor_events_peer_cmd);
+  install_element (ENABLE_NODE, &no_debug_bgp_neighbor_events_peer_cmd);
+  install_element (CONFIG_NODE, &no_debug_bgp_neighbor_events_peer_cmd);
+
+  /* deb bgp keepalive A.B.C.D */
+  install_element (ENABLE_NODE, &debug_bgp_keepalive_peer_cmd);
+  install_element (CONFIG_NODE, &debug_bgp_keepalive_peer_cmd);
+  install_element (ENABLE_NODE, &no_debug_bgp_keepalive_peer_cmd);
+  install_element (CONFIG_NODE, &no_debug_bgp_keepalive_peer_cmd);
+
+  install_element (ENABLE_NODE, &no_debug_bgp_neighbor_events_cmd);
+  install_element (CONFIG_NODE, &no_debug_bgp_neighbor_events_cmd);
   install_element (ENABLE_NODE, &no_debug_bgp_nht_cmd);
-  install_element (ENABLE_NODE, &undebug_bgp_nht_cmd);
   install_element (CONFIG_NODE, &no_debug_bgp_nht_cmd);
-  install_element (ENABLE_NODE, &no_debug_bgp_filter_cmd);
-  install_element (ENABLE_NODE, &undebug_bgp_filter_cmd);
-  install_element (CONFIG_NODE, &no_debug_bgp_filter_cmd);
   install_element (ENABLE_NODE, &no_debug_bgp_keepalive_cmd);
-  install_element (ENABLE_NODE, &undebug_bgp_keepalive_cmd);
   install_element (CONFIG_NODE, &no_debug_bgp_keepalive_cmd);
   install_element (ENABLE_NODE, &no_debug_bgp_update_cmd);
-  install_element (ENABLE_NODE, &undebug_bgp_update_cmd);
   install_element (CONFIG_NODE, &no_debug_bgp_update_cmd);
-  install_element (ENABLE_NODE, &no_debug_bgp_normal_cmd);
-  install_element (ENABLE_NODE, &undebug_bgp_normal_cmd);
-  install_element (CONFIG_NODE, &no_debug_bgp_normal_cmd);
   install_element (ENABLE_NODE, &no_debug_bgp_zebra_cmd);
-  install_element (ENABLE_NODE, &undebug_bgp_zebra_cmd);
   install_element (CONFIG_NODE, &no_debug_bgp_zebra_cmd);
-  install_element (ENABLE_NODE, &no_debug_bgp_all_cmd);
-  install_element (ENABLE_NODE, &undebug_bgp_all_cmd);
+  install_element (ENABLE_NODE, &no_debug_bgp_cmd);
+}
+
+/* Return true if this prefix is on the per_prefix_list of prefixes to debug
+ * for BGP_DEBUG_TYPE
+ */
+static int
+bgp_debug_per_prefix (struct prefix *p, unsigned long term_bgp_debug_type,
+                      unsigned int BGP_DEBUG_TYPE, struct list *per_prefix_list)
+{
+  struct bgp_debug_filter *filter;
+  struct listnode *node, *nnode;
+
+  if (term_bgp_debug_type & BGP_DEBUG_TYPE)
+    {
+      /* We are debugging all prefixes so return true */
+      if (!per_prefix_list || list_isempty(per_prefix_list))
+        return 1;
+
+      else
+        {
+          if (!p)
+            return 0;
+
+          for (ALL_LIST_ELEMENTS (per_prefix_list, node, nnode, filter))
+            if (filter->p->prefixlen == p->prefixlen && prefix_match(filter->p, p))
+              return 1;
+
+          return 0;
+        }
+    }
+
+  return 0;
+}
+
+/* Return true if this peer is on the per_peer_list of peers to debug
+ * for BGP_DEBUG_TYPE
+ */
+static int
+bgp_debug_per_peer(struct peer *peer, unsigned long term_bgp_debug_type,
+                   unsigned int BGP_DEBUG_TYPE, struct list *per_peer_list)
+{
+  struct bgp_debug_filter *filter;
+  struct listnode *node, *nnode;
+
+  if (term_bgp_debug_type & BGP_DEBUG_TYPE)
+    {
+      /* We are debugging all peers so return true */
+      if (!per_peer_list || list_isempty(per_peer_list))
+        return 1;
+
+      else
+        {
+          if (!peer)
+            return 0;
+
+          for (ALL_LIST_ELEMENTS (per_peer_list, node, nnode, filter))
+            if (filter->peer == peer)
+              return 1;
+
+          return 0;
+        }
+    }
+
+  return 0;
+}
+
+int
+bgp_debug_neighbor_events (struct peer *peer)
+{
+  return bgp_debug_per_peer (peer,
+                             term_bgp_debug_neighbor_events,
+                             BGP_DEBUG_NEIGHBOR_EVENTS,
+                             bgp_debug_neighbor_events_peers);
+}
+
+int
+bgp_debug_keepalive (struct peer *peer)
+{
+  return bgp_debug_per_peer (peer,
+                             term_bgp_debug_keepalive,
+                             BGP_DEBUG_KEEPALIVE,
+                             bgp_debug_keepalive_peers);
+}
+
+int
+bgp_debug_update (struct peer *peer, struct prefix *p, unsigned int inbound)
+{
+  if (inbound)
+    {
+      if (bgp_debug_per_peer (peer, term_bgp_debug_update, BGP_DEBUG_UPDATE_IN,
+                              bgp_debug_update_in_peers))
+        return 1;
+    }
+
+  /* outbound */
+  else
+    {
+      if (bgp_debug_per_peer (peer, term_bgp_debug_update,
+                              BGP_DEBUG_UPDATE_OUT,
+                              bgp_debug_update_out_peers))
+        return 1;
+    }
+
+
+  if (BGP_DEBUG (update, UPDATE_PREFIX))
+    {
+      if (bgp_debug_per_prefix (p, term_bgp_debug_update,
+                                BGP_DEBUG_UPDATE_PREFIX,
+                                bgp_debug_update_prefixes))
+        return 1;
+    }
+
+  return 0;
+}
+
+int
+bgp_debug_zebra (struct prefix *p)
+{
+  if (BGP_DEBUG (zebra, ZEBRA))
+    {
+      if (bgp_debug_per_prefix (p, term_bgp_debug_zebra, BGP_DEBUG_ZEBRA,
+                                bgp_debug_zebra_prefixes))
+        return 1;
+    }
+
+  return 0;
 }
index 0090f814a97f56c0eb9219b1c81a2bd5ee51cff0..b8ad7b9cfa69ed5fa4276721677b64a1dd93c836 100644 (file)
@@ -59,47 +59,49 @@ extern void bgp_packet_dump (struct stream *);
 extern int debug (unsigned int option);
 
 extern unsigned long conf_bgp_debug_as4;
-extern unsigned long conf_bgp_debug_fsm;
-extern unsigned long conf_bgp_debug_events;
+extern unsigned long conf_bgp_debug_neighbor_events;
 extern unsigned long conf_bgp_debug_packet;
-extern unsigned long conf_bgp_debug_filter;
 extern unsigned long conf_bgp_debug_keepalive;
 extern unsigned long conf_bgp_debug_update;
-extern unsigned long conf_bgp_debug_normal;
 extern unsigned long conf_bgp_debug_zebra;
 extern unsigned long conf_bgp_debug_nht;
 
 extern unsigned long term_bgp_debug_as4;
-extern unsigned long term_bgp_debug_fsm;
-extern unsigned long term_bgp_debug_events;
+extern unsigned long term_bgp_debug_neighbor_events;
 extern unsigned long term_bgp_debug_packet;
-extern unsigned long term_bgp_debug_filter;
 extern unsigned long term_bgp_debug_keepalive;
 extern unsigned long term_bgp_debug_update;
-extern unsigned long term_bgp_debug_normal;
 extern unsigned long term_bgp_debug_zebra;
 extern unsigned long term_bgp_debug_nht;
 
+extern struct list *bgp_debug_neighbor_events_peers;
+extern struct list *bgp_debug_keepalive_peers;
+extern struct list *bgp_debug_update_in_peers;
+extern struct list *bgp_debug_update_out_peers;
+extern struct list *bgp_debug_update_prefixes;
+extern struct list *bgp_debug_zebra_prefixes;
+
+struct bgp_debug_filter
+{
+  struct peer *peer;
+  struct prefix *p;
+};
+
 #define BGP_DEBUG_AS4                 0x01
 #define BGP_DEBUG_AS4_SEGMENT         0x02
 
-#define BGP_DEBUG_FSM                 0x01
-#define BGP_DEBUG_EVENTS              0x01
+#define BGP_DEBUG_NEIGHBOR_EVENTS     0x01
 #define BGP_DEBUG_PACKET              0x01
-#define BGP_DEBUG_FILTER              0x01
 #define BGP_DEBUG_KEEPALIVE           0x01
 #define BGP_DEBUG_UPDATE_IN           0x01
 #define BGP_DEBUG_UPDATE_OUT          0x02
-#define BGP_DEBUG_NORMAL              0x01
+#define BGP_DEBUG_UPDATE_PREFIX       0x04
 #define BGP_DEBUG_ZEBRA               0x01
 #define BGP_DEBUG_NHT                 0x01
 
 #define BGP_DEBUG_PACKET_SEND         0x01
 #define BGP_DEBUG_PACKET_SEND_DETAIL  0x02
 
-#define BGP_DEBUG_PACKET_RECV         0x01
-#define BGP_DEBUG_PACKET_RECV_DETAIL  0x02
-
 #define CONF_DEBUG_ON(a, b)    (conf_bgp_debug_ ## a |= (BGP_DEBUG_ ## b))
 #define CONF_DEBUG_OFF(a, b)   (conf_bgp_debug_ ## a &= ~(BGP_DEBUG_ ## b))
 
@@ -127,5 +129,9 @@ extern void bgp_notify_print (struct peer *, struct bgp_notify *, const char *);
 
 extern const struct message bgp_status_msg[];
 extern const int bgp_status_msg_max;
+extern int bgp_debug_neighbor_events(struct peer *peer);
+extern int bgp_debug_keepalive(struct peer *peer);
+extern int bgp_debug_update(struct peer *peer, struct prefix *p, unsigned int inbound);
+extern int bgp_debug_zebra(struct prefix *p);
 
 #endif /* _QUAGGA_BGP_DEBUG_H */
index 1a392b2b11975c517c00635e136d92d722145563..f70ad25aac4a43c33ba6506d9c82ef83eef7784d 100644 (file)
@@ -314,9 +314,8 @@ bgp_start_timer (struct thread *thread)
   peer = THREAD_ARG (thread);
   peer->t_start = NULL;
 
-  if (BGP_DEBUG (fsm, FSM))
-    zlog (peer->log, LOG_DEBUG,
-         "%s [FSM] Timer (start timer expire).", peer->host);
+  if (bgp_debug_neighbor_events(peer))
+    zlog_debug("%s [FSM] Timer (start timer expire).", peer->host);
 
   THREAD_VAL (thread) = BGP_Start;
   bgp_event (thread);  /* bgp_event unlocks peer */
@@ -334,9 +333,8 @@ bgp_connect_timer (struct thread *thread)
   peer = THREAD_ARG (thread);
   peer->t_connect = NULL;
 
-  if (BGP_DEBUG (fsm, FSM))
-    zlog (peer->log, LOG_DEBUG, "%s [FSM] Timer (connect timer expire)",
-         peer->host);
+  if (bgp_debug_neighbor_events(peer))
+    zlog_debug("%s [FSM] Timer (connect timer expire)", peer->host);
 
   if (CHECK_FLAG(peer->sflags, PEER_STATUS_ACCEPT_PEER))
     {
@@ -362,10 +360,8 @@ bgp_holdtime_timer (struct thread *thread)
   peer = THREAD_ARG (thread);
   peer->t_holdtime = NULL;
 
-  if (BGP_DEBUG (fsm, FSM))
-    zlog (peer->log, LOG_DEBUG,
-         "%s [FSM] Timer (holdtime timer expire)",
-         peer->host);
+  if (bgp_debug_neighbor_events(peer))
+    zlog_debug ("%s [FSM] Timer (holdtime timer expire)", peer->host);
 
   THREAD_VAL (thread) = Hold_Timer_expired;
   bgp_event (thread); /* bgp_event unlocks peer */
@@ -382,10 +378,8 @@ bgp_keepalive_timer (struct thread *thread)
   peer = THREAD_ARG (thread);
   peer->t_keepalive = NULL;
 
-  if (BGP_DEBUG (fsm, FSM))
-    zlog (peer->log, LOG_DEBUG,
-         "%s [FSM] Timer (keepalive timer expire)",
-         peer->host);
+  if (bgp_debug_neighbor_events(peer))
+    zlog_debug ("%s [FSM] Timer (keepalive timer expire)", peer->host);
 
   THREAD_VAL (thread) = KeepAlive_timer_expired;
   bgp_event (thread); /* bgp_event unlocks peer */
@@ -418,10 +412,8 @@ bgp_routeadv_timer (struct thread *thread)
   peer->t_routeadv = NULL;
   peer->radv_adjusted = 0;
 
-  if (BGP_DEBUG (fsm, FSM))
-    zlog (peer->log, LOG_DEBUG,
-         "%s [FSM] Timer (routeadv timer expire)",
-         peer->host);
+  if (bgp_debug_neighbor_events(peer))
+    zlog_debug ("%s [FSM] Timer (routeadv timer expire)", peer->host);
 
   peer->synctime = bgp_clock ();
 
@@ -481,7 +473,7 @@ bgp_graceful_restart_timer_expire (struct thread *thread)
   UNSET_FLAG (peer->sflags, PEER_STATUS_NSF_WAIT);
   BGP_TIMER_OFF (peer->t_gr_stale);
 
-  if (BGP_DEBUG (events, EVENTS))
+  if (bgp_debug_neighbor_events(peer))
     {
       zlog_debug ("%s graceful restart timer expired", peer->host);
       zlog_debug ("%s graceful restart stalepath timer stopped", peer->host);
@@ -502,7 +494,7 @@ bgp_graceful_stale_timer_expire (struct thread *thread)
   peer = THREAD_ARG (thread);
   peer->t_gr_stale = NULL;
 
-  if (BGP_DEBUG (events, EVENTS))
+  if (bgp_debug_neighbor_events(peer))
     zlog_debug ("%s graceful restart stalepath timer expired", peer->host);
 
   /* NSF delete stale route */
@@ -663,9 +655,8 @@ bgp_adjust_routeadv (struct peer *peer)
     {
       BGP_TIMER_OFF(peer->t_routeadv);
       BGP_TIMER_ON(peer->t_routeadv, bgp_routeadv_timer, 0);
-      if (BGP_DEBUG (update, UPDATE_OUT))
-       zlog (peer->log, LOG_DEBUG, "%s: MRAI timer to expire instantly\n",
-             peer->host);
+      if (bgp_debug_update(peer, NULL, 0))
+       zlog_debug ("%s: MRAI timer to expire instantly", peer->host);
       return;
     }
 
@@ -694,9 +685,8 @@ bgp_adjust_routeadv (struct peer *peer)
     {
       BGP_TIMER_OFF(peer->t_routeadv);
       BGP_TIMER_ON(peer->t_routeadv, bgp_routeadv_timer, diff);
-      if (BGP_DEBUG (update, UPDATE_OUT))
-       zlog (peer->log, LOG_DEBUG, "%s: MRAI timer to expire in %f secs\n",
-             peer->host, diff);
+      if (bgp_debug_update(peer, NULL, 0))
+       zlog_debug ("%s: MRAI timer to expire in %f secs", peer->host, diff);
     }
 }
 
@@ -936,7 +926,7 @@ bgp_fsm_change_status (struct peer *peer, int status)
       bgp_update_delay_applicable(peer->bgp))
     bgp_update_delay_process_status_change(peer);
 
-  if (BGP_DEBUG (normal, NORMAL))
+  if (bgp_debug_neighbor_events(peer))
     zlog_debug ("%s went from %s to %s",
                peer->host,
                LOOKUP (bgp_status_msg, peer->ostatus),
@@ -986,12 +976,12 @@ bgp_stop (struct peer *peer)
       if (peer->t_gr_stale)
        {
          BGP_TIMER_OFF (peer->t_gr_stale);
-         if (BGP_DEBUG (events, EVENTS))
+          if (bgp_debug_neighbor_events(peer))
            zlog_debug ("%s graceful restart stalepath timer stopped", peer->host);
        }
       if (CHECK_FLAG (peer->sflags, PEER_STATUS_NSF_WAIT))
        {
-         if (BGP_DEBUG (events, EVENTS))
+          if (bgp_debug_neighbor_events(peer))
            {
              zlog_debug ("%s graceful restart timer started for %d sec",
                          peer->host, peer->v_gr_restart);
@@ -1170,7 +1160,7 @@ bgp_connect_success (struct peer *peer)
 
   BGP_READ_ON (peer->t_read, bgp_read, peer->fd);
 
-  if (BGP_DEBUG (normal, NORMAL))
+  if (bgp_debug_neighbor_events(peer))
     {
       char buf1[SU_ADDRSTRLEN];
 
@@ -1205,8 +1195,8 @@ bgp_start (struct peer *peer)
 
   if (BGP_PEER_START_SUPPRESSED (peer))
     {
-      if (BGP_DEBUG (fsm, FSM))
-        plog_err (peer->log, "%s [FSM] Trying to start suppressed peer"
+      if (bgp_debug_neighbor_events(peer))
+        zlog_err ("%s [FSM] Trying to start suppressed peer"
                   " - this is never supposed to happen!", peer->host);
       return -1;
     }
@@ -1251,21 +1241,21 @@ bgp_start (struct peer *peer)
   switch (status)
     {
     case connect_error:
-      if (BGP_DEBUG (fsm, FSM))
-       plog_debug (peer->log, "%s [FSM] Connect error", peer->host);
+      if (bgp_debug_neighbor_events(peer))
+       zlog_debug ("%s [FSM] Connect error", peer->host);
       BGP_EVENT_ADD (peer, TCP_connection_open_failed);
       break;
     case connect_success:
-      if (BGP_DEBUG (fsm, FSM))
-       plog_debug (peer->log, "%s [FSM] Connect immediately success",
+      if (bgp_debug_neighbor_events(peer))
+       zlog_debug ("%s [FSM] Connect immediately success",
                   peer->host);
       BGP_EVENT_ADD (peer, TCP_connection_open);
       break;
     case connect_in_progress:
       /* To check nonblocking connect, we wait until socket is
          readable or writable. */
-      if (BGP_DEBUG (fsm, FSM))
-       plog_debug (peer->log, "%s [FSM] Non blocking connect waiting result",
+      if (bgp_debug_neighbor_events(peer))
+       zlog_debug ("%s [FSM] Non blocking connect waiting result",
                   peer->host);
       if (peer->fd < 0)
        {
@@ -1326,7 +1316,7 @@ bgp_fsm_keepalive_expire (struct peer *peer)
 static int
 bgp_fsm_event_error (struct peer *peer)
 {
-  plog_err (peer->log, "%s [FSM] unexpected packet received in state %s",
+  zlog_err ("%s [FSM] unexpected packet received in state %s",
            peer->host, LOOKUP (bgp_status_msg, peer->status));
 
   return bgp_stop_with_notify (peer, BGP_NOTIFY_FSM_ERR, 0);
@@ -1337,8 +1327,8 @@ bgp_fsm_event_error (struct peer *peer)
 static int
 bgp_fsm_holdtime_expire (struct peer *peer)
 {
-  if (BGP_DEBUG (fsm, FSM))
-    plog_debug (peer->log, "%s [FSM] Hold timer expire", peer->host);
+  if (bgp_debug_neighbor_events(peer))
+    zlog_debug ("%s [FSM] Hold timer expire", peer->host);
 
   return bgp_stop_with_notify (peer, BGP_NOTIFY_HOLD_ERR, 0);
 }
@@ -1419,7 +1409,7 @@ bgp_establish (struct peer *peer)
       if (peer->t_gr_stale)
        {
          BGP_TIMER_OFF (peer->t_gr_stale);
-         if (BGP_DEBUG (events, EVENTS))
+          if (bgp_debug_neighbor_events(peer))
            zlog_debug ("%s graceful restart stalepath timer stopped", peer->host);
        }
     }
@@ -1427,7 +1417,7 @@ bgp_establish (struct peer *peer)
   if (peer->t_gr_restart)
     {
       BGP_TIMER_OFF (peer->t_gr_restart);
-      if (BGP_DEBUG (events, EVENTS))
+      if (bgp_debug_neighbor_events(peer))
        zlog_debug ("%s graceful restart timer stopped", peer->host);
     }
 
@@ -1470,7 +1460,7 @@ bgp_establish (struct peer *peer)
 
   if (peer->doppelganger && (peer->doppelganger->status != Deleted))
     {
-      if (BGP_DEBUG (events, EVENTS))
+      if (bgp_debug_neighbor_events(peer))
        zlog_debug("[Event] Deleting stub connection for peer %s", peer->host);
 
       if (peer->doppelganger->status > Active)
@@ -1508,8 +1498,8 @@ bgp_fsm_update (struct peer *peer)
 static int
 bgp_ignore (struct peer *peer)
 {
-  if (BGP_DEBUG (fsm, FSM))
-    zlog (peer->log, LOG_DEBUG, "%s [FSM] bgp_ignore called", peer->host);
+  if (bgp_debug_neighbor_events(peer))
+    zlog_debug ("%s [FSM] bgp_ignore called", peer->host);
   return 0;
 }
 
@@ -1747,8 +1737,8 @@ bgp_event_update (struct peer *peer, int event)
   /* Logging this event. */
   next = FSM [peer->status -1][event - 1].next_state;
 
-  if (BGP_DEBUG (fsm, FSM) && peer->status != next)
-    plog_debug (peer->log, "%s [FSM] %s (%s->%s)", peer->host,
+  if (bgp_debug_neighbor_events(peer) && peer->status != next)
+    zlog_debug ("%s [FSM] %s (%s->%s)", peer->host,
               bgp_event_str[event],
               LOOKUP (bgp_status_msg, peer->status),
               LOOKUP (bgp_status_msg, next));
index b9d114f4d0eacfdbf50e3d2bdc6752045de493a3..62fcb64d6aba23e916c2e04cc53bead2fb2b500b 100644 (file)
@@ -176,7 +176,7 @@ Report bugs to %s\n", progname, ZEBRA_BUG_ADDRESS);
 void 
 sighup (void)
 {
-  zlog (NULL, LOG_INFO, "SIGHUP received");
+  zlog_info ("SIGHUP received");
 
   /* Terminate all thread. */
   bgp_terminate ();
@@ -302,9 +302,6 @@ bgp_exit (int status)
   if (zlog_default)
     closezlog (zlog_default);
 
-  if (CONF_BGP_DEBUG (normal, NORMAL))
-    log_memstats_stderr ("bgpd");
-
   exit (status);
 }
 
index 5590b0513bc3a0c5f0c9ea79edfe8da98758700e..b354520ed87bba17ce0c61cfd7cff70db401bb1d 100644 (file)
@@ -412,7 +412,7 @@ bgp_info_mpath_update (struct bgp_node *rn, struct bgp_info *new_best,
   old_mpath_count = 0;
   prev_mpath = new_best;
   mp_node = listhead (mp_list);
-  debug = BGP_DEBUG (events, EVENTS);
+  debug = bgp_debug_update(NULL, &rn->p, 1) || bgp_debug_update(NULL, &rn->p, 0);
 
   if (debug)
     prefix2str (&rn->p, pfx_buf, sizeof (pfx_buf));
index 87ec784b37c7fe8a02eb7c9a7f676c3526cf4623..a36af72ff94ff5237e0f930d14c5b18d0f6fb11d 100644 (file)
@@ -67,8 +67,7 @@ bgp_md5_set_socket (int socket, union sockunion *su, const char *password)
 #endif /* HAVE_TCP_MD5SIG */
   
   if (ret < 0)
-    zlog (NULL, LOG_WARNING, "can't set TCP_MD5SIG option on socket %d: %s",
-          socket, safe_strerror (en));
+    zlog_warn ("can't set TCP_MD5SIG option on socket %d: %s", socket, safe_strerror (en));
 
   return ret;
 }
@@ -222,14 +221,11 @@ bgp_accept (struct thread *thread)
   /* Set socket send buffer size */
   bgp_update_sock_send_buffer_size(bgp_sock);
 
-  if (BGP_DEBUG (events, EVENTS))
-    zlog_debug ("[Event] BGP connection from host %s", inet_sutop (&su, buf));
-
   /* Check remote IP address */
   peer1 = peer_lookup (NULL, &su);
   if (! peer1)
     {
-      if (BGP_DEBUG (events, EVENTS))
+      if (bgp_debug_neighbor_events(peer))
        {
          zlog_debug ("[Event] BGP connection IP address %s is not configured",
                      inet_sutop (&su, buf));
@@ -240,8 +236,9 @@ bgp_accept (struct thread *thread)
 
   if (CHECK_FLAG(peer1->flags, PEER_FLAG_SHUTDOWN))
     {
-      zlog_debug ("[Event] connection from %s rejected due to admin shutdown",
-                 inet_sutop (&su, buf));
+      if (bgp_debug_neighbor_events(peer))
+        zlog_debug ("[Event] connection from %s rejected due to admin shutdown",
+                    inet_sutop (&su, buf));
       close (bgp_sock);
       return -1;
     }
@@ -256,19 +253,22 @@ bgp_accept (struct thread *thread)
     {
       struct bgp *bgp = peer1->bgp;
 
-      if (BGP_DEBUG (events, EVENTS))
+      if (bgp_debug_neighbor_events(peer1))
         zlog_debug("[Event] Closing incoming conn for %s (0x%x) state %d",
                    peer1->host, peer1, peer1->status);
       close (bgp_sock);
       return -1;
     }
 
+  if (bgp_debug_neighbor_events(peer1))
+    zlog_debug ("[Event] BGP connection from host %s", inet_sutop (&su, buf));
+
   if (peer1->doppelganger)
     {
       /* We have an existing connection. Kill the existing one and run
         with this one.
       */
-      if (BGP_DEBUG (events, EVENTS))
+      if (bgp_debug_neighbor_events(peer))
        zlog_debug ("[Event] New active connection from peer %s, Killing"
                    " previous active connection", peer1->host);
       peer_delete(peer1->doppelganger);
@@ -338,7 +338,7 @@ bgp_bind (struct peer *peer)
 
   if (ret < 0)
     {
-      zlog (peer->log, LOG_INFO, "bind to interface %s failed", name);
+      zlog_info ("bind to interface %s failed", name);
       return ret;
     }
 #endif /* SO_BINDTODEVICE */
@@ -456,9 +456,9 @@ bgp_connect (struct peer *peer)
     ifindex = if_nametoindex (peer->conf_if ? peer->conf_if : peer->ifname);
 #endif /* HAVE_IPV6 */
 
-  if (BGP_DEBUG (events, EVENTS))
-    plog_debug (peer->log, "%s [Event] Connect start to %s fd %d",
-              peer->host, peer->host, peer->fd);
+  if (bgp_debug_neighbor_events(peer))
+    zlog_debug ("%s [Event] Connect start to %s fd %d",
+               peer->host, peer->host, peer->fd);
 
   /* Connect to the remote peer. */
   return sockunion_connect (peer->fd, &peer->su, htons (peer->port), ifindex);
index a48f3f7121286a639e6d3b18623374db5ca7be3a..0bcccb8aab26eda9aade4ac3b08bf8e03ab843e4 100644 (file)
@@ -155,7 +155,7 @@ bgp_capability_mp (struct peer *peer, struct capability_header *hdr)
   
   bgp_capability_mp_data (s, &mpc);
   
-  if (BGP_DEBUG (normal, NORMAL))
+  if (bgp_debug_neighbor_events(peer->host))
     zlog_debug ("%s OPEN has MP_EXT CAP for afi/safi: %u/%u",
                peer->host, mpc.afi, mpc.safi);
   
@@ -177,7 +177,7 @@ static void
 bgp_capability_orf_not_support (struct peer *peer, afi_t afi, safi_t safi,
                                u_char type, u_char mode)
 {
-  if (BGP_DEBUG (normal, NORMAL))
+  if (bgp_debug_neighbor_events(peer))
     zlog_debug ("%s Addr-family %d/%d has ORF type/mode %d/%d not supported",
               peer->host, afi, safi, type, mode);
 }
@@ -216,7 +216,7 @@ bgp_capability_orf_entry (struct peer *peer, struct capability_header *hdr)
   afi = entry.mpc.afi;
   safi = entry.mpc.safi;
   
-  if (BGP_DEBUG (normal, NORMAL))
+  if (bgp_debug_neighbor_events(peer))
     zlog_debug ("%s ORF Cap entry for afi/safi: %u/%u",
                peer->host, entry.mpc.afi, entry.mpc.safi);
 
@@ -293,7 +293,7 @@ bgp_capability_orf_entry (struct peer *peer, struct capability_header *hdr)
           continue;
         }
       
-      if (BGP_DEBUG (normal, NORMAL))
+      if (bgp_debug_neighbor_events(peer))
         zlog_debug ("%s OPEN has %s ORF capability"
                     " as %s for afi/safi: %d/%d",
                     peer->host, LOOKUP (orf_type_str, type),
@@ -351,7 +351,7 @@ bgp_capability_restart (struct peer *peer, struct capability_header *caphdr)
   UNSET_FLAG (restart_flag_time, 0xF000);
   peer->v_gr_restart = restart_flag_time;
 
-  if (BGP_DEBUG (normal, NORMAL))
+  if (bgp_debug_neighbor_events(peer))
     {
       zlog_debug ("%s OPEN has Graceful Restart capability", peer->host);
       zlog_debug ("%s Peer has%srestarted. Restart Time : %d",
@@ -367,21 +367,21 @@ bgp_capability_restart (struct peer *peer, struct capability_header *caphdr)
       
       if (!bgp_afi_safi_valid_indices (afi, &safi))
         {
-          if (BGP_DEBUG (normal, NORMAL))
+          if (bgp_debug_neighbor_events(peer))
             zlog_debug ("%s Addr-family %d/%d(afi/safi) not supported."
                         " Ignore the Graceful Restart capability",
                         peer->host, afi, safi);
         }
       else if (!peer->afc[afi][safi])
         {
-          if (BGP_DEBUG (normal, NORMAL))
+          if (bgp_debug_neighbor_events(peer))
             zlog_debug ("%s Addr-family %d/%d(afi/safi) not enabled."
                         " Ignore the Graceful Restart capability",
                         peer->host, afi, safi);
         }
       else
         {
-          if (BGP_DEBUG (normal, NORMAL))
+          if (bgp_debug_neighbor_events(peer))
             zlog_debug ("%s Address family %s is%spreserved", peer->host,
                         afi_safi_print (afi, safi),
                         CHECK_FLAG (peer->af_cap[afi][safi],
@@ -486,7 +486,7 @@ bgp_capability_parse (struct peer *peer, size_t length, int *mp_capability,
          return -1;
        }
       
-      if (BGP_DEBUG (normal, NORMAL))
+      if (bgp_debug_neighbor_events(peer))
        zlog_debug ("%s OPEN has %s capability (%u), length %u",
                   peer->host,
                   LOOKUP (capcode_str, caphdr.code),
@@ -715,7 +715,7 @@ bgp_open_option_parse (struct peer *peer, u_char length, int *mp_capability)
   ret = 0;
   error = error_data;
 
-  if (BGP_DEBUG (normal, NORMAL))
+  if (bgp_debug_neighbor_events(peer))
     zlog_debug ("%s rcv OPEN w/ OPTION parameter len: %u",
               peer->host, length);
   
@@ -744,7 +744,7 @@ bgp_open_option_parse (struct peer *peer, u_char length, int *mp_capability)
          return -1;
        }
 
-      if (BGP_DEBUG (normal, NORMAL))
+      if (bgp_debug_neighbor_events(peer))
        zlog_debug ("%s rcvd OPEN w/ optional parameter type %u (%s) len %u",
                   peer->host, opt_type,
                   opt_type == BGP_OPEN_OPT_AUTH ? "Authentication" :
@@ -811,7 +811,7 @@ bgp_open_option_parse (struct peer *peer, u_char length, int *mp_capability)
          && ! peer->afc_nego[AFI_IP6][SAFI_UNICAST]
          && ! peer->afc_nego[AFI_IP6][SAFI_MULTICAST])
        {
-         plog_err (peer->log, "%s [Error] Configured AFI/SAFIs do not "
+         zlog_err ("%s [Error] Configured AFI/SAFIs do not "
                    "overlap with received MP capabilities",
                    peer->host);
 
index 0b41c7d1a96b93ae8968a109c821cfd2a41c2008..16284bd5bfe195e3d04c883088bc9d915989dd1f 100644 (file)
@@ -118,7 +118,7 @@ bgp_connect_check (struct peer *peer, int change_state)
   /* If getsockopt is fail, this is fatal error. */
   if (ret < 0)
     {
-      zlog (peer->log, LOG_INFO, "can't get sockopt for nonblocking connect");
+      zlog_info ("can't get sockopt for nonblocking connect");
       BGP_EVENT_ADD (peer, TCP_fatal_error);
       return -1;
     }      
@@ -131,9 +131,9 @@ bgp_connect_check (struct peer *peer, int change_state)
     }
   else
     {
-      if (BGP_DEBUG (events, EVENTS))
-         plog_debug (peer->log, "%s [Event] Connect failed (%s)",
-                    peer->host, safe_strerror (errno));
+      if (bgp_debug_neighbor_events(peer))
+         zlog_debug ("%s [Event] Connect failed (%s)",
+                     peer->host, safe_strerror (errno));
       if (change_state)
        BGP_EVENT_ADD (peer, TCP_connection_open_failed);
       return 0;
@@ -158,6 +158,8 @@ bgp_update_packet (struct peer *peer, afi_t afi, safi_t safi)
   size_t mpattrlen_pos = 0;
   size_t mpattr_pos = 0;
   int num_pfx_adv = 0;
+  char send_attr_str[BUFSIZ];
+  int send_attr_printed;
 
   s = peer->work;
   stream_reset (s);
@@ -229,6 +231,14 @@ bgp_update_packet (struct peer *peer, afi_t afi, safi_t safi)
                 adv = bgp_advertise_clean (peer, adv->adj, afi, safi);
               return NULL;
             }
+
+          if (BGP_DEBUG (update, UPDATE_OUT) ||
+              BGP_DEBUG (update, UPDATE_PREFIX))
+            {
+              memset (send_attr_str, 0, BUFSIZ);
+              send_attr_printed = 0;
+              bgp_dump_attr (peer, adv->baa->attr, send_attr_str, BUFSIZ);
+            }
        }
 
       if (afi == AFI_IP && safi == SAFI_UNICAST)
@@ -251,14 +261,19 @@ bgp_update_packet (struct peer *peer, afi_t afi, safi_t safi)
        }
       num_pfx_adv++;
 
-      if (BGP_DEBUG (update, UPDATE_OUT))
+      if (bgp_debug_update(peer, &rn->p, 0))
         {
+        if (!send_attr_printed)
+          {
+            zlog_debug ("%s send UPDATE w/ attr: %s", peer->host, send_attr_str);
+            send_attr_printed = 1;
+          }
           char buf[INET6_BUFSIZ];
 
-          zlog (peer->log, LOG_DEBUG, "%s send UPDATE %s/%d",
-                peer->host,
-                inet_ntop (rn->p.family, &(rn->p.u.prefix), buf, INET6_BUFSIZ),
-                rn->p.prefixlen);
+          zlog_debug ("%s send UPDATE %s/%d",
+                      peer->host,
+                      inet_ntop (rn->p.family, &(rn->p.u.prefix), buf, INET6_BUFSIZ),
+                      rn->p.prefixlen);
         }
 
       /* Synchnorize attribute.  */
@@ -289,10 +304,9 @@ bgp_update_packet (struct peer *peer, afi_t afi, safi_t safi)
        packet = stream_dup (s);
       bgp_packet_set_size (packet);
       if (BGP_DEBUG (update, UPDATE_OUT))
-        zlog(peer->log, LOG_DEBUG,
-             "%s form UPDATE (adv) total len %d numPfx %d",
-             peer->host,
-             (stream_get_endp (s) - stream_get_getp (s)), num_pfx_adv);
+        zlog_debug("%s form UPDATE (adv) total len %d numPfx %d",
+                   peer->host,
+                   (stream_get_endp (s) - stream_get_getp (s)), num_pfx_adv);
       bgp_packet_add (peer, packet);
       stream_reset (s);
       stream_reset (snlri);
@@ -310,7 +324,7 @@ bgp_update_packet_eor (struct peer *peer, afi_t afi, safi_t safi)
   if (DISABLE_BGP_ANNOUNCE)
     return NULL;
 
-  if (BGP_DEBUG (normal, NORMAL))
+  if (bgp_debug_neighbor_events(peer))
     zlog_debug ("send End-of-RIB for %s to %s", afi_safi_print (afi, safi), peer->host);
 
   s = stream_new (BGP_MAX_PACKET_SIZE);
@@ -421,14 +435,14 @@ bgp_withdraw_packet (struct peer *peer, afi_t afi, safi_t safi)
        }
       num_pfx_wd++;
 
-      if (BGP_DEBUG (update, UPDATE_OUT))
+      if (bgp_debug_update(peer, &rn->p, 0))
         {
           char buf[INET6_BUFSIZ];
 
-          zlog (peer->log, LOG_DEBUG, "%s send UPDATE %s/%d -- unreachable",
-                peer->host,
-                inet_ntop (rn->p.family, &(rn->p.u.prefix), buf, INET6_BUFSIZ),
-                rn->p.prefixlen);
+          zlog_debug ("%s send UPDATE %s/%d -- unreachable",
+                      peer->host,
+                      inet_ntop (rn->p.family, &(rn->p.u.prefix), buf, INET6_BUFSIZ),
+                      rn->p.prefixlen);
         }
 
       peer->scount[afi][safi]--;
@@ -457,10 +471,9 @@ bgp_withdraw_packet (struct peer *peer, afi_t afi, safi_t safi)
        }
       bgp_packet_set_size (s);
       if (BGP_DEBUG (update, UPDATE_OUT))
-        zlog(peer->log, LOG_DEBUG,
-             "%s form UPDATE (wd) total len %d numPfx %d",
-             peer->host,
-             (stream_get_endp (s) - stream_get_getp (s)), num_pfx_wd);
+        zlog_debug("%s form UPDATE (wd) total len %d numPfx %d",
+                   peer->host,
+                  (stream_get_endp (s) - stream_get_getp (s)), num_pfx_wd);
       packet = stream_dup (s);
       bgp_packet_add (peer, packet);
       stream_reset (s);
@@ -491,16 +504,16 @@ bgp_default_update_send (struct peer *peer, struct attr *attr,
 #endif /* HAVE_IPV6 */
 
   /* Logging the attribute. */
-  if (BGP_DEBUG (update, UPDATE_OUT))
+  if (bgp_debug_update(peer, &p, 0))
     {
       char attrstr[BUFSIZ];
       char buf[INET6_BUFSIZ];
       attrstr[0] = '\0';
 
       bgp_dump_attr (peer, attr, attrstr, BUFSIZ);
-      zlog (peer->log, LOG_DEBUG, "%s send UPDATE %s/%d %s",
-           peer->host, inet_ntop(p.family, &(p.u.prefix), buf, INET6_BUFSIZ),
-           p.prefixlen, attrstr);
+      zlog_debug ("%s send UPDATE %s/%d %s",
+                 peer->host, inet_ntop(p.family, &(p.u.prefix), buf, INET6_BUFSIZ),
+                 p.prefixlen, attrstr);
     }
 
   s = stream_new (BGP_MAX_PACKET_SIZE);
@@ -565,13 +578,13 @@ bgp_default_withdraw_send (struct peer *peer, afi_t afi, safi_t safi)
 
   total_attr_len = 0;
 
-  if (BGP_DEBUG (update, UPDATE_OUT))
+  if (bgp_debug_update(peer, &p, 0))
     {
       char buf[INET6_BUFSIZ];
 
-      zlog (peer->log, LOG_DEBUG, "%s send UPDATE %s/%d -- unreachable",
-            peer->host, inet_ntop(p.family, &(p.u.prefix), buf, INET6_BUFSIZ),
-            p.prefixlen);
+      zlog_debug ("%s send UPDATE %s/%d -- unreachable",
+                  peer->host, inet_ntop(p.family, &(p.u.prefix), buf, INET6_BUFSIZ),
+                  p.prefixlen);
     }
 
   s = stream_new (BGP_MAX_PACKET_SIZE);
@@ -746,7 +759,7 @@ bgp_peer_schedule_updates(struct peer *peer)
   /* If withdraw FIFO exists, immediately schedule write */
   if (bgp_peer_wd_fifo_exists(peer) && !peer->t_write)
     {
-      if (BGP_DEBUG (events, EVENTS))
+      if (bgp_debug_update(peer, NULL, 0))
         zlog_debug("%s scheduling write thread", peer->host);
       BGP_WRITE_ON (peer->t_write, bgp_write, peer->fd);
     }
@@ -754,7 +767,7 @@ bgp_peer_schedule_updates(struct peer *peer)
   /* If update FIFO exists, fire MRAI timer */
   if (bgp_peer_adv_fifo_exists(peer, 0) && !peer->radv_adjusted)
     {
-      if (BGP_DEBUG (events, EVENTS))
+      if (bgp_debug_update(peer, NULL, 0))
         zlog_debug("%s scheduling MRAI timer", peer->host);
       bgp_adjust_routeadv(peer);
     }
@@ -966,11 +979,8 @@ bgp_keepalive_send (struct peer *peer)
   /* Dump packet if debug option is set. */
   /* bgp_packet_dump (s); */
  
-  if (BGP_DEBUG (keepalive, KEEPALIVE))  
+  if (bgp_debug_keepalive(peer))
     zlog_debug ("%s sending KEEPALIVE", peer->host); 
-  if (BGP_DEBUG (normal, NORMAL))
-    zlog_debug ("%s send message type %d, length (incl. header) %d",
-               peer->host, BGP_MSG_KEEPALIVE, length);
 
   /* Add packet to the peer. */
   bgp_packet_add (peer, s);
@@ -1016,15 +1026,11 @@ bgp_open_send (struct peer *peer)
   /* Set BGP packet length. */
   length = bgp_packet_set_size (s);
 
-  if (BGP_DEBUG (normal, NORMAL))
+  if (bgp_debug_neighbor_events(peer))
     zlog_debug ("%s sending OPEN, version %d, my as %u, holdtime %d, id %s", 
               peer->host, BGP_VERSION_4, local_as,
               send_holdtime, inet_ntoa (peer->local_id));
 
-  if (BGP_DEBUG (normal, NORMAL))
-    zlog_debug ("%s send message type %d, length (incl. header) %d",
-              peer->host, BGP_MSG_OPEN, length);
-
   /* Dump packet if debug option is set. */
   /* bgp_packet_dump (s); */
 
@@ -1096,33 +1102,16 @@ bgp_notify_send_with_data (struct peer *peer, u_char code, u_char sub_code,
       XFREE (MTYPE_TMP, bgp_notify.data);
   }
 
-  if (BGP_DEBUG (normal, NORMAL))
-    zlog_debug ("%s send message type %d, length (incl. header) %d",
-              peer->host, BGP_MSG_NOTIFY, length);
-
   /* peer reset cause */
   if (sub_code != BGP_NOTIFY_CEASE_CONFIG_CHANGE)
     {
       if (sub_code == BGP_NOTIFY_CEASE_ADMIN_RESET)
-      {
         peer->last_reset = PEER_DOWN_USER_RESET;
-        zlog_info ("Notification sent to neighbor %s: User reset", peer->host);
-      }
       else if (sub_code == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN)
-      {
         peer->last_reset = PEER_DOWN_USER_SHUTDOWN;
-        zlog_info ("Notification sent to neighbor %s: shutdown", peer->host);
-      }
       else
-      {
         peer->last_reset = PEER_DOWN_NOTIFY_SEND;
-        zlog_info ("Notification sent to neighbor %s: type %u/%u",
-                   peer->host, code, sub_code);
-      }
     }
-  else
-     zlog_info ("Notification sent to neighbor %s:%d: configuration change",
-                peer->host, peer->fd);
 
   /* Call immediately. */
   BGP_WRITE_OFF (peer->t_write);
@@ -1187,7 +1176,7 @@ bgp_route_refresh_send (struct peer *peer, afi_t afi, safi_t safi,
          {
            UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND);
            stream_putc (s, ORF_COMMON_PART_REMOVE_ALL);
-           if (BGP_DEBUG (normal, NORMAL))
+            if (bgp_debug_neighbor_events(peer))
              zlog_debug ("%s sending REFRESH_REQ to remove ORF(%d) (%s) for afi/safi: %d/%d", 
                         peer->host, orf_type,
                         (when_to_refresh == REFRESH_DEFER ? "defer" : "immediate"),
@@ -1199,7 +1188,7 @@ bgp_route_refresh_send (struct peer *peer, afi_t afi, safi_t safi,
            prefix_bgp_orf_entry (s, filter->plist[FILTER_IN].plist,
                                  ORF_COMMON_PART_ADD, ORF_COMMON_PART_PERMIT,
                                  ORF_COMMON_PART_DENY);
-           if (BGP_DEBUG (normal, NORMAL))
+            if (bgp_debug_neighbor_events(peer))
              zlog_debug ("%s sending REFRESH_REQ with pfxlist ORF(%d) (%s) for afi/safi: %d/%d", 
                         peer->host, orf_type,
                         (when_to_refresh == REFRESH_DEFER ? "defer" : "immediate"),
@@ -1214,14 +1203,11 @@ bgp_route_refresh_send (struct peer *peer, afi_t afi, safi_t safi,
   /* Set packet size. */
   length = bgp_packet_set_size (s);
 
-  if (BGP_DEBUG (normal, NORMAL))
+  if (bgp_debug_neighbor_events(peer))
     {
       if (! orf_refresh)
        zlog_debug ("%s sending REFRESH_REQ for afi/safi: %d/%d", 
                   peer->host, afi, safi);
-      zlog_debug ("%s send message type %d, length (incl. header) %d",
-                peer->host, CHECK_FLAG (peer->cap, PEER_CAP_REFRESH_NEW_RCV) ?
-                BGP_MSG_ROUTE_REFRESH_NEW : BGP_MSG_ROUTE_REFRESH_OLD, length);
     }
 
   /* Make real packet. */
@@ -1262,7 +1248,7 @@ bgp_capability_send (struct peer *peer, afi_t afi, safi_t safi,
       stream_putc (s, 0);
       stream_putc (s, safi);
 
-      if (BGP_DEBUG (normal, NORMAL))
+      if (bgp_debug_neighbor_events(peer))
         zlog_debug ("%s sending CAPABILITY has %s MP_EXT CAP for afi/safi: %d/%d",
                   peer->host, action == CAPABILITY_ACTION_SET ?
                   "Advertising" : "Removing", afi, safi);
@@ -1278,10 +1264,6 @@ bgp_capability_send (struct peer *peer, afi_t afi, safi_t safi,
   /* Add packet to the peer. */
   bgp_packet_add (peer, packet);
 
-  if (BGP_DEBUG (normal, NORMAL))
-    zlog_debug ("%s send message type %d, length (incl. header) %d",
-              peer->host, BGP_MSG_CAPABILITY, length);
-
   BGP_WRITE_ON (peer->t_write, bgp_write, peer->fd);
 }
 
@@ -1386,7 +1368,7 @@ bgp_open_receive (struct peer *peer, bgp_size_t size)
   remote_id.s_addr = stream_get_ipv4 (peer->ibuf);
 
   /* Receive OPEN message log  */
-  if (BGP_DEBUG (normal, NORMAL))
+  if (bgp_debug_neighbor_events(peer))
     zlog_debug ("%s rcv OPEN, version %d, remote-as (in open) %u,"
                 " holdtime %d, id %s",
                peer->host, version, remote_as, holdtime,
@@ -1461,7 +1443,7 @@ bgp_open_receive (struct peer *peer, bgp_size_t size)
       || IPV4_CLASS_DE (ntohl (remote_id.s_addr))
       || ntohl (peer->local_id.s_addr) == ntohl (remote_id.s_addr))
     {
-      if (BGP_DEBUG (normal, NORMAL))
+      if (bgp_debug_neighbor_events(peer))
        zlog_debug ("%s bad OPEN, wrong router identifier %s",
                   peer->host, inet_ntoa (remote_id));
       bgp_notify_send_with_data (peer, 
@@ -1479,7 +1461,7 @@ bgp_open_receive (struct peer *peer, bgp_size_t size)
     {
       u_int16_t maxver = htons(BGP_VERSION_4);
       /* XXX this reply may not be correct if version < 4  XXX */
-      if (BGP_DEBUG (normal, NORMAL))
+      if (bgp_debug_neighbor_events(peer))
        zlog_debug ("%s bad protocol version, remote requested %d, local request %d",
                   peer->host, version, BGP_VERSION_4);
       /* Data must be in network byte order here */
@@ -1493,7 +1475,7 @@ bgp_open_receive (struct peer *peer, bgp_size_t size)
   /* Check neighbor as number. */
   if (remote_as != peer->as)
     {
-      if (BGP_DEBUG (normal, NORMAL))
+      if (bgp_debug_neighbor_events(peer))
        zlog_debug ("%s bad OPEN, remote AS is %u, expected %u",
                   peer->host, remote_as, peer->as);
       bgp_notify_send_with_data (peer, 
@@ -1548,7 +1530,7 @@ bgp_open_receive (struct peer *peer, bgp_size_t size)
     }
   else
     {
-      if (BGP_DEBUG (normal, NORMAL))
+      if (bgp_debug_neighbor_events(peer))
        zlog_debug ("%s rcvd OPEN w/ OPTION parameter len: 0",
                   peer->host);
     }
@@ -1604,7 +1586,7 @@ bgp_check_update_delay(struct bgp *bgp)
   struct listnode *node, *nnode;
   struct peer *peer;
 
-  if (BGP_DEBUG (normal, NORMAL))
+  if (bgp_debug_neighbor_events(peer))
     zlog_debug ("Checking update delay, T: %d R: %d I:%d E: %d", bgp->established,
                 bgp->restarted_peers, bgp->implicit_eors, bgp->explicit_eors);
 
@@ -1623,7 +1605,7 @@ bgp_check_update_delay(struct bgp *bgp)
                 && !CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN)
                 && !peer->update_delay_over)
               {
-                if (BGP_DEBUG (normal, NORMAL))
+                if (bgp_debug_neighbor_events(peer))
                   zlog_debug (" Peer %s pending, continuing read-only mode",
                               peer->host);
                 return;
@@ -1644,7 +1626,7 @@ bgp_update_restarted_peers (struct peer *peer)
   if (!bgp_update_delay_active(peer->bgp)) return; /* BGP update delay has ended */
   if (peer->update_delay_over) return; /* This peer has already been considered */
 
-  if (BGP_DEBUG (normal, NORMAL))
+  if (bgp_debug_neighbor_events(peer))
     zlog_debug ("Peer %s: Checking restarted", peer->host);
 
   if (peer->status == Established)
@@ -1665,7 +1647,7 @@ bgp_update_implicit_eors (struct peer *peer)
   if (!bgp_update_delay_active(peer->bgp)) return; /* BGP update delay has ended */
   if (peer->update_delay_over) return; /* This peer has already been considered */
 
-  if (BGP_DEBUG (normal, NORMAL))
+  if (bgp_debug_neighbor_events(peer))
     zlog_debug ("Peer %s: Checking implicit EORs", peer->host);
 
   if (peer->status == Established)
@@ -1687,7 +1669,7 @@ bgp_update_explicit_eors (struct peer *peer)
   if (!bgp_update_delay_active(peer->bgp)) return; /* BGP update delay has ended */
   if (peer->update_delay_over) return; /* This peer has already been considered */
 
-  if (BGP_DEBUG (normal, NORMAL))
+  if (bgp_debug_neighbor_events(peer))
     zlog_debug ("Peer %s: Checking explicit EORs", peer->host);
 
   for (afi = AFI_IP; afi < AFI_MAX; afi++)
@@ -1696,7 +1678,7 @@ bgp_update_explicit_eors (struct peer *peer)
         if (peer->afc_nego[afi][safi] &&
             !CHECK_FLAG(peer->af_sflags[afi][safi], PEER_STATUS_EOR_RECEIVED))
           {
-            if (BGP_DEBUG (normal, NORMAL))
+            if (bgp_debug_neighbor_events(peer))
               zlog_debug ("   afi %d safi %d didnt receive EOR", afi, safi);
             return;
           }
@@ -1743,6 +1725,8 @@ bgp_update_receive (struct peer *peer, bgp_size_t size)
   memset (&mp_withdraw, 0, sizeof (struct bgp_nlri));
   attr.extra = &extra;
   num_pfx_adv = num_pfx_wd = 0;
+  memset (peer->rcvd_attr_str, 0, BUFSIZ);
+  peer->rcvd_attr_printed = 0;
 
   s = peer->ibuf;
   end = stream_pnt (s) + size;
@@ -1783,8 +1767,7 @@ bgp_update_receive (struct peer *peer, bgp_size_t size)
       if (ret < 0)
        return -1;
 
-      if (BGP_DEBUG (packet, PACKET_RECV))
-       zlog_debug ("%s [Update:RECV] Unfeasible NLRI received", peer->host);
+      zlog_err ("%s [Update:RECV] Unfeasible NLRI received", peer->host);
 
       withdraw.afi = AFI_IP;
       withdraw.safi = SAFI_UNICAST;
@@ -1844,24 +1827,21 @@ bgp_update_receive (struct peer *peer, bgp_size_t size)
     }
   
   /* Logging the attribute. */
-  if (attr_parse_ret == BGP_ATTR_PARSE_WITHDRAW
-      || BGP_DEBUG (update, UPDATE_IN))
+  if (attr_parse_ret == BGP_ATTR_PARSE_WITHDRAW ||
+      BGP_DEBUG (update, UPDATE_IN) ||
+      BGP_DEBUG (update, UPDATE_PREFIX))
     {
-      char attrstr[BUFSIZ];
-      attrstr[0] = '\0';
-
-      ret= bgp_dump_attr (peer, &attr, attrstr, BUFSIZ);
-      int lvl = (attr_parse_ret == BGP_ATTR_PARSE_WITHDRAW)
-                 ? LOG_ERR : LOG_DEBUG;
+      ret = bgp_dump_attr (peer, &attr, peer->rcvd_attr_str, BUFSIZ);
       
       if (attr_parse_ret == BGP_ATTR_PARSE_WITHDRAW)
-        zlog (peer->log, LOG_ERR,
-              "%s rcvd UPDATE with errors in attr(s)!! Withdrawing route.",
-              peer->host);
+        zlog_err ("%s rcvd UPDATE with errors in attr(s)!! Withdrawing route.",
+                  peer->host);
 
-      if (ret)
-       zlog (peer->log, lvl, "%s rcvd UPDATE w/ attr: %s",
-             peer->host, attrstr);
+      if (ret && bgp_debug_update(peer, NULL, 1))
+        {
+          zlog_debug ("%s rcvd UPDATE w/ attr: %s", peer->host, peer->rcvd_attr_str);
+          peer->rcvd_attr_printed = 1;
+        }
     }
   
   /* Network Layer Reachability Information. */
@@ -1887,10 +1867,9 @@ bgp_update_receive (struct peer *peer, bgp_size_t size)
     }
 
   if (BGP_DEBUG (update, UPDATE_IN))
-    zlog(peer->log, LOG_DEBUG,
-         "%s rcvd UPDATE wlen %d wpfx %d attrlen %d alen %d apfx %d",
-         peer->host, withdraw_len, num_pfx_wd, attribute_len,
-         update_len, num_pfx_adv);
+    zlog_debug("%s rcvd UPDATE wlen %d wpfx %d attrlen %d alen %d apfx %d",
+               peer->host, withdraw_len, num_pfx_wd, attribute_len,
+               update_len, num_pfx_adv);
 
   /* NLRI is processed only when the peer is configured specific
      Address Family and Subsequent Address Family. */
@@ -1938,9 +1917,8 @@ bgp_update_receive (struct peer *peer, bgp_size_t size)
          if (peer->nsf[AFI_IP][SAFI_UNICAST])
            bgp_clear_stale_route (peer, AFI_IP, SAFI_UNICAST);
 
-         if (BGP_DEBUG (normal, NORMAL))
-           zlog (peer->log, LOG_DEBUG, "rcvd End-of-RIB for IPv4 Unicast from %s",
-                 peer->host);
+          if (bgp_debug_neighbor_events(peer))
+           zlog_debug ("rcvd End-of-RIB for IPv4 Unicast from %s", peer->host);
        }
     }
   if (peer->afc[AFI_IP][SAFI_MULTICAST])
@@ -1973,9 +1951,8 @@ bgp_update_receive (struct peer *peer, bgp_size_t size)
          if (peer->nsf[AFI_IP][SAFI_MULTICAST])
            bgp_clear_stale_route (peer, AFI_IP, SAFI_MULTICAST);
 
-         if (BGP_DEBUG (normal, NORMAL))
-           zlog (peer->log, LOG_DEBUG, "rcvd End-of-RIB for IPv4 Multicast from %s",
-                 peer->host);
+          if (bgp_debug_neighbor_events(peer))
+           zlog_debug ("rcvd End-of-RIB for IPv4 Multicast from %s", peer->host);
        }
     }
   if (peer->afc[AFI_IP6][SAFI_UNICAST])
@@ -2007,9 +1984,8 @@ bgp_update_receive (struct peer *peer, bgp_size_t size)
          if (peer->nsf[AFI_IP6][SAFI_UNICAST])
            bgp_clear_stale_route (peer, AFI_IP6, SAFI_UNICAST);
 
-         if (BGP_DEBUG (normal, NORMAL))
-           zlog (peer->log, LOG_DEBUG, "rcvd End-of-RIB for IPv6 Unicast from %s",
-                 peer->host);
+          if (bgp_debug_neighbor_events(peer))
+           zlog_debug ("rcvd End-of-RIB for IPv6 Unicast from %s", peer->host);
        }
     }
   if (peer->afc[AFI_IP6][SAFI_MULTICAST])
@@ -2042,9 +2018,8 @@ bgp_update_receive (struct peer *peer, bgp_size_t size)
          if (peer->nsf[AFI_IP6][SAFI_MULTICAST])
            bgp_clear_stale_route (peer, AFI_IP6, SAFI_MULTICAST);
 
-         if (BGP_DEBUG (update, UPDATE_IN))
-           zlog (peer->log, LOG_DEBUG, "rcvd End-of-RIB for IPv6 Multicast from %s",
-                 peer->host);
+         if (bgp_debug_update(peer, NULL, 1))
+           zlog_debug ("rcvd End-of-RIB for IPv6 Multicast from %s", peer->host);
        }
     }
   if (peer->afc[AFI_IP][SAFI_MPLS_VPN])
@@ -2064,17 +2039,17 @@ bgp_update_receive (struct peer *peer, bgp_size_t size)
          && mp_withdraw.safi == SAFI_MPLS_LABELED_VPN
          && mp_withdraw.length == 0)
        {
-         /* End-of-RIB received */
-    if (!CHECK_FLAG (peer->af_sflags[AFI_IP][SAFI_MPLS_VPN],
+
+          /* End-of-RIB received */
+          if (!CHECK_FLAG (peer->af_sflags[AFI_IP][SAFI_MPLS_VPN],
                            PEER_STATUS_EOR_RECEIVED))
-      {
+            {
              SET_FLAG (peer->af_sflags[AFI_IP][SAFI_MPLS_VPN], PEER_STATUS_EOR_RECEIVED);
-        bgp_update_explicit_eors(peer);
-      }
+              bgp_update_explicit_eors(peer);
+            }
 
-         if (BGP_DEBUG (update, UPDATE_IN))
-           zlog (peer->log, LOG_DEBUG, "rcvd End-of-RIB for VPNv4 Unicast from %s",
-                 peer->host);
+         if (bgp_debug_update(peer, NULL, 1))
+           zlog_debug ("rcvd End-of-RIB for VPNv4 Unicast from %s", peer->host);
        }
     }
 
@@ -2176,7 +2151,7 @@ bgp_notify_receive (struct peer *peer, bgp_size_t size)
 static void
 bgp_keepalive_receive (struct peer *peer, bgp_size_t size)
 {
-  if (BGP_DEBUG (keepalive, KEEPALIVE))  
+  if (bgp_debug_keepalive(peer))
     zlog_debug ("%s KEEPALIVE rcvd", peer->host); 
   
   BGP_EVENT_ADD (peer, Receive_KEEPALIVE_message);
@@ -2194,7 +2169,7 @@ bgp_route_refresh_receive (struct peer *peer, bgp_size_t size)
   /* If peer does not have the capability, send notification. */
   if (! CHECK_FLAG (peer->cap, PEER_CAP_REFRESH_ADV))
     {
-      plog_err (peer->log, "%s [Error] BGP route refresh is not enabled",
+      zlog_err ("%s [Error] BGP route refresh is not enabled",
                peer->host);
       bgp_notify_send (peer,
                       BGP_NOTIFY_HEADER_ERR,
@@ -2205,8 +2180,7 @@ bgp_route_refresh_receive (struct peer *peer, bgp_size_t size)
   /* Status must be Established. */
   if (peer->status != Established) 
     {
-      plog_err (peer->log,
-               "%s [Error] Route refresh packet received under status %s",
+      zlog_err ("%s [Error] Route refresh packet received under status %s",
                peer->host, LOOKUP (bgp_status_msg, peer->status));
       bgp_notify_send (peer, BGP_NOTIFY_FSM_ERR, 0);
       return;
@@ -2219,7 +2193,7 @@ bgp_route_refresh_receive (struct peer *peer, bgp_size_t size)
   reserved = stream_getc (s);
   safi = stream_getc (s);
 
-  if (BGP_DEBUG (normal, NORMAL))
+  if (bgp_debug_update(peer, NULL, 0))
     zlog_debug ("%s rcvd REFRESH_REQ for afi/safi: %d/%d",
               peer->host, afi, safi);
 
@@ -2228,11 +2202,8 @@ bgp_route_refresh_receive (struct peer *peer, bgp_size_t size)
       || (safi != SAFI_UNICAST && safi != SAFI_MULTICAST
          && safi != SAFI_MPLS_LABELED_VPN))
     {
-      if (BGP_DEBUG (normal, NORMAL))
-       {
-         zlog_debug ("%s REFRESH_REQ for unrecognized afi/safi: %d/%d - ignored",
-                    peer->host, afi, safi);
-       }
+      zlog_info ("%s REFRESH_REQ for unrecognized afi/safi: %d/%d - ignored",
+                peer->host, afi, safi);
       return;
     }
 
@@ -2277,7 +2248,7 @@ bgp_route_refresh_receive (struct peer *peer, bgp_size_t size)
              char name[BUFSIZ];
              int ret;
 
-             if (BGP_DEBUG (normal, NORMAL))
+              if (bgp_debug_neighbor_events(peer))
                {
                  zlog_debug ("%s rcvd Prefixlist ORF(%d) length %d",
                             peer->host, orf_type, orf_len);
@@ -2304,7 +2275,7 @@ bgp_route_refresh_receive (struct peer *peer, bgp_size_t size)
                  /* after ++: p_pnt <= p_end */
                  if (common & ORF_COMMON_PART_REMOVE_ALL)
                    {
-                     if (BGP_DEBUG (normal, NORMAL))
+                      if (bgp_debug_neighbor_events(peer))
                        zlog_debug ("%s rcvd Remove-All pfxlist ORF request", peer->host);
                      prefix_bgp_orf_remove_all (name);
                      break;
@@ -2343,7 +2314,7 @@ bgp_route_refresh_receive (struct peer *peer, bgp_size_t size)
                    memcpy (&orfp.p.u.prefix, p_pnt, psize);
                  p_pnt += psize;
 
-                 if (BGP_DEBUG (normal, NORMAL))
+                  if (bgp_debug_neighbor_events(peer))
                    {
                      char buf[INET6_BUFSIZ];
 
@@ -2364,9 +2335,8 @@ bgp_route_refresh_receive (struct peer *peer, bgp_size_t size)
 
                  if (!ok || (ret != CMD_SUCCESS))
                    {
-                     if (BGP_DEBUG (normal, NORMAL))
-                       zlog_debug ("%s Received misformatted prefixlist ORF."
-                                   " Remove All pfxlist", peer->host);
+                     zlog_info ("%s Received misformatted prefixlist ORF."
+                                " Remove All pfxlist", peer->host);
                      prefix_bgp_orf_remove_all (name);
                      break;
                    }
@@ -2376,7 +2346,7 @@ bgp_route_refresh_receive (struct peer *peer, bgp_size_t size)
            }
          stream_forward_getp (s, orf_len);
        }
-      if (BGP_DEBUG (normal, NORMAL))
+      if (bgp_debug_neighbor_events(peer))
        zlog_debug ("%s rcvd Refresh %s ORF request", peer->host,
                   when_to_refresh == REFRESH_DEFER ? "Defer" : "Immediate");
       if (when_to_refresh == REFRESH_DEFER)
@@ -2427,7 +2397,7 @@ bgp_capability_msg_parse (struct peer *peer, u_char *pnt, bgp_size_t length)
           return -1;
         }
 
-      if (BGP_DEBUG (normal, NORMAL))
+      if (bgp_debug_neighbor_events(peer))
        zlog_debug ("%s CAPABILITY has action: %d, code: %u, length %u",
                   peer->host, action, hdr->code, hdr->length);
 
@@ -2454,14 +2424,14 @@ bgp_capability_msg_parse (struct peer *peer, u_char *pnt, bgp_size_t length)
           
           if (!bgp_afi_safi_valid_indices (afi, &safi))
             {
-              if (BGP_DEBUG (normal, NORMAL))
+              if (bgp_debug_neighbor_events(peer))
                 zlog_debug ("%s Dynamic Capability MP_EXT afi/safi invalid "
                             "(%u/%u)", peer->host, afi, safi);
               continue;
             }
           
          /* Address family check.  */
-          if (BGP_DEBUG (normal, NORMAL))
+          if (bgp_debug_neighbor_events(peer))
             zlog_debug ("%s CAPABILITY has %s MP_EXT CAP for afi/safi: %u/%u",
                        peer->host,
                        action == CAPABILITY_ACTION_SET 
@@ -2510,13 +2480,13 @@ bgp_capability_receive (struct peer *peer, bgp_size_t size)
   /* Fetch pointer. */
   pnt = stream_pnt (peer->ibuf);
 
-  if (BGP_DEBUG (normal, NORMAL))
+  if (bgp_debug_neighbor_events(peer))
     zlog_debug ("%s rcv CAPABILITY", peer->host);
 
   /* If peer does not have the capability, send notification. */
   if (! CHECK_FLAG (peer->cap, PEER_CAP_DYNAMIC_ADV))
     {
-      plog_err (peer->log, "%s [Error] BGP dynamic capability is not enabled",
+      zlog_err ("%s [Error] BGP dynamic capability is not enabled",
                peer->host);
       bgp_notify_send (peer,
                       BGP_NOTIFY_HEADER_ERR,
@@ -2527,8 +2497,8 @@ bgp_capability_receive (struct peer *peer, bgp_size_t size)
   /* Status must be Established. */
   if (peer->status != Established)
     {
-      plog_err (peer->log,
-               "%s [Error] Dynamic capability packet received under status %s", peer->host, LOOKUP (bgp_status_msg, peer->status));
+      zlog_err ("%s [Error] Dynamic capability packet received under status %s",
+                peer->host, LOOKUP (bgp_status_msg, peer->status));
       bgp_notify_send (peer, BGP_NOTIFY_FSM_ERR, 0);
       return -1;
     }
@@ -2560,8 +2530,8 @@ bgp_read_packet (struct peer *peer)
       if (nbytes == -2)
        return -1;
 
-      plog_err (peer->log, "%s [Error] bgp_read_packet error: %s",
-                peer->host, safe_strerror (errno));
+      zlog_err ("%s [Error] bgp_read_packet error: %s",
+               peer->host, safe_strerror (errno));
 
       if (peer->status == Established) 
        {
@@ -2581,9 +2551,9 @@ bgp_read_packet (struct peer *peer)
   /* When read byte is zero : clear bgp peer and return */
   if (nbytes == 0) 
     {
-      if (BGP_DEBUG (events, EVENTS))
-       plog_debug (peer->log, "%s [Event] BGP connection closed fd %d",
-                  peer->host, peer->fd);
+      if (bgp_debug_neighbor_events(peer))
+       zlog_debug ("%s [Event] BGP connection closed fd %d",
+                   peer->host, peer->fd);
 
       if (peer->status == Established) 
        {
@@ -2681,10 +2651,6 @@ bgp_read (struct thread *thread)
       size = stream_getw (peer->ibuf);
       type = stream_getc (peer->ibuf);
 
-      if (BGP_DEBUG (normal, NORMAL) && type != 2 && type != 0)
-       zlog_debug ("%s rcv message type %d, length (excl. header) %d",
-                  peer->host, type, size - BGP_HEADER_SIZE);
-
       /* Marker check */
       if (((type == BGP_MSG_OPEN) || (type == BGP_MSG_KEEPALIVE))
          && ! bgp_marker_all_one (peer->ibuf, BGP_MARKER_SIZE))
@@ -2702,10 +2668,9 @@ bgp_read (struct thread *thread)
          && type != BGP_MSG_ROUTE_REFRESH_OLD
          && type != BGP_MSG_CAPABILITY)
        {
-         if (BGP_DEBUG (normal, NORMAL))
-           plog_debug (peer->log,
-                     "%s unknown message type 0x%02x",
-                     peer->host, type);
+          if (bgp_debug_neighbor_events(peer))
+           zlog_debug ("%s unknown message type 0x%02x",
+                       peer->host, type);
          bgp_notify_send_with_data (peer,
                                     BGP_NOTIFY_HEADER_ERR,
                                     BGP_NOTIFY_HEADER_BAD_MESTYPE,
@@ -2723,12 +2688,11 @@ bgp_read (struct thread *thread)
          || (type == BGP_MSG_ROUTE_REFRESH_OLD && size < BGP_MSG_ROUTE_REFRESH_MIN_SIZE)
          || (type == BGP_MSG_CAPABILITY && size < BGP_MSG_CAPABILITY_MIN_SIZE))
        {
-         if (BGP_DEBUG (normal, NORMAL))
-           plog_debug (peer->log,
-                     "%s bad message length - %d for %s",
-                     peer->host, size, 
-                     type == 128 ? "ROUTE-REFRESH" :
-                     bgp_type_str[(int) type]);
+          if (bgp_debug_neighbor_events(peer))
+           zlog_debug ("%s bad message length - %d for %s",
+                       peer->host, size,
+                       type == 128 ? "ROUTE-REFRESH" :
+                       bgp_type_str[(int) type]);
          bgp_notify_send_with_data (peer,
                                     BGP_NOTIFY_HEADER_ERR,
                                     BGP_NOTIFY_HEADER_BAD_MESLEN,
index e8cbe8c26068e986f3bc32c94898d551518433d0..cb46c1cbaef8692ca08fdb3fcb20cb845dccbf1e 100644 (file)
@@ -586,7 +586,7 @@ bgp_input_filter (struct peer *peer, struct prefix *p, struct attr *attr,
 #define FILTER_EXIST_WARN(F,f,filter) \
   if (BGP_DEBUG (update, UPDATE_IN) \
       && !(F ## _IN (filter))) \
-    plog_warn (peer->log, "%s: Could not find configured input %s-list %s!", \
+    zlog_warn ("%s: Could not find configured input %s-list %s!", \
                peer->host, #f, F ## _IN_NAME(filter));
   
   if (DISTRIBUTE_IN_NAME (filter)) {
@@ -625,7 +625,7 @@ bgp_output_filter (struct peer *peer, struct prefix *p, struct attr *attr,
 #define FILTER_EXIST_WARN(F,f,filter) \
   if (BGP_DEBUG (update, UPDATE_OUT) \
       && !(F ## _OUT (filter))) \
-    plog_warn (peer->log, "%s: Could not find configured output %s-list %s!", \
+    zlog_warn ("%s: Could not find configured output %s-list %s!", \
                peer->host, #f, F ## _OUT_NAME(filter));
 
   if (DISTRIBUTE_OUT_NAME (filter)) {
@@ -961,12 +961,11 @@ bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p,
     {
       if (IPV4_ADDR_SAME (&peer->remote_id, &riattr->extra->originator_id))
        {
-         if (BGP_DEBUG (filter, FILTER))  
-           zlog (peer->log, LOG_DEBUG,
-                 "%s [Update:SEND] %s/%d originator-id is same as remote router-id",
-                 peer->host,
-                 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
-                 p->prefixlen);
+          if (bgp_debug_update(peer, p, 0))
+           zlog_debug("%s [Update:SEND] %s/%d originator-id is same as remote router-id",
+                      peer->host,
+                      inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
+                      p->prefixlen);
          return 0;
        }
     }
@@ -984,12 +983,11 @@ bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p,
   /* Output filter check. */
   if (bgp_output_filter (peer, p, riattr, afi, safi) == FILTER_DENY)
     {
-      if (BGP_DEBUG (filter, FILTER))
-       zlog (peer->log, LOG_DEBUG,
-             "%s [Update:SEND] %s/%d is filtered",
-             peer->host,
-             inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
-             p->prefixlen);
+      if (bgp_debug_update(peer, p, 0))
+       zlog_debug("%s [Update:SEND] %s/%d is filtered",
+                  peer->host,
+                  inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
+                  p->prefixlen);
       return 0;
     }
 
@@ -997,10 +995,9 @@ bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p,
   /* AS path loop check. */
   if (aspath_loop_check (riattr->aspath, peer->as))
     {
-      if (BGP_DEBUG (filter, FILTER))  
-        zlog (peer->log, LOG_DEBUG, 
-             "%s [Update:SEND] suppress announcement to peer AS %u is AS path.",
-             peer->host, peer->as);
+      if (bgp_debug_update(peer, p, 0))
+        zlog_debug("%s [Update:SEND] suppress announcement to peer AS %u is AS path.",
+                  peer->host, peer->as);
       return 0;
     }
 #endif /* BGP_SEND_ASPATH_CHECK */
@@ -1010,11 +1007,10 @@ bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p,
     {
       if (aspath_loop_check(riattr->aspath, bgp->confed_id))
        {
-         if (BGP_DEBUG (filter, FILTER))  
-           zlog (peer->log, LOG_DEBUG, 
-                 "%s [Update:SEND] suppress announcement to peer AS %u is AS path.",
-                 peer->host,
-                 bgp->confed_id);
+          if (bgp_debug_update(peer, p, 0))
+           zlog_debug("%s [Update:SEND] suppress announcement to peer AS %u is AS path.",
+                      peer->host,
+                      bgp->confed_id);
          return 0;
        }      
     }
@@ -1254,12 +1250,11 @@ bgp_announce_check_rsclient (struct bgp_info *ri, struct peer *rsclient,
       if (IPV4_ADDR_SAME (&rsclient->remote_id, 
                           &riattr->extra->originator_id))
         {
-         if (BGP_DEBUG (filter, FILTER))
-           zlog (rsclient->log, LOG_DEBUG,
-                 "%s [Update:SEND] %s/%d originator-id is same as remote router-id",
-                 rsclient->host,
-                 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
-                 p->prefixlen);
+          if (bgp_debug_update(rsclient, p, 0))
+            zlog_debug ("%s [Update:SEND] %s/%d originator-id is same as remote router-id",
+                        rsclient->host,
+                        inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
+                        p->prefixlen);
          return 0;
        }
     }
@@ -1277,12 +1272,11 @@ bgp_announce_check_rsclient (struct bgp_info *ri, struct peer *rsclient,
   /* Output filter check. */
   if (bgp_output_filter (rsclient, p, riattr, afi, safi) == FILTER_DENY)
     {
-      if (BGP_DEBUG (filter, FILTER))
-       zlog (rsclient->log, LOG_DEBUG,
-             "%s [Update:SEND] %s/%d is filtered",
-             rsclient->host,
-             inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
-             p->prefixlen);
+      if (bgp_debug_update(rsclient, p, 0))
+        zlog_debug ("%s [Update:SEND] %s/%d is filtered",
+                    rsclient->host,
+                    inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
+                    p->prefixlen);
       return 0;
     }
 
@@ -1290,10 +1284,9 @@ bgp_announce_check_rsclient (struct bgp_info *ri, struct peer *rsclient,
   /* AS path loop check. */
   if (aspath_loop_check (riattr->aspath, rsclient->as))
     {
-      if (BGP_DEBUG (filter, FILTER))
-        zlog (rsclient->log, LOG_DEBUG,
-             "%s [Update:SEND] suppress announcement to peer AS %u is AS path.",
-             rsclient->host, rsclient->as);
+      if (bgp_debug_update(rsclient, p, 0))
+        zlog_debug ("%s [Update:SEND] suppress announcement to peer AS %u is AS path.",
+                    rsclient->host, rsclient->as);
       return 0;
     }
 #endif /* BGP_SEND_ASPATH_CHECK */
@@ -1916,7 +1909,7 @@ bgp_maximum_prefix_restart_timer (struct thread *thread)
   peer = THREAD_ARG (thread);
   peer->t_pmax_restart = NULL;
 
-  if (BGP_DEBUG (events, EVENTS))
+  if (bgp_debug_neighbor_events(peer))
     zlog_debug ("%s Maximum-prefix restart timer expired, restore peering",
                peer->host);
 
@@ -1938,10 +1931,9 @@ bgp_maximum_prefix_overflow (struct peer *peer, afi_t afi,
          && ! always)
        return 0;
 
-      zlog (peer->log, LOG_INFO,
-           "%%MAXPFXEXCEED: No. of %s prefix received from %s %ld exceed, "
-           "limit %ld", afi_safi_print (afi, safi), peer->host,
-           peer->pcount[afi][safi], peer->pmax[afi][safi]);
+      zlog_info ("%%MAXPFXEXCEED: No. of %s prefix received from %s %ld exceed, "
+                "limit %ld", afi_safi_print (afi, safi), peer->host,
+                peer->pcount[afi][safi], peer->pmax[afi][safi]);
       SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT);
 
       if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING))
@@ -1971,7 +1963,7 @@ bgp_maximum_prefix_overflow (struct peer *peer, afi_t afi,
        {
          peer->v_pmax_restart = peer->pmax_restart[afi][safi] * 60;
 
-         if (BGP_DEBUG (events, EVENTS))
+          if (bgp_debug_neighbor_events(peer))
            zlog_debug ("%s Maximum-prefix restart timer started for %d secs",
                        peer->host, peer->v_pmax_restart);
 
@@ -1990,10 +1982,9 @@ bgp_maximum_prefix_overflow (struct peer *peer, afi_t afi,
          && ! always)
        return 0;
 
-      zlog (peer->log, LOG_INFO,
-           "%%MAXPFX: No. of %s prefix received from %s reaches %ld, max %ld",
-           afi_safi_print (afi, safi), peer->host, peer->pcount[afi][safi],
-           peer->pmax[afi][safi]);
+      zlog_info ("%%MAXPFX: No. of %s prefix received from %s reaches %ld, max %ld",
+                afi_safi_print (afi, safi), peer->host, peer->pcount[afi][safi],
+                peer->pmax[afi][safi]);
       SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD);
     }
   else
@@ -2148,12 +2139,12 @@ bgp_update_rsclient (struct peer *rsclient, afi_t afi, safi_t safi,
 
           bgp_info_unset_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
 
-          if (BGP_DEBUG (update, UPDATE_IN))
-            zlog (peer->log, LOG_DEBUG,
-                    "%s rcvd %s/%d for RS-client %s...duplicate ignored",
-                    peer->host,
-                    inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
-                    p->prefixlen, rsclient->host);
+          if (bgp_debug_update(peer, p, 1))
+            zlog_debug ("%s rcvd %s/%d for RS-client %s...duplicate ignored",
+                        peer->host,
+                        inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
+                        p->prefixlen, rsclient->host);
+
 
           bgp_unlock_node (rn);
           bgp_attr_unintern (&attr_new);
@@ -2166,11 +2157,11 @@ bgp_update_rsclient (struct peer *rsclient, afi_t afi, safi_t safi,
         bgp_info_restore (rn, ri);
       
       /* Received Logging. */
-      if (BGP_DEBUG (update, UPDATE_IN))
-        zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s",
-                peer->host,
-                inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
-                p->prefixlen, rsclient->host);
+      if (bgp_debug_update(peer, p, 1))
+        zlog_debug ("%s rcvd %s/%d for RS-client %s",
+                    peer->host,
+                    inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
+                    p->prefixlen, rsclient->host);
 
       /* The attribute is changed. */
       bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
@@ -2193,12 +2184,12 @@ bgp_update_rsclient (struct peer *rsclient, afi_t afi, safi_t safi,
     }
 
   /* Received Logging. */
-  if (BGP_DEBUG (update, UPDATE_IN))
+  if (bgp_debug_update(peer, p, 1))
     {
-      zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s",
-              peer->host,
-              inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
-              p->prefixlen, rsclient->host);
+      zlog_debug ("%s rcvd %s/%d for RS-client %s",
+                  peer->host,
+                  inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
+                  p->prefixlen, rsclient->host);
     }
 
   new = info_make(type, sub_type, peer, attr_new, rn);
@@ -2223,12 +2214,11 @@ bgp_update_rsclient (struct peer *rsclient, afi_t afi, safi_t safi,
  filtered: 
 
   /* This BGP update is filtered.  Log the reason then update BGP entry.  */
-  if (BGP_DEBUG (update, UPDATE_IN))
-        zlog (peer->log, LOG_DEBUG,
-        "%s rcvd UPDATE about %s/%d -- DENIED for RS-client %s due to: %s",
-        peer->host,
-        inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
-        p->prefixlen, rsclient->host, reason);
+  if (bgp_debug_update(peer, p, 1))
+        zlog_debug ("%s rcvd UPDATE about %s/%d -- DENIED for RS-client %s due to: %s",
+                    peer->host,
+                    inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
+                    p->prefixlen, rsclient->host, reason);
 
   if (ri)
     bgp_rib_remove (rn, ri, peer, afi, safi);
@@ -2260,11 +2250,10 @@ bgp_withdraw_rsclient (struct peer *rsclient, afi_t afi, safi_t safi,
   /* Withdraw specified route from routing table. */
   if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
     bgp_rib_withdraw (rn, ri, peer, afi, safi);
-  else if (BGP_DEBUG (update, UPDATE_IN))
-    zlog (peer->log, LOG_DEBUG,
-          "%s Can't find the route %s/%d", peer->host,
-          inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
-          p->prefixlen);
+  else if (bgp_debug_update(peer, p, 1))
+    zlog_debug ("%s Can't find the route %s/%d", peer->host,
+                inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
+                p->prefixlen);
 
   /* Unlock bgp_node_get() lock. */
   bgp_unlock_node (rn);
@@ -2393,11 +2382,11 @@ bgp_update_main (struct peer *peer, struct prefix *p, struct attr *attr,
              && peer->sort == BGP_PEER_EBGP
              && CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
            {
-             if (BGP_DEBUG (update, UPDATE_IN))  
-                 zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d",
-                 peer->host,
-                 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
-                 p->prefixlen);
+             if (bgp_debug_update(peer, p, 1))
+                 zlog_debug ("%s rcvd %s/%d",
+                             peer->host,
+                             inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
+                             p->prefixlen);
 
              if (bgp_damp_update (ri, rn, afi, safi) != BGP_DAMP_SUPPRESSED)
                {
@@ -2407,12 +2396,19 @@ bgp_update_main (struct peer *peer, struct prefix *p, struct attr *attr,
            }
           else /* Duplicate - odd */
            {
-             if (BGP_DEBUG (update, UPDATE_IN))  
-               zlog (peer->log, LOG_DEBUG,
-               "%s rcvd %s/%d...duplicate ignored",
-               peer->host,
-               inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
-               p->prefixlen);
+             if (bgp_debug_update(peer, p, 1))
+                {
+                if (!peer->rcvd_attr_printed)
+                  {
+                    zlog_debug ("%s rcvd UPDATE w/ attr: %s", peer->host, peer->rcvd_attr_str);
+                    peer->rcvd_attr_printed = 1;
+                  }
+
+                 zlog_debug ("%s rcvd %s/%d...duplicate ignored",
+                             peer->host,
+                             inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
+                             p->prefixlen);
+                }
 
              /* graceful restart STALE flag unset. */
              if (CHECK_FLAG (ri->flags, BGP_INFO_STALE))
@@ -2431,20 +2427,20 @@ bgp_update_main (struct peer *peer, struct prefix *p, struct attr *attr,
       /* Withdraw/Announce before we fully processed the withdraw */
       if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
         {
-          if (BGP_DEBUG (update, UPDATE_IN))
-            zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d, flapped quicker than processing",
-            peer->host,
-            inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
-            p->prefixlen);
+          if (bgp_debug_update(peer, p, 1))
+            zlog_debug ("%s rcvd %s/%d, flapped quicker than processing",
+                        peer->host,
+                        inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
+                        p->prefixlen);
           bgp_info_restore (rn, ri);
         }
 
       /* Received Logging. */
-      if (BGP_DEBUG (update, UPDATE_IN))  
-       zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d",
-             peer->host,
-             inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
-             p->prefixlen);
+      if (bgp_debug_update(peer, p, 1))
+       zlog_debug ("%s rcvd %s/%d",
+                   peer->host,
+                   inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
+                   p->prefixlen);
 
       /* graceful restart STALE flag unset. */
       if (CHECK_FLAG (ri->flags, BGP_INFO_STALE))
@@ -2524,12 +2520,18 @@ bgp_update_main (struct peer *peer, struct prefix *p, struct attr *attr,
     }
 
   /* Received Logging. */
-  if (BGP_DEBUG (update, UPDATE_IN))  
+  if (bgp_debug_update(peer, p, 1))
     {
-      zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d",
-           peer->host,
-           inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
-           p->prefixlen);
+      if (!peer->rcvd_attr_printed)
+        {
+          zlog_debug ("%s rcvd UPDATE w/ attr: %s", peer->host, peer->rcvd_attr_str);
+          peer->rcvd_attr_printed = 1;
+        }
+
+      zlog_debug ("%s rcvd %s/%d",
+                 peer->host,
+                 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
+                 p->prefixlen);
     }
 
   /* Make new BGP info. */
@@ -2586,12 +2588,19 @@ bgp_update_main (struct peer *peer, struct prefix *p, struct attr *attr,
   /* This BGP update is filtered.  Log the reason then update BGP
      entry.  */
  filtered:
-  if (BGP_DEBUG (update, UPDATE_IN))
-    zlog (peer->log, LOG_DEBUG,
-         "%s rcvd UPDATE about %s/%d -- DENIED due to: %s",
-         peer->host,
-         inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
-         p->prefixlen, reason);
+  if (bgp_debug_update(peer, p, 1))
+    {
+      if (!peer->rcvd_attr_printed)
+        {
+          zlog_debug ("%s rcvd UPDATE w/ attr: %s", peer->host, peer->rcvd_attr_str);
+          peer->rcvd_attr_printed = 1;
+        }
+
+      zlog_debug ("%s rcvd UPDATE about %s/%d -- DENIED due to: %s",
+                  peer->host,
+                  inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
+                  p->prefixlen, reason);
+    }
 
   if (ri)
     bgp_rib_remove (rn, ri, peer, afi, safi);
@@ -2649,11 +2658,11 @@ bgp_withdraw (struct peer *peer, struct prefix *p, struct attr *attr,
     }
 
   /* Logging. */
-  if (BGP_DEBUG (update, UPDATE_IN))  
-    zlog (peer->log, LOG_DEBUG, "%s rcvd UPDATE about %s/%d -- withdrawn",
-         peer->host,
-         inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
-         p->prefixlen);
+  if (bgp_debug_update(peer, p, 1))
+    zlog_debug ("%s rcvd UPDATE about %s/%d -- withdrawn",
+               peer->host,
+               inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
+               p->prefixlen);
 
   /* Lookup node. */
   rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd);
@@ -2672,11 +2681,10 @@ bgp_withdraw (struct peer *peer, struct prefix *p, struct attr *attr,
   /* Withdraw specified route from routing table. */
   if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
     bgp_rib_withdraw (rn, ri, peer, afi, safi);
-  else if (BGP_DEBUG (update, UPDATE_IN))
-    zlog (peer->log, LOG_DEBUG, 
-         "%s Can't find the route %s/%d", peer->host,
-         inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
-         p->prefixlen);
+  else if (bgp_debug_update(peer, p, 1))
+    zlog_debug ("%s Can't find the route %s/%d", peer->host,
+               inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
+               p->prefixlen);
 
   /* Unlock bgp_node_get() lock. */
   bgp_unlock_node (rn);
@@ -3356,9 +3364,8 @@ bgp_nlri_parse (struct peer *peer, struct attr *attr, struct bgp_nlri *packet)
              * semantically incorrect (eg. an unexpected multicast IP
              * address), it should ignore the prefix.
              */
-             zlog (peer->log, LOG_ERR, 
-                   "IPv4 unicast NLRI is multicast address %s",
-                   inet_ntoa (p.u.prefix4));
+             zlog_err ("IPv4 unicast NLRI is multicast address %s",
+                       inet_ntoa (p.u.prefix4));
 
              return -1;
            }
@@ -3372,9 +3379,8 @@ bgp_nlri_parse (struct peer *peer, struct attr *attr, struct bgp_nlri *packet)
            {
              char buf[BUFSIZ];
 
-             zlog (peer->log, LOG_WARNING, 
-                   "IPv6 link-local NLRI received %s ignore this NLRI",
-                   inet_ntop (AF_INET6, &p.u.prefix6, buf, BUFSIZ));
+             zlog_warn ("IPv6 link-local NLRI received %s ignore this NLRI",
+                        inet_ntop (AF_INET6, &p.u.prefix6, buf, BUFSIZ));
 
              continue;
            }
@@ -3426,8 +3432,7 @@ bgp_nlri_sanity_check (struct peer *peer, int afi, u_char *pnt,
       if ((afi == AFI_IP && prefixlen > 32)
          || (afi == AFI_IP6 && prefixlen > 128))
        {
-         plog_err (peer->log, 
-                   "%s [Error] Update packet error (wrong prefix length %d)",
+         zlog_err ("%s [Error] Update packet error (wrong prefix length %d)",
                    peer->host, prefixlen);
          bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, 
                           BGP_NOTIFY_UPDATE_INVAL_NETWORK);
@@ -3439,8 +3444,7 @@ bgp_nlri_sanity_check (struct peer *peer, int afi, u_char *pnt,
 
       if (pnt + psize > end)
        {
-         plog_err (peer->log, 
-                   "%s [Error] Update packet error"
+         zlog_err ("%s [Error] Update packet error"
                    " (prefix data overflow prefix size is %d)",
                    peer->host, psize);
          bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, 
@@ -3455,8 +3459,7 @@ bgp_nlri_sanity_check (struct peer *peer, int afi, u_char *pnt,
   /* Packet length consistency check. */
   if (pnt != end)
     {
-      plog_err (peer->log,
-               "%s [Error] Update packet error"
+      zlog_err ("%s [Error] Update packet error"
                " (prefix length mismatch with total length)",
                peer->host);
       bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, 
@@ -3581,11 +3584,10 @@ bgp_static_update_rsclient (struct peer *rsclient, struct prefix *p,
         == RMAP_DENY)
     {
       /* This BGP update is filtered.  Log the reason then update BGP entry.  */
-      if (BGP_DEBUG (update, UPDATE_IN))
-              zlog (rsclient->log, LOG_DEBUG,
-              "Static UPDATE about %s/%d -- DENIED for RS-client %s due to: import-policy",
-              inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
-              p->prefixlen, rsclient->host);
+      if (bgp_debug_update(rsclient, p, 1))
+        zlog_debug ("Static UPDATE about %s/%d -- DENIED for RS-client %s due to: import-policy",
+                    inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
+                    p->prefixlen, rsclient->host);
 
       bgp->peer_self->rmap_type = 0;
 
@@ -10351,8 +10353,7 @@ bgp_peer_count_walker (struct thread *t)
             {
               pc->count[PCOUNT_COUNTED]++;
               if (CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE))
-                plog_warn (peer->log,
-                           "%s [pcount] %s/%d is counted but flags 0x%x",
+                zlog_warn ("%s [pcount] %s/%d is counted but flags 0x%x",
                            peer->host,
                            inet_ntop(rn->p.family, &rn->p.u.prefix,
                                      buf, SU_ADDRSTRLEN),
@@ -10362,8 +10363,7 @@ bgp_peer_count_walker (struct thread *t)
           else
             {
               if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE))
-                plog_warn (peer->log,
-                           "%s [pcount] %s/%d not counted but flags 0x%x",
+                zlog_warn ("%s [pcount] %s/%d not counted but flags 0x%x",
                            peer->host,
                            inet_ntop(rn->p.family, &rn->p.u.prefix,
                                      buf, SU_ADDRSTRLEN),
index e9a19f93d078d910168ba379128500dcbf91f4dd..2a88f0f082cfaeb1b593f9bd265b13b755daf074 100644 (file)
@@ -2652,7 +2652,7 @@ bgp_route_map_process_peer (char *rmap_name, struct peer *peer,
              if (CHECK_FLAG (peer->af_flags[afi][safi],
                              PEER_FLAG_SOFT_RECONFIG))
                {
-                 if (BGP_DEBUG(events, EVENTS))
+                  if (bgp_debug_update(peer, NULL, 1))
                    zlog_debug("Processing route_map %s update on "
                               "peer %s (inbound, soft-reconfig)",
                               rmap_name, peer->host);
@@ -2663,7 +2663,7 @@ bgp_route_map_process_peer (char *rmap_name, struct peer *peer,
                       || CHECK_FLAG (peer->cap, PEER_CAP_REFRESH_NEW_RCV))
                {
 
-                 if (BGP_DEBUG(events, EVENTS))
+                  if (bgp_debug_update(peer, NULL, 1))
                    zlog_debug("Processing route_map %s update on "
                               "peer %s (inbound, route-refresh)",
                               rmap_name, peer->host);
@@ -2699,7 +2699,7 @@ bgp_route_map_process_peer (char *rmap_name, struct peer *peer,
          if (CHECK_FLAG (peer->af_flags[afi][safi],
                          PEER_FLAG_SOFT_RECONFIG))
            {
-             if (BGP_DEBUG(events, EVENTS))
+              if (bgp_debug_update(peer, NULL, 1))
                zlog_debug("Processing route_map %s update on "
                           "peer %s (import, soft-reconfig)",
                           rmap_name, peer->host);
@@ -2709,7 +2709,7 @@ bgp_route_map_process_peer (char *rmap_name, struct peer *peer,
          else if (CHECK_FLAG (peer->cap, PEER_CAP_REFRESH_OLD_RCV)
                   || CHECK_FLAG (peer->cap, PEER_CAP_REFRESH_NEW_RCV))
            {
-             if (BGP_DEBUG(events, EVENTS))
+              if (bgp_debug_update(peer, NULL, 1))
                zlog_debug("Processing route_map %s update on "
                           "peer %s (import, route-refresh)",
                           rmap_name, peer->host);
@@ -2725,7 +2725,7 @@ bgp_route_map_process_peer (char *rmap_name, struct peer *peer,
          filter->map[RMAP_OUT].map =
            route_map_lookup_by_name (filter->map[RMAP_OUT].name);
 
-         if (BGP_DEBUG(events, EVENTS))
+          if (bgp_debug_update(peer, NULL, 0))
            zlog_debug("Processing route_map %s update on peer %s (outbound)",
                       rmap_name, peer->host);
 
@@ -2817,7 +2817,7 @@ bgp_route_map_process_update (void *arg, char *rmap_name, int route_update)
                peer->default_rmap[afi][safi].map =
                  route_map_lookup_by_name (peer->default_rmap[afi][safi].name);
 
-               if (BGP_DEBUG(events, EVENTS))
+                if (bgp_debug_update(peer, NULL, 0))
                  zlog_debug("Processing route_map %s update on "
                             "default-originate", rmap_name);
 
@@ -2838,7 +2838,7 @@ bgp_route_map_process_update (void *arg, char *rmap_name, int route_update)
          {
            bgp->table_map[afi][safi].map =
              route_map_lookup_by_name (bgp->table_map[afi][safi].name);
-           if (BGP_DEBUG(events, EVENTS))
+            if (BGP_DEBUG (zebra, ZEBRA))
              zlog_debug("Processing route_map %s update on "
                         "table map", rmap_name);
            if (route_update)
@@ -2861,7 +2861,7 @@ bgp_route_map_process_update (void *arg, char *rmap_name, int route_update)
                if (route_update)
                  if (!bgp_static->backdoor)
                    {
-                     if (BGP_DEBUG(events, EVENTS))
+                      if (bgp_debug_zebra(&bn->p))
                        zlog_debug("Processing route_map %s update on "
                                   "static route %s", rmap_name,
                                   inet_ntop (bn->p.family, &bn->p.u.prefix,
@@ -2883,7 +2883,7 @@ bgp_route_map_process_update (void *arg, char *rmap_name, int route_update)
 
            if (bgp->redist[afi][i] && route_update)
              {
-               if (BGP_DEBUG(events, EVENTS))
+                if (BGP_DEBUG (zebra, ZEBRA))
                  zlog_debug("Processing route_map %s update on "
                             "redistributed routes", rmap_name);
 
@@ -2908,14 +2908,8 @@ bgp_route_map_update_timer(struct thread *thread)
 
   bgp->t_rmap_update = NULL;
 
-  if (BGP_DEBUG(events, EVENTS))
-    zlog_debug("Started processing route map update");
-
   route_map_walk_update_list((void *)bgp, bgp_route_map_process_update_cb);
 
-  if (BGP_DEBUG(events, EVENTS))
-    zlog_debug("Finished processing route map update");
-
   return (0);
 }
 
@@ -2929,9 +2923,6 @@ bgp_route_map_mark_update (char *rmap_name)
     {
       if (bgp->t_rmap_update == NULL)
        {
-         if (BGP_DEBUG(events, EVENTS))
-           zlog_debug("Starting route map update timer (in %d secs)",
-                      bgp->rmap_update_timer);
          /* rmap_update_timer of 0 means don't do route updates */
          if (bgp->rmap_update_timer)
            bgp->t_rmap_update =
@@ -2946,9 +2937,6 @@ bgp_route_map_mark_update (char *rmap_name)
 static void
 bgp_route_map_add (const char *rmap_name)
 {
-  if (BGP_DEBUG (events, EVENTS))
-    zlog_debug ("received route-map add of %s", rmap_name);
-
   if (route_map_mark_updated(rmap_name, 0) == 0)
     bgp_route_map_mark_update(rmap_name);
 
@@ -2958,9 +2946,6 @@ bgp_route_map_add (const char *rmap_name)
 static void
 bgp_route_map_delete (const char *rmap_name)
 {
-  if (BGP_DEBUG (events, EVENTS))
-    zlog_debug ("received route-map delete of %s", rmap_name);
-
   if (route_map_mark_updated(rmap_name, 1) == 0)
     bgp_route_map_mark_update(rmap_name);
 
@@ -2970,9 +2955,6 @@ bgp_route_map_delete (const char *rmap_name)
 static void
 bgp_route_map_event (route_map_event_t event, const char *rmap_name)
 {
-  if (BGP_DEBUG (events, EVENTS))
-    zlog_debug ("received route-map event for %s", rmap_name);
-
   if (route_map_mark_updated(rmap_name, 0) == 0)
     bgp_route_map_mark_update(rmap_name);
 
index 73ac58d2cab4ee0e90a62b0a3590bbb6b8ed903f..8b9d3c39d49099e250c3a05d347feef5c445a275 100644 (file)
@@ -1775,7 +1775,7 @@ peer_announce_routes_if_rmap_out (struct bgp *bgp)
                filter = &peer->filter[afi][safi];
                if (ROUTE_MAP_OUT_NAME(filter))
                  {
-                   if (BGP_DEBUG(update, UPDATE_OUT))
+                   if (bgp_debug_update(peer, NULL, 0))
                      zlog_debug("%s: Announcing routes again for peer %s"
                                 "(afi=%d, safi=%d", __func__, peer->host, afi,
                                 safi);
index 3c81d638ce5f745d8ead5f385937fe48db49730d..d2787ec820d4f3e893155d32e9efed2c53e06a50 100644 (file)
@@ -95,7 +95,7 @@ bgp_router_id_update (int command, struct zclient *zclient, zebra_size_t length)
 
   zebra_router_id_update_read(zclient->ibuf,&router_id);
 
-  if (BGP_DEBUG(zebra, ZEBRA))
+  if (BGP_DEBUG (zebra, ZEBRA))
     {
       char buf[128];
       prefix2str(&router_id, buf, sizeof(buf));
@@ -170,7 +170,7 @@ bgp_interface_add (int command, struct zclient *zclient, zebra_size_t length)
 
   ifp = zebra_interface_add_read (zclient->ibuf);
 
-  if (BGP_DEBUG(zebra, ZEBRA) && ifp)
+  if (BGP_DEBUG (zebra, ZEBRA) && ifp)
     zlog_debug("Zebra rcvd: interface add %s", ifp->name);
 
   return 0;
@@ -187,7 +187,7 @@ bgp_interface_delete (int command, struct zclient *zclient,
   ifp = zebra_interface_state_read (s);
   ifp->ifindex = IFINDEX_INTERNAL;
 
-  if (BGP_DEBUG(zebra, ZEBRA))
+  if (BGP_DEBUG (zebra, ZEBRA))
     zlog_debug("Zebra rcvd: interface delete %s", ifp->name);
 
   return 0;
@@ -208,7 +208,7 @@ bgp_interface_up (int command, struct zclient *zclient, zebra_size_t length)
   if (! ifp)
     return 0;
 
-  if (BGP_DEBUG(zebra, ZEBRA))
+  if (BGP_DEBUG (zebra, ZEBRA))
     zlog_debug("Zebra rcvd: interface %s up", ifp->name);
 
   for (ALL_LIST_ELEMENTS (ifp->connected, node, nnode, c))
@@ -234,7 +234,7 @@ bgp_interface_down (int command, struct zclient *zclient, zebra_size_t length)
   if (! ifp)
     return 0;
 
-  if (BGP_DEBUG(zebra, ZEBRA))
+  if (BGP_DEBUG (zebra, ZEBRA))
     zlog_debug("Zebra rcvd: interface %s down", ifp->name);
 
   for (ALL_LIST_ELEMENTS (ifp->connected, node, nnode, c))
@@ -280,7 +280,7 @@ bgp_interface_bfd_dest_down (int command, struct zclient *zclient,
   if (ifp == NULL)
     return 0;
 
-  if (BGP_DEBUG(zebra, ZEBRA))
+  if (BGP_DEBUG (zebra, ZEBRA))
     {
       char buf[128];
       prefix2str(&p, buf, sizeof(buf));
@@ -320,7 +320,7 @@ bgp_interface_address_add (int command, struct zclient *zclient,
   if (ifc == NULL)
     return 0;
 
-  if (BGP_DEBUG(zebra, ZEBRA))
+  if (bgp_debug_zebra(ifc->address))
     {
       char buf[128];
       prefix2str(ifc->address, buf, sizeof(buf));
@@ -345,7 +345,7 @@ bgp_interface_address_delete (int command, struct zclient *zclient,
   if (ifc == NULL)
     return 0;
 
-  if (BGP_DEBUG(zebra, ZEBRA))
+  if (bgp_debug_zebra(ifc->address))
     {
       char buf[128];
       prefix2str(ifc->address, buf, sizeof(buf));
@@ -372,7 +372,7 @@ bgp_interface_nbr_address_add (int command, struct zclient *zclient,
   if (ifc == NULL)
     return 0;
 
-  if (BGP_DEBUG(zebra, ZEBRA))
+  if (bgp_debug_zebra(ifc->address))
     {
       char buf[128];
       prefix2str(ifc->address, buf, sizeof(buf));
@@ -397,7 +397,7 @@ bgp_interface_nbr_address_delete (int command, struct zclient *zclient,
   if (ifc == NULL)
     return 0;
 
-  if (BGP_DEBUG(zebra, ZEBRA))
+  if (bgp_debug_zebra(ifc->address))
     {
       char buf[128];
       prefix2str(ifc->address, buf, sizeof(buf));
@@ -465,7 +465,7 @@ zebra_read_ipv4 (int command, struct zclient *zclient, zebra_size_t length)
 
   if (command == ZEBRA_IPV4_ROUTE_ADD)
     {
-      if (BGP_DEBUG(zebra, ZEBRA))
+      if (bgp_debug_zebra(&p))
        {
          char buf[2][INET_ADDRSTRLEN];
          zlog_debug("Zebra rcvd: IPv4 route add %s %s/%d nexthop %s metric %u tag %d",
@@ -481,7 +481,7 @@ zebra_read_ipv4 (int command, struct zclient *zclient, zebra_size_t length)
     }
   else
     {
-      if (BGP_DEBUG(zebra, ZEBRA))
+      if (bgp_debug_zebra(&p))
        {
          char buf[2][INET_ADDRSTRLEN];
          zlog_debug("Zebra rcvd: IPv4 route delete %s %s/%d "
@@ -558,7 +558,7 @@ zebra_read_ipv6 (int command, struct zclient *zclient, zebra_size_t length)
 
   if (command == ZEBRA_IPV6_ROUTE_ADD)
     {
-      if (BGP_DEBUG(zebra, ZEBRA))
+      if (bgp_debug_zebra(&p))
        {
          char buf[2][INET6_ADDRSTRLEN];
          zlog_debug("Zebra rcvd: IPv6 route add %s %s/%d nexthop %s metric %u tag %d",
@@ -574,7 +574,7 @@ zebra_read_ipv6 (int command, struct zclient *zclient, zebra_size_t length)
     }
   else
     {
-      if (BGP_DEBUG(zebra, ZEBRA))
+      if (bgp_debug_zebra(&p))
        {
          char buf[2][INET6_ADDRSTRLEN];
          zlog_debug("Zebra rcvd: IPv6 route delete %s %s/%d "
@@ -901,7 +901,7 @@ bgp_table_map_apply (struct route_map *map, struct prefix *p,
   if (route_map_apply(map, p, RMAP_BGP, info) != RMAP_DENYMATCH)
     return 1;
 
-  if (BGP_DEBUG(zebra, ZEBRA))
+  if (bgp_debug_zebra(p))
     {
       if (p->family == AF_INET)
         {
@@ -1072,7 +1072,7 @@ bgp_zebra_announce (struct prefix *p, struct bgp_info *info, struct bgp *bgp,
          api.distance = distance;
        }
 
-      if (BGP_DEBUG(zebra, ZEBRA))
+      if (bgp_debug_zebra(p))
         {
           int i;
           zlog_debug("Zebra send: IPv4 route %s %s/%d metric %u tag %d"
@@ -1234,7 +1234,7 @@ bgp_zebra_announce (struct prefix *p, struct bgp_info *info, struct bgp *bgp,
           api.tag = tag;
         }
 
-      if (BGP_DEBUG(zebra, ZEBRA))
+      if (bgp_debug_zebra(p))
         {
           int i;
           zlog_debug("Zebra send: IPv6 route %s %s/%d metric %u tag %d",
@@ -1324,7 +1324,7 @@ bgp_zebra_withdraw (struct prefix *p, struct bgp_info *info, safi_t safi)
           api.tag = info->attr->extra->tag;
         }
 
-      if (BGP_DEBUG(zebra, ZEBRA))
+      if (bgp_debug_zebra(p))
        {
          char buf[2][INET_ADDRSTRLEN];
          zlog_debug("Zebra send: IPv4 route delete %s/%d nexthop %s metric %u tag %d",
@@ -1389,7 +1389,7 @@ bgp_zebra_withdraw (struct prefix *p, struct bgp_info *info, safi_t safi)
           api.tag = info->attr->extra->tag;
         }
 
-      if (BGP_DEBUG(zebra, ZEBRA))
+      if (bgp_debug_zebra(p))
        {
          char buf[2][INET6_ADDRSTRLEN];
          zlog_debug("Zebra send: IPv6 route delete %s/%d nexthop %s metric %u tag %d",
@@ -1423,7 +1423,7 @@ bgp_redistribute_set (struct bgp *bgp, afi_t afi, int type)
   if (zclient->sock < 0)
     return CMD_WARNING;
 
-  if (BGP_DEBUG(zebra, ZEBRA))
+  if (BGP_DEBUG (zebra, ZEBRA))
     zlog_debug("Zebra send: redistribute add %s", zebra_route_string(type));
 
   /* Send distribute add message to zebra. */
@@ -1439,7 +1439,7 @@ bgp_redistribute_resend (struct bgp *bgp, afi_t afi, int type)
   if (zclient->sock < 0)
     return -1;
 
-  if (BGP_DEBUG(zebra, ZEBRA))
+  if (BGP_DEBUG (zebra, ZEBRA))
     zlog_debug("Zebra send: redistribute add %s", zebra_route_string(type));
 
   /* Send distribute add message to zebra. */
@@ -1508,7 +1508,7 @@ bgp_redistribute_unset (struct bgp *bgp, afi_t afi, int type)
       && zclient->sock >= 0)
     {
       /* Send distribute delete message to zebra. */
-      if (BGP_DEBUG(zebra, ZEBRA))
+      if (BGP_DEBUG (zebra, ZEBRA))
        zlog_debug("Zebra send: redistribute delete %s",
                   zebra_route_string(type));
       zebra_redistribute_send (ZEBRA_REDISTRIBUTE_DELETE, zclient, type);
index bb60f08eb4410908f9effd82af7b256a2e2c8b91..f6d06c0e659ad39505bf6e329acc3e716cdb4770 100644 (file)
@@ -565,7 +565,7 @@ peer_rsclient_active (struct peer *peer)
 }
 
 /* Peer comparison function for sorting.  */
-static int
+int
 peer_cmp (struct peer *p1, struct peer *p2)
 {
   return sockunion_cmp (&p1->su, &p2->su);
@@ -1384,13 +1384,13 @@ peer_nsf_stop (struct peer *peer)
   if (peer->t_gr_restart)
     {
       BGP_TIMER_OFF (peer->t_gr_restart);
-      if (BGP_DEBUG (events, EVENTS))
+      if (bgp_debug_neighbor_events(peer))
        zlog_debug ("%s graceful restart timer stopped", peer->host);
     }
   if (peer->t_gr_stale)
     {
       BGP_TIMER_OFF (peer->t_gr_stale);
-      if (BGP_DEBUG (events, EVENTS))
+      if (bgp_debug_neighbor_events(peer))
        zlog_debug ("%s graceful restart stalepath timer stopped", peer->host);
     }
   bgp_clear_route_all (peer);
@@ -2731,7 +2731,7 @@ peer_flag_modify_action (struct peer *peer, u_int32_t flag)
          if (peer->t_pmax_restart)
            {
              BGP_TIMER_OFF (peer->t_pmax_restart);
-              if (BGP_DEBUG (events, EVENTS))
+              if (bgp_debug_neighbor_events(peer))
                zlog_debug ("%s Maximum-prefix restart timer canceled",
                            peer->host);
            }
@@ -4936,7 +4936,7 @@ peer_ttl_security_hops_set (struct peer *peer, int gtsm_hops)
            }
          else if (peer->status < Established)
            {
-             if (BGP_DEBUG (events, EVENTS))
+              if (bgp_debug_neighbor_events(peer))
                zlog_debug ("%s Min-ttl changed", peer->host);
               bgp_session_reset(peer);
            }
@@ -5006,7 +5006,7 @@ peer_clear (struct peer *peer, struct listnode **nnode)
          if (peer->t_pmax_restart)
            {
              BGP_TIMER_OFF (peer->t_pmax_restart);
-             if (BGP_DEBUG (events, EVENTS))
+              if (bgp_debug_neighbor_events(peer))
                zlog_debug ("%s Maximum-prefix restart timer canceled",
                            peer->host);
            }
index 2dbc6434388d576d0b977500b1c5fc50163e95ba..743b8d78e7d688af39484192c25220f2510c8d44 100644 (file)
@@ -412,7 +412,6 @@ struct peer
   char *ifname;                        /* bind interface name. */
   char *update_if;
   union sockunion *update_source;
-  struct zlog *log;
 
   union sockunion *su_local;   /* Sockunion of local address.  */
   union sockunion *su_remote;  /* Sockunion of remote address.  */
@@ -606,6 +605,12 @@ struct peer
   /* ORF Prefix-list */
   struct prefix_list *orf_plist[AFI_MAX][SAFI_MAX];
 
+  /* Text description of last attribute rcvd */
+  char rcvd_attr_str[BUFSIZ];
+
+  /* Track if we printed the attribute in debugs */
+  int rcvd_attr_printed;
+
   /* Prefix count. */
   unsigned long pcount[AFI_MAX][SAFI_MAX];
 
@@ -1071,4 +1076,6 @@ extern int peer_ttl_security_hops_unset (struct peer *);
 
 extern int bgp_route_map_update_timer (struct thread *thread);
 extern void bgp_route_map_terminate(void);
+
+extern int peer_cmp (struct peer *p1, struct peer *p2);
 #endif /* _QUAGGA_BGPD_H */
index ce6a26214e511e89dbd7868589386ba0ff0730af..12b51e3b6bf3f09b3b52b9f18dc0c921a81fcbc1 100644 (file)
@@ -778,9 +778,10 @@ print_debug (struct vty *vty, int flags, int onoff)
 
 DEFUN (show_debugging,
        show_debugging_cmd,
-       "show debugging",
+       "show debugging isis",
        SHOW_STR
-       "State of each debugging option\n")
+       "State of each debugging option\n"
+       ISIS_STR)
 {
   vty_out (vty, "IS-IS:%s", VTY_NEWLINE);
   print_debug (vty, isis->debugs, 1);
index 99a5aadd90238efe5dfae81c61a30d7b6d057b5d..06f1171aeeb591e023ba39de216cb2cf7d19bbb7 100644 (file)
--- a/lib/log.c
+++ b/lib/log.c
@@ -582,28 +582,6 @@ ZLOG_FUNC(zlog_debug, LOG_DEBUG)
 
 #undef ZLOG_FUNC
 
-#define PLOG_FUNC(FUNCNAME,PRIORITY) \
-void \
-FUNCNAME(struct zlog *zl, const char *format, ...) \
-{ \
-  va_list args; \
-  va_start(args, format); \
-  vzlog (zl, PRIORITY, format, args); \
-  va_end(args); \
-}
-
-PLOG_FUNC(plog_err, LOG_ERR)
-
-PLOG_FUNC(plog_warn, LOG_WARNING)
-
-PLOG_FUNC(plog_info, LOG_INFO)
-
-PLOG_FUNC(plog_notice, LOG_NOTICE)
-
-PLOG_FUNC(plog_debug, LOG_DEBUG)
-
-#undef PLOG_FUNC
-
 void
 _zlog_assert_failed (const char *assertion, const char *file,
                     unsigned int line, const char *function)
index cf247a8387e0b4da4d1dd7ab71cd7080d26142c5..b27ba2530d323726c5601c2c400bbaf1526cee25 100644 (file)
--- a/lib/log.h
+++ b/lib/log.h
@@ -120,18 +120,6 @@ extern void zlog_info (const char *format, ...) PRINTF_ATTRIBUTE(1, 2);
 extern void zlog_notice (const char *format, ...) PRINTF_ATTRIBUTE(1, 2);
 extern void zlog_debug (const char *format, ...) PRINTF_ATTRIBUTE(1, 2);
 
-/* For bgpd's peer oriented log. */
-extern void plog_err (struct zlog *, const char *format, ...)
-  PRINTF_ATTRIBUTE(2, 3);
-extern void plog_warn (struct zlog *, const char *format, ...)
-  PRINTF_ATTRIBUTE(2, 3);
-extern void plog_info (struct zlog *, const char *format, ...)
-  PRINTF_ATTRIBUTE(2, 3);
-extern void plog_notice (struct zlog *, const char *format, ...)
-  PRINTF_ATTRIBUTE(2, 3);
-extern void plog_debug (struct zlog *, const char *format, ...)
-  PRINTF_ATTRIBUTE(2, 3);
-
 /* Set logging level for the given destination.  If the log_level
    argument is ZLOG_DISABLED, then the destination is disabled.
    This function should not be used for file logging (use zlog_set_file
index 00ed0a48ee58524a443c556a3bc3a10b4e71ea2e..ca3a4a4f7615e4efebc9d6bcab00138e8687be2a 100644 (file)
@@ -146,6 +146,8 @@ struct memory_list memory_list_bgp[] =
   { MTYPE_TRANSIT,             "BGP transit attr"              },
   { MTYPE_TRANSIT_VAL,         "BGP transit val"               },
   { 0, NULL },
+  { MTYPE_BGP_DEBUG_FILTER,     "BGP debug filter"              },
+  { 0, NULL },
   { MTYPE_BGP_DISTANCE,                "BGP distance"                  },
   { MTYPE_BGP_NEXTHOP_CACHE,   "BGP nexthop"                   },
   { MTYPE_BGP_CONFED_LIST,     "BGP confed list"               },
index 65c6a7002b65d352659112d81376ea644398580e..31976e9ad8feb1e6a9bb46bd21001b7c64ffc735 100644 (file)
@@ -605,15 +605,11 @@ main (void)
   struct peer *peer;
   int i, j;
   
-  conf_bgp_debug_fsm = -1UL;
-  conf_bgp_debug_events = -1UL;
+  conf_bgp_debug_neighbor_events = -1UL;
   conf_bgp_debug_packet = -1UL;
-  conf_bgp_debug_normal = -1UL;
   conf_bgp_debug_as4 = -1UL;
-  term_bgp_debug_fsm = -1UL;
-  term_bgp_debug_events = -1UL;
+  term_bgp_debug_neighbor_events = -1UL;
   term_bgp_debug_packet = -1UL;
-  term_bgp_debug_normal = -1UL;
   term_bgp_debug_as4 = -1UL;
   
   master = thread_master_create ();
index aa8e485d6e52229d9441ca8059726b9b413e0229..831c755b980b006878ac91e30220fc64c5588bdf 100644 (file)
@@ -502,15 +502,11 @@ main (void)
   struct peer *peer;
   int i, j;
   
-  conf_bgp_debug_fsm = -1UL;
-  conf_bgp_debug_events = -1UL;
+  conf_bgp_debug_neighbor_events = -1UL;
   conf_bgp_debug_packet = -1UL;
-  conf_bgp_debug_normal = -1UL;
   conf_bgp_debug_as4 = -1UL;
-  term_bgp_debug_fsm = -1UL;
-  term_bgp_debug_events = -1UL;
+  term_bgp_debug_neighbor_events = -1UL;
   term_bgp_debug_packet = -1UL;
-  term_bgp_debug_normal = -1UL;
   term_bgp_debug_as4 = -1UL;
   
   master = thread_master_create ();