summaryrefslogtreecommitdiff
path: root/bgpd/bgp_debug.c
diff options
context:
space:
mode:
Diffstat (limited to 'bgpd/bgp_debug.c')
-rw-r--r--bgpd/bgp_debug.c53
1 files changed, 31 insertions, 22 deletions
diff --git a/bgpd/bgp_debug.c b/bgpd/bgp_debug.c
index 0993d6de57..cd6ba00846 100644
--- a/bgpd/bgp_debug.c
+++ b/bgpd/bgp_debug.c
@@ -627,8 +627,8 @@ static int bgp_debug_parse_evpn_prefix(struct vty *vty, struct cmd_token **argv,
int argc, struct prefix **argv_pp)
{
struct prefix *argv_p;
- struct ethaddr mac;
- struct ipaddr ip;
+ struct ethaddr mac = {};
+ struct ipaddr ip = {};
int evpn_type = 0;
int mac_idx = 0;
int ip_idx = 0;
@@ -639,28 +639,37 @@ static int bgp_debug_parse_evpn_prefix(struct vty *vty, struct cmd_token **argv,
return CMD_WARNING;
if (evpn_type == BGP_EVPN_MAC_IP_ROUTE) {
- memset(&ip, 0, sizeof(struct ipaddr));
+ memset(&ip, 0, sizeof(ip));
- argv_find(argv, argc, "mac", &mac_idx);
- (void)prefix_str2mac(argv[mac_idx + 1]->arg, &mac);
+ if (argv_find(argv, argc, "mac", &mac_idx))
+ if (!prefix_str2mac(argv[mac_idx + 1]->arg, &mac)) {
+ vty_out(vty, "%% Malformed MAC address\n");
+ return CMD_WARNING;
+ }
- argv_find(argv, argc, "ip", &ip_idx);
- str2ipaddr(argv[ip_idx + 1]->arg, &ip);
+ if (argv_find(argv, argc, "ip", &ip_idx))
+ if (str2ipaddr(argv[ip_idx + 1]->arg, &ip) != 0) {
+ vty_out(vty, "%% Malformed IP address\n");
+ return CMD_WARNING;
+ }
build_evpn_type2_prefix((struct prefix_evpn *)argv_p,
&mac, &ip);
} else if (evpn_type == BGP_EVPN_IMET_ROUTE) {
- memset(&ip, 0, sizeof(struct ipaddr));
+ memset(&ip, 0, sizeof(ip));
- argv_find(argv, argc, "ip", &ip_idx);
- str2ipaddr(argv[ip_idx + 1]->arg, &ip);
+ if (argv_find(argv, argc, "ip", &ip_idx))
+ if (str2ipaddr(argv[ip_idx + 1]->arg, &ip) != 0) {
+ vty_out(vty, "%% Malformed IP address\n");
+ return CMD_WARNING;
+ }
build_evpn_type3_prefix((struct prefix_evpn *)argv_p,
ip.ipaddr_v4);
} else if (evpn_type == BGP_EVPN_IP_PREFIX_ROUTE) {
struct prefix ip_prefix;
- memset(&ip_prefix, 0, sizeof(struct prefix));
+ memset(&ip_prefix, 0, sizeof(ip_prefix));
if (argv_find(argv, argc, "ip", &ip_idx)) {
(void)str2prefix(argv[ip_idx + 1]->arg, &ip_prefix);
apply_mask(&ip_prefix);
@@ -2567,9 +2576,9 @@ static int bgp_debug_per_prefix(const struct prefix *p,
/* 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(char *host, unsigned long term_bgp_debug_type,
- unsigned int BGP_DEBUG_TYPE,
- struct list *per_peer_list)
+static bool bgp_debug_per_peer(char *host, 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;
@@ -2577,25 +2586,25 @@ static int bgp_debug_per_peer(char *host, unsigned long term_bgp_debug_type,
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;
+ return true;
else {
if (!host)
- return 0;
+ return false;
for (ALL_LIST_ELEMENTS(per_peer_list, node, nnode,
filter))
if (strcmp(filter->host, host) == 0)
- return 1;
+ return true;
- return 0;
+ return false;
}
}
- return 0;
+ return false;
}
-int bgp_debug_neighbor_events(struct peer *peer)
+bool bgp_debug_neighbor_events(const struct peer *peer)
{
char *host = NULL;
@@ -2607,7 +2616,7 @@ int bgp_debug_neighbor_events(struct peer *peer)
bgp_debug_neighbor_events_peers);
}
-int bgp_debug_keepalive(struct peer *peer)
+bool bgp_debug_keepalive(const struct peer *peer)
{
char *host = NULL;
@@ -2619,7 +2628,7 @@ int bgp_debug_keepalive(struct peer *peer)
bgp_debug_keepalive_peers);
}
-bool bgp_debug_update(struct peer *peer, const struct prefix *p,
+bool bgp_debug_update(const struct peer *peer, const struct prefix *p,
struct update_group *updgrp, unsigned int inbound)
{
char *host = NULL;