]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib, bgpd: Add more debugs to GR Capability exchange
authorDonald Sharp <sharpd@nvidia.com>
Thu, 9 Mar 2023 13:36:51 +0000 (08:36 -0500)
committerDonald Sharp <sharpd@nvidia.com>
Thu, 9 Mar 2023 13:36:51 +0000 (08:36 -0500)
a) Make it legible what type of message is being passed
back and forth instead of having to guess it from
the insufficient debugs

b) Make it explicit which bgp instance is sending this
data

c) Cleanup bgp_zebra_update to have a cleaner api

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
bgpd/bgp_fsm.c
bgpd/bgp_route.c
bgpd/bgp_zebra.c
bgpd/bgp_zebra.h
lib/log.c
lib/log.h

index 59a8fcb92a07e0090dbc7c9a346061ab8761fefa..fb7b998777a7da509701762fb78e85fd90aeb805 100644 (file)
@@ -2047,7 +2047,7 @@ static int bgp_start_deferral_timer(struct bgp *bgp, afi_t afi, safi_t safi,
        if (gr_info->af_enabled[afi][safi] == false) {
                gr_info->af_enabled[afi][safi] = true;
                /* Send message to RIB */
-               bgp_zebra_update(afi, safi, bgp->vrf_id,
+               bgp_zebra_update(bgp, afi, safi,
                                 ZEBRA_CLIENT_ROUTE_UPDATE_PENDING);
        }
        if (BGP_DEBUG(update, UPDATE_OUT))
@@ -2194,7 +2194,7 @@ static enum bgp_fsm_state_progress bgp_establish(struct peer *peer)
                                /* Send route processing complete
                                   message to RIB */
                                bgp_zebra_update(
-                                       afi, safi, peer->bgp->vrf_id,
+                                       peer->bgp, afi, safi,
                                        ZEBRA_CLIENT_ROUTE_UPDATE_COMPLETE);
                }
        } else {
@@ -2206,7 +2206,7 @@ static enum bgp_fsm_state_progress bgp_establish(struct peer *peer)
                                /* Send route processing complete
                                   message to RIB */
                                bgp_zebra_update(
-                                       afi, safi, peer->bgp->vrf_id,
+                                       peer->bgp, afi, safi,
                                        ZEBRA_CLIENT_ROUTE_UPDATE_COMPLETE);
                }
        }
