]> git.proxmox.com Git - mirror_frr.git/commitdiff
bgpd: Add vrf information to best path debugging
authorDonald Sharp <sharpd@nvidia.com>
Fri, 12 Nov 2021 15:46:48 +0000 (10:46 -0500)
committerDonald Sharp <sharpd@nvidia.com>
Fri, 12 Nov 2021 18:24:04 +0000 (13:24 -0500)
When debugging issues for routes in multiple vrf's.  It would
be extremely useful if the debug output had which vrf we
are acting on.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
bgpd/bgp_mpath.c
bgpd/bgp_mpath.h
bgpd/bgp_route.c
tests/bgpd/test_mpath.c

index 1d727d267a9b4b7bc7cba563879ab7b9fd568fe8..42077d4e8e7f544d741335386f8f8b1f40fcfe55 100644 (file)
@@ -508,7 +508,7 @@ static void bgp_path_info_mpath_attr_set(struct bgp_path_info *path,
  * Compare and sync up the multipath list with the mp_list generated by
  * bgp_best_selection
  */
-void bgp_path_info_mpath_update(struct bgp_dest *dest,
+void bgp_path_info_mpath_update(struct bgp *bgp, struct bgp_dest *dest,
                                struct bgp_path_info *new_best,
                                struct bgp_path_info *old_best,
                                struct list *mp_list,
@@ -553,11 +553,11 @@ void bgp_path_info_mpath_update(struct bgp_dest *dest,
 
        if (debug)
                zlog_debug(
-                       "%pRN: starting mpath update, newbest %s num candidates %d old-mpath-count %d old-cum-bw u%" PRIu64,
-                       bgp_dest_to_rnode(dest),
+                       "%pRN(%s): starting mpath update, newbest %s num candidates %d old-mpath-count %d old-cum-bw u%" PRIu64,
+                       bgp_dest_to_rnode(dest), bgp->name_pretty,
                        new_best ? new_best->peer->host : "NONE",
-                       mp_list ? listcount(mp_list) : 0,
-                       old_mpath_count, old_cum_bw);
+                       mp_list ? listcount(mp_list) : 0, old_mpath_count,
+                       old_cum_bw);
 
        /*
         * We perform an ordered walk through both lists in parallel.
@@ -589,8 +589,8 @@ void bgp_path_info_mpath_update(struct bgp_dest *dest,
 
                if (debug)
                        zlog_debug(
-                               "%pRN: comparing candidate %s with existing mpath %s",
-                               bgp_dest_to_rnode(dest),
+                               "%pRN(%s): comparing candidate %s with existing mpath %s",
+                               bgp_dest_to_rnode(dest), bgp->name_pretty,
                                tmp_info ? tmp_info->peer->host : "NONE",
                                cur_mpath ? cur_mpath->peer->host : "NONE");
 
@@ -734,9 +734,9 @@ void bgp_path_info_mpath_update(struct bgp_dest *dest,
 
                if (debug)
                        zlog_debug(
-                               "%pRN: New mpath count (incl newbest) %d mpath-change %s all_paths_lb %d cum_bw u%" PRIu64,
-                               bgp_dest_to_rnode(dest), mpath_count,
-                               mpath_changed ? "YES" : "NO",
+                               "%pRN(%s): New mpath count (incl newbest) %d mpath-change %s all_paths_lb %d cum_bw u%" PRIu64,
+                               bgp_dest_to_rnode(dest), bgp->name_pretty,
+                               mpath_count, mpath_changed ? "YES" : "NO",
                                all_paths_lb, cum_bw);
 
                if (mpath_changed
index a07e48159e4d6cc6bf6ad3e1272e2ffa2a371323..5476297c3d328390aedca84ef76e6bc7ac4578de 100644 (file)
@@ -64,7 +64,7 @@ extern void bgp_mp_list_init(struct list *);
 extern void bgp_mp_list_clear(struct list *);
 extern void bgp_mp_list_add(struct list *mp_list, struct bgp_path_info *mpinfo);
 extern void bgp_mp_dmed_deselect(struct bgp_path_info *dmed_best);
-extern void bgp_path_info_mpath_update(struct bgp_dest *dest,
+extern void bgp_path_info_mpath_update(struct bgp *bgp, struct bgp_dest *dest,
                                       struct bgp_path_info *new_best,
                                       struct bgp_path_info *old_best,
                                       struct list *mp_list,
index fdaee9b600e9c5b2a2250c1050dc834a104c7e76..ee432cdc55c766911988e0779d0a33814cfd3c48 100644 (file)
@@ -605,17 +605,17 @@ static int bgp_path_info_cmp(struct bgp *bgp, struct bgp_path_info *new,
        if (exist == NULL) {
                *reason = bgp_path_selection_first;
                if (debug)
-                       zlog_debug("%s: %s is the initial bestpath", pfx_buf,
-                                  new_buf);
+                       zlog_debug("%s(%s): %s is the initial bestpath",
+                                  pfx_buf, bgp->name_pretty, new_buf);
                return 1;
        }
 
        if (debug) {
                bgp_path_info_path_with_addpath_rx_str(exist, exist_buf,
                                                       sizeof(exist_buf));
-               zlog_debug("%s: Comparing %s flags 0x%x with %s flags 0x%x",
-                          pfx_buf, new_buf, new->flags, exist_buf,
-                          exist->flags);
+               zlog_debug("%s(%s): Comparing %s flags 0x%x with %s flags 0x%x",
+                          pfx_buf, bgp->name_pretty, new_buf, new->flags,
+                          exist_buf, exist->flags);
        }
 
        newattr = new->attr;
@@ -2404,8 +2404,8 @@ void bgp_best_selection(struct bgp *bgp, struct bgp_dest *dest,
                                bgp_path_info_path_with_addpath_rx_str(
                                        new_select, path_buf, sizeof(path_buf));
                                zlog_debug(
-                                       "%pBD: %s is the bestpath from AS %u",
-                                       dest, path_buf,
+                                       "%pBD(%s): %s is the bestpath from AS %u",
+                                       dest, bgp->name_pretty, path_buf,
                                        aspath_get_first_as(
                                                new_select->attr->aspath));
                        }
@@ -2481,8 +2481,8 @@ void bgp_best_selection(struct bgp *bgp, struct bgp_dest *dest,
                else
                        snprintf(path_buf, sizeof(path_buf), "NONE");
                zlog_debug(
-                       "%pBD: After path selection, newbest is %s oldbest was %s",
-                       dest, path_buf,
+                       "%pBD(%s): After path selection, newbest is %s oldbest was %s",
+                       dest, bgp->name_pretty, path_buf,
                        old_select ? old_select->peer->host : "NONE");
        }
 
@@ -2497,8 +2497,9 @@ void bgp_best_selection(struct bgp *bgp, struct bgp_dest *dest,
                        if (pi == new_select) {
                                if (debug)
                                        zlog_debug(
-                                               "%pBD: %s is the bestpath, add to the multipath list",
-                                               dest, path_buf);
+                                               "%pBD(%s): %s is the bestpath, add to the multipath list",
+                                               dest, bgp->name_pretty,
+                                               path_buf);
                                bgp_mp_list_add(&mp_list, pi);
                                continue;
                        }
@@ -2534,7 +2535,7 @@ void bgp_best_selection(struct bgp *bgp, struct bgp_dest *dest,
                }
        }
 
-       bgp_path_info_mpath_update(dest, new_select, old_select, &mp_list,
+       bgp_path_info_mpath_update(bgp, dest, new_select, old_select, &mp_list,
                                   mpath_cfg);
        bgp_path_info_mpath_aggregate_update(new_select, old_select);
        bgp_mp_list_clear(&mp_list);
@@ -2793,8 +2794,9 @@ static void bgp_process_main_one(struct bgp *bgp, struct bgp_dest *dest,
 
        debug = bgp_debug_bestpath(dest);
        if (debug)
-               zlog_debug("%s: p=%pBD afi=%s, safi=%s start", __func__, dest,
-                          afi2str(afi), safi2str(safi));
+               zlog_debug("%s: p=%pBDi(%s) afi=%s, safi=%s start", __func__,
+                          dest, bgp->name_pretty, afi2str(afi),
+                          safi2str(safi));
 
        /* The best path calculation for the route is deferred if
         * BGP_NODE_SELECT_DEFER is set
@@ -2856,9 +2858,9 @@ static void bgp_process_main_one(struct bgp *bgp, struct bgp_dest *dest,
 
        if (debug)
                zlog_debug(
-                       "%s: p=%pBD afi=%s, safi=%s, old_select=%p, new_select=%p",
-                       __func__, dest, afi2str(afi), safi2str(safi),
-                       old_select, new_select);
+                       "%s: p=%pBD(%s) afi=%s, safi=%s, old_select=%p, new_select=%p",
+                       __func__, dest, bgp->name_pretty, afi2str(afi),
+                       safi2str(safi), old_select, new_select);
 
        /* If best route remains the same and this is not due to user-initiated
         * clear, see exactly what needs to be done.
index d1ca356b949c6a5466d66ad865882683f9f0370a..b93cbd8e5a673f0895e2c64ac77635c83bdfc22a 100644 (file)
@@ -330,7 +330,7 @@ static int run_bgp_path_info_mpath_update(testcase_t *t)
        bgp_mp_list_add(&mp_list, &test_mp_list_info[1]);
        new_best = &test_mp_list_info[3];
        old_best = NULL;
-       bgp_path_info_mpath_update(&test_rn, new_best, old_best, &mp_list,
+       bgp_path_info_mpath_update(NULL, &test_rn, new_best, old_best, &mp_list,
                                   &mp_cfg);
        bgp_mp_list_clear(&mp_list);
        EXPECT_TRUE(bgp_path_info_mpath_count(new_best) == 2, test_result);
@@ -345,7 +345,7 @@ static int run_bgp_path_info_mpath_update(testcase_t *t)
        bgp_mp_list_add(&mp_list, &test_mp_list_info[1]);
        new_best = &test_mp_list_info[0];
        old_best = &test_mp_list_info[3];
-       bgp_path_info_mpath_update(&test_rn, new_best, old_best, &mp_list,
+       bgp_path_info_mpath_update(NULL, &test_rn, new_best, old_best, &mp_list,
                                   &mp_cfg);
        bgp_mp_list_clear(&mp_list);
        EXPECT_TRUE(bgp_path_info_mpath_count(new_best) == 1, test_result);