LCOV - code coverage report
Current view: top level - bgpd - bgp_debug.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 15 326 4.6 %
Date: 2015-11-19 Functions: 1 26 3.8 %

          Line data    Source code
       1             : /* BGP-4, BGP-4+ packet debug routine
       2             :    Copyright (C) 1996, 97, 99 Kunihiro Ishiguro
       3             : 
       4             : This file is part of GNU Zebra.
       5             : 
       6             : GNU Zebra is free software; you can redistribute it and/or modify it
       7             : under the terms of the GNU General Public License as published by the
       8             : Free Software Foundation; either version 2, or (at your option) any
       9             : later version.
      10             : 
      11             : GNU Zebra is distributed in the hope that it will be useful, but
      12             : WITHOUT ANY WARRANTY; without even the implied warranty of
      13             : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      14             : General Public License for more details.
      15             : 
      16             : You should have received a copy of the GNU General Public License
      17             : along with GNU Zebra; see the file COPYING.  If not, write to the Free
      18             : Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
      19             : 02111-1307, USA.  */
      20             : 
      21             : #include <zebra.h>
      22             : 
      23             : #include <lib/version.h>
      24             : #include "prefix.h"
      25             : #include "linklist.h"
      26             : #include "stream.h"
      27             : #include "command.h"
      28             : #include "str.h"
      29             : #include "log.h"
      30             : #include "sockunion.h"
      31             : 
      32             : #include "bgpd/bgpd.h"
      33             : #include "bgpd/bgp_aspath.h"
      34             : #include "bgpd/bgp_route.h"
      35             : #include "bgpd/bgp_attr.h"
      36             : #include "bgpd/bgp_debug.h"
      37             : #include "bgpd/bgp_community.h"
      38             : 
      39             : unsigned long conf_bgp_debug_as4;
      40             : unsigned long conf_bgp_debug_fsm;
      41             : unsigned long conf_bgp_debug_events;
      42             : unsigned long conf_bgp_debug_packet;
      43             : unsigned long conf_bgp_debug_filter;
      44             : unsigned long conf_bgp_debug_keepalive;
      45             : unsigned long conf_bgp_debug_update;
      46             : unsigned long conf_bgp_debug_normal;
      47             : unsigned long conf_bgp_debug_zebra;
      48             : 
      49             : unsigned long term_bgp_debug_as4;
      50             : unsigned long term_bgp_debug_fsm;
      51             : unsigned long term_bgp_debug_events;
      52             : unsigned long term_bgp_debug_packet;
      53             : unsigned long term_bgp_debug_filter;
      54             : unsigned long term_bgp_debug_keepalive;
      55             : unsigned long term_bgp_debug_update;
      56             : unsigned long term_bgp_debug_normal;
      57             : unsigned long term_bgp_debug_zebra;
      58             : 
      59             : /* messages for BGP-4 status */
      60             : const struct message bgp_status_msg[] = 
      61             : {
      62             :   { Idle, "Idle" },
      63             :   { Connect, "Connect" },
      64             :   { Active, "Active" },
      65             :   { OpenSent, "OpenSent" },
      66             :   { OpenConfirm, "OpenConfirm" },
      67             :   { Established, "Established" },
      68             :   { Clearing,    "Clearing"    },
      69             :   { Deleted,     "Deleted"     },
      70             : };
      71             : const int bgp_status_msg_max = BGP_STATUS_MAX;
      72             : 
      73             : /* BGP message type string. */
      74             : const char *bgp_type_str[] =
      75             : {
      76             :   NULL,
      77             :   "OPEN",
      78             :   "UPDATE",
      79             :   "NOTIFICATION",
      80             :   "KEEPALIVE",
      81             :   "ROUTE-REFRESH",
      82             :   "CAPABILITY"
      83             : };
      84             : 
      85             : /* message for BGP-4 Notify */
      86             : static const struct message bgp_notify_msg[] = 
      87             : {
      88             :   { BGP_NOTIFY_HEADER_ERR, "Message Header Error"},
      89             :   { BGP_NOTIFY_OPEN_ERR, "OPEN Message Error"},
      90             :   { BGP_NOTIFY_UPDATE_ERR, "UPDATE Message Error"},
      91             :   { BGP_NOTIFY_HOLD_ERR, "Hold Timer Expired"},
      92             :   { BGP_NOTIFY_FSM_ERR, "Finite State Machine Error"},
      93             :   { BGP_NOTIFY_CEASE, "Cease"},
      94             :   { BGP_NOTIFY_CAPABILITY_ERR, "CAPABILITY Message Error"},
      95             : };
      96             : static const int bgp_notify_msg_max = BGP_NOTIFY_MAX;
      97             : 
      98             : static const struct message bgp_notify_head_msg[] = 
      99             : {
     100             :   { BGP_NOTIFY_HEADER_NOT_SYNC, "/Connection Not Synchronized"},
     101             :   { BGP_NOTIFY_HEADER_BAD_MESLEN, "/Bad Message Length"},
     102             :   { BGP_NOTIFY_HEADER_BAD_MESTYPE, "/Bad Message Type"}
     103             : };
     104             : static const int bgp_notify_head_msg_max = BGP_NOTIFY_HEADER_MAX;
     105             : 
     106             : static const struct message bgp_notify_open_msg[] = 
     107             : {
     108             :   { BGP_NOTIFY_SUBCODE_UNSPECIFIC, "/Unspecific"},
     109             :   { BGP_NOTIFY_OPEN_UNSUP_VERSION, "/Unsupported Version Number" },
     110             :   { BGP_NOTIFY_OPEN_BAD_PEER_AS, "/Bad Peer AS"},
     111             :   { BGP_NOTIFY_OPEN_BAD_BGP_IDENT, "/Bad BGP Identifier"},
     112             :   { BGP_NOTIFY_OPEN_UNSUP_PARAM, "/Unsupported Optional Parameter"},
     113             :   { BGP_NOTIFY_OPEN_AUTH_FAILURE, "/Authentication Failure"},
     114             :   { BGP_NOTIFY_OPEN_UNACEP_HOLDTIME, "/Unacceptable Hold Time"}, 
     115             :   { BGP_NOTIFY_OPEN_UNSUP_CAPBL, "/Unsupported Capability"},
     116             : };
     117             : static const int bgp_notify_open_msg_max = BGP_NOTIFY_OPEN_MAX;
     118             : 
     119             : static const struct message bgp_notify_update_msg[] = 
     120             : {
     121             :   { BGP_NOTIFY_SUBCODE_UNSPECIFIC, "/Unspecific"},
     122             :   { BGP_NOTIFY_UPDATE_MAL_ATTR, "/Malformed Attribute List"},
     123             :   { BGP_NOTIFY_UPDATE_UNREC_ATTR, "/Unrecognized Well-known Attribute"},
     124             :   { BGP_NOTIFY_UPDATE_MISS_ATTR, "/Missing Well-known Attribute"},
     125             :   { BGP_NOTIFY_UPDATE_ATTR_FLAG_ERR, "/Attribute Flags Error"},
     126             :   { BGP_NOTIFY_UPDATE_ATTR_LENG_ERR, "/Attribute Length Error"},
     127             :   { BGP_NOTIFY_UPDATE_INVAL_ORIGIN, "/Invalid ORIGIN Attribute"},
     128             :   { BGP_NOTIFY_UPDATE_AS_ROUTE_LOOP, "/AS Routing Loop"},
     129             :   { BGP_NOTIFY_UPDATE_INVAL_NEXT_HOP, "/Invalid NEXT_HOP Attribute"},
     130             :   { BGP_NOTIFY_UPDATE_OPT_ATTR_ERR, "/Optional Attribute Error"},
     131             :   { BGP_NOTIFY_UPDATE_INVAL_NETWORK, "/Invalid Network Field"},
     132             :   { BGP_NOTIFY_UPDATE_MAL_AS_PATH, "/Malformed AS_PATH"},
     133             : };
     134             : static const int bgp_notify_update_msg_max = BGP_NOTIFY_UPDATE_MAX;
     135             : 
     136             : static const struct message bgp_notify_cease_msg[] =
     137             : {
     138             :   { BGP_NOTIFY_SUBCODE_UNSPECIFIC, "/Unspecific"},
     139             :   { BGP_NOTIFY_CEASE_MAX_PREFIX, "/Maximum Number of Prefixes Reached"},
     140             :   { BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN, "/Administratively Shutdown"},
     141             :   { BGP_NOTIFY_CEASE_PEER_UNCONFIG, "/Peer Unconfigured"},
     142             :   { BGP_NOTIFY_CEASE_ADMIN_RESET, "/Administratively Reset"},
     143             :   { BGP_NOTIFY_CEASE_CONNECT_REJECT, "/Connection Rejected"},
     144             :   { BGP_NOTIFY_CEASE_CONFIG_CHANGE, "/Other Configuration Change"},
     145             :   { BGP_NOTIFY_CEASE_COLLISION_RESOLUTION, "/Connection collision resolution"},
     146             :   { BGP_NOTIFY_CEASE_OUT_OF_RESOURCE, "/Out of Resource"},
     147             : };
     148             : static const int bgp_notify_cease_msg_max = BGP_NOTIFY_CEASE_MAX;
     149             : 
     150             : static const struct message bgp_notify_capability_msg[] = 
     151             : {
     152             :   { BGP_NOTIFY_SUBCODE_UNSPECIFIC, "/Unspecific"},
     153             :   { BGP_NOTIFY_CAPABILITY_INVALID_ACTION, "/Invalid Action Value" },
     154             :   { BGP_NOTIFY_CAPABILITY_INVALID_LENGTH, "/Invalid Capability Length"},
     155             :   { BGP_NOTIFY_CAPABILITY_MALFORMED_CODE, "/Malformed Capability Value"},
     156             : };
     157             : static const int bgp_notify_capability_msg_max = BGP_NOTIFY_CAPABILITY_MAX;
     158             : 
     159             : /* Origin strings. */
     160             : const char *bgp_origin_str[] = {"i","e","?"};
     161             : const char *bgp_origin_long_str[] = {"IGP","EGP","incomplete"};
     162             : 
     163             : /* Dump attribute. */
     164             : int
     165           0 : bgp_dump_attr (struct peer *peer, struct attr *attr, char *buf, size_t size)
     166             : {
     167           0 :   if (! attr)
     168           0 :     return 0;
     169             : 
     170           0 :   if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP)))
     171           0 :     snprintf (buf, size, "nexthop %s", inet_ntoa (attr->nexthop));
     172             : 
     173           0 :   if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_ORIGIN)))
     174           0 :     snprintf (buf + strlen (buf), size - strlen (buf), ", origin %s",
     175           0 :               bgp_origin_str[attr->origin]);
     176             : 
     177             : #ifdef HAVE_IPV6
     178           0 :   if (attr->extra)
     179             :     {
     180             :       char addrbuf[BUFSIZ];
     181             : 
     182             :       /* Add MP case. */
     183           0 :       if (attr->extra->mp_nexthop_len == 16 
     184           0 :           || attr->extra->mp_nexthop_len == 32)
     185           0 :         snprintf (buf + strlen (buf), size - strlen (buf), ", mp_nexthop %s",
     186           0 :                   inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, 
     187             :                              addrbuf, BUFSIZ));
     188             : 
     189           0 :       if (attr->extra->mp_nexthop_len == 32)
     190           0 :         snprintf (buf + strlen (buf), size - strlen (buf), "(%s)",
     191           0 :                   inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, 
     192             :                              addrbuf, BUFSIZ));
     193             :     }
     194             : #endif /* HAVE_IPV6 */
     195             : 
     196           0 :   if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)))
     197           0 :     snprintf (buf + strlen (buf), size - strlen (buf), ", localpref %u",
     198             :               attr->local_pref);
     199             : 
     200           0 :   if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))) 
     201           0 :     snprintf (buf + strlen (buf), size - strlen (buf), ", metric %u",
     202             :               attr->med);
     203             : 
     204           0 :   if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES))) 
     205           0 :     snprintf (buf + strlen (buf), size - strlen (buf), ", community %s",
     206             :               community_str (attr->community));
     207             : 
     208           0 :   if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE)))
     209           0 :     snprintf (buf + strlen (buf), size - strlen (buf), ", atomic-aggregate");
     210             : 
     211           0 :   if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR)))
     212           0 :     snprintf (buf + strlen (buf), size - strlen (buf), ", aggregated by %u %s",
     213           0 :               attr->extra->aggregator_as,
     214           0 :               inet_ntoa (attr->extra->aggregator_addr));
     215             : 
     216           0 :   if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)))
     217           0 :     snprintf (buf + strlen (buf), size - strlen (buf), ", originator %s",
     218           0 :               inet_ntoa (attr->extra->originator_id));
     219             : 
     220           0 :   if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_CLUSTER_LIST)))
     221             :     {
     222             :       int i;
     223             : 
     224           0 :       snprintf (buf + strlen (buf), size - strlen (buf), ", clusterlist");
     225           0 :       for (i = 0; i < attr->extra->cluster->length / 4; i++)
     226           0 :         snprintf (buf + strlen (buf), size - strlen (buf), " %s",
     227           0 :                   inet_ntoa (attr->extra->cluster->list[i]));
     228             :     }
     229             : 
     230           0 :   if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AS_PATH))) 
     231           0 :     snprintf (buf + strlen (buf), size - strlen (buf), ", path %s",
     232             :               aspath_print (attr->aspath));
     233             : 
     234           0 :   if (strlen (buf) > 1)
     235           0 :     return 1;
     236             :   else
     237           0 :     return 0;
     238             : }
     239             : 
     240             : /* dump notify packet */
     241             : void
     242          34 : bgp_notify_print(struct peer *peer, struct bgp_notify *bgp_notify, 
     243             :                  const char *direct)
     244             : {
     245             :   const char *subcode_str;
     246             :   const char *code_str;
     247             : 
     248          34 :   subcode_str = "";
     249          34 :   code_str = LOOKUP_DEF (bgp_notify_msg, bgp_notify->code,
     250             :                          "Unrecognized Error Code");
     251             : 
     252          34 :   switch (bgp_notify->code)
     253             :     {
     254             :     case BGP_NOTIFY_HEADER_ERR:
     255           0 :       subcode_str = LOOKUP_DEF (bgp_notify_head_msg, bgp_notify->subcode,
     256             :                                 "Unrecognized Error Subcode");
     257           0 :       break;
     258             :     case BGP_NOTIFY_OPEN_ERR:
     259           0 :       subcode_str = LOOKUP_DEF (bgp_notify_open_msg, bgp_notify->subcode,
     260             :                                 "Unrecognized Error Subcode");
     261           0 :       break;
     262             :     case BGP_NOTIFY_UPDATE_ERR:
     263          19 :       subcode_str = LOOKUP_DEF (bgp_notify_update_msg, bgp_notify->subcode,
     264             :                                 "Unrecognized Error Subcode");
     265          19 :       break;
     266             :     case BGP_NOTIFY_HOLD_ERR:
     267           0 :       break;
     268             :     case BGP_NOTIFY_FSM_ERR:
     269           0 :       break;
     270             :     case BGP_NOTIFY_CEASE:
     271          15 :       subcode_str = LOOKUP_DEF (bgp_notify_cease_msg, bgp_notify->subcode,
     272             :                                 "Unrecognized Error Subcode");
     273          15 :       break;
     274             :     case BGP_NOTIFY_CAPABILITY_ERR:
     275           0 :       subcode_str = LOOKUP_DEF (bgp_notify_capability_msg, bgp_notify->subcode,
     276             :                                 "Unrecognized Error Subcode");
     277           0 :       break;
     278             :     }
     279             : 
     280          34 :   if (bgp_flag_check (peer->bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES))
     281           0 :     zlog_info ("%%NOTIFICATION: %s neighbor %s %d/%d (%s%s) %d bytes %s",
     282           0 :               strcmp (direct, "received") == 0 ? "received from" : "sent to",
     283           0 :               peer->host, bgp_notify->code, bgp_notify->subcode,
     284           0 :               code_str, subcode_str, bgp_notify->length,
     285           0 :               bgp_notify->data ? bgp_notify->data : "");
     286          34 :   else if (BGP_DEBUG (normal, NORMAL))
     287          84 :     plog_debug (peer->log, "%s %s NOTIFICATION %d/%d (%s%s) %d bytes %s",
     288             :                peer ? peer->host : "",
     289          42 :                direct, bgp_notify->code, bgp_notify->subcode,
     290          21 :                code_str, subcode_str, bgp_notify->length,
     291          21 :                bgp_notify->data ? bgp_notify->data : "");
     292          34 : }
     293             : 
     294             : /* Debug option setting interface. */
     295             : unsigned long bgp_debug_option = 0;
     296             : 
     297             : int  
     298           0 : debug (unsigned int option)
     299             : {
     300           0 :   return bgp_debug_option & option; 
     301             : }
     302             : 
     303           0 : DEFUN (debug_bgp_as4,
     304             :        debug_bgp_as4_cmd,
     305             :        "debug bgp as4",
     306             :        DEBUG_STR
     307             :        BGP_STR
     308             :        "BGP AS4 actions\n")
     309             : {
     310           0 :   if (vty->node == CONFIG_NODE)
     311           0 :     DEBUG_ON (as4, AS4);
     312             :   else
     313             :     {
     314           0 :       TERM_DEBUG_ON (as4, AS4);
     315           0 :       vty_out (vty, "BGP as4 debugging is on%s", VTY_NEWLINE);
     316             :     }
     317           0 :   return CMD_SUCCESS;
     318             : }
     319             : 
     320           0 : DEFUN (no_debug_bgp_as4,
     321             :        no_debug_bgp_as4_cmd,
     322             :        "no debug bgp as4",
     323             :        NO_STR
     324             :        DEBUG_STR
     325             :        BGP_STR
     326             :        "BGP AS4 actions\n")
     327             : {
     328           0 :   if (vty->node == CONFIG_NODE)
     329           0 :     DEBUG_OFF (as4, AS4);
     330             :   else
     331             :     {
     332           0 :       TERM_DEBUG_OFF (as4, AS4);
     333           0 :       vty_out (vty, "BGP as4 debugging is off%s", VTY_NEWLINE);
     334             :     }
     335           0 :   return CMD_SUCCESS;
     336             : }
     337             : 
     338             : ALIAS (no_debug_bgp_as4,
     339             :        undebug_bgp_as4_cmd,
     340             :        "undebug bgp as4",
     341             :        UNDEBUG_STR
     342             :        BGP_STR
     343             :        "BGP AS4 actions\n")
     344             : 
     345           0 : DEFUN (debug_bgp_as4_segment,
     346             :        debug_bgp_as4_segment_cmd,
     347             :        "debug bgp as4 segment",
     348             :        DEBUG_STR
     349             :        BGP_STR
     350             :        "BGP AS4 actions\n"
     351             :        "BGP AS4 aspath segment handling\n")
     352             : {
     353           0 :   if (vty->node == CONFIG_NODE)
     354           0 :     DEBUG_ON (as4, AS4_SEGMENT);
     355             :   else
     356             :     {
     357           0 :       TERM_DEBUG_ON (as4, AS4_SEGMENT);
     358           0 :       vty_out (vty, "BGP as4 segment debugging is on%s", VTY_NEWLINE);
     359             :     }
     360           0 :   return CMD_SUCCESS;
     361             : }
     362             : 
     363           0 : DEFUN (no_debug_bgp_as4_segment,
     364             :        no_debug_bgp_as4_segment_cmd,
     365             :        "no debug bgp as4 segment",
     366             :        NO_STR
     367             :        DEBUG_STR
     368             :        BGP_STR
     369             :        "BGP AS4 actions\n"
     370             :        "BGP AS4 aspath segment handling\n")
     371             : {
     372           0 :   if (vty->node == CONFIG_NODE)
     373           0 :     DEBUG_OFF (as4, AS4_SEGMENT);
     374             :   else
     375             :     {
     376           0 :       TERM_DEBUG_OFF (as4, AS4_SEGMENT);
     377           0 :       vty_out (vty, "BGP as4 segment debugging is off%s", VTY_NEWLINE);
     378             :     }
     379           0 :   return CMD_SUCCESS;
     380             : }
     381             : 
     382             : ALIAS (no_debug_bgp_as4_segment,
     383             :        undebug_bgp_as4_segment_cmd,
     384             :        "undebug bgp as4 segment",
     385             :        UNDEBUG_STR
     386             :        BGP_STR
     387             :        "BGP AS4 actions\n"
     388             :        "BGP AS4 aspath segment handling\n")
     389             : 
     390           0 : DEFUN (debug_bgp_fsm,
     391             :        debug_bgp_fsm_cmd,
     392             :        "debug bgp fsm",
     393             :        DEBUG_STR
     394             :        BGP_STR
     395             :        "BGP Finite State Machine\n")
     396             : {
     397           0 :   if (vty->node == CONFIG_NODE)
     398           0 :     DEBUG_ON (fsm, FSM);
     399             :   else
     400             :     {
     401           0 :       TERM_DEBUG_ON (fsm, FSM);
     402           0 :       vty_out (vty, "BGP fsm debugging is on%s", VTY_NEWLINE);
     403             :     }
     404           0 :   return CMD_SUCCESS;
     405             : }
     406             : 
     407           0 : DEFUN (no_debug_bgp_fsm,
     408             :        no_debug_bgp_fsm_cmd,
     409             :        "no debug bgp fsm",
     410             :        NO_STR
     411             :        DEBUG_STR
     412             :        BGP_STR
     413             :        "Finite State Machine\n")
     414             : {
     415           0 :   if (vty->node == CONFIG_NODE)
     416           0 :     DEBUG_OFF (fsm, FSM);
     417             :   else
     418             :     {
     419           0 :       TERM_DEBUG_OFF (fsm, FSM);
     420           0 :       vty_out (vty, "BGP fsm debugging is off%s", VTY_NEWLINE);
     421             :     }
     422           0 :   return CMD_SUCCESS;
     423             : }
     424             : 
     425             : ALIAS (no_debug_bgp_fsm,
     426             :        undebug_bgp_fsm_cmd,
     427             :        "undebug bgp fsm",
     428             :        UNDEBUG_STR
     429             :        BGP_STR
     430             :        "Finite State Machine\n")
     431             : 
     432           0 : DEFUN (debug_bgp_events,
     433             :        debug_bgp_events_cmd,
     434             :        "debug bgp events",
     435             :        DEBUG_STR
     436             :        BGP_STR
     437             :        "BGP events\n")
     438             : {
     439           0 :   if (vty->node == CONFIG_NODE)
     440           0 :     DEBUG_ON (events, EVENTS);
     441             :   else
     442             :     {
     443           0 :       TERM_DEBUG_ON (events, EVENTS);
     444           0 :       vty_out (vty, "BGP events debugging is on%s", VTY_NEWLINE);
     445             :     }
     446           0 :   return CMD_SUCCESS;
     447             : }
     448             : 
     449           0 : DEFUN (no_debug_bgp_events,
     450             :        no_debug_bgp_events_cmd,
     451             :        "no debug bgp events",
     452             :        NO_STR
     453             :        DEBUG_STR
     454             :        BGP_STR
     455             :        "BGP events\n")
     456             : {
     457           0 :   if (vty->node == CONFIG_NODE)
     458           0 :     DEBUG_OFF (events, EVENTS);
     459             :   else
     460             :     {
     461           0 :       TERM_DEBUG_OFF (events, EVENTS);
     462           0 :       vty_out (vty, "BGP events debugging is off%s", VTY_NEWLINE);
     463             :     }
     464           0 :   return CMD_SUCCESS;
     465             : }
     466             : 
     467             : ALIAS (no_debug_bgp_events,
     468             :        undebug_bgp_events_cmd,
     469             :        "undebug bgp events",
     470             :        UNDEBUG_STR
     471             :        BGP_STR
     472             :        "BGP events\n")
     473             : 
     474           0 : DEFUN (debug_bgp_filter,
     475             :        debug_bgp_filter_cmd,
     476             :        "debug bgp filters",
     477             :        DEBUG_STR
     478             :        BGP_STR
     479             :        "BGP filters\n")
     480             : {
     481           0 :   if (vty->node == CONFIG_NODE)
     482           0 :     DEBUG_ON (filter, FILTER);
     483             :   else
     484             :     {
     485           0 :       TERM_DEBUG_ON (filter, FILTER);
     486           0 :       vty_out (vty, "BGP filters debugging is on%s", VTY_NEWLINE);
     487             :     }
     488           0 :   return CMD_SUCCESS;
     489             : }
     490             : 
     491           0 : DEFUN (no_debug_bgp_filter,
     492             :        no_debug_bgp_filter_cmd,
     493             :        "no debug bgp filters",
     494             :        NO_STR
     495             :        DEBUG_STR
     496             :        BGP_STR
     497             :        "BGP filters\n")
     498             : {
     499           0 :   if (vty->node == CONFIG_NODE)
     500           0 :     DEBUG_OFF (filter, FILTER);
     501             :   else
     502             :     {
     503           0 :       TERM_DEBUG_OFF (filter, FILTER);
     504           0 :       vty_out (vty, "BGP filters debugging is off%s", VTY_NEWLINE);
     505             :     }
     506           0 :   return CMD_SUCCESS;
     507             : }
     508             : 
     509             : ALIAS (no_debug_bgp_filter,
     510             :        undebug_bgp_filter_cmd,
     511             :        "undebug bgp filters",
     512             :        UNDEBUG_STR
     513             :        BGP_STR
     514             :        "BGP filters\n")
     515             : 
     516           0 : DEFUN (debug_bgp_keepalive,
     517             :        debug_bgp_keepalive_cmd,
     518             :        "debug bgp keepalives",
     519             :        DEBUG_STR
     520             :        BGP_STR
     521             :        "BGP keepalives\n")
     522             : {
     523           0 :   if (vty->node == CONFIG_NODE)
     524           0 :     DEBUG_ON (keepalive, KEEPALIVE);
     525             :   else
     526             :     {
     527           0 :       TERM_DEBUG_ON (keepalive, KEEPALIVE);
     528           0 :       vty_out (vty, "BGP keepalives debugging is on%s", VTY_NEWLINE);
     529             :     }
     530           0 :   return CMD_SUCCESS;
     531             : }
     532             : 
     533           0 : DEFUN (no_debug_bgp_keepalive,
     534             :        no_debug_bgp_keepalive_cmd,
     535             :        "no debug bgp keepalives",
     536             :        NO_STR
     537             :        DEBUG_STR
     538             :        BGP_STR
     539             :        "BGP keepalives\n")
     540             : {
     541           0 :   if (vty->node == CONFIG_NODE)
     542           0 :     DEBUG_OFF (keepalive, KEEPALIVE);
     543             :   else
     544             :     {
     545           0 :       TERM_DEBUG_OFF (keepalive, KEEPALIVE);
     546           0 :       vty_out (vty, "BGP keepalives debugging is off%s", VTY_NEWLINE);
     547             :     }
     548           0 :   return CMD_SUCCESS;
     549             : }
     550             : 
     551             : ALIAS (no_debug_bgp_keepalive,
     552             :        undebug_bgp_keepalive_cmd,
     553             :        "undebug bgp keepalives",
     554             :        UNDEBUG_STR
     555             :        BGP_STR
     556             :        "BGP keepalives\n")
     557             : 
     558           0 : DEFUN (debug_bgp_update,
     559             :        debug_bgp_update_cmd,
     560             :        "debug bgp updates",
     561             :        DEBUG_STR
     562             :        BGP_STR
     563             :        "BGP updates\n")
     564             : {
     565           0 :   if (vty->node == CONFIG_NODE)
     566             :     {
     567           0 :       DEBUG_ON (update, UPDATE_IN);
     568           0 :       DEBUG_ON (update, UPDATE_OUT);
     569             :     }
     570             :   else
     571             :     {
     572           0 :       TERM_DEBUG_ON (update, UPDATE_IN);
     573           0 :       TERM_DEBUG_ON (update, UPDATE_OUT);
     574           0 :       vty_out (vty, "BGP updates debugging is on%s", VTY_NEWLINE);
     575             :     }
     576           0 :   return CMD_SUCCESS;
     577             : }
     578             : 
     579           0 : DEFUN (debug_bgp_update_direct,
     580             :        debug_bgp_update_direct_cmd,
     581             :        "debug bgp updates (in|out)",
     582             :        DEBUG_STR
     583             :        BGP_STR
     584             :        "BGP updates\n"
     585             :        "Inbound updates\n"
     586             :        "Outbound updates\n")
     587             : {
     588           0 :   if (vty->node == CONFIG_NODE)
     589             :     {
     590           0 :       if (strncmp ("i", argv[0], 1) == 0)
     591             :         {
     592           0 :           DEBUG_OFF (update, UPDATE_OUT);
     593           0 :           DEBUG_ON (update, UPDATE_IN);
     594             :         }
     595             :       else
     596             :         {       
     597           0 :           DEBUG_OFF (update, UPDATE_IN);
     598           0 :           DEBUG_ON (update, UPDATE_OUT);
     599             :         }
     600             :     }
     601             :   else
     602             :     {
     603           0 :       if (strncmp ("i", argv[0], 1) == 0)
     604             :         {
     605           0 :           TERM_DEBUG_OFF (update, UPDATE_OUT);
     606           0 :           TERM_DEBUG_ON (update, UPDATE_IN);
     607           0 :           vty_out (vty, "BGP updates debugging is on (inbound)%s", VTY_NEWLINE);
     608             :         }
     609             :       else
     610             :         {
     611           0 :           TERM_DEBUG_OFF (update, UPDATE_IN);
     612           0 :           TERM_DEBUG_ON (update, UPDATE_OUT);
     613           0 :           vty_out (vty, "BGP updates debugging is on (outbound)%s", VTY_NEWLINE);
     614             :         }
     615             :     }
     616           0 :   return CMD_SUCCESS;
     617             : }
     618             : 
     619           0 : DEFUN (no_debug_bgp_update,
     620             :        no_debug_bgp_update_cmd,
     621             :        "no debug bgp updates",
     622             :        NO_STR
     623             :        DEBUG_STR
     624             :        BGP_STR
     625             :        "BGP updates\n")
     626             : {
     627           0 :   if (vty->node == CONFIG_NODE)
     628             :     {
     629           0 :       DEBUG_OFF (update, UPDATE_IN);
     630           0 :       DEBUG_OFF (update, UPDATE_OUT);
     631             :     }
     632             :   else
     633             :     {
     634           0 :       TERM_DEBUG_OFF (update, UPDATE_IN);
     635           0 :       TERM_DEBUG_OFF (update, UPDATE_OUT);
     636           0 :       vty_out (vty, "BGP updates debugging is off%s", VTY_NEWLINE);
     637             :     }
     638           0 :   return CMD_SUCCESS;
     639             : }
     640             : 
     641             : ALIAS (no_debug_bgp_update,
     642             :        undebug_bgp_update_cmd,
     643             :        "undebug bgp updates",
     644             :        UNDEBUG_STR
     645             :        BGP_STR
     646             :        "BGP updates\n")
     647             : 
     648           0 : DEFUN (debug_bgp_normal,
     649             :        debug_bgp_normal_cmd,
     650             :        "debug bgp",
     651             :        DEBUG_STR
     652             :        BGP_STR)
     653             : {
     654           0 :   if (vty->node == CONFIG_NODE)
     655           0 :     DEBUG_ON (normal, NORMAL);
     656             :   else
     657             :     {
     658           0 :       TERM_DEBUG_ON (normal, NORMAL);
     659           0 :       vty_out (vty, "BGP debugging is on%s", VTY_NEWLINE);
     660             :     }
     661           0 :   return CMD_SUCCESS;
     662             : }
     663             : 
     664           0 : DEFUN (no_debug_bgp_normal,
     665             :        no_debug_bgp_normal_cmd,
     666             :        "no debug bgp",
     667             :        NO_STR
     668             :        DEBUG_STR
     669             :        BGP_STR)
     670             : {
     671           0 :   if (vty->node == CONFIG_NODE)
     672           0 :     DEBUG_OFF (normal, NORMAL);
     673             :   else
     674             :     {
     675           0 :       TERM_DEBUG_OFF (normal, NORMAL);
     676           0 :       vty_out (vty, "BGP debugging is off%s", VTY_NEWLINE);
     677             :     }
     678           0 :   return CMD_SUCCESS;
     679             : }
     680             : 
     681             : ALIAS (no_debug_bgp_normal,
     682             :        undebug_bgp_normal_cmd,
     683             :        "undebug bgp",
     684             :        UNDEBUG_STR
     685             :        BGP_STR)
     686             : 
     687           0 : DEFUN (debug_bgp_zebra,
     688             :        debug_bgp_zebra_cmd,
     689             :        "debug bgp zebra",
     690             :        DEBUG_STR
     691             :        BGP_STR
     692             :        "BGP Zebra messages\n")
     693             : {
     694           0 :   if (vty->node == CONFIG_NODE)
     695           0 :     DEBUG_ON (zebra, ZEBRA);
     696             :   else
     697             :     {
     698           0 :       TERM_DEBUG_ON (zebra, ZEBRA);
     699           0 :       vty_out (vty, "BGP zebra debugging is on%s", VTY_NEWLINE);
     700             :     }
     701           0 :   return CMD_SUCCESS;
     702             : }
     703             : 
     704           0 : DEFUN (no_debug_bgp_zebra,
     705             :        no_debug_bgp_zebra_cmd,
     706             :        "no debug bgp zebra",
     707             :        NO_STR
     708             :        DEBUG_STR
     709             :        BGP_STR
     710             :        "BGP Zebra messages\n")
     711             : {
     712           0 :   if (vty->node == CONFIG_NODE)
     713           0 :     DEBUG_OFF (zebra, ZEBRA);
     714             :   else
     715             :     {
     716           0 :       TERM_DEBUG_OFF (zebra, ZEBRA);
     717           0 :       vty_out (vty, "BGP zebra debugging is off%s", VTY_NEWLINE);
     718             :     }
     719           0 :   return CMD_SUCCESS;
     720             : }
     721             : 
     722             : ALIAS (no_debug_bgp_zebra,
     723             :        undebug_bgp_zebra_cmd,
     724             :        "undebug bgp zebra",
     725             :        UNDEBUG_STR
     726             :        BGP_STR
     727             :        "BGP Zebra messages\n")
     728             : 
     729           0 : DEFUN (no_debug_bgp_all,
     730             :        no_debug_bgp_all_cmd,
     731             :        "no debug all bgp",
     732             :        NO_STR
     733             :        DEBUG_STR
     734             :        "Enable all debugging\n"
     735             :        BGP_STR)
     736             : {
     737           0 :   TERM_DEBUG_OFF (normal, NORMAL);
     738           0 :   TERM_DEBUG_OFF (events, EVENTS);
     739           0 :   TERM_DEBUG_OFF (keepalive, KEEPALIVE);
     740           0 :   TERM_DEBUG_OFF (update, UPDATE_IN);
     741           0 :   TERM_DEBUG_OFF (update, UPDATE_OUT);
     742           0 :   TERM_DEBUG_OFF (as4, AS4);
     743           0 :   TERM_DEBUG_OFF (as4, AS4_SEGMENT);
     744           0 :   TERM_DEBUG_OFF (fsm, FSM);
     745           0 :   TERM_DEBUG_OFF (filter, FILTER);
     746           0 :   TERM_DEBUG_OFF (zebra, ZEBRA);
     747           0 :   vty_out (vty, "All possible debugging has been turned off%s", VTY_NEWLINE);
     748             :       
     749           0 :   return CMD_SUCCESS;
     750             : }
     751             : 
     752             : ALIAS (no_debug_bgp_all,
     753             :        undebug_bgp_all_cmd,
     754             :        "undebug all bgp",
     755             :        UNDEBUG_STR
     756             :        "Enable all debugging\n"
     757             :        BGP_STR)
     758             : 
     759           0 : DEFUN (show_debugging_bgp,
     760             :        show_debugging_bgp_cmd,
     761             :        "show debugging bgp",
     762             :        SHOW_STR
     763             :        DEBUG_STR
     764             :        BGP_STR)
     765             : {
     766           0 :   vty_out (vty, "BGP debugging status:%s", VTY_NEWLINE);
     767             : 
     768           0 :   if (BGP_DEBUG (normal, NORMAL))
     769           0 :     vty_out (vty, "  BGP debugging is on%s", VTY_NEWLINE);
     770           0 :   if (BGP_DEBUG (events, EVENTS))
     771           0 :     vty_out (vty, "  BGP events debugging is on%s", VTY_NEWLINE);
     772           0 :   if (BGP_DEBUG (keepalive, KEEPALIVE))
     773           0 :     vty_out (vty, "  BGP keepalives debugging is on%s", VTY_NEWLINE);
     774           0 :   if (BGP_DEBUG (update, UPDATE_IN) && BGP_DEBUG (update, UPDATE_OUT))
     775           0 :     vty_out (vty, "  BGP updates debugging is on%s", VTY_NEWLINE);
     776           0 :   else if (BGP_DEBUG (update, UPDATE_IN))
     777           0 :     vty_out (vty, "  BGP updates debugging is on (inbound)%s", VTY_NEWLINE);
     778           0 :   else if (BGP_DEBUG (update, UPDATE_OUT))
     779           0 :     vty_out (vty, "  BGP updates debugging is on (outbound)%s", VTY_NEWLINE);
     780           0 :   if (BGP_DEBUG (fsm, FSM))
     781           0 :     vty_out (vty, "  BGP fsm debugging is on%s", VTY_NEWLINE);
     782           0 :   if (BGP_DEBUG (filter, FILTER))
     783           0 :     vty_out (vty, "  BGP filter debugging is on%s", VTY_NEWLINE);
     784           0 :   if (BGP_DEBUG (zebra, ZEBRA))
     785           0 :     vty_out (vty, "  BGP zebra debugging is on%s", VTY_NEWLINE);
     786           0 :   if (BGP_DEBUG (as4, AS4))
     787           0 :     vty_out (vty, "  BGP as4 debugging is on%s", VTY_NEWLINE);
     788           0 :   if (BGP_DEBUG (as4, AS4_SEGMENT))
     789           0 :     vty_out (vty, "  BGP as4 aspath segment debugging is on%s", VTY_NEWLINE);
     790           0 :   vty_out (vty, "%s", VTY_NEWLINE);
     791           0 :   return CMD_SUCCESS;
     792             : }
     793             : 
     794             : static int
     795           0 : bgp_config_write_debug (struct vty *vty)
     796             : {
     797           0 :   int write = 0;
     798             : 
     799           0 :   if (CONF_BGP_DEBUG (normal, NORMAL))
     800             :     {
     801           0 :       vty_out (vty, "debug bgp%s", VTY_NEWLINE);
     802           0 :       write++;
     803             :     }
     804             : 
     805           0 :   if (CONF_BGP_DEBUG (as4, AS4))
     806             :     {
     807           0 :       vty_out (vty, "debug bgp as4%s", VTY_NEWLINE);
     808           0 :       write++;
     809             :     }
     810             : 
     811           0 :   if (CONF_BGP_DEBUG (as4, AS4_SEGMENT))
     812             :     {
     813           0 :       vty_out (vty, "debug bgp as4 segment%s", VTY_NEWLINE);
     814           0 :       write++;
     815             :     }
     816             : 
     817           0 :   if (CONF_BGP_DEBUG (events, EVENTS))
     818             :     {
     819           0 :       vty_out (vty, "debug bgp events%s", VTY_NEWLINE);
     820           0 :       write++;
     821             :     }
     822             : 
     823           0 :   if (CONF_BGP_DEBUG (keepalive, KEEPALIVE))
     824             :     {
     825           0 :       vty_out (vty, "debug bgp keepalives%s", VTY_NEWLINE);
     826           0 :       write++;
     827             :     }
     828             : 
     829           0 :   if (CONF_BGP_DEBUG (update, UPDATE_IN) && CONF_BGP_DEBUG (update, UPDATE_OUT))
     830             :     {
     831           0 :       vty_out (vty, "debug bgp updates%s", VTY_NEWLINE);
     832           0 :       write++;
     833             :     }
     834           0 :   else if (CONF_BGP_DEBUG (update, UPDATE_IN))
     835             :     {
     836           0 :       vty_out (vty, "debug bgp updates in%s", VTY_NEWLINE);
     837           0 :       write++;
     838             :     }
     839           0 :   else if (CONF_BGP_DEBUG (update, UPDATE_OUT))
     840             :     {
     841           0 :       vty_out (vty, "debug bgp updates out%s", VTY_NEWLINE);
     842           0 :       write++;
     843             :     }
     844             : 
     845           0 :   if (CONF_BGP_DEBUG (fsm, FSM))
     846             :     {
     847           0 :       vty_out (vty, "debug bgp fsm%s", VTY_NEWLINE);
     848           0 :       write++;
     849             :     }
     850             : 
     851           0 :   if (CONF_BGP_DEBUG (filter, FILTER))
     852             :     {
     853           0 :       vty_out (vty, "debug bgp filters%s", VTY_NEWLINE);
     854           0 :       write++;
     855             :     }
     856             : 
     857           0 :   if (CONF_BGP_DEBUG (zebra, ZEBRA))
     858             :     {
     859           0 :       vty_out (vty, "debug bgp zebra%s", VTY_NEWLINE);
     860           0 :       write++;
     861             :     }
     862             : 
     863           0 :   return write;
     864             : }
     865             : 
     866             : static struct cmd_node debug_node =
     867             : {
     868             :   DEBUG_NODE,
     869             :   "",
     870             :   1
     871             : };
     872             : 
     873             : void
     874           0 : bgp_debug_init (void)
     875             : {
     876           0 :   install_node (&debug_node, bgp_config_write_debug);
     877             : 
     878           0 :   install_element (ENABLE_NODE, &show_debugging_bgp_cmd);
     879             : 
     880           0 :   install_element (ENABLE_NODE, &debug_bgp_as4_cmd);
     881           0 :   install_element (CONFIG_NODE, &debug_bgp_as4_cmd);
     882           0 :   install_element (ENABLE_NODE, &debug_bgp_as4_segment_cmd);
     883           0 :   install_element (CONFIG_NODE, &debug_bgp_as4_segment_cmd);
     884             : 
     885           0 :   install_element (ENABLE_NODE, &debug_bgp_fsm_cmd);
     886           0 :   install_element (CONFIG_NODE, &debug_bgp_fsm_cmd);
     887           0 :   install_element (ENABLE_NODE, &debug_bgp_events_cmd);
     888           0 :   install_element (CONFIG_NODE, &debug_bgp_events_cmd);
     889           0 :   install_element (ENABLE_NODE, &debug_bgp_filter_cmd);
     890           0 :   install_element (CONFIG_NODE, &debug_bgp_filter_cmd);
     891           0 :   install_element (ENABLE_NODE, &debug_bgp_keepalive_cmd);
     892           0 :   install_element (CONFIG_NODE, &debug_bgp_keepalive_cmd);
     893           0 :   install_element (ENABLE_NODE, &debug_bgp_update_cmd);
     894           0 :   install_element (CONFIG_NODE, &debug_bgp_update_cmd);
     895           0 :   install_element (ENABLE_NODE, &debug_bgp_update_direct_cmd);
     896           0 :   install_element (CONFIG_NODE, &debug_bgp_update_direct_cmd);
     897           0 :   install_element (ENABLE_NODE, &debug_bgp_normal_cmd);
     898           0 :   install_element (CONFIG_NODE, &debug_bgp_normal_cmd);
     899           0 :   install_element (ENABLE_NODE, &debug_bgp_zebra_cmd);
     900           0 :   install_element (CONFIG_NODE, &debug_bgp_zebra_cmd);
     901             : 
     902           0 :   install_element (ENABLE_NODE, &no_debug_bgp_as4_cmd);
     903           0 :   install_element (ENABLE_NODE, &undebug_bgp_as4_cmd);
     904           0 :   install_element (CONFIG_NODE, &no_debug_bgp_as4_cmd);
     905           0 :   install_element (ENABLE_NODE, &no_debug_bgp_as4_segment_cmd);
     906           0 :   install_element (ENABLE_NODE, &undebug_bgp_as4_segment_cmd);
     907           0 :   install_element (CONFIG_NODE, &no_debug_bgp_as4_segment_cmd);
     908             : 
     909           0 :   install_element (ENABLE_NODE, &no_debug_bgp_fsm_cmd);
     910           0 :   install_element (ENABLE_NODE, &undebug_bgp_fsm_cmd);
     911           0 :   install_element (CONFIG_NODE, &no_debug_bgp_fsm_cmd);
     912           0 :   install_element (ENABLE_NODE, &no_debug_bgp_events_cmd);
     913           0 :   install_element (ENABLE_NODE, &undebug_bgp_events_cmd);
     914           0 :   install_element (CONFIG_NODE, &no_debug_bgp_events_cmd);
     915           0 :   install_element (ENABLE_NODE, &no_debug_bgp_filter_cmd);
     916           0 :   install_element (ENABLE_NODE, &undebug_bgp_filter_cmd);
     917           0 :   install_element (CONFIG_NODE, &no_debug_bgp_filter_cmd);
     918           0 :   install_element (ENABLE_NODE, &no_debug_bgp_keepalive_cmd);
     919           0 :   install_element (ENABLE_NODE, &undebug_bgp_keepalive_cmd);
     920           0 :   install_element (CONFIG_NODE, &no_debug_bgp_keepalive_cmd);
     921           0 :   install_element (ENABLE_NODE, &no_debug_bgp_update_cmd);
     922           0 :   install_element (ENABLE_NODE, &undebug_bgp_update_cmd);
     923           0 :   install_element (CONFIG_NODE, &no_debug_bgp_update_cmd);
     924           0 :   install_element (ENABLE_NODE, &no_debug_bgp_normal_cmd);
     925           0 :   install_element (ENABLE_NODE, &undebug_bgp_normal_cmd);
     926           0 :   install_element (CONFIG_NODE, &no_debug_bgp_normal_cmd);
     927           0 :   install_element (ENABLE_NODE, &no_debug_bgp_zebra_cmd);
     928           0 :   install_element (ENABLE_NODE, &undebug_bgp_zebra_cmd);
     929           0 :   install_element (CONFIG_NODE, &no_debug_bgp_zebra_cmd);
     930           0 :   install_element (ENABLE_NODE, &no_debug_bgp_all_cmd);
     931           0 :   install_element (ENABLE_NODE, &undebug_bgp_all_cmd);
     932           0 : }

Generated by: LCOV version 1.10