Skip to content

Commit

Permalink
bgpd: add [no] debug bgp pbr vty command
Browse files Browse the repository at this point in the history
This command is used to troubleshoot the routes that are installed inbgp
pbr fib, before being injected in zebra.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
  • Loading branch information
pguibert6WIND committed Apr 30, 2018
1 parent f3d32fa commit 1a80fc0
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
53 changes: 53 additions & 0 deletions bgpd/bgp_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ unsigned long conf_bgp_debug_update_groups;
unsigned long conf_bgp_debug_vpn;
unsigned long conf_bgp_debug_flowspec;
unsigned long conf_bgp_debug_labelpool;
unsigned long conf_bgp_debug_pbr;

unsigned long term_bgp_debug_as4;
unsigned long term_bgp_debug_neighbor_events;
Expand All @@ -75,6 +76,7 @@ unsigned long term_bgp_debug_update_groups;
unsigned long term_bgp_debug_vpn;
unsigned long term_bgp_debug_flowspec;
unsigned long term_bgp_debug_labelpool;
unsigned long term_bgp_debug_pbr;

struct list *bgp_debug_neighbor_events_peers = NULL;
struct list *bgp_debug_keepalive_peers = NULL;
Expand Down Expand Up @@ -1653,7 +1655,40 @@ DEFUN (no_debug_bgp_vpn,

if (vty->node != CONFIG_NODE)
vty_out(vty, "disabled debug bgp vpn %s\n", argv[idx]->text);
return CMD_SUCCESS;
}

/* debug bgp pbr */
DEFUN (debug_bgp_pbr,
debug_bgp_pbr_cmd,
"debug bgp pbr",
DEBUG_STR
BGP_STR
"BGP policy based routing\n")
{
if (vty->node == CONFIG_NODE)
DEBUG_ON(pbr, PBR);
else {
TERM_DEBUG_ON(pbr, PBR);
vty_out(vty, "BGP policy based routing is on\n");
}
return CMD_SUCCESS;
}

DEFUN (no_debug_bgp_pbr,
no_debug_bgp_pbr_cmd,
"no debug bgp pbr",
NO_STR
DEBUG_STR
BGP_STR
"BGP policy based routing\n")
{
if (vty->node == CONFIG_NODE)
DEBUG_OFF(pbr, PBR);
else {
TERM_DEBUG_OFF(pbr, PBR);
vty_out(vty, "BGP policy based routing is off\n");
}
return CMD_SUCCESS;
}

Expand Down Expand Up @@ -1733,6 +1768,7 @@ DEFUN (no_debug_bgp,
TERM_DEBUG_OFF(vpn, VPN_LEAK_LABEL);
TERM_DEBUG_OFF(flowspec, FLOWSPEC);
TERM_DEBUG_OFF(labelpool, LABELPOOL);
TERM_DEBUG_OFF(pbr, PBR);
vty_out(vty, "All possible debugging has been turned off\n");

return CMD_SUCCESS;
Expand Down Expand Up @@ -1808,6 +1844,9 @@ DEFUN_NOSH (show_debugging_bgp,
if (BGP_DEBUG(labelpool, LABELPOOL))
vty_out(vty, " BGP labelpool debugging is on\n");

if (BGP_DEBUG(pbr, PBR))
vty_out(vty, " BGP policy based routing debugging is on\n");

vty_out(vty, "\n");
return CMD_SUCCESS;
}
Expand Down Expand Up @@ -1865,6 +1904,9 @@ int bgp_debug_count(void)
if (BGP_DEBUG(labelpool, LABELPOOL))
ret++;

if (BGP_DEBUG(pbr, PBR))
ret++;

return ret;
}

Expand Down Expand Up @@ -1966,6 +2008,10 @@ static int bgp_config_write_debug(struct vty *vty)
write++;
}

if (CONF_BGP_DEBUG(pbr, PBR)) {
vty_out(vty, "debug bgp pbr\n");
write++;
}
return write;
}

Expand Down Expand Up @@ -2069,6 +2115,13 @@ void bgp_debug_init(void)
install_element(CONFIG_NODE, &debug_bgp_labelpool_cmd);
install_element(ENABLE_NODE, &no_debug_bgp_labelpool_cmd);
install_element(CONFIG_NODE, &no_debug_bgp_labelpool_cmd);

/* debug bgp pbr */
install_element(ENABLE_NODE, &debug_bgp_pbr_cmd);
install_element(CONFIG_NODE, &debug_bgp_pbr_cmd);
install_element(ENABLE_NODE, &no_debug_bgp_pbr_cmd);
install_element(CONFIG_NODE, &no_debug_bgp_pbr_cmd);

}

/* Return true if this prefix is on the per_prefix_list of prefixes to debug
Expand Down
3 changes: 3 additions & 0 deletions bgpd/bgp_debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ extern unsigned long conf_bgp_debug_update_groups;
extern unsigned long conf_bgp_debug_vpn;
extern unsigned long conf_bgp_debug_flowspec;
extern unsigned long conf_bgp_debug_labelpool;
extern unsigned long conf_bgp_debug_pbr;

extern unsigned long term_bgp_debug_as4;
extern unsigned long term_bgp_debug_neighbor_events;
Expand All @@ -89,6 +90,7 @@ extern unsigned long term_bgp_debug_update_groups;
extern unsigned long term_bgp_debug_vpn;
extern unsigned long term_bgp_debug_flowspec;
extern unsigned long term_bgp_debug_labelpool;
extern unsigned long term_bgp_debug_pbr;

extern struct list *bgp_debug_neighbor_events_peers;
extern struct list *bgp_debug_keepalive_peers;
Expand Down Expand Up @@ -123,6 +125,7 @@ struct bgp_debug_filter {
#define BGP_DEBUG_VPN_LEAK_LABEL 0x08
#define BGP_DEBUG_FLOWSPEC 0x01
#define BGP_DEBUG_LABELPOOL 0x01
#define BGP_DEBUG_PBR 0x01

#define BGP_DEBUG_PACKET_SEND 0x01
#define BGP_DEBUG_PACKET_SEND_DETAIL 0x02
Expand Down

0 comments on commit 1a80fc0

Please sign in to comment.