index 56f548bfd5483ea6bfc60f4a1ed09f14505785e9..4320259cc946ad123893ca30b0d018aafca1af13 100644 (file)
@@ -3405,7 +3405,7 @@ void bgp_best_path_select_defer(struct bgp *bgp, afi_t afi, safi_t safi)
        if (!bgp->gr_info[afi][safi].gr_deferred) {
                bgp_send_delayed_eor(bgp);
                /* Send route processing complete message to RIB */
-               bgp_zebra_update(afi, safi, bgp->vrf_id,
+               bgp_zebra_update(bgp, afi, safi,
                                 ZEBRA_CLIENT_ROUTE_UPDATE_COMPLETE);
                return;
        }
index d05768da05145889941e4c7addb47899968ad44a..ada1f0d26308059793e1e7f2e8c86ec4c5a57aae 100644 (file)
@@ -3748,16 +3748,22 @@ int bgp_zebra_send_capabilities(struct bgp *bgp, bool disable)
        struct zapi_cap api;
        int ret = BGP_GR_SUCCESS;
 
+       if (BGP_DEBUG(zebra, ZEBRA))
+               zlog_debug("%s: Sending %sable for %s", __func__,
+                          disable ? "dis" : "en", bgp->name_pretty);
+
        if (zclient == NULL) {
                if (BGP_DEBUG(zebra, ZEBRA))
-                       zlog_debug("zclient invalid");
+                       zlog_debug("%s: %s zclient invalid", __func__,
+                                  bgp->name_pretty);
                return BGP_GR_FAILURE;
        }
 
        /* Check if the client is connected */
        if ((zclient->sock < 0) || (zclient->t_connect)) {
                if (BGP_DEBUG(zebra, ZEBRA))
-                       zlog_debug("client not connected");
+                       zlog_debug("%s: %s client not connected", __func__,
+                                  bgp->name_pretty);
                return BGP_GR_FAILURE;
        }
 
@@ -3776,7 +3782,8 @@ int bgp_zebra_send_capabilities(struct bgp *bgp, bool disable)
 
        if (zclient_capabilities_send(ZEBRA_CLIENT_CAPABILITIES, zclient, &api)
            == ZCLIENT_SEND_FAILURE) {
-               zlog_err("error sending capability");
+               zlog_err("%s: %s error sending capability", __func__,
+                        bgp->name_pretty);
                ret = BGP_GR_FAILURE;
        } else {
                if (disable)
@@ -3785,7 +3792,8 @@ int bgp_zebra_send_capabilities(struct bgp *bgp, bool disable)
                        bgp->present_zebra_gr_state = ZEBRA_GR_ENABLE;
 
                if (BGP_DEBUG(zebra, ZEBRA))
-                       zlog_debug("send capabilty success");
+                       zlog_debug("%s: %s send capabilty success", __func__,
+                                  bgp->name_pretty);
                ret = BGP_GR_SUCCESS;
        }
        return ret;
@@ -3794,32 +3802,41 @@ int bgp_zebra_send_capabilities(struct bgp *bgp, bool disable)
 /* Send route update pesding or completed status to RIB for the
  * specific AFI, SAFI
  */
-int bgp_zebra_update(afi_t afi, safi_t safi, vrf_id_t vrf_id, int type)
+int bgp_zebra_update(struct bgp *bgp, afi_t afi, safi_t safi,
+                    enum zserv_client_capabilities type)
 {
        struct zapi_cap api = {0};
 
+       if (BGP_DEBUG(zebra, ZEBRA))
+               zlog_debug("%s: %s afi: %u safi: %u Command %s", __func__,
+                          bgp->name_pretty, afi, safi,
+                          zserv_gr_client_cap_string(type));
+
        if (zclient == NULL) {
                if (BGP_DEBUG(zebra, ZEBRA))
-                       zlog_debug("zclient == NULL, invalid");
+                       zlog_debug("%s: %s zclient == NULL, invalid", __func__,
+                                  bgp->name_pretty);
                return BGP_GR_FAILURE;
        }
 
        /* Check if the client is connected */
        if ((zclient->sock < 0) || (zclient->t_connect)) {
                if (BGP_DEBUG(zebra, ZEBRA))
-                       zlog_debug("client not connected");
+                       zlog_debug("%s: %s client not connected", __func__,
+                                  bgp->name_pretty);
                return BGP_GR_FAILURE;
        }
 
        api.afi = afi;
        api.safi = safi;
-       api.vrf_id = vrf_id;
+       api.vrf_id = bgp->vrf_id;
        api.cap = type;
 
        if (zclient_capabilities_send(ZEBRA_CLIENT_CAPABILITIES, zclient, &api)
            == ZCLIENT_SEND_FAILURE) {
                if (BGP_DEBUG(zebra, ZEBRA))
-                       zlog_debug("error sending capability");
+                       zlog_debug("%s: %s error sending capability", __func__,
+                                  bgp->name_pretty);
                return BGP_GR_FAILURE;
        }
        return BGP_GR_SUCCESS;
@@ -3831,6 +3848,10 @@ int bgp_zebra_stale_timer_update(struct bgp *bgp)
 {
        struct zapi_cap api;
 
+       if (BGP_DEBUG(zebra, ZEBRA))
+               zlog_debug("%s: %s Timer Update to %u", __func__,
+                          bgp->name_pretty, bgp->rib_stale_time);
+
        if (zclient == NULL) {
                if (BGP_DEBUG(zebra, ZEBRA))
                        zlog_debug("zclient invalid");
@@ -3840,7 +3861,8 @@ int bgp_zebra_stale_timer_update(struct bgp *bgp)
        /* Check if the client is connected */
        if ((zclient->sock < 0) || (zclient->t_connect)) {
                if (BGP_DEBUG(zebra, ZEBRA))
-                       zlog_debug("client not connected");
+                       zlog_debug("%s: %s client not connected", __func__,
+                                  bgp->name_pretty);
                return BGP_GR_FAILURE;
        }
 
@@ -3851,11 +3873,11 @@ int bgp_zebra_stale_timer_update(struct bgp *bgp)
        if (zclient_capabilities_send(ZEBRA_CLIENT_CAPABILITIES, zclient, &api)
            == ZCLIENT_SEND_FAILURE) {
                if (BGP_DEBUG(zebra, ZEBRA))
-                       zlog_debug("error sending capability");
+                       zlog_debug("%s: %s error sending capability", __func__,
+                                  bgp->name_pretty);
                return BGP_GR_FAILURE;
        }
-       if (BGP_DEBUG(zebra, ZEBRA))
-               zlog_debug("send capabilty success");
+
        return BGP_GR_SUCCESS;
 }
 
index 8a0203c32db1e3a103cfdaa38dc7cc0db2596b45..6f28f7b900cce08c771f04e4f2aedc5b0f0e39e4 100644 (file)
@@ -114,7 +114,8 @@ extern void bgp_send_pbr_iptable(struct bgp_pbr_action *pba,
 extern void bgp_zebra_announce_default(struct bgp *bgp, struct nexthop *nh,
                                afi_t afi, uint32_t table_id, bool announce);
 extern int bgp_zebra_send_capabilities(struct bgp *bgp, bool disable);
-extern int bgp_zebra_update(afi_t afi, safi_t safi, vrf_id_t vrf_id, int type);
+extern int bgp_zebra_update(struct bgp *bgp, afi_t afi, safi_t safi,
+                           enum zserv_client_capabilities);
 extern int bgp_zebra_stale_timer_update(struct bgp *bgp);
 extern int bgp_zebra_srv6_manager_get_locator_chunk(const char *name);
 extern int bgp_zebra_srv6_manager_release_locator_chunk(const char *name);
index b1a06bfb26bb0cf29570be065279663774fa5e13..f7ab86fd9db140d7119af7d4484243267e6fea6a 100644 (file)
--- a/lib/log.c
+++ b/lib/log.c
@@ -506,6 +506,26 @@ const char *zserv_command_string(unsigned int command)
        return command_types[command].string;
 }
 
+#define DESC_ENTRY(T) [(T)] = {(T), (#T), '\0'}
+static const struct zebra_desc_table gr_client_cap_types[] = {
+       DESC_ENTRY(ZEBRA_CLIENT_GR_CAPABILITIES),
+       DESC_ENTRY(ZEBRA_CLIENT_ROUTE_UPDATE_COMPLETE),
+       DESC_ENTRY(ZEBRA_CLIENT_ROUTE_UPDATE_PENDING),
+       DESC_ENTRY(ZEBRA_CLIENT_GR_DISABLE),
+       DESC_ENTRY(ZEBRA_CLIENT_RIB_STALE_TIME),
+};
+#undef DESC_ENTRY
+
+const char *zserv_gr_client_cap_string(uint32_t zcc)
+{
+       if (zcc >= array_size(gr_client_cap_types)) {
+               flog_err(EC_LIB_DEVELOPMENT, "unknown zserv command type: %u",
+                        zcc);
+               return unknown.string;
+       }
+       return gr_client_cap_types[zcc].string;
+}
+
 int proto_name2num(const char *s)
 {
        unsigned i;
index b8452ac215a8cb449e96ff9d9459faac683fb7bc..8a95b7a005fda6bea02b2707a102864f8247ece3 100644 (file)
--- a/lib/log.h
+++ b/lib/log.h
@@ -113,6 +113,7 @@ extern int proto_name2num(const char *s);
 extern int proto_redistnum(int afi, const char *s);
 
 extern const char *zserv_command_string(unsigned int command);
+extern const char *zserv_gr_client_cap_string(unsigned int zcc);
 
 #define OSPF_LOG(level, cond, fmt, ...)                                        \
        do {                                                                   \