listnode_delete(list, filter);
prefix_free(&filter->p);
XFREE(MTYPE_BGP_DEBUG_STR, filter->host);
+ XFREE(MTYPE_BGP_DEBUG_STR, filter->plist_name);
XFREE(MTYPE_BGP_DEBUG_FILTER, filter);
}
}
if (filter->host)
vty_out(vty, " %s", filter->host);
+ if (filter->plist_name)
+ vty_out(vty, " with prefix-list %s",
+ filter->plist_name);
+
if (filter->p && filter->p->family == AF_EVPN)
bgp_debug_print_evpn_prefix(vty, "", filter->p);
else if (filter->p)
if (list && !list_isempty(list)) {
for (ALL_LIST_ELEMENTS(list, node, nnode, filter)) {
- if (filter->host) {
+ if (filter->host && filter->plist_name) {
+ vty_out(vty, "%s %s prefix-list %s\n", desc,
+ filter->host, filter->plist_name);
+ write++;
+ } else if (filter->host) {
vty_out(vty, "%s %s\n", desc, filter->host);
write++;
}
}
static void bgp_debug_list_add_entry(struct list *list, const char *host,
- const struct prefix *p)
+ const struct prefix *p,
+ const char *plist_name)
{
struct bgp_debug_filter *filter;
prefix_copy(filter->p, p);
}
+ if (plist_name)
+ filter->plist_name = XSTRDUP(MTYPE_BGP_DEBUG_STR, plist_name);
+
listnode_add(list, filter);
}
if (host && strcmp(filter->host, host) == 0) {
listnode_delete(list, filter);
XFREE(MTYPE_BGP_DEBUG_STR, filter->host);
+ XFREE(MTYPE_BGP_DEBUG_STR, filter->plist_name);
XFREE(MTYPE_BGP_DEBUG_FILTER, filter);
return true;
} else if (p && filter->p->prefixlen == p->prefixlen
}
static bool bgp_debug_list_has_entry(struct list *list, const char *host,
- const struct prefix *p)
+ const struct prefix *p,
+ const char *plist_name)
{
struct bgp_debug_filter *filter;
struct listnode *node, *nnode;
for (ALL_LIST_ELEMENTS(list, node, nnode, filter)) {
- if (host) {
- if (strcmp(filter->host, host) == 0) {
+ if (host && plist_name) {
+ if (strmatch(filter->host, host) && filter->plist_name &&
+ strmatch(filter->plist_name, plist_name))
+ return true;
+ } else if (host) {
+ if (strmatch(filter->host, host))
return true;
- }
} else if (p) {
if (filter->p->prefixlen == p->prefixlen
&& prefix_match(filter->p, p)) {
bool bgp_debug_peer_updout_enabled(char *host)
{
- return (bgp_debug_list_has_entry(bgp_debug_update_out_peers, host,
+ return (bgp_debug_list_has_entry(bgp_debug_update_out_peers, host, NULL,
NULL));
}
bgp_debug_neighbor_events_peers = list_new();
if (bgp_debug_list_has_entry(bgp_debug_neighbor_events_peers, host,
- NULL)) {
+ NULL, NULL)) {
vty_out(vty,
"BGP neighbor-events debugging is already enabled for %s\n",
host);
return CMD_SUCCESS;
}
- bgp_debug_list_add_entry(bgp_debug_neighbor_events_peers, host, NULL);
+ bgp_debug_list_add_entry(bgp_debug_neighbor_events_peers, host, NULL,
+ NULL);
if (vty->node == CONFIG_NODE)
DEBUG_ON(neighbor_events, NEIGHBOR_EVENTS);
if (!bgp_debug_keepalive_peers)
bgp_debug_keepalive_peers = list_new();
- if (bgp_debug_list_has_entry(bgp_debug_keepalive_peers, host, NULL)) {
+ if (bgp_debug_list_has_entry(bgp_debug_keepalive_peers, host, NULL,
+ NULL)) {
vty_out(vty,
"BGP keepalive debugging is already enabled for %s\n",
host);
return CMD_SUCCESS;
}
- bgp_debug_list_add_entry(bgp_debug_keepalive_peers, host, NULL);
+ bgp_debug_list_add_entry(bgp_debug_keepalive_peers, host, NULL, NULL);
if (vty->node == CONFIG_NODE)
DEBUG_ON(keepalive, KEEPALIVE);
if (!bgp_debug_bestpath_prefixes)
bgp_debug_bestpath_prefixes = list_new();
- if (bgp_debug_list_has_entry(bgp_debug_bestpath_prefixes, NULL,
- prefix)) {
+ if (bgp_debug_list_has_entry(bgp_debug_bestpath_prefixes, NULL, prefix,
+ NULL)) {
vty_out(vty,
"BGP bestpath debugging is already enabled for %s\n",
prefix_str);
return CMD_SUCCESS;
}
- bgp_debug_list_add_entry(bgp_debug_bestpath_prefixes, NULL, prefix);
+ bgp_debug_list_add_entry(bgp_debug_bestpath_prefixes, NULL, prefix,
+ NULL);
if (vty->node == CONFIG_NODE) {
DEBUG_ON(bestpath, BESTPATH);
return CMD_SUCCESS;
}
-DEFUN (debug_bgp_update_direct_peer,
+DEFPY (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 bgp updates <in|out> <A.B.C.D|X:X::X:X|WORD> [prefix-list PREFIXLIST_NAME$plist]",
DEBUG_STR
BGP_STR
"BGP 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")
+ "BGP neighbor on interface to debug\n"
+ "Use prefix-list to filter prefixes to debug\n"
+ "Name of prefix-list\n")
{
int idx_in_out = 3;
int idx_peer = 4;
if (inbound) {
if (bgp_debug_list_has_entry(bgp_debug_update_in_peers, host,
- NULL)) {
+ NULL, plist)) {
vty_out(vty,
"BGP inbound update debugging is already enabled for %s\n",
host);
else {
if (bgp_debug_list_has_entry(bgp_debug_update_out_peers, host,
- NULL)) {
+ NULL, plist)) {
vty_out(vty,
"BGP outbound update debugging is already enabled for %s\n",
host);
}
if (inbound)
- bgp_debug_list_add_entry(bgp_debug_update_in_peers, host, NULL);
+ bgp_debug_list_add_entry(bgp_debug_update_in_peers, host, NULL,
+ plist);
else {
struct peer *peer;
struct peer_af *paf;
int afidx;
- bgp_debug_list_add_entry(bgp_debug_update_out_peers, host,
- NULL);
+ bgp_debug_list_add_entry(bgp_debug_update_out_peers, host, NULL,
+ plist);
peer = bgp_find_peer(vty, host);
if (peer) {
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 debug bgp updates <in|out> <A.B.C.D|X:X::X:X|WORD> [prefix-list PREFIXLIST_NAME]",
NO_STR
DEBUG_STR
BGP_STR
"Outbound updates\n"
"BGP neighbor IP address to debug\n"
"BGP IPv6 neighbor to debug\n"
- "BGP neighbor on interface to debug\n")
+ "BGP neighbor on interface to debug\n"
+ "Use prefix-list to filter prefixes to debug\n"
+ "Name of prefix-list\n")
{
int idx_in_out = 4;
int idx_peer = 5;
if (!bgp_debug_update_prefixes)
bgp_debug_update_prefixes = list_new();
- if (bgp_debug_list_has_entry(bgp_debug_update_prefixes, NULL,
- &argv_p)) {
+ if (bgp_debug_list_has_entry(bgp_debug_update_prefixes, NULL, &argv_p,
+ NULL)) {
vty_out(vty,
"BGP updates debugging is already enabled for %pFX\n",
&argv_p);
return CMD_SUCCESS;
}
- bgp_debug_list_add_entry(bgp_debug_update_prefixes, NULL, &argv_p);
+ bgp_debug_list_add_entry(bgp_debug_update_prefixes, NULL, &argv_p, NULL);
if (vty->node == CONFIG_NODE) {
DEBUG_ON(update, UPDATE_PREFIX);
if (!bgp_debug_update_prefixes)
bgp_debug_update_prefixes = list_new();
- if (bgp_debug_list_has_entry(bgp_debug_update_prefixes, NULL, prefix)) {
+ if (bgp_debug_list_has_entry(bgp_debug_update_prefixes, NULL, prefix,
+ NULL)) {
vty_out(vty,
"BGP updates debugging is already enabled for %s\n",
prefix_str);
return CMD_SUCCESS;
}
- bgp_debug_list_add_entry(bgp_debug_update_prefixes, NULL, prefix);
+ bgp_debug_list_add_entry(bgp_debug_update_prefixes, NULL, prefix, NULL);
if (vty->node == CONFIG_NODE) {
DEBUG_ON(update, UPDATE_PREFIX);
if (!bgp_debug_zebra_prefixes)
bgp_debug_zebra_prefixes = list_new();
- if (bgp_debug_list_has_entry(bgp_debug_zebra_prefixes, NULL, prefix)) {
+ if (bgp_debug_list_has_entry(bgp_debug_zebra_prefixes, NULL, prefix,
+ NULL)) {
vty_out(vty, "BGP zebra debugging is already enabled for %s\n",
prefix_str);
return CMD_SUCCESS;
}
- bgp_debug_list_add_entry(bgp_debug_zebra_prefixes, NULL, prefix);
+ bgp_debug_list_add_entry(bgp_debug_zebra_prefixes, NULL, prefix, NULL);
if (vty->node == CONFIG_NODE)
DEBUG_ON(zebra, ZEBRA);
/* Return true if this peer is on the per_peer_list of peers to debug
* for BGP_DEBUG_TYPE
*/
-static bool bgp_debug_per_peer(char *host, unsigned long term_bgp_debug_type,
+static bool bgp_debug_per_peer(char *host, const struct prefix *p,
+ unsigned long term_bgp_debug_type,
unsigned int BGP_DEBUG_TYPE,
struct list *per_peer_list)
{
if (!per_peer_list || list_isempty(per_peer_list))
return true;
- else {
- if (!host)
- return false;
+ if (!host)
+ return false;
- for (ALL_LIST_ELEMENTS(per_peer_list, node, nnode,
- filter))
- if (strcmp(filter->host, host) == 0)
- return true;
+ for (ALL_LIST_ELEMENTS(per_peer_list, node, nnode, filter))
+ if (strmatch(filter->host, host) &&
+ filter->plist_name && p) {
+ struct prefix_list *plist;
+ afi_t afi = family2afi(p->family);
- return false;
- }
+ plist = prefix_list_lookup(afi,
+ filter->plist_name);
+
+ if (!plist)
+ continue;
+
+ return prefix_list_apply(plist, p) ==
+ PREFIX_PERMIT;
+ } else if (strmatch(filter->host, host)) {
+ return true;
+ }
+
+ return false;
}
return false;
if (peer)
host = peer->host;
- return bgp_debug_per_peer(host, term_bgp_debug_neighbor_events,
+ return bgp_debug_per_peer(host, NULL, term_bgp_debug_neighbor_events,
BGP_DEBUG_NEIGHBOR_EVENTS,
bgp_debug_neighbor_events_peers);
}
if (peer)
host = peer->host;
- return bgp_debug_per_peer(host, term_bgp_debug_keepalive,
+ return bgp_debug_per_peer(host, NULL, term_bgp_debug_keepalive,
BGP_DEBUG_KEEPALIVE,
bgp_debug_keepalive_peers);
}
host = peer->host;
if (inbound) {
- if (bgp_debug_per_peer(host, term_bgp_debug_update,
+ if (bgp_debug_per_peer(host, p, term_bgp_debug_update,
BGP_DEBUG_UPDATE_IN,
bgp_debug_update_in_peers))
return true;
/* outbound */
else {
- if (bgp_debug_per_peer(host, term_bgp_debug_update,
+ if (bgp_debug_per_peer(host, p, term_bgp_debug_update,
BGP_DEBUG_UPDATE_OUT,
bgp_debug_update_out_peers))
return true;