LCOV - code coverage report
Current view: top level - zebra - debug.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 55 155 35.5 %
Date: 2015-11-19 Functions: 6 18 33.3 %

          Line data    Source code
       1             : /*
       2             :  * Zebra debug related function
       3             :  * Copyright (C) 1999 Kunihiro Ishiguro
       4             :  *
       5             :  * This file is part of GNU Zebra.
       6             :  *
       7             :  * GNU Zebra is free software; you can redistribute it and/or modify it
       8             :  * under the terms of the GNU General Public License as published by the
       9             :  * Free Software Foundation; either version 2, or (at your option) any
      10             :  * later version.
      11             :  *
      12             :  * GNU Zebra is distributed in the hope that it will be useful, but
      13             :  * WITHOUT ANY WARRANTY; without even the implied warranty of
      14             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      15             :  * General Public License for more details.
      16             :  *
      17             :  * You should have received a copy of the GNU General Public License
      18             :  * along with GNU Zebra; see the file COPYING.  If not, write to the 
      19             :  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 
      20             :  * Boston, MA 02111-1307, USA.  
      21             :  */
      22             : 
      23             : #include <zebra.h>
      24             : #include "command.h"
      25             : #include "debug.h"
      26             : 
      27             : /* For debug statement. */
      28             : unsigned long zebra_debug_event;
      29             : unsigned long zebra_debug_packet;
      30             : unsigned long zebra_debug_kernel;
      31             : unsigned long zebra_debug_rib;
      32             : unsigned long zebra_debug_fpm;
      33             : 
      34           0 : DEFUN (show_debugging_zebra,
      35             :        show_debugging_zebra_cmd,
      36             :        "show debugging zebra",
      37             :        SHOW_STR
      38             :        "Debugging information\n"
      39             :        "Zebra configuration\n")
      40             : {
      41           0 :   vty_out (vty, "Zebra debugging status:%s", VTY_NEWLINE);
      42             : 
      43           0 :   if (IS_ZEBRA_DEBUG_EVENT)
      44           0 :     vty_out (vty, "  Zebra event debugging is on%s", VTY_NEWLINE);
      45             : 
      46           0 :   if (IS_ZEBRA_DEBUG_PACKET)
      47             :     {
      48           0 :       if (IS_ZEBRA_DEBUG_SEND && IS_ZEBRA_DEBUG_RECV)
      49             :         {
      50           0 :           vty_out (vty, "  Zebra packet%s debugging is on%s",
      51           0 :                    IS_ZEBRA_DEBUG_DETAIL ? " detail" : "",
      52           0 :                    VTY_NEWLINE);
      53             :         }
      54             :       else
      55             :         {
      56           0 :           if (IS_ZEBRA_DEBUG_SEND)
      57           0 :             vty_out (vty, "  Zebra packet send%s debugging is on%s",
      58           0 :                      IS_ZEBRA_DEBUG_DETAIL ? " detail" : "",
      59           0 :                      VTY_NEWLINE);
      60             :           else
      61           0 :             vty_out (vty, "  Zebra packet receive%s debugging is on%s",
      62           0 :                      IS_ZEBRA_DEBUG_DETAIL ? " detail" : "",
      63           0 :                      VTY_NEWLINE);
      64             :         }
      65             :     }
      66             : 
      67           0 :   if (IS_ZEBRA_DEBUG_KERNEL)
      68           0 :     vty_out (vty, "  Zebra kernel debugging is on%s", VTY_NEWLINE);
      69             : 
      70           0 :   if (IS_ZEBRA_DEBUG_RIB)
      71           0 :     vty_out (vty, "  Zebra RIB debugging is on%s", VTY_NEWLINE);
      72           0 :   if (IS_ZEBRA_DEBUG_RIB_Q)
      73           0 :     vty_out (vty, "  Zebra RIB queue debugging is on%s", VTY_NEWLINE);
      74             : 
      75           0 :   if (IS_ZEBRA_DEBUG_FPM)
      76           0 :     vty_out (vty, "  Zebra FPM debugging is on%s", VTY_NEWLINE);
      77             : 
      78           0 :   return CMD_SUCCESS;
      79             : }
      80             : 
      81          45 : DEFUN (debug_zebra_events,
      82             :        debug_zebra_events_cmd,
      83             :        "debug zebra events",
      84             :        DEBUG_STR
      85             :        "Zebra configuration\n"
      86             :        "Debug option set for zebra events\n")
      87             : {
      88          45 :   zebra_debug_event = ZEBRA_DEBUG_EVENT;
      89          45 :   return CMD_WARNING;
      90             : }
      91             : 
      92          45 : DEFUN (debug_zebra_packet,
      93             :        debug_zebra_packet_cmd,
      94             :        "debug zebra packet",
      95             :        DEBUG_STR
      96             :        "Zebra configuration\n"
      97             :        "Debug option set for zebra packet\n")
      98             : {
      99          45 :   zebra_debug_packet = ZEBRA_DEBUG_PACKET;
     100          45 :   zebra_debug_packet |= ZEBRA_DEBUG_SEND;
     101          45 :   zebra_debug_packet |= ZEBRA_DEBUG_RECV;
     102          45 :   return CMD_SUCCESS;
     103             : }
     104             : 
     105           0 : DEFUN (debug_zebra_packet_direct,
     106             :        debug_zebra_packet_direct_cmd,
     107             :        "debug zebra packet (recv|send)",
     108             :        DEBUG_STR
     109             :        "Zebra configuration\n"
     110             :        "Debug option set for zebra packet\n"
     111             :        "Debug option set for receive packet\n"
     112             :        "Debug option set for send packet\n")
     113             : {
     114           0 :   zebra_debug_packet = ZEBRA_DEBUG_PACKET;
     115           0 :   if (strncmp ("send", argv[0], strlen (argv[0])) == 0)
     116           0 :     zebra_debug_packet |= ZEBRA_DEBUG_SEND;
     117           0 :   if (strncmp ("recv", argv[0], strlen (argv[0])) == 0)
     118           0 :     zebra_debug_packet |= ZEBRA_DEBUG_RECV;
     119           0 :   zebra_debug_packet &= ~ZEBRA_DEBUG_DETAIL;
     120           0 :   return CMD_SUCCESS;
     121             : }
     122             : 
     123           0 : DEFUN (debug_zebra_packet_detail,
     124             :        debug_zebra_packet_detail_cmd,
     125             :        "debug zebra packet (recv|send) detail",
     126             :        DEBUG_STR
     127             :        "Zebra configuration\n"
     128             :        "Debug option set for zebra packet\n"
     129             :        "Debug option set for receive packet\n"
     130             :        "Debug option set for send packet\n"
     131             :        "Debug option set detailed information\n")
     132             : {
     133           0 :   zebra_debug_packet = ZEBRA_DEBUG_PACKET;
     134           0 :   if (strncmp ("send", argv[0], strlen (argv[0])) == 0)
     135           0 :     zebra_debug_packet |= ZEBRA_DEBUG_SEND;
     136           0 :   if (strncmp ("recv", argv[0], strlen (argv[0])) == 0)
     137           0 :     zebra_debug_packet |= ZEBRA_DEBUG_RECV;
     138           0 :   zebra_debug_packet |= ZEBRA_DEBUG_DETAIL;
     139           0 :   return CMD_SUCCESS;
     140             : }
     141             : 
     142          45 : DEFUN (debug_zebra_kernel,
     143             :        debug_zebra_kernel_cmd,
     144             :        "debug zebra kernel",
     145             :        DEBUG_STR
     146             :        "Zebra configuration\n"
     147             :        "Debug option set for zebra between kernel interface\n")
     148             : {
     149          45 :   zebra_debug_kernel = ZEBRA_DEBUG_KERNEL;
     150          45 :   return CMD_SUCCESS;
     151             : }
     152             : 
     153          45 : DEFUN (debug_zebra_rib,
     154             :        debug_zebra_rib_cmd,
     155             :        "debug zebra rib",
     156             :        DEBUG_STR
     157             :        "Zebra configuration\n"
     158             :        "Debug RIB events\n")
     159             : {
     160          45 :   SET_FLAG (zebra_debug_rib, ZEBRA_DEBUG_RIB);
     161          45 :   return CMD_SUCCESS;
     162             : }
     163             : 
     164           0 : DEFUN (debug_zebra_rib_q,
     165             :        debug_zebra_rib_q_cmd,
     166             :        "debug zebra rib queue",
     167             :        DEBUG_STR
     168             :        "Zebra configuration\n"
     169             :        "Debug RIB events\n"
     170             :        "Debug RIB queueing\n")
     171             : {
     172           0 :   SET_FLAG (zebra_debug_rib, ZEBRA_DEBUG_RIB_Q);
     173           0 :   return CMD_SUCCESS;
     174             : }
     175             : 
     176          45 : DEFUN (debug_zebra_fpm,
     177             :        debug_zebra_fpm_cmd,
     178             :        "debug zebra fpm",
     179             :        DEBUG_STR
     180             :        "Zebra configuration\n"
     181             :        "Debug zebra FPM events\n")
     182             : {
     183          45 :   SET_FLAG (zebra_debug_fpm, ZEBRA_DEBUG_FPM);
     184          45 :   return CMD_SUCCESS;
     185             : }
     186             : 
     187           0 : DEFUN (no_debug_zebra_events,
     188             :        no_debug_zebra_events_cmd,
     189             :        "no debug zebra events",
     190             :        NO_STR
     191             :        DEBUG_STR
     192             :        "Zebra configuration\n"
     193             :        "Debug option set for zebra events\n")
     194             : {
     195           0 :   zebra_debug_event = 0;
     196           0 :   return CMD_SUCCESS;
     197             : }
     198             : 
     199           0 : DEFUN (no_debug_zebra_packet,
     200             :        no_debug_zebra_packet_cmd,
     201             :        "no debug zebra packet",
     202             :        NO_STR
     203             :        DEBUG_STR
     204             :        "Zebra configuration\n"
     205             :        "Debug option set for zebra packet\n")
     206             : {
     207           0 :   zebra_debug_packet = 0;
     208           0 :   return CMD_SUCCESS;
     209             : }
     210             : 
     211           0 : DEFUN (no_debug_zebra_packet_direct,
     212             :        no_debug_zebra_packet_direct_cmd,
     213             :        "no debug zebra packet (recv|send)",
     214             :        NO_STR
     215             :        DEBUG_STR
     216             :        "Zebra configuration\n"
     217             :        "Debug option set for zebra packet\n"
     218             :        "Debug option set for receive packet\n"
     219             :        "Debug option set for send packet\n")
     220             : {
     221           0 :   if (strncmp ("send", argv[0], strlen (argv[0])) == 0)
     222           0 :     zebra_debug_packet &= ~ZEBRA_DEBUG_SEND;
     223           0 :   if (strncmp ("recv", argv[0], strlen (argv[0])) == 0)
     224           0 :     zebra_debug_packet &= ~ZEBRA_DEBUG_RECV;
     225           0 :   return CMD_SUCCESS;
     226             : }
     227             : 
     228           0 : DEFUN (no_debug_zebra_kernel,
     229             :        no_debug_zebra_kernel_cmd,
     230             :        "no debug zebra kernel",
     231             :        NO_STR
     232             :        DEBUG_STR
     233             :        "Zebra configuration\n"
     234             :        "Debug option set for zebra between kernel interface\n")
     235             : {
     236           0 :   zebra_debug_kernel = 0;
     237           0 :   return CMD_SUCCESS;
     238             : }
     239             : 
     240           0 : DEFUN (no_debug_zebra_rib,
     241             :        no_debug_zebra_rib_cmd,
     242             :        "no debug zebra rib",
     243             :        NO_STR
     244             :        DEBUG_STR
     245             :        "Zebra configuration\n"
     246             :        "Debug zebra RIB\n")
     247             : {
     248           0 :   zebra_debug_rib = 0;
     249           0 :   return CMD_SUCCESS;
     250             : }
     251             : 
     252           0 : DEFUN (no_debug_zebra_rib_q,
     253             :        no_debug_zebra_rib_q_cmd,
     254             :        "no debug zebra rib queue",
     255             :        NO_STR
     256             :        DEBUG_STR
     257             :        "Zebra configuration\n"
     258             :        "Debug zebra RIB\n"
     259             :        "Debug RIB queueing\n")
     260             : {
     261           0 :   UNSET_FLAG (zebra_debug_rib, ZEBRA_DEBUG_RIB_Q);
     262           0 :   return CMD_SUCCESS;
     263             : }
     264             : 
     265           0 : DEFUN (no_debug_zebra_fpm,
     266             :        no_debug_zebra_fpm_cmd,
     267             :        "no debug zebra fpm",
     268             :        NO_STR
     269             :        DEBUG_STR
     270             :        "Zebra configuration\n"
     271             :        "Debug zebra FPM events\n")
     272             : {
     273           0 :   zebra_debug_fpm = 0;
     274           0 :   return CMD_SUCCESS;
     275             : }
     276             : 
     277             : /* Debug node. */
     278             : struct cmd_node debug_node =
     279             : {
     280             :   DEBUG_NODE,
     281             :   "",                         /* Debug node has no interface. */
     282             :   1
     283             : };
     284             : 
     285             : static int
     286           0 : config_write_debug (struct vty *vty)
     287             : {
     288           0 :   int write = 0;
     289             : 
     290           0 :   if (IS_ZEBRA_DEBUG_EVENT)
     291             :     {
     292           0 :       vty_out (vty, "debug zebra events%s", VTY_NEWLINE);
     293           0 :       write++;
     294             :     }
     295           0 :   if (IS_ZEBRA_DEBUG_PACKET)
     296             :     {
     297           0 :       if (IS_ZEBRA_DEBUG_SEND && IS_ZEBRA_DEBUG_RECV)
     298             :         {
     299           0 :           vty_out (vty, "debug zebra packet%s%s",
     300           0 :                    IS_ZEBRA_DEBUG_DETAIL ? " detail" : "",
     301           0 :                    VTY_NEWLINE);
     302           0 :           write++;
     303             :         }
     304             :       else
     305             :         {
     306           0 :           if (IS_ZEBRA_DEBUG_SEND)
     307           0 :             vty_out (vty, "debug zebra packet send%s%s",
     308           0 :                      IS_ZEBRA_DEBUG_DETAIL ? " detail" : "",
     309           0 :                      VTY_NEWLINE);
     310             :           else
     311           0 :             vty_out (vty, "debug zebra packet recv%s%s",
     312           0 :                      IS_ZEBRA_DEBUG_DETAIL ? " detail" : "",
     313           0 :                      VTY_NEWLINE);
     314           0 :           write++;
     315             :         }
     316             :     }
     317           0 :   if (IS_ZEBRA_DEBUG_KERNEL)
     318             :     {
     319           0 :       vty_out (vty, "debug zebra kernel%s", VTY_NEWLINE);
     320           0 :       write++;
     321             :     }
     322           0 :   if (IS_ZEBRA_DEBUG_RIB)
     323             :     {
     324           0 :       vty_out (vty, "debug zebra rib%s", VTY_NEWLINE);
     325           0 :       write++;
     326             :     }
     327           0 :   if (IS_ZEBRA_DEBUG_RIB_Q)
     328             :     {
     329           0 :       vty_out (vty, "debug zebra rib queue%s", VTY_NEWLINE);
     330           0 :       write++;
     331             :     }
     332           0 :   if (IS_ZEBRA_DEBUG_FPM)
     333             :     {
     334           0 :       vty_out (vty, "debug zebra fpm%s", VTY_NEWLINE);
     335           0 :       write++;
     336             :     }
     337           0 :   return write;
     338             : }
     339             : 
     340             : void
     341          45 : zebra_debug_init (void)
     342             : {
     343          45 :   zebra_debug_event = 0;
     344          45 :   zebra_debug_packet = 0;
     345          45 :   zebra_debug_kernel = 0;
     346          45 :   zebra_debug_rib = 0;
     347          45 :   zebra_debug_fpm = 0;
     348             : 
     349          45 :   install_node (&debug_node, config_write_debug);
     350             : 
     351          45 :   install_element (VIEW_NODE, &show_debugging_zebra_cmd);
     352             : 
     353          45 :   install_element (ENABLE_NODE, &show_debugging_zebra_cmd);
     354          45 :   install_element (ENABLE_NODE, &debug_zebra_events_cmd);
     355          45 :   install_element (ENABLE_NODE, &debug_zebra_packet_cmd);
     356          45 :   install_element (ENABLE_NODE, &debug_zebra_packet_direct_cmd);
     357          45 :   install_element (ENABLE_NODE, &debug_zebra_packet_detail_cmd);
     358          45 :   install_element (ENABLE_NODE, &debug_zebra_kernel_cmd);
     359          45 :   install_element (ENABLE_NODE, &debug_zebra_rib_cmd);
     360          45 :   install_element (ENABLE_NODE, &debug_zebra_rib_q_cmd);
     361          45 :   install_element (ENABLE_NODE, &debug_zebra_fpm_cmd);
     362          45 :   install_element (ENABLE_NODE, &no_debug_zebra_events_cmd);
     363          45 :   install_element (ENABLE_NODE, &no_debug_zebra_packet_cmd);
     364          45 :   install_element (ENABLE_NODE, &no_debug_zebra_kernel_cmd);
     365          45 :   install_element (ENABLE_NODE, &no_debug_zebra_rib_cmd);
     366          45 :   install_element (ENABLE_NODE, &no_debug_zebra_rib_q_cmd);
     367          45 :   install_element (ENABLE_NODE, &no_debug_zebra_fpm_cmd);
     368             : 
     369          45 :   install_element (CONFIG_NODE, &debug_zebra_events_cmd);
     370          45 :   install_element (CONFIG_NODE, &debug_zebra_packet_cmd);
     371          45 :   install_element (CONFIG_NODE, &debug_zebra_packet_direct_cmd);
     372          45 :   install_element (CONFIG_NODE, &debug_zebra_packet_detail_cmd);
     373          45 :   install_element (CONFIG_NODE, &debug_zebra_kernel_cmd);
     374          45 :   install_element (CONFIG_NODE, &debug_zebra_rib_cmd);
     375          45 :   install_element (CONFIG_NODE, &debug_zebra_rib_q_cmd);
     376          45 :   install_element (CONFIG_NODE, &debug_zebra_fpm_cmd);
     377          45 :   install_element (CONFIG_NODE, &no_debug_zebra_events_cmd);
     378          45 :   install_element (CONFIG_NODE, &no_debug_zebra_packet_cmd);
     379          45 :   install_element (CONFIG_NODE, &no_debug_zebra_kernel_cmd);
     380          45 :   install_element (CONFIG_NODE, &no_debug_zebra_rib_cmd);
     381          45 :   install_element (CONFIG_NODE, &no_debug_zebra_rib_q_cmd);
     382          45 :   install_element (CONFIG_NODE, &no_debug_zebra_fpm_cmd);
     383          45 : }

Generated by: LCOV version 1.10