]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: add resolved_prefix visibility on nht 15636/head
authorPhilippe Guibert <philippe.guibert@6wind.com>
Fri, 29 Mar 2024 11:07:14 +0000 (12:07 +0100)
committerPhilippe Guibert <philippe.guibert@6wind.com>
Fri, 29 Mar 2024 16:20:31 +0000 (17:20 +0100)
The nexthop tracking never displays the prefix that
has been used in ZEBRA to resolve its nexthop. This
information will be useful if some decision has to be
taken regarding any loops, that is to say if for instance
a BGP prefix is resolved over a prefix in ZEBRA that is
exactly the same.

Store the value in bgp nexthop context, and display it.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
bgpd/bgp_nexthop.c
bgpd/bgp_nexthop.h
bgpd/bgp_nht.c

index d12dc22330133eb196f6e641f86fd128d00d17f0..98eb9565bf20f8ad87b39bd9853da9c4eaf7f09a 100644 (file)
@@ -1003,6 +1003,8 @@ static void bgp_show_nexthop(struct vty *vty, struct bgp *bgp,
                        if (bnc->is_evpn_gwip_nexthop)
                                json_object_boolean_true_add(json_nexthop,
                                                             "isEvpnGatewayIp");
+                       json_object_string_addf(json, "resolvedPrefix", "%pFX",
+                                               &bnc->resolved_prefix);
                } else {
                        vty_out(vty, " %s valid [IGP metric %d], #paths %d",
                                buf, bnc->metric, bnc->path_count);
@@ -1010,6 +1012,8 @@ static void bgp_show_nexthop(struct vty *vty, struct bgp *bgp,
                                vty_out(vty, ", peer %s", peer->host);
                        if (bnc->is_evpn_gwip_nexthop)
                                vty_out(vty, " EVPN Gateway IP");
+                       vty_out(vty, "\n  Resolved prefix %pFX",
+                               &bnc->resolved_prefix);
                        vty_out(vty, "\n");
                }
                bgp_show_nexthops_detail(vty, bgp, bnc, json_nexthop);
index 830883872e77bd06edb1819d53710836c7a2f5db..430c8f17e890b583097f5647d84001f7d7a5b512 100644 (file)
@@ -90,6 +90,7 @@ struct bgp_nexthop_cache {
        struct bgp_nexthop_cache_head *tree;
 
        struct prefix prefix;
+       struct prefix resolved_prefix;
        void *nht_info; /* In BGP, peer session */
        LIST_HEAD(path_list, bgp_path_info) paths;
        unsigned int path_count;
index 786d07c5a946347617944de820d71b734057b160..20a285b9d97eee8a4435d8f048deff5db52977e5 100644 (file)
@@ -626,6 +626,8 @@ static void bgp_process_nexthop_update(struct bgp_nexthop_cache *bnc,
        } else if (nhr->nexthop_num) {
                struct peer *peer = bnc->nht_info;
 
+               prefix_copy(&bnc->resolved_prefix, &nhr->prefix);
+
                /* notify bgp fsm if nbr ip goes from invalid->valid */
                if (!bnc->nexthop_num)
                        UNSET_FLAG(bnc->flags, BGP_NEXTHOP_PEER_NOTIFIED);
@@ -731,6 +733,7 @@ static void bgp_process_nexthop_update(struct bgp_nexthop_cache *bnc,
                        }
                }
        } else {
+               memset(&bnc->resolved_prefix, 0, sizeof(bnc->resolved_prefix));
                bnc->flags &= ~BGP_NEXTHOP_EVPN_INCOMPLETE;
                bnc->flags &= ~BGP_NEXTHOP_VALID;
                bnc->flags &= ~BGP_NEXTHOP_LABELED_VALID;