From 32391affccca873000c39c6df1fc8c490d02f703 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 14 Mar 2018 20:14:36 -0400 Subject: [PATCH] zebra: Add some additional vrf info to debugs There were several places where when I am attempting to debug zebra functionality that I would really like to have the ability to know what vrf I think I am operating on. Add the vrf_id to a bunch of zlog_debug messages to help figure out issues when they happen. Signed-off-by: Donald Sharp --- zebra/zebra_rib.c | 24 ++++++++++++++---------- zebra/zserv.c | 31 +++++++++++++++++-------------- 2 files changed, 31 insertions(+), 24 deletions(-) diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index 72dbfb12fc..d654579b1c 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -685,7 +685,8 @@ struct route_entry *rib_match_ipv4_multicast(vrf_id_t vrf_id, char buf[BUFSIZ]; inet_ntop(AF_INET, &addr, buf, BUFSIZ); - zlog_debug("%s: %s: found %s, using %s", __func__, buf, + zlog_debug("%s: %s: vrf: %u found %s, using %s", + __func__, buf, vrf_id, mre ? (ure ? "MRIB+URIB" : "MRIB") : ure ? "URIB" : "nothing", re == ure ? "URIB" : re == mre ? "MRIB" : "none"); @@ -1608,9 +1609,9 @@ static void rib_process(struct route_node *rn) if (re != old_selected) { if (IS_ZEBRA_DEBUG_RIB) zlog_debug( - "%s: %s: imported via import-table but denied " + "%s: %u:%s: imported via import-table but denied " "by the ip protocol table route-map", - __func__, buf); + __func__, vrf_id, buf); rib_unlink(rn, re); } else SET_FLAG(re->status, @@ -2191,9 +2192,9 @@ void _route_entry_dump(const char *func, union prefixconstptr pp, for (ALL_NEXTHOPS(re->ng, nexthop)) { inet_ntop(p->family, &nexthop->gate, straddr, INET6_ADDRSTRLEN); - zlog_debug("%s: %s %s[%u] with flags %s%s%s", func, + zlog_debug("%s: %s %s[%u] vrf %u with flags %s%s%s", func, (nexthop->rparent ? " NH" : "NH"), straddr, - nexthop->ifindex, + nexthop->ifindex, nexthop->vrf_id, (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_ACTIVE) ? "ACTIVE " : ""), @@ -2221,7 +2222,8 @@ void rib_lookup_and_dump(struct prefix_ipv4 *p, vrf_id_t vrf_id) /* Lookup table. */ table = zebra_vrf_table(AFI_IP, SAFI_UNICAST, vrf_id); if (!table) { - zlog_err("%s: zebra_vrf_table() returned NULL", __func__); + zlog_err("%s:%u zebra_vrf_table() returned NULL", + __func__, vrf_id); return; } @@ -2230,7 +2232,7 @@ void rib_lookup_and_dump(struct prefix_ipv4 *p, vrf_id_t vrf_id) /* No route for this prefix. */ if (!rn) { - zlog_debug("%s: lookup failed for %s", __func__, + zlog_debug("%s:%u lookup failed for %s", __func__, vrf_id, prefix2str((struct prefix *)p, prefix_buf, sizeof(prefix_buf))); return; @@ -2241,8 +2243,9 @@ void rib_lookup_and_dump(struct prefix_ipv4 *p, vrf_id_t vrf_id) /* let's go */ RNODE_FOREACH_RE (rn, re) { - zlog_debug("%s: rn %p, re %p: %s, %s", __func__, (void *)rn, - (void *)re, + zlog_debug("%s:%u rn %p, re %p: %s, %s", + __func__, vrf_id, + (void *)rn, (void *)re, (CHECK_FLAG(re->status, ROUTE_ENTRY_REMOVED) ? "removed" : "NOT removed"), @@ -2266,7 +2269,8 @@ void rib_lookup_and_pushup(struct prefix_ipv4 *p, vrf_id_t vrf_id) rib_dest_t *dest; if (NULL == (table = zebra_vrf_table(AFI_IP, SAFI_UNICAST, vrf_id))) { - zlog_err("%s: zebra_vrf_table() returned NULL", __func__); + zlog_err("%s:%u zebra_vrf_table() returned NULL", + __func__, vrf_id); return; } diff --git a/zebra/zserv.c b/zebra/zserv.c index 0def903803..709605d770 100644 --- a/zebra/zserv.c +++ b/zebra/zserv.c @@ -663,9 +663,9 @@ int zsend_route_notify_owner(struct route_entry *re, struct prefix *p, char buff[PREFIX_STRLEN]; zlog_debug( - "Not Notifying Owner: %u about prefix %s(%u) %d", + "Not Notifying Owner: %u about prefix %s(%u) %d vrf: %u", re->type, prefix2str(p, buff, sizeof(buff)), - re->table, note); + re->table, note, re->vrf_id); } return 0; } @@ -673,9 +673,9 @@ int zsend_route_notify_owner(struct route_entry *re, struct prefix *p, if (IS_ZEBRA_DEBUG_PACKET) { char buff[PREFIX_STRLEN]; - zlog_debug("Notifying Owner: %u about prefix %s(%u) %d", + zlog_debug("Notifying Owner: %u about prefix %s(%u) %d vrf: %u", re->type, prefix2str(p, buff, sizeof(buff)), - re->table, note); + re->table, note, re->vrf_id); } s = stream_new(ZEBRA_MAX_PACKET_SIZ); @@ -849,9 +849,10 @@ static void zread_rnh_register(ZAPI_HANDLER_ARGS) if (IS_ZEBRA_DEBUG_NHT) zlog_debug( - "rnh_register msg from client %s: hdr->length=%d, type=%s\n", + "rnh_register msg from client %s: hdr->length=%d, type=%s vrf=%u\n", zebra_route_string(client->proto), hdr->length, - (type == RNH_NEXTHOP_TYPE) ? "nexthop" : "route"); + (type == RNH_NEXTHOP_TYPE) ? "nexthop" : "route", + zvrf->vrf->vrf_id); s = msg; @@ -924,8 +925,9 @@ static void zread_rnh_unregister(ZAPI_HANDLER_ARGS) if (IS_ZEBRA_DEBUG_NHT) zlog_debug( - "rnh_unregister msg from client %s: hdr->length=%d\n", - zebra_route_string(client->proto), hdr->length); + "rnh_unregister msg from client %s: hdr->length=%d vrf: %u\n", + zebra_route_string(client->proto), hdr->length, + zvrf->vrf->vrf_id); s = msg; @@ -1997,8 +1999,9 @@ static void zread_hello(ZAPI_HANDLER_ARGS) /* accept only dynamic routing protocols */ if ((proto < ZEBRA_ROUTE_MAX) && (proto > ZEBRA_ROUTE_STATIC)) { zlog_notice( - "client %d says hello and bids fair to announce only %s routes", - client->sock, zebra_route_string(proto)); + "client %d says hello and bids fair to announce only %s routes vrf=%u", + client->sock, zebra_route_string(proto), + zvrf->vrf->vrf_id); if (instance) zlog_notice("client protocol instance %d", instance); @@ -2130,8 +2133,8 @@ static void zread_label_manager_connect(struct zserv *client, zsend_label_manager_connect_response(client, vrf_id, 1); return; } - zlog_notice("client %d with instance %u connected as %s", client->sock, - instance, zebra_route_string(proto)); + zlog_notice("client %d with vrf %u instance %u connected as %s", + client->sock, vrf_id, instance, zebra_route_string(proto)); client->proto = proto; client->instance = instance; @@ -2142,8 +2145,8 @@ static void zread_label_manager_connect(struct zserv *client, release_daemon_chunks(proto, instance); zlog_debug( - " Label Manager client connected: sock %d, proto %s, instance %u", - client->sock, zebra_route_string(proto), instance); + " Label Manager client connected: sock %d, proto %s, vrf %u instance %u", + client->sock, zebra_route_string(proto), vrf_id, instance); /* send response back */ zsend_label_manager_connect_response(client, vrf_id, 0); -- 2.39.5