unsigned long conf_bgp_debug_keepalive;
unsigned long conf_bgp_debug_update;
unsigned long conf_bgp_debug_normal;
+unsigned long conf_bgp_debug_zebra;
unsigned long term_bgp_debug_fsm;
unsigned long term_bgp_debug_events;
unsigned long term_bgp_debug_keepalive;
unsigned long term_bgp_debug_update;
unsigned long term_bgp_debug_normal;
+unsigned long term_bgp_debug_zebra;
/* messages for BGP-4 status */
struct message bgp_status_msg[] =
UNDEBUG_STR
BGP_STR)
+DEFUN (debug_bgp_zebra,
+ debug_bgp_zebra_cmd,
+ "debug bgp zebra",
+ DEBUG_STR
+ BGP_STR
+ "BGP Zebra messages\n")
+{
+ if (vty->node == CONFIG_NODE)
+ DEBUG_ON (zebra, ZEBRA);
+ else
+ {
+ TERM_DEBUG_ON (zebra, ZEBRA);
+ vty_out (vty, "BGP zebra debugging is on%s", VTY_NEWLINE);
+ }
+ return CMD_SUCCESS;
+}
+
+DEFUN (no_debug_bgp_zebra,
+ no_debug_bgp_zebra_cmd,
+ "no debug bgp zebra",
+ NO_STR
+ DEBUG_STR
+ BGP_STR
+ "BGP Zebra messages\n")
+{
+ if (vty->node == CONFIG_NODE)
+ DEBUG_OFF (zebra, ZEBRA);
+ else
+ {
+ TERM_DEBUG_OFF (zebra, ZEBRA);
+ vty_out (vty, "BGP zebra debugging is off%s", VTY_NEWLINE);
+ }
+ return CMD_SUCCESS;
+}
+
+ALIAS (no_debug_bgp_zebra,
+ undebug_bgp_zebra_cmd,
+ "undebug bgp zebra",
+ UNDEBUG_STR
+ DEBUG_STR
+ BGP_STR
+ "BGP Zebra messages\n")
+
DEFUN (no_debug_bgp_all,
no_debug_bgp_all_cmd,
"no debug all bgp",
TERM_DEBUG_OFF (update, UPDATE_OUT);
TERM_DEBUG_OFF (fsm, FSM);
TERM_DEBUG_OFF (filter, FILTER);
+ TERM_DEBUG_OFF (zebra, ZEBRA);
vty_out (vty, "All possible debugging has been turned off%s", VTY_NEWLINE);
return CMD_SUCCESS;
vty_out (vty, " BGP fsm debugging is on%s", VTY_NEWLINE);
if (BGP_DEBUG (filter, FILTER))
vty_out (vty, " BGP filter debugging is on%s", VTY_NEWLINE);
+ if (BGP_DEBUG (zebra, ZEBRA))
+ vty_out (vty, " BGP zebra debugging is on%s", VTY_NEWLINE);
vty_out (vty, "%s", VTY_NEWLINE);
return CMD_SUCCESS;
}
write++;
}
+ if (CONF_BGP_DEBUG (zebra, ZEBRA))
+ {
+ vty_out (vty, "debug bgp zebra%s", VTY_NEWLINE);
+ write++;
+ }
+
return write;
}
install_element (CONFIG_NODE, &debug_bgp_update_direct_cmd);
install_element (ENABLE_NODE, &debug_bgp_normal_cmd);
install_element (CONFIG_NODE, &debug_bgp_normal_cmd);
+ install_element (ENABLE_NODE, &debug_bgp_zebra_cmd);
+ install_element (CONFIG_NODE, &debug_bgp_zebra_cmd);
install_element (ENABLE_NODE, &no_debug_bgp_fsm_cmd);
install_element (ENABLE_NODE, &undebug_bgp_fsm_cmd);
install_element (ENABLE_NODE, &no_debug_bgp_normal_cmd);
install_element (ENABLE_NODE, &undebug_bgp_normal_cmd);
install_element (CONFIG_NODE, &no_debug_bgp_normal_cmd);
+ install_element (ENABLE_NODE, &no_debug_bgp_zebra_cmd);
+ install_element (ENABLE_NODE, &undebug_bgp_zebra_cmd);
+ install_element (CONFIG_NODE, &no_debug_bgp_zebra_cmd);
install_element (ENABLE_NODE, &no_debug_bgp_all_cmd);
install_element (ENABLE_NODE, &undebug_bgp_all_cmd);
}
#include "bgpd/bgp_nexthop.h"
#include "bgpd/bgp_zebra.h"
#include "bgpd/bgp_fsm.h"
+#include "bgpd/bgp_debug.h"
\f
/* All information about zebra. */
static struct zclient *zclient = NULL;
struct bgp *bgp;
zebra_router_id_update_read(zclient->ibuf,&router_id);
+
+ if (BGP_DEBUG(zebra, ZEBRA))
+ {
+ char buf[128];
+ prefix2str(&router_id, buf, sizeof(buf));
+ zlog_debug("Zebra rcvd: router id update %s", buf);
+ }
+
router_id_zebra = router_id.u.prefix4;
for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
ifp = zebra_interface_add_read (zclient->ibuf);
+ if (BGP_DEBUG(zebra, ZEBRA) && ifp)
+ zlog_debug("Zebra rcvd: interface add %s", ifp->name);
+
return 0;
}
ifp = zebra_interface_state_read (s);
ifp->ifindex = IFINDEX_INTERNAL;
+ if (BGP_DEBUG(zebra, ZEBRA))
+ zlog_debug("Zebra rcvd: interface delete %s", ifp->name);
+
return 0;
}
if (! ifp)
return 0;
+ if (BGP_DEBUG(zebra, ZEBRA))
+ zlog_debug("Zebra rcvd: interface %s up", ifp->name);
+
for (ALL_LIST_ELEMENTS (ifp->connected, node, nnode, c))
bgp_connected_add (c);
if (! ifp)
return 0;
+ if (BGP_DEBUG(zebra, ZEBRA))
+ zlog_debug("Zebra rcvd: interface %s down", ifp->name);
+
for (ALL_LIST_ELEMENTS (ifp->connected, node, nnode, c))
bgp_connected_delete (c);
if (ifc == NULL)
return 0;
+ if (BGP_DEBUG(zebra, ZEBRA))
+ {
+ char buf[128];
+ prefix2str(ifc->address, buf, sizeof(buf));
+ zlog_debug("Zebra rcvd: interface %s address add %s",
+ ifc->ifp->name, buf);
+ }
+
if (if_is_operative (ifc->ifp))
bgp_connected_add (ifc);
if (ifc == NULL)
return 0;
+ if (BGP_DEBUG(zebra, ZEBRA))
+ {
+ char buf[128];
+ prefix2str(ifc->address, buf, sizeof(buf));
+ zlog_debug("Zebra rcvd: interface %s address delete %s",
+ ifc->ifp->name, buf);
+ }
+
if (if_is_operative (ifc->ifp))
bgp_connected_delete (ifc);
api.metric = 0;
if (command == ZEBRA_IPV4_ROUTE_ADD)
- bgp_redistribute_add ((struct prefix *)&p, &nexthop, api.metric, api.type);
+ {
+ if (BGP_DEBUG(zebra, ZEBRA))
+ {
+ char buf[2][INET_ADDRSTRLEN];
+ zlog_debug("Zebra rcvd: IPv4 route add %s %s/%d nexthop %s metric %u",
+ zebra_route_string(api.type),
+ inet_ntop(AF_INET, &p.prefix, buf[0], sizeof(buf[0])),
+ p.prefixlen,
+ inet_ntop(AF_INET, &nexthop, buf[1], sizeof(buf[1])),
+ api.metric);
+ }
+ bgp_redistribute_add((struct prefix *)&p, &nexthop, api.metric, api.type);
+ }
else
- bgp_redistribute_delete ((struct prefix *)&p, api.type);
+ {
+ if (BGP_DEBUG(zebra, ZEBRA))
+ {
+ char buf[2][INET_ADDRSTRLEN];
+ zlog_debug("Zebra rcvd: IPv4 route delete %s %s/%d "
+ "nexthop %s metric %u",
+ zebra_route_string(api.type),
+ inet_ntop(AF_INET, &p.prefix, buf[0], sizeof(buf[0])),
+ p.prefixlen,
+ inet_ntop(AF_INET, &nexthop, buf[1], sizeof(buf[1])),
+ api.metric);
+ }
+ bgp_redistribute_delete((struct prefix *)&p, api.type);
+ }
return 0;
}
return 0;
if (command == ZEBRA_IPV6_ROUTE_ADD)
- bgp_redistribute_add ((struct prefix *)&p, NULL, api.metric, api.type);
+ {
+ if (BGP_DEBUG(zebra, ZEBRA))
+ {
+ char buf[INET6_ADDRSTRLEN];
+ zlog_debug("Zebra rcvd: IPv6 route add %s %s/%d metric %u",
+ zebra_route_string(api.type),
+ inet_ntop(AF_INET6, &p.prefix, buf, sizeof(buf)),
+ p.prefixlen, api.metric);
+ }
+ bgp_redistribute_add ((struct prefix *)&p, NULL, api.metric, api.type);
+ }
else
- bgp_redistribute_delete ((struct prefix *) &p, api.type);
+ {
+ if (BGP_DEBUG(zebra, ZEBRA))
+ {
+ char buf[INET6_ADDRSTRLEN];
+ zlog_debug("Zebra rcvd: IPv6 route delete %s %s/%d metric %u",
+ zebra_route_string(api.type),
+ inet_ntop(AF_INET6, &p.prefix, buf, sizeof(buf)),
+ p.prefixlen, api.metric);
+ }
+ bgp_redistribute_delete ((struct prefix *) &p, api.type);
+ }
return 0;
}
SET_FLAG (api.message, ZAPI_MESSAGE_DISTANCE);
api.distance = distance;
}
+
+ if (BGP_DEBUG(zebra, ZEBRA))
+ {
+ char buf[2][INET_ADDRSTRLEN];
+ zlog_debug("Zebra send: IPv4 route add %s/%d nexthop %s metric %u",
+ inet_ntop(AF_INET, &p->u.prefix4, buf[0], sizeof(buf[0])),
+ p->prefixlen,
+ inet_ntop(AF_INET, nexthop, buf[1], sizeof(buf[1])),
+ api.metric);
+ }
+
zapi_ipv4_route (ZEBRA_IPV4_ROUTE_ADD, zclient,
(struct prefix_ipv4 *) p, &api);
}
SET_FLAG (api.message, ZAPI_MESSAGE_METRIC);
api.metric = info->attr->med;
+ if (BGP_DEBUG(zebra, ZEBRA))
+ {
+ char buf[2][INET6_ADDRSTRLEN];
+ zlog_debug("Zebra send: IPv6 route add %s/%d nexthop %s metric %u",
+ inet_ntop(AF_INET6, &p->u.prefix6, buf[0], sizeof(buf[0])),
+ p->prefixlen,
+ inet_ntop(AF_INET6, nexthop, buf[1], sizeof(buf[1])),
+ api.metric);
+ }
+
zapi_ipv6_route (ZEBRA_IPV6_ROUTE_ADD, zclient,
(struct prefix_ipv6 *) p, &api);
}
SET_FLAG (api.message, ZAPI_MESSAGE_METRIC);
api.metric = info->attr->med;
+ if (BGP_DEBUG(zebra, ZEBRA))
+ {
+ char buf[2][INET_ADDRSTRLEN];
+ zlog_debug("Zebra send: IPv4 route delete %s/%d nexthop %s metric %u",
+ inet_ntop(AF_INET, &p->u.prefix4, buf[0], sizeof(buf[0])),
+ p->prefixlen,
+ inet_ntop(AF_INET, nexthop, buf[1], sizeof(buf[1])),
+ api.metric);
+ }
+
zapi_ipv4_route (ZEBRA_IPV4_ROUTE_DELETE, zclient,
(struct prefix_ipv4 *) p, &api);
}
SET_FLAG (api.message, ZAPI_MESSAGE_METRIC);
api.metric = info->attr->med;
+ if (BGP_DEBUG(zebra, ZEBRA))
+ {
+ char buf[2][INET6_ADDRSTRLEN];
+ zlog_debug("Zebra send: IPv6 route delete %s/%d nexthop %s metric %u",
+ inet_ntop(AF_INET6, &p->u.prefix6, buf[0], sizeof(buf[0])),
+ p->prefixlen,
+ inet_ntop(AF_INET6, nexthop, buf[1], sizeof(buf[1])),
+ api.metric);
+ }
+
zapi_ipv6_route (ZEBRA_IPV6_ROUTE_DELETE, zclient,
(struct prefix_ipv6 *) p, &api);
}
/* Return if zebra connection is not established. */
if (zclient->sock < 0)
return CMD_WARNING;
+
+ if (BGP_DEBUG(zebra, ZEBRA))
+ zlog_debug("Zebra send: redistribute add %s", zebra_route_string(type));
/* Send distribute add message to zebra. */
zebra_redistribute_send (ZEBRA_REDISTRIBUTE_ADD, zclient, type);
if (bgp->redist[AFI_IP][type] == 0
&& bgp->redist[AFI_IP6][type] == 0
&& zclient->sock >= 0)
- /* Send distribute delete message to zebra. */
- zebra_redistribute_send (ZEBRA_REDISTRIBUTE_DELETE, zclient, type);
+ {
+ /* Send distribute delete message to zebra. */
+ if (BGP_DEBUG(zebra, ZEBRA))
+ zlog_debug("Zebra send: redistribute delete %s",
+ zebra_route_string(type));
+ zebra_redistribute_send (ZEBRA_REDISTRIBUTE_DELETE, zclient, type);
+ }
/* Withdraw redistributed routes from current BGP's routing table. */
bgp_redistribute_withdraw (bgp, afi, type